code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const windows = std.os.windows; const WORD = windows.WORD; const DWORD = windows.DWORD; const HANDLE = windows.HANDLE; const LONG = windows.LONG; const LPARAM = windows.LPARAM; const WPARAM = windows.WPARAM; const HRESULT = windows.HRESULT; const GUID = windows.GUID; const ULONG = windows.ULONG; const WINAPI = windows.WINAPI; const BOOL = windows.BOOL; const LPCSTR = windows.LPCSTR; const HWND = windows.HWND; const RECT = windows.RECT; const SHORT = windows.SHORT; const POINT = windows.POINT; const HINSTANCE = windows.HINSTANCE; const HCURSOR = windows.HCURSOR; const SIZE_T = windows.SIZE_T; const LPVOID = windows.LPVOID; pub const INT8 = i8; pub const UINT8 = u8; pub const UINT16 = c_ushort; pub const UINT32 = c_uint; pub const UINT64 = c_ulonglong; pub const HMONITOR = HANDLE; pub const REFERENCE_TIME = c_longlong; pub const LUID = extern struct { LowPart: DWORD, HighPart: LONG, }; pub const VT_UI4 = 19; pub const VT_I8 = 20; pub const VT_UI8 = 21; pub const VT_INT = 22; pub const VT_UINT = 23; pub const VARTYPE = u16; pub const PROPVARIANT = extern struct { vt: VARTYPE, wReserved1: WORD = 0, wReserved2: WORD = 0, wReserved3: WORD = 0, u: extern union { intVal: i32, uintVal: u32, hVal: i64, }, decVal: u64 = 0, }; comptime { std.debug.assert(@sizeOf(PROPVARIANT) == 24); } pub const WHEEL_DELTA = 120; pub inline fn GET_WHEEL_DELTA_WPARAM(wparam: WPARAM) i16 { return @bitCast(i16, @intCast(u16, (wparam >> 16) & 0xffff)); } pub inline fn GET_X_LPARAM(lparam: LPARAM) i32 { return @intCast(i32, @bitCast(i16, @intCast(u16, lparam & 0xffff))); } pub inline fn GET_Y_LPARAM(lparam: LPARAM) i32 { return @intCast(i32, @bitCast(i16, @intCast(u16, (lparam >> 16) & 0xffff))); } pub fn IUnknownVTable(comptime T: type) type { return extern struct { unknown: extern struct { QueryInterface: fn (*T, *const GUID, ?*?*anyopaque) callconv(WINAPI) HRESULT, AddRef: fn (*T) callconv(WINAPI) ULONG, Release: fn (*T) callconv(WINAPI) ULONG, }, }; } pub const IID_IUnknown = GUID.parse("{00000000-0000-0000-C000-000000000046}"); pub const IUnknown = extern struct { v: *const IUnknownVTable(Self), const Self = @This(); usingnamespace Methods(Self); pub fn Methods(comptime T: type) type { return extern struct { pub inline fn QueryInterface(self: *T, guid: *const GUID, outobj: ?*?*anyopaque) HRESULT { return self.v.unknown.QueryInterface(self, guid, outobj); } pub inline fn AddRef(self: *T) ULONG { return self.v.unknown.AddRef(self); } pub inline fn Release(self: *T) ULONG { return self.v.unknown.Release(self); } }; } pub fn VTable(comptime T: type) type { return extern struct { QueryInterface: fn (*T, *const GUID, ?*?*anyopaque) callconv(WINAPI) HRESULT, AddRef: fn (*T) callconv(WINAPI) ULONG, Release: fn (*T) callconv(WINAPI) ULONG, }; } }; pub extern "kernel32" fn ExitThread(DWORD) callconv(WINAPI) void; pub extern "kernel32" fn TerminateThread(HANDLE, DWORD) callconv(WINAPI) BOOL; pub extern "user32" fn SetProcessDPIAware() callconv(WINAPI) BOOL; pub extern "user32" fn LoadCursorA( hInstance: ?HINSTANCE, lpCursorName: LPCSTR, ) callconv(WINAPI) HCURSOR; pub extern "user32" fn GetClientRect(HWND, *RECT) callconv(WINAPI) BOOL; pub extern "user32" fn SetWindowTextA(hWnd: ?HWND, lpString: LPCSTR) callconv(WINAPI) BOOL; pub extern "user32" fn GetAsyncKeyState(vKey: c_int) callconv(WINAPI) SHORT; pub extern "user32" fn GetKeyState(vKey: c_int) callconv(WINAPI) SHORT; pub const TME_LEAVE = 0x00000002; pub const TRACKMOUSEEVENT = extern struct { cbSize: DWORD, dwFlags: DWORD, hwndTrack: ?HWND, dwHoverTime: DWORD, }; pub extern "user32" fn TrackMouseEvent(event: *TRACKMOUSEEVENT) callconv(WINAPI) BOOL; pub extern "user32" fn SetCapture(hWnd: ?HWND) callconv(WINAPI) ?HWND; pub extern "user32" fn GetCapture() callconv(WINAPI) ?HWND; pub extern "user32" fn ReleaseCapture() callconv(WINAPI) BOOL; pub extern "user32" fn GetForegroundWindow() callconv(WINAPI) ?HWND; pub extern "user32" fn IsChild(hWndParent: ?HWND, hWnd: ?HWND) callconv(WINAPI) BOOL; pub extern "user32" fn GetCursorPos(point: *POINT) callconv(WINAPI) BOOL; pub extern "user32" fn ScreenToClient( hWnd: ?HWND, lpPoint: *POINT, ) callconv(WINAPI) BOOL; pub const CLSCTX_INPROC_SERVER = 0x1; pub extern "ole32" fn CoCreateInstance( rclsid: *const GUID, pUnkOuter: ?*IUnknown, dwClsContext: DWORD, riid: *const GUID, ppv: *?*anyopaque, ) callconv(WINAPI) HRESULT; pub extern "ole32" fn CoTaskMemAlloc(size: SIZE_T) callconv(WINAPI) ?LPVOID; pub const VK_LBUTTON = 0x01; pub const VK_RBUTTON = 0x02; pub const VK_TAB = 0x09; pub const VK_ESCAPE = 0x1B; pub const VK_LEFT = 0x25; pub const VK_UP = 0x26; pub const VK_RIGHT = 0x27; pub const VK_DOWN = 0x28; pub const VK_PRIOR = 0x21; pub const VK_NEXT = 0x22; pub const VK_END = 0x23; pub const VK_HOME = 0x24; pub const VK_DELETE = 0x2E; pub const VK_BACK = 0x08; pub const VK_RETURN = 0x0D; pub const VK_CONTROL = 0x11; pub const VK_SHIFT = 0x10; pub const VK_MENU = 0x12; pub const VK_SPACE = 0x20; pub const VK_INSERT = 0x2D; pub const VK_LSHIFT = 0xA0; pub const VK_RSHIFT = 0xA1; pub const VK_LCONTROL = 0xA2; pub const VK_RCONTROL = 0xA3; pub const VK_LMENU = 0xA4; pub const VK_RMENU = 0xA5; pub const VK_LWIN = 0x5B; pub const VK_RWIN = 0x5C; pub const VK_APPS = 0x5D; pub const VK_OEM_1 = 0xBA; pub const VK_OEM_PLUS = 0xBB; pub const VK_OEM_COMMA = 0xBC; pub const VK_OEM_MINUS = 0xBD; pub const VK_OEM_PERIOD = 0xBE; pub const VK_OEM_2 = 0xBF; pub const VK_OEM_3 = 0xC0; pub const VK_OEM_4 = 0xDB; pub const VK_OEM_5 = 0xDC; pub const VK_OEM_6 = 0xDD; pub const VK_OEM_7 = 0xDE; pub const VK_CAPITAL = 0x14; pub const VK_SCROLL = 0x91; pub const VK_NUMLOCK = 0x90; pub const VK_SNAPSHOT = 0x2C; pub const VK_PAUSE = 0x13; pub const VK_NUMPAD0 = 0x60; pub const VK_NUMPAD1 = 0x61; pub const VK_NUMPAD2 = 0x62; pub const VK_NUMPAD3 = 0x63; pub const VK_NUMPAD4 = 0x64; pub const VK_NUMPAD5 = 0x65; pub const VK_NUMPAD6 = 0x66; pub const VK_NUMPAD7 = 0x67; pub const VK_NUMPAD8 = 0x68; pub const VK_NUMPAD9 = 0x69; pub const VK_MULTIPLY = 0x6A; pub const VK_ADD = 0x6B; pub const VK_SEPARATOR = 0x6C; pub const VK_SUBTRACT = 0x6D; pub const VK_DECIMAL = 0x6E; pub const VK_DIVIDE = 0x6F; pub const VK_F1 = 0x70; pub const VK_F2 = 0x71; pub const VK_F3 = 0x72; pub const VK_F4 = 0x73; pub const VK_F5 = 0x74; pub const VK_F6 = 0x75; pub const VK_F7 = 0x76; pub const VK_F8 = 0x77; pub const VK_F9 = 0x78; pub const VK_F10 = 0x79; pub const VK_F11 = 0x7A; pub const VK_F12 = 0x7B; pub const IM_VK_KEYPAD_ENTER = VK_RETURN + 256; pub const KF_EXTENDED = 0x0100; pub const E_FILE_NOT_FOUND = @bitCast(HRESULT, @as(c_ulong, 0x80070002)); pub const MiscError = error{ E_FILE_NOT_FOUND, S_FALSE, }; pub const GUID_NULL = GUID.parse("{00000000-0000-0000-0000-000000000000}");
modules/platform/vendored/zwin32/src/misc.zig
const std = @import("std"); const log = std.debug.warn; const stdout = &std.io.getStdOut().outStream(); const assert = @import("std").debug.assert; const fmt = @import("std").fmt; const c = @import("c.zig"); const gw = c.gw; const gmp = c.gmp; const glue = @import("glue.zig"); const u_zero = @import("u_zero.zig"); const test_data = @import("test_data.zig"); const helper = @import("helper.zig"); pub fn get_residue(ctx: *gw.gwhandle, u: gw.gwnum, output: *[16]u8) !void { var gdata = ctx.gdata; // FIXME: this 0 needs to be size of giants buffer var g: gw.giant = gw.popg(&gdata, 0); const success = gw.gwtogiant(ctx, u, g); //log("bitlen {}\n", .{gw.bitlen(g)}); const succ = try fmt.bufPrint(output, "{X:0>8}{X:0>8}", .{ g.*.n[1], g.*.n[0] }); } pub fn full_llr_run(k: u32, b: u32, n: u32, c_: i32, threads_: u8) !bool { // calculate N for Jacobi var N: gmp.mpz_t = u_zero.calculate_N(k, n); const n_digits = gmp.mpz_sizeinbase(&N, 10); log("LLR testing: {}*{}^{}{} [{} digits] on {} threads\n", .{ k, b, n, c_, n_digits, threads_ }); // calculate U0 try stdout.print("step #1 find U0 ...\n", .{}); var u0_gmp: gmp.mpz_t = undefined; try u_zero.find_u0(k, n, N, &u0_gmp); // print the u0 if it's small enough if (n_digits <= 8) { try stdout.print("U0: {}\n", .{gmp.mpz_get_ui(&u0_gmp)}); } // use given threadcount or determine the fastest one using benchmarking const threads: u8 = blk: { if (threads_ > 0) { break :blk threads_; } try stdout.print("step #1.5 benchmark threadcount ...\n", .{}); break :blk helper.benchmark_threads(u0_gmp, k, n); }; // create gwnum context for LLR core loop var ctx: gw.gwhandle = undefined; helper.create_gwhandle(&ctx, threads, k, n); // move U0 from gmp to gw // this has to be the first gwalloc to get large pages // TODO: Verify we got large pages var u: gw.gwnum = gw.gwalloc(&ctx); glue.gmp_to_gw(u0_gmp, u, &ctx); const fft_size = gw.gwfftlen(&ctx) / 1024; try stdout.print("step #2 LLR test using FFT size {}KB\n", .{fft_size}); const llr_start = std.time.milliTimestamp(); // core LLR loop var i: usize = 1; var next_log_i = i; var errored = false; var near_fft = false; const careful_bounds: u32 = 50; const i_penultimate: u32 = n - 1; const upto_careful: u32 = @intCast(u32, n - 1 - helper.min(u32, careful_bounds, n - 1)); // this subtracts 2 after every squaring gw.gwsetaddin(&ctx, -2); while (i < i_penultimate) : (i += 1) { if (i == next_log_i and n >= 10000) { const pct: usize = @intCast(usize, (i * 100 / @intCast(usize, (n - 1)))); if (pct % 10 != 0) { if (pct % 2 == 0) { try stdout.print(".", .{}); } } else { try stdout.print("{}", .{pct / 10}); } // log again on next percent next_log_i = ((n / 100) * (pct + 1)) + (n / 200 * 1); } // gwstartnextfft may ruin the results if run under // incorrect conditions. gwstartnextfft needs to be // 1 less then gwsquare if (i >= careful_bounds and i < upto_careful - 1) { gw.gwstartnextfft(&ctx, 1); } else { gw.gwstartnextfft(&ctx, 0); } if (i >= careful_bounds and i < upto_careful) { gw.gwsquare2(&ctx, u, u); } else { gw.gwsquare2_carefully(&ctx, u, u); } // check if near fft limit if (gw.gwnear_fft_limit(&ctx, 0.5) != 0) { ctx.NORMNUM = 1; if (!near_fft) { log("WARNING: near FFT limit @ {}\n", .{i}); near_fft = true; } } // error_check if (near_fft) { if (gw.gw_test_illegal_sumout(&ctx) != 0) { errored = true; log("ERROR: illegal sumout @ {}\n", .{i}); } if (gw.gw_test_mismatched_sums(&ctx) != 0) { errored = true; log("ERROR: mismatched sums @ {}\n", .{i}); } if (gw.gw_get_maxerr(&ctx) >= 0.40) { errored = true; log("ERROR: maxerr > 0.4 @ {} = {}\n", .{ i, gw.gw_get_maxerr(&ctx) }); } } } // cosmetic progressbar end tick if (n >= 10000) { try stdout.print("X ", .{}); } const llr_took = std.time.milliTimestamp() - llr_start; try stdout.print("[{}ms]\n", .{llr_took}); const maybe = if (errored) "maybe " else ""; const residue_zero = gw.gwiszero(&ctx, u) == 1; if (residue_zero) { log("#> {}*{}^{}{} [{} digits] IS {}PRIME\n", .{ k, b, n, c_, n_digits, maybe }); } else { var residue: [16]u8 = undefined; try get_residue(&ctx, u, &residue); log("#> {}*{}^{}{} [{} digits] is {}not prime. LLR Res64: {}\n", .{ k, b, n, c_, n_digits, maybe, residue }); } return residue_zero; }
llr.zig
const std = @import("std"); const math = std.math; const Allocator = std.mem.Allocator; const G = @import("global_config.zig"); const print = std.debug.print; const panic = std.debug.panic; const expect = std.testing.expect; const expectError = std.testing.expectError; const buf_size: u32 = G.buf_size; const zero_buf = [_]f32{0.0} ** buf_size; const Order = std.math.Order; fn beginsSooner(context: void, a: *Instrument, b: *Instrument) Order { _ = context; if (a.approx_start_time == b.approx_start_time) { return Order.eq; } else if (a.approx_start_time < b.approx_start_time) { return Order.lt; } return Order.gt; } pub const NoteQueue = std.PriorityQueue(*Instrument, void, beginsSooner); pub const Instrument = struct { /// Interface for instruments. /// runtime polymorphism inspired by https://zig.news/david_vanderson/interfaces-in-zig-o1c /// playFn: compute soundwave of instrument /// t0: offset in seconds. /// n_frames: number of frames. /// returns buffer of audio // TODO change API so that we also pass a buffer, and we "add" to the buffer instead of assigning? // indeed some instruments like Sine do not need a buffer at all? playFn: fn (*Instrument, f32, u32) []const f32, deinitFn: fn (*Instrument, Allocator) void, approx_start_time: f32, volume: f32, real_start_time: f32 = 0, over: bool = false, started: bool = false, pub fn play(instr: *Instrument, t0: f32, n_frames: u32) []const f32 { instr.started = true; const buf = (instr.playFn)(instr, t0, n_frames); // set over to true when all zeros var s: f32 = 0; for (buf) |v| { s += @fabs(v); } if (s <= 0.0001) { instr.over = true; } return buf; } pub fn deinit(instr: *Instrument, alloc: Allocator) void { return (instr.deinitFn)(instr, alloc); } }; pub const Signal = union(enum) { instrument: *Instrument, constant: f32, }; // one way to create an instrument and compose them easily. See createKick for example. /// * f: a function with signature: fn(f32, ...), where /// - f32 is time /// - the rest of the arguments are other values /// * L: the number of other arguments (except t0) /// * InputTypes: either f32 for float constant, or the FF generated type (not Instrument, despite the name) pub fn FF(comptime f: anytype, comptime InputTypes: anytype, comptime EnvelopeType: ?type) type { // TODO instead of a simple function of a single f32 time that returns a single f32, // take a whole []f32 and return []f32? // benefits: 1) faster? 2) allows for filters? const dynamic = switch (@typeInfo(@TypeOf(InputTypes))) { .ComptimeInt => true, .Struct => false, else => return error.Wrong, }; const PlainFnArgsType = std.meta.ArgsTuple(@TypeOf(f)); const L = switch (dynamic) { true => InputTypes, false => InputTypes.len, }; // TODO reinstate this check? // const args_tmp: PlainFnArgsType = undefined; // args only used in the following check: // if ((args_tmp.len - 1) != L) { // return error.WrongArgNumber; // } return struct { instrument: Instrument, inputs: [L]Signal, envelope: ?Signal, dynamic: bool, buf: []f32, pub fn play(instr: *Instrument, t0: f32, n_frames: u32) []const f32 { const PlayFnArgsType = std.meta.ArgsTuple(@TypeOf(@This().play)); // @setRuntimeSafety(true); var self = @fieldParentPtr(@This(), "instrument", instr); // print("call play() with instr={*}, L={}, LL={}\n", .{ instr, L, self.LL }); if (instr.over) { return zero_buf[0..n_frames]; } var args: PlainFnArgsType = undefined; // var args: [L]f32 = [_]f32{0} ** L; // if (!dynamic) { // inline for (InputTypes) |_, i| { // args[i] = 0.0; // } // } else { // for (args) |*a, i| { // a.* = 0.0; // _ = i; // } // } var res_bufs = [_]?[]const f32{undefined} ** (L); var dynamic_args = [_]f32{0.0} ** (L); if (!dynamic) { inline for (InputTypes) |IType, i| { switch (IType) { f32 => { args[i + 1] = self.inputs[i].constant; }, else => { var sub_args: PlayFnArgsType = undefined; sub_args[0] = self.inputs[i].instrument; sub_args[1] = t0; sub_args[2] = n_frames; // print("L={}, instr={*}, sub_args={}\n", .{ L, instr, sub_args }); // dynamic dispatch was // res_bufs[i] = @call(.{}, self.inputs[i].instrument.playFn, sub_args); // static dispatch: res_bufs[i] = @call(.{}, IType.play, sub_args); // print("subcall {}\n", .{res_bufs[i].?[5]}); }, } } } else { for (self.inputs) |input, j| { switch (input) { .constant => { dynamic_args[j] = input.constant; }, .instrument => { var sub_args: PlayFnArgsType = undefined; sub_args[0] = input.instrument; sub_args[1] = t0; sub_args[2] = n_frames; res_bufs[j] = @call(.{}, input.instrument.playFn, sub_args); }, } } } var env_buf: ?[]const f32 = null; var env_val: ?f32 = null; if (EnvelopeType) |T| { switch (T) { f32 => env_val = self.envelope.?.constant, else => { var sub_args: PlayFnArgsType = undefined; sub_args[0] = self.envelope.?.instrument; sub_args[1] = t0; sub_args[2] = n_frames; env_buf = @call(.{}, T.play, sub_args); }, } } for (self.buf[0..n_frames]) |*v, t| { const ft = @intToFloat(f32, t); // print("wrap L {}, args {}, {}\n", .{ L, args, @field(args, "0") }); var result: f32 = undefined; if (!dynamic) { args[0] = t0 + (ft * G.sec_per_frame); inline for (InputTypes) |IType, i| { switch (IType) { f32 => {}, else => { args[i + 1] = res_bufs[i].?[t]; }, } } result = @call(.{}, f, args); } else { for (self.inputs) |input, j| { switch (input) { .instrument => { dynamic_args[j] = res_bufs[j].?[t]; }, .constant => {}, } } var tt = t0 + (ft * G.sec_per_frame); if (L == 1) { result = f(tt, dynamic_args[0]); } else if (L == 2) { result = f(tt, dynamic_args[0], dynamic_args[1]); } else if (L == 3) { result = f(tt, dynamic_args[0], dynamic_args[1], dynamic_args[2]); } } if (env_val) |env_val_| { v.* = result * env_val_; } else if (env_buf) |env_buf_| { v.* = result * env_buf_[t]; } else { v.* = result; } } // print("Return L{}\n", .{L}); return self.buf[0..n_frames]; } pub fn init(alloc: Allocator, approx_start_time: f32, duration: f32, volume: f32, instruments: [L]Signal, envelope: ?Signal) !*@This() { const S = @This(); // TODO duration? or should duration be handled inside the function directly? _ = duration; _ = approx_start_time; _ = instruments; var buf = try alloc.alloc(f32, buf_size); if (L != instruments.len) { print( "Error! Not enough Signals. Expected {}, got {}.\n", .{ instruments.len, L }, ); return error.WrongArgNumber; } var a = try alloc.create(S); a.* = @This(){ .instrument = Instrument{ .approx_start_time = approx_start_time, .playFn = @This().play, .deinitFn = @This().deinit, .volume = volume, }, .inputs = instruments, .envelope = envelope, .buf = buf, .dynamic = dynamic, }; print("Init instr {*}\n", .{&a.instrument}); return a; } pub fn deinit(instr: *Instrument, alloc: Allocator) void { var self = @fieldParentPtr(@This(), "instrument", instr); for (self.inputs) |i| { switch (i) { .constant => {}, .instrument => { i.instrument.deinit(alloc); }, } } alloc.free(self.buf); alloc.destroy(self); } }; } // pub fn kickFreq(t: f32, f: f32) f32 { pub fn kickFreq(t: f32, f: f32, v: f32) f32 { // @setRuntimeSafety(true); return f / std.math.pow(f32, (t + 0.001), v); } pub fn osc(t: f32, f: f32) f32 { // @setRuntimeSafety(true); return std.math.sin(t * std.math.pi * f); } pub fn linearEnv(t: f32, slope: f32) f32 { return math.max(1 + slope * t, 0); } pub fn createOsc(alloc: Allocator, t0: f32, vol: f32, f: f32, slope: f32) !*Instrument { const Env = FF(linearEnv, .{f32}, null); var linear_env = try Env.init(alloc, t0, 0.0, 1.0, [1]Signal{.{ .constant = slope }}, null); const Osc = FF(osc, .{f32}, Env); var ins = [_]Signal{.{ .constant = f }}; var osc_ = try Osc.init(alloc, t0, 0.0, vol, ins, Signal{ .instrument = &linear_env.instrument }); // print("Here, init osc {*}\n", .{osc_.instrument}); return &osc_.instrument; } pub fn createKick(alloc: Allocator, t0: f32, vol: f32, f: f32, v: f32, comptime static: bool) !*Instrument { var ins = [_]Signal{ .{ .constant = f }, .{ .constant = v }, }; const KF = switch (static) { true => FF(kickFreq, .{ f32, f32 }, null), false => FF(kickFreq, 2, null), }; var kick_freq = try KF.init(alloc, t0, 0.0, 1.0, ins, null); const Env = FF(linearEnv, .{f32}, null); var linear_env = try Env.init(alloc, t0, 0.0, 1.0, [1]Signal{.{ .constant = -1.0 }}, null); const K = switch (static) { true => FF(osc, .{KF}, Env), false => FF(osc, 1, Env), }; var kick = try K.init(alloc, t0, 0.0, vol, [1]Signal{.{ .instrument = &kick_freq.instrument }}, Signal{ .instrument = &linear_env.instrument }); // print("Here, init kick {*}\n", .{kick.instrument}); return &kick.instrument; } pub fn fullKick(t: f32, f: f32, v: f32) f32 { const ff: f32 = f / std.math.pow(f32, (t + 0.001), v); return osc(t, ff); } // Single function kick to test performance pub fn createFastKick(alloc: Allocator, t0: f32, vol: f32, f: f32, v: f32, comptime static: bool) !*Instrument { var ins = [_]Signal{ .{ .constant = f }, .{ .constant = v }, }; const KF = switch (static) { true => FF(fullKick, .{ f32, f32 }, null), false => FF(fullKick, 2, null), }; var kick_freq = try KF.init(alloc, t0, 0.0, vol, ins, null); print("Create static ? {} kick {}\n", .{ static, !kick_freq.dynamic }); return &kick_freq.instrument; } test "dynamic dispatch" { // var alloc = std.testing.allocator; // var ins = [_]Signal{ // .{ .constant = 100 }, // .{ .constant = 0.5 }, // }; // const t0: f32 = 0.0; // const KF = FF(kickFreq, 2, null); // var kick_freq = try KF.init(alloc, t0, 0.0, 1.0, ins, null); // // var kick_freq = try FF(kickFreq, 2).init(alloc, t0, 0.0, 1.0, ins); // const K = FF(osc, 1, null); // var kick = try K.init(alloc, t0, 0.0, 1.0, [1]Signal{.{ .instrument = &kick_freq.instrument }}, null); // defer kick.instrument.deinit(alloc); // instruments = InstrumentList.init(alloc) // var time = benchmarkInstruments(&kick.instrument, 200); // print("Time: {}\n", .{time}); } test "comptime loop" { comptime var l: u32 = 0; comptime var k: u32 = 0; inline while (l < 3) : (l += 1) { k += l * l; } print("k={}\n", .{k}); }
src/instruments.zig
const std = @import("std"); const math = std.math; const assert = std.debug.assert; const print = std.debug.print; const Allocator = std.mem.Allocator; pub const util = @import("util.zig"); pub const vector_math = @import("vector_math.zig"); const Color = vector_math.Color; const Vertex = vector_math.Vertex; const Vec3 = vector_math.Vec3; const Transform = vector_math.Transform; const Vec2 = vector_math.Vec2; const Plane = vector_math.Plane; const BmpHeader = packed struct { file_type: u16, file_size: u32, reserved1: u16, reserved2: u16, bitmap_offset: u32, size: u32, width: i32, height: i32, planes: u16, bits_per_pixel: u16, compression: u32, size_of_bitmap: u32, horz_resolution: i32, vert_resolution: i32, colors_used: u32, colors_important: u32, }; pub const Texture = struct { width: u32, height: u32, raw: []u8, }; /// Maps a u and v value, from 0 to 1, to a pixel on a texture and returns the pixel color pub inline fn textureMap(u: f32, v: f32, tex: Texture) Color { const tex_u = @floatToInt(u32, (@intToFloat(f32, tex.width) * u)) % tex.width; const tex_v = @floatToInt(u32, (@intToFloat(f32, tex.height) * v)) % tex.height; const tex_pos = (tex_u + tex_v * tex.height) * 4; const pixel = tex.raw[tex_pos..][0..4]; return Color{ .r = @intToFloat(f32, pixel[2]) / 255.0, .g = @intToFloat(f32, pixel[1]) / 255.0, .b = @intToFloat(f32, pixel[0]) / 255.0, .a = @intToFloat(f32, pixel[3]) / 255.0, }; } /// Return a color from rgba values, 0 to 255 pub fn colorFromRgba(r: u8, g: u8, b: u8, a: u8) Color { return Color{ .r = @intToFloat(f32, r) / 255.0, .g = @intToFloat(f32, g) / 255.0, .b = @intToFloat(f32, b) / 255.0, .a = @intToFloat(f32, a) / 255.0, }; } /// Return a texture from a BMP data, it does not do a allocation, the BMP data pointer is passed directly to the texture data pub fn textureFromBmpData(bmp_data: []const u8) !Texture { const header: *const BmpHeader = @ptrCast(*const BmpHeader, bmp_data[0..@sizeOf(BmpHeader)]); if (header.file_type != 0x4d42) return error.NotBmpFile; if (header.compression != 3) return error.CompressedFile; if (header.bits_per_pixel != 32) return error.InvalidBitsPerPixel; var result_image: Texture = undefined; result_image.width = @intCast(u32, header.width); result_image.height = @intCast(u32, header.height); result_image.pitch = 0; result_image.raw = bmp_data[header.bitmap_offset..]; return result_image; } /// Load a BMP file and returns a Texture. Memory must be freed by the caller pub inline fn loadBMP(al: *Allocator, path: []const u8) !Texture { const data = try std.fs.cwd().readFileAlloc(al, path, 1024 * 1024 * 128); return textureFromBmpData(data); } const TGAHeader = packed struct { id_lenth: u8, colour_map_type: u8, data_type_code: u8, color_map_origin: u16, color_map_length: u16, color_map_depth: u8, x_origin: u16, y_origin: u16, width: u16, height: u16, bits_per_pixel: u8, image_descriptor: u8, }; /// Return a texture from a TGA data. Memory must be freed by the caller pub fn textureFromTgaData(al: *Allocator, file_data: []const u8) !Texture { const header = @ptrCast(*const TGAHeader, &file_data[0]); // Assert that the image is Runlength encoded RGB if (header.data_type_code != 10) { return error.InvalidTGAFormat; } if (header.bits_per_pixel != 32) { return error.InvalidBitsPerPixel; } var data = file_data[(@sizeOf(TGAHeader) + header.id_lenth)..][0..(file_data.len - 26)]; var result = Texture{ .width = header.width, .height = header.height, .raw = undefined, }; var result_data = try al.alloc(u8, @intCast(u32, header.width) * @intCast(u32, header.height) * 4); for (result_data) |*rd| rd.* = 0; errdefer al.free(result.raw); var index: usize = 0; var texture_index: usize = 0; outer_loop: while (index < data.len) { const pb = data[index]; index += 1; const packet_len = pb & 0x7f; if ((pb & 0x80) == 0x00) { // raw packet var i: usize = 0; while (i <= packet_len) : (i += 1) { const alpha = data[index + 3]; const multiplier = @boolToInt(alpha != 0); result_data[texture_index] = data[index] * multiplier; result_data[texture_index + 1] = data[index + 1] * multiplier; result_data[texture_index + 2] = data[index + 2] * multiplier; result_data[texture_index + 3] = alpha; texture_index += 4; if (texture_index >= result_data.len - 3) break :outer_loop; index += 4; } } else { // rl packet var i: usize = 0; while (i <= packet_len) : (i += 1) { const alpha = data[index + 3]; const multiplier = @boolToInt(alpha != 0); result_data[texture_index] = data[index] * multiplier; result_data[texture_index + 1] = data[index + 1] * multiplier; result_data[texture_index + 2] = data[index + 2] * multiplier; result_data[texture_index + 3] = alpha; texture_index += 4; if (texture_index >= result_data.len - 3) break :outer_loop; } index += 4; } } result.raw = result_data; return result; } /// Load a TGA texture. Memory must be freed by the caller pub fn loadTGA(al: *Allocator, path: []const u8) !Texture { const file_data = try std.fs.cwd().readFileAlloc(al, path, 1024 * 1024 * 128); defer al.free(file_data); return try textureFromTgaData(al, file_data); } /// The bitmap font texture is a 16x16 ascii characters /// The font size x and y is the character size in pixels on the texture pub const BitmapFont = struct { texture: Texture, font_size_x: u32, font_size_y: u32, character_spacing: u32, }; pub const Mesh = struct { v: []Vertex, i: []u32, texture: Texture, }; pub const TextureMode = enum { Strech, Tile, }; const RasterMode = enum { Points, Lines, NoShadow, Texture, }; pub const Camera3D = struct { pos: Vec3 = .{}, rotation: Vec3 = .{}, // Euler angles fov: f32 = 70, near: f32 = 0.1, far: f32 = 100.0, }; pub const ClipTriangleReturn = struct { triangle0: [3]Vertex, triangle1: [3]Vertex, count: u32 = 0, }; /// Converts screen coordinates (-1, 1) to pixel coordinates (0, screen size) pub inline fn screenToPixel(sc: f32, screen_size: u32) i32 { return @floatToInt(i32, (sc + 1.0) * 0.5 * @intToFloat(f32, screen_size)); } pub const Buffer = struct { width: u32, height: u32, screen: []u8, depth: []f32, pub fn allocate(b: *Buffer, al: *Allocator, width: u32, height: u32) !void { b.screen = try al.alloc(u8, width * height * 4); errdefer al.free(b.screen); b.depth = try al.alloc(f32, width * height); errdefer al.free(b.depth); b.width = width; b.height = height; } pub fn free(b: *Buffer, al: *Allocator) void { al.free(b.screen); al.free(b.depth); } pub fn resize(b: *Buffer, al: *Allocator, width: u32, height: u32) !void { b.screen = try al.realloc(b.screen, width * height * 4); errdefer al.free(b.screen); b.depth = try al.realloc(b.depth, width * height); errdefer al.free(b.depth); b.width = width; b.height = height; } /// Draw a single pixel to the screen pub inline fn putPixel(b: Buffer, xi: i64, yi: i64, color: Color) void { if (xi > b.width - 1) return; if (yi > b.height - 1) return; if (xi < 0) return; if (yi < 0) return; const x = @intCast(u64, xi); const y = @intCast(u64, yi); const pixel = b.screen[(x + y * b.width) * 4 ..][0..3]; // TODO: Alpha blending if (color.a > 0.999) { pixel[0] = @floatToInt(u8, color.b * 255); pixel[1] = @floatToInt(u8, color.g * 255); pixel[2] = @floatToInt(u8, color.r * 255); } } /// Draw a pixel on the screen using RGBA colors pub inline fn putPixelRGBA(buf: Buffer, x: i64, y: i64, r: u8, g: u8, b: u8, a: u8) void { if (x > buf.width - 1) return; if (y > buf.height - 1) return; if (x < 0) return; if (y < 0) return; const pixel = buf.screen[@intCast(usize, x + y * buf.width) * 4 ..][0..3]; // TODO: Alpha blending if (a > 0) { pixel[0] = r; pixel[1] = g; pixel[2] = b; } } /// Draw a solid colored circle on the screen pub fn fillCircle(b: Buffer, x: i64, y: i64, d: u64, color: Color) void { var r = @intCast(i64, d / 2) + 1; var v: i64 = -r; while (v <= r) : (v += 1) { var u: i64 = -r; while (u <= r) : (u += 1) { if (u * u + v * v < (d * d / 4)) { putPixel(b, x + u, y + v, color); } } } } var print_buff: [512]u8 = undefined; /// Draw a formated text on the screen pub fn drawBitmapFontFmt(b: Buffer, comptime fmt: []const u8, args: anytype, x: i64, y: i64, scale_x: u64, scale_y: u64, font: BitmapFont) void { const fpst = std.fmt.bufPrint(&print_buff, fmt, args) catch { drawBitmapFont(b, "text to long", x, y, scale_x, scale_y, font); return; }; drawBitmapFont(b, fpst, x, y, scale_x, scale_y, font); } /// Draw a text on the screen pub fn drawBitmapFont(b: Buffer, text: []const u8, x: i64, y: i64, scale_x: u64, scale_y: u64, font: BitmapFont) void { for (text) |t, i| { // const char_index: u64 = t; // const fx = char_index % 16 * font.font_size_x; // const fy = char_index / 16 * font.font_size_y; const x_pos = x + @intCast(i64, i * scale_x * font.character_spacing); drawBitmapChar(b, t, x_pos, y, scale_x, scale_y, font); } } /// Draw a character on the screen pub fn drawBitmapChar(b: Buffer, char: u8, x: i64, y: i64, scale_x: u64, scale_y: u64, font: BitmapFont) void { const fx = char % 16 * font.font_size_x; const fy = char / 16 * font.font_size_y; const scale_x_i64 = @intCast(i64, scale_x); const scale_y_i64 = @intCast(i64, scale_y); var yi: i64 = 0; while (yi < font.font_size_y) : (yi += 1) { var xi: i64 = 0; while (xi < font.font_size_x) : (xi += 1) { const tex_pos = @intCast(usize, (fx + xi) + (fy + yi) * font.texture.width) * 4; const color = font.texture.raw[tex_pos..][0..4]; var sy: i64 = 0; while (sy < scale_y) : (sy += 1) { var sx: i64 = 0; while (sx < scale_x) : (sx += 1) { const x_pos = x + xi * scale_x_i64 + sx; const y_pos = y + yi * scale_y_i64 + sy; putPixelRGBA(b, x_pos, y_pos, color[0], color[1], color[2], color[3]); } } } } } /// draw a filled rectangle pub fn fillRect(b: Buffer, x: i64, y: i64, w: u64, h: u64, color: Color) void { // Clamp values const max_x = @intCast(i64, b.width); const max_y = @intCast(i64, b.height); const x1 = std.math.clamp(x, 0, max_x); const y1 = std.math.clamp(y, 0, max_y); const sx2 = @intCast(i64, w) + x; const sy2 = @intCast(i64, h) + y; const x2 = std.math.clamp(sx2, 0, max_x); const y2 = std.math.clamp(sy2, 0, max_y); var y_i: i64 = y1; while (y_i < y2) : (y_i += 1) { var x_i: i64 = x1; while (x_i < x2) : (x_i += 1) { putPixel(b, x_i, y_i, color); } } } /// Draw a texture on the screen, the texture can be resized pub fn drawTexture(b: Buffer, x: i64, y: i64, w: u64, h: u64, tex: Texture) void { const max_x = @intCast(i64, b.width); const max_y = @intCast(i64, b.height); const x1 = @intCast(u64, std.math.clamp(x, 0, max_x)); const y1 = @intCast(u64, std.math.clamp(y, 0, max_y)); const sx2 = @intCast(i64, w) + x; const sy2 = @intCast(i64, h) + y; const x2 = @intCast(u64, std.math.clamp(sx2, 0, max_x)); const y2 = @intCast(u64, std.math.clamp(sy2, 0, max_y)); var texture_y: u64 = @intCast(u64, @intCast(i64, y1) - y); var screen_y: u64 = y1; while (screen_y < y2) : (screen_y += 1) { var texture_x: u64 = @intCast(u64, @intCast(i64, x1) - x); var screen_x: u64 = x1; while (screen_x < x2) : (screen_x += 1) { // get pointer to pixel on the screen const buffer_i = 4 * (screen_x + screen_y * b.width); const pixel = b.screen[buffer_i..]; // get pointer to pixel on texture const tex_pixel_pos = 4 * (((texture_x * tex.width) / w) + ((texture_y * tex.height) / h) * tex.width); const tex_pixel = tex.raw[tex_pixel_pos..]; @memcpy(pixel.ptr, tex_pixel.ptr, 4); texture_x += 1; } texture_y += 1; } } /// Blit texture on screen, does not change the size of the texture pub fn blitTexture(b: Buffer, x: i64, y: i64, tex: Texture) void { // Clamp values const max_x = @intCast(i64, b.width); const max_y = @intCast(i64, b.height); const x1 = @intCast(u32, std.math.clamp(x, 0, max_x)); const y1 = @intCast(u32, std.math.clamp(y, 0, max_y)); const sx2 = @intCast(i64, tex.width) + x; const sy2 = @intCast(i64, tex.height) + y; const x2 = @intCast(u32, std.math.clamp(sx2, 0, max_x)); const y2 = @intCast(u32, std.math.clamp(sy2, 0, max_y)); var texture_y: u32 = if (y < y1) @intCast(u32, @intCast(i64, y1) - y) else 0; var screen_y: u32 = y1; const texture_x: u32 = if (x < x1 and x2 > 0) @intCast(u32, @intCast(i64, x1) - x) else 0; while (screen_y < y2) : (screen_y += 1) { // get pointer to pixel on texture const tex_pixel_pos = 4 * (texture_x + texture_y * tex.width); const tex_pixel = tex.raw[tex_pixel_pos..]; // get pointer to pixel on screen const buffer_i = 4 * (x1 + screen_y * b.width); const pixel = b.screen[buffer_i..]; @memcpy(pixel.ptr, tex_pixel.ptr, 4 * (x2 - x1)); texture_y += 1; } } /// Blit texture on screen, does not change the size of the texture pub fn blitTextureAlpha(b: Buffer, x: i64, y: i64, tex: Texture) void { // Clamp values const max_x = @intCast(i64, b.width); const max_y = @intCast(i64, b.height); const x1 = @intCast(u32, std.math.clamp(x, 0, max_x)); const y1 = @intCast(u32, std.math.clamp(y, 0, max_y)); const sx2 = @intCast(i64, tex.width) + x; const sy2 = @intCast(i64, tex.height) + y; const x2 = @intCast(u32, std.math.clamp(sx2, 0, max_x)); const y2 = @intCast(u32, std.math.clamp(sy2, 0, max_y)); var texture_y: u32 = if (y < y1) @intCast(u32, @intCast(i64, y1) - y) else 0; var screen_y: u32 = y1; const texture_x: u32 = if (x < x1 and x2 > 0) @intCast(u32, @intCast(i64, x1) - x) else 0; while (screen_y < y2) : (screen_y += 1) { // get pointer to pixel on texture const tex_pixel_pos = 4 * (texture_x + texture_y * tex.width); const tex_pixel = tex.raw[tex_pixel_pos..]; // get pointer to pixel on screen const buffer_i = 4 * (x1 + screen_y * b.width); const pixel = b.screen[buffer_i..]; var xi: u32 = x1; while (xi < x2) : (xi += 1) { const pos = (xi - x1) * 4; if (tex_pixel[pos + 3] > 0) { pixel[pos] = tex_pixel[pos]; pixel[pos + 1] = tex_pixel[pos + 1]; pixel[pos + 2] = tex_pixel[pos + 2]; } } texture_y += 1; } } /// draw a hollow rectangle pub fn drawRect(b: Buffer, x: i64, y: i64, w: u64, h: u64, color: Color) void { // const width = @intCast(i64, std.math.clamp(w, 0, b.width)) - x; // const height = @intCast(i64, std.math.clamp(h, 0, b.height)) - y; const max_x = @intCast(i64, b.width); const max_y = @intCast(i64, b.height); const x1 = std.math.clamp(x, 0, max_x); const y1 = std.math.clamp(y, 0, max_y); const sx2 = @intCast(i64, w) + x; const sy2 = @intCast(i64, h) + y; const x2 = std.math.clamp(sx2, 0, max_x); const y2 = std.math.clamp(sy2, 0, max_y); if (x2 == 0 or y2 == 0) return; var xi: i64 = x1; while (xi < x2) : (xi += 1) { putPixel(b, xi, y1, color); putPixel(b, xi, y2 - 1, color); } var yi: i64 = y1; while (yi < y2) : (yi += 1) { putPixel(b, x1, yi, color); putPixel(b, x2 - 1, yi, color); } } /// draw a line with a width of 1 pixel pub fn drawLine(b: Buffer, xa: i64, ya: i64, xb: i64, yb: i64, color: Color) void { const xr = std.math.max(xa, xb); const xl = std.math.min(xa, xb); const yu = std.math.min(ya, yb); const yd = std.math.max(ya, yb); const x_dist = xr - xl; const y_dist = yd - yu; if (x_dist < y_dist) { var y = yu; var dx = @intToFloat(f32, x_dist) / @intToFloat(f32, y_dist); var x: f32 = 0.0; if (ya == yu) { x = @intToFloat(f32, xa); if (xa == xr) dx = -dx; } else { x = @intToFloat(f32, xb); if (xb == xr) dx = -dx; } while (y <= yd) : (y += 1) { putPixel(b, @floatToInt(i64, x), y, color); x += dx; } } else { var x = xl; var dy = @intToFloat(f32, y_dist) / @intToFloat(f32, x_dist); var y: f32 = 0.0; if (xa == xl) { y = @intToFloat(f32, ya); if (ya == yd) dy = -dy; } else { y = @intToFloat(f32, yb); if (yb == yd) dy = -dy; } while (x <= xr) : (x += 1) { putPixel(b, x, @floatToInt(i64, y), color); y += dy; } } } /// Draw a line with a width defined by line_width pub fn drawLineWidth(b: Buffer, xa: i64, ya: i64, xb: i64, yb: i64, color: Color, line_width: u64) void { if (line_width == 1) { drawLine(b, xa, ya, xb, yb, color); return; } const xr = std.math.max(xa, xb); const xl = std.math.min(xa, xb); const yu = std.math.min(ya, yb); const yd = std.math.max(ya, yb); const x_dist = xr - xl; const y_dist = yd - yu; if (x_dist < y_dist) { var y = yu; var dx = @intToFloat(f32, x_dist) / @intToFloat(f32, y_dist); var x: f32 = 0.0; if (ya == yu) { x = @intToFloat(f32, xa); if (xa == xr) dx = -dx; } else { x = @intToFloat(f32, xb); if (xb == xr) dx = -dx; } while (y <= yd) : (y += 1) { fillCircle(b, @floatToInt(i64, x), y, line_width, color); x += dx; } } else { var x = xl; var dy = @intToFloat(f32, y_dist) / @intToFloat(f32, x_dist); var y: f32 = 0.0; if (xa == xl) { y = @intToFloat(f32, ya); if (ya == yd) dy = -dy; } else { y = @intToFloat(f32, yb); if (yb == yd) dy = -dy; } while (x <= xr) : (x += 1) { fillCircle(b, x, @floatToInt(i64, y), line_width / 2, color); y += dy; } } } /// Fill the screen with a RGB color pub fn fillScreenWithRGBColor(buf: Buffer, r: u8, g: u8, b: u8) void { var index: usize = 0; while (index < buf.screen.len) : (index += 4) { buf.screen[index] = b; buf.screen[index + 1] = g; buf.screen[index + 2] = r; } } /// Draw a triangle pub inline fn drawTriangle(b: Buffer, xa: i64, ya: i64, xb: i64, yb: i64, xc: i64, yc: i64, color: Color, line_width: u64) void { drawLineWidth(b, xa, ya, xb, yb, color, line_width); drawLineWidth(b, xb, yb, xc, yc, color, line_width); drawLineWidth(b, xc, yc, xa, ya, color, line_width); } /// Draw a solid triangle pub fn fillTriangle(b: Buffer, xa: i64, ya: i64, xb: i64, yb: i64, xc: i64, yc: i64, color: Color) void { const x_left = math.min(math.min(xa, xb), math.max(xc, 0)); const x_right = math.max(math.max(xa, xb), math.min(xc, @intCast(i64, b.width))); const y_up = math.min(math.min(ya, yb), math.max(yc, 0)); const y_down = math.max(math.max(ya, yb), math.min(yc, @intCast(i64, b.height))); var y: i64 = y_up; while (y < y_down) : (y += 1) { var x: i64 = x_left; while (x < x_right) : (x += 1) { var w0 = vector_math.edgeFunctionI(xb, yb, xc, yc, x, y); var w1 = vector_math.edgeFunctionI(xc, yc, xa, ya, x, y); var w2 = vector_math.edgeFunctionI(xa, ya, xb, yb, x, y); if (w0 >= 0 and w1 >= 0 and w2 >= 0) { putPixel(b, x, y, color); } } } } // ==== 3d renderer ==== /// Raster a triangle pub fn rasterTriangle(b: Buffer, triangle: [3]Vertex, texture: Texture, face_lighting: f32) void { @setFloatMode(.Optimized); const v_size = 4; const face_lighting_i = @floatToInt(u16, face_lighting * 255); const xa = screenToPixel(triangle[0].pos.x, b.width); const xb = screenToPixel(triangle[1].pos.x, b.width); const xc = screenToPixel(triangle[2].pos.x, b.width); const ya = screenToPixel(-triangle[0].pos.y, b.height); const yb = screenToPixel(-triangle[1].pos.y, b.height); const yc = screenToPixel(-triangle[2].pos.y, b.height); const x_left = math.max(math.min(math.min(xa, xb), xc), 0); const x_right = math.min(math.max(math.max(xa, xb), xc), @intCast(i64, b.width - 1)); const y_up = math.max(math.min(math.min(ya, yb), yc), 0); const y_down = math.min(math.max(math.max(ya, yb), yc), @intCast(i64, b.height - 1)); const w0_a = @intToFloat(f32, yc - yb); const w1_a = @intToFloat(f32, ya - yc); const area = @intToFloat(f32, util.edgeFunctionI(xa, ya, xb, yb, xc, yc)); if (area < 0.0001 and area > -0.0001) return; const w0_a_v = @splat(v_size, w0_a); const w1_a_v = @splat(v_size, w1_a); const area_v = @splat(v_size, area); const one_v = @splat(v_size, @as(f32, 1.0)); const zero_v = @splat(v_size, @as(f32, 0.0)); const inc_v: std.meta.Vector(v_size, f32) = blk: { var v = @splat(v_size, @as(f32, 0.0)); var i: u64 = 0; while (i < v_size) : (i += 1) v[i] = @intToFloat(f32, i); break :blk v; }; // const false_v = @splat(v_size, @as(bool, false)); const xb_v = @splat(v_size, @intToFloat(f32, xb)); const xc_v = @splat(v_size, @intToFloat(f32, xc)); const tri0_w_v = @splat(v_size, triangle[0].w); const tri1_w_v = @splat(v_size, triangle[1].w); const tri2_w_v = @splat(v_size, triangle[2].w); const tri0_u_v = @splat(v_size, triangle[0].uv.x); const tri1_u_v = @splat(v_size, triangle[1].uv.x); const tri2_u_v = @splat(v_size, triangle[2].uv.x); const tri0_v_v = @splat(v_size, triangle[0].uv.y); const tri1_v_v = @splat(v_size, triangle[1].uv.y); const tri2_v_v = @splat(v_size, triangle[2].uv.y); const tex_width_v = @splat(v_size, @intToFloat(f32, texture.width)); const tex_height_v = @splat(v_size, @intToFloat(f32, texture.height)); var y: i64 = y_up; while (y <= y_down) : (y += 1) { var x: i64 = x_left; const db_iy = y * @intCast(i64, b.width); const w0_b = @intToFloat(f32, (y -% yb) *% (xc -% xb)); const w1_b = @intToFloat(f32, (y -% yc) *% (xa -% xc)); const w0_b_v = @splat(v_size, w0_b); const w1_b_v = @splat(v_size, w1_b); while (x <= x_right) { const x_v = @splat(v_size, @intToFloat(f32, x)) + inc_v; var w0_v = ((x_v - xb_v) * w0_a_v - w0_b_v) / area_v; var w1_v = ((x_v - xc_v) * w1_a_v - w1_b_v) / area_v; var w2_v = one_v - w1_v - w0_v; const w0_cmp_v = w0_v < zero_v; const w1_cmp_v = w1_v < zero_v; const w2_cmp_v = w2_v < zero_v; if (@reduce(.And, w0_cmp_v)) { x += v_size; continue; } if (@reduce(.And, w1_cmp_v)) { x += v_size; continue; } if (@reduce(.And, w2_cmp_v)) { x += v_size; continue; } w0_v /= tri0_w_v; w1_v /= tri1_w_v; w2_v /= tri2_w_v; const w_sum = w0_v + w1_v + w2_v; if (@reduce(.Or, w_sum == zero_v)) { x += v_size; continue; } w0_v /= w_sum; w1_v /= w_sum; w2_v /= w_sum; var db_i = @intCast(u64, x + db_iy); db_i = math.min(db_i, b.width * b.height - v_size); var depth_slice = b.depth[db_i..][0..v_size]; const depth_v: std.meta.Vector(v_size, f32) = depth_slice.*; const z_v = tri0_w_v * w0_v + tri1_w_v * w1_v + tri2_w_v * w2_v; const z_mask_v = depth_v < z_v; if (@reduce(.And, z_mask_v)) { x += v_size; continue; } var u_v = tri0_u_v * w0_v + tri1_u_v * w1_v + tri2_u_v * w2_v; var v_v = tri0_v_v * w0_v + tri1_v_v * w1_v + tri2_v_v * w2_v; u_v *= tex_width_v; v_v *= tex_height_v; var i: u64 = 0; while (i < v_size and x < b.width) : (i += 1) { // var w0 = w0_v[i]; // var w1 = w1_v[i]; // var w2 = w2_v[i]; if (!(w0_cmp_v[i] or w1_cmp_v[i] or w2_cmp_v[i])) { const z = z_v[i]; if (!z_mask_v[i]) { depth_slice[i] = z; const tex_u = @intCast(usize, @mod(@floatToInt(i64, u_v[i]), @intCast(i64, texture.width))); const tex_v = @intCast(usize, @mod(@floatToInt(i64, v_v[i]), @intCast(i64, texture.height))); const tex_pos = (tex_u + tex_v * texture.width) * 4; var tpixel = texture.raw[tex_pos..][0..4].*; tpixel[0] = @intCast(u8, tpixel[0] * face_lighting_i / 255); tpixel[1] = @intCast(u8, tpixel[1] * face_lighting_i / 255); tpixel[2] = @intCast(u8, tpixel[2] * face_lighting_i / 255); const pixel_pos = @intCast(u64, x + y * @intCast(i64, b.width)) * 4; const pixel = b.screen[pixel_pos..][0..4]; if (tpixel[3] > 0) { pixel[0] = tpixel[0]; pixel[1] = tpixel[1]; pixel[2] = tpixel[2]; } } } x += 1; } } } } pub fn drawMesh(b: Buffer, mesh: Mesh, mode: RasterMode, cam: Camera3D, transform: Transform) void { const hw_ratio = @intToFloat(f32, b.height) / @intToFloat(f32, b.width); const proj_matrix = vector_math.perspectiveMatrix(cam.near, cam.far, cam.fov, hw_ratio); var index: u64 = 0; main_loop: while (index < mesh.i.len - 2) : (index += 3) { const ia = mesh.i[index]; const ib = mesh.i[index + 1]; const ic = mesh.i[index + 2]; var triangle = [_]Vertex{ mesh.v[ia], mesh.v[ib], mesh.v[ic] }; // World Trasform { var i: u64 = 0; while (i < 3) : (i += 1) { triangle[i].pos = vector_math.Vec3_add(triangle[i].pos, transform.position); } } // Calculate normal var n = Vec3{}; { const t1 = vector_math.Vec3_sub(triangle[1].pos, triangle[0].pos); const t2 = vector_math.Vec3_sub(triangle[2].pos, triangle[0].pos); n = vector_math.Vec3_normalize(vector_math.Vec3_cross(t1, t2)); } const face_normal_dir = vector_math.Vec3_dot(n, vector_math.Vec3_sub(triangle[0].pos, cam.pos)); if (face_normal_dir > 0.0) continue; // Lighting var face_lighting: f32 = 1.0; { var ld = vector_math.Vec3_normalize(Vec3.c(0.5, -2.0, 1.0)); face_lighting = vector_math.Vec3_dot(ld, n.neg()); if (face_lighting < 0.1) face_lighting = 0.1; } var triangle_l: [8][3]Vertex = undefined; var triangle_l_len: u64 = 1; triangle_l[0] = triangle; // Camera Trasform { var i: u64 = 0; while (i < 3) : (i += 1) { triangle_l[0][i].pos = vector_math.Vec3_sub(triangle_l[0][i].pos, cam.pos); triangle_l[0][i].pos = vector_math.rotateVectorOnY(triangle_l[0][i].pos, cam.rotation.y); triangle_l[0][i].pos = vector_math.rotateVectorOnX(triangle_l[0][i].pos, cam.rotation.x); } } { // clip near const cliping_result = clipTriangle(triangle_l[0], Plane.c(0, 0, -1, -cam.near)); if (cliping_result.count == 0) continue :main_loop; triangle_l[0] = cliping_result.triangle0; if (cliping_result.count == 2) { triangle_l_len += 1; triangle_l[1] = cliping_result.triangle1; } } { // clip far const cliping_result = clipTriangle(triangle_l[0], Plane.c(0, 0, 1, cam.far)); if (cliping_result.count == 0) continue :main_loop; triangle_l[0] = cliping_result.triangle0; } // Projection var j: u64 = 0; while (j < triangle_l_len) : (j += 1) { var i: u64 = 0; while (i < 3) : (i += 1) { var new_t = Vec3{}; new_t.x = proj_matrix[0][0] * triangle_l[j][i].pos.x; new_t.y = proj_matrix[1][1] * triangle_l[j][i].pos.y; new_t.z = proj_matrix[2][2] * triangle_l[j][i].pos.z + proj_matrix[2][3]; const new_w = proj_matrix[3][2] * triangle_l[j][i].pos.z + proj_matrix[3][3]; triangle_l[j][i].w = new_w; //std.debug.print("w = {d:0.4}\n", .{new_w}); triangle_l[j][i].pos = vector_math.Vec3_div_F(new_t, new_w); } } // Cliping on the side const planes = [_]Plane{ Plane.c(-1, 0, 0, 1), Plane.c(1, 0, 0, 1), Plane.c(0, 1, 0, 1), Plane.c(0, -1, 0, 1), }; // NOTE(Samuel): Cliping on the side // HACK(Samuel): On the side I'm only cliping triangles that are completly outside of the screen for (planes) |plane| { var tl_index: u64 = 0; const len = triangle_l_len; while (tl_index < len) : (tl_index += 1) { const cliping_result = clipTriangle(triangle_l[tl_index], plane); if (cliping_result.count == 0) { for (triangle_l[tl_index..triangle_l_len]) |*it, i| { it.* = triangle_l[tl_index + i + 1]; } triangle_l_len -= 1; } } } if (triangle_l_len == 0) continue :main_loop; var tl_index: u64 = 0; while (tl_index < triangle_l_len) : (tl_index += 1) { triangle = triangle_l[tl_index]; switch (mode) { .Points, .Lines => { // const pixel_size_y = 1.0 / @intToFloat(f32, b.height); // const pixel_size_x = 1.0 / @intToFloat(f32, b.width); const xa = screenToPixel(triangle[0].pos.x, b.width); const xb = screenToPixel(triangle[1].pos.x, b.width); const xc = screenToPixel(triangle[2].pos.x, b.width); const ya = screenToPixel(-triangle[0].pos.y, b.height); const yb = screenToPixel(-triangle[1].pos.y, b.height); const yc = screenToPixel(-triangle[2].pos.y, b.height); if (mode == .Points) { fillCircle(b, xa, ya, 5, Color.c(1, 1, 1, 1)); fillCircle(b, xb, yb, 5, Color.c(1, 1, 1, 1)); fillCircle(b, xc, yc, 5, Color.c(1, 1, 1, 1)); } else if (mode == .Lines) { const line_color = Color.c(1, 1, 1, 1); drawTriangle(b, xa, ya, xb, yb, xc, yc, line_color, 1); } }, .NoShadow => { rasterTriangle(b, triangle, mesh.texture, 1.0); }, .Texture => { rasterTriangle(b, triangle, mesh.texture, face_lighting); }, } } } } }; /// Return a cube mesh pub fn cubeMesh(al: *Allocator) Mesh { var cube_v = [_]Vertex{ Vertex.c(Vec3.c(-0.5, 0.5, 0.5), Vec2.c(0, 1)), Vertex.c(Vec3.c(0.5, 0.5, 0.5), Vec2.c(1, 1)), Vertex.c(Vec3.c(-0.5, -0.5, 0.5), Vec2.c(0, 0)), Vertex.c(Vec3.c(0.5, -0.5, 0.5), Vec2.c(1, 0)), Vertex.c(Vec3.c(-0.5, 0.5, -0.5), Vec2.c(1, 1)), Vertex.c(Vec3.c(0.5, 0.5, -0.5), Vec2.c(0, 1)), Vertex.c(Vec3.c(-0.5, -0.5, -0.5), Vec2.c(1, 0)), Vertex.c(Vec3.c(0.5, -0.5, -0.5), Vec2.c(0, 0)), // top Vertex.c(Vec3.c(-0.5, 0.5, 0.5), Vec2.c(0, 0)), Vertex.c(Vec3.c(0.5, 0.5, 0.5), Vec2.c(1, 0)), Vertex.c(Vec3.c(-0.5, -0.5, 0.5), Vec2.c(0, 1)), Vertex.c(Vec3.c(0.5, -0.5, 0.5), Vec2.c(1, 1)), Vertex.c(Vec3.c(-0.5, 0.5, -0.5), Vec2.c(0, 1)), Vertex.c(Vec3.c(0.5, 0.5, -0.5), Vec2.c(1, 1)), Vertex.c(Vec3.c(-0.5, -0.5, -0.5), Vec2.c(0, 0)), Vertex.c(Vec3.c(0.5, -0.5, -0.5), Vec2.c(1, 0)), }; var cube_i = [_]u32{ 0, 2, 3, 0, 3, 1, 1, 3, 7, 1, 7, 5, 4, 6, 2, 4, 2, 0, 5, 7, 6, 5, 6, 4, // top 4 + 8, 0 + 8, 1 + 8, 4 + 8, 1 + 8, 5 + 8, 6 + 8, 3 + 8, 2 + 8, 6 + 8, 7 + 8, 3 + 8, }; var cube_mesh = Mesh{ .v = al.alloc(Vertex, cube_v.len) catch @panic("alloc error\n"), .i = al.alloc(u32, cube_i.len) catch @panic("alloc error\n"), .texture = undefined, }; var i: u64 = 0; while (i < cube_v.len) : (i += 1) { cube_mesh.v[i] = cube_v[i]; } i = 0; while (i < cube_i.len) : (i += 1) { cube_mesh.i[i] = cube_i[i]; } return cube_mesh; } pub fn clipTriangle(triangle: [3]Vertex, plane: Plane) ClipTriangleReturn { var result = ClipTriangleReturn{ .triangle0 = triangle, .triangle1 = triangle, .count = 1, }; // Count outside of the plane var out_count: u64 = 0; const t0_out = blk: { const plane_origin = vector_math.Vec3_mul_F(plane.n, -plane.d); const d = vector_math.Vec3_dot(plane.n, vector_math.Vec3_sub(triangle[0].pos, plane_origin)); if (d < 0.0) { out_count += 1; break :blk true; } break :blk false; }; const t1_out = blk: { const plane_origin = vector_math.Vec3_mul_F(plane.n, -plane.d); const d = vector_math.Vec3_dot(plane.n, vector_math.Vec3_sub(triangle[1].pos, plane_origin)); if (d < 0.0) { out_count += 1; break :blk true; } break :blk false; }; // const t2_out = blk: { // const plane_origin = vector_math.Vec3_mul_F(plane.n, -plane.d); // const d = vector_math.Vec3_dot(plane.n, vector_math.Vec3_sub(triangle[2].pos, plane_origin)); // if (d < 0.0) { // out_count += 1; // break :blk true; // } // break :blk false; // }; if (out_count == 1) { var out_i: u64 = 0; if (!t0_out) { out_i = 1; if (!t1_out) out_i = 2; } const in_i1 = (out_i + 1) % 3; const in_i2 = (out_i + 2) % 3; var t1: f32 = 0.0; var t2: f32 = 0.0; const pos1 = vector_math.lineIntersectPlaneT(triangle[in_i1].pos, triangle[out_i].pos, plane, &t1); const pos2 = vector_math.lineIntersectPlaneT(triangle[in_i2].pos, triangle[out_i].pos, plane, &t2); //const color1 = vector_math.Color_lerp(triangle[in_i1].color, triangle[out_i].color, t1); //const color2 = vector_math.Color_lerp(triangle[in_i2].color, triangle[out_i].color, t2); var uv1 = Vec2{}; var uv2 = Vec2{}; uv1.x = vector_math.lerp(triangle[in_i1].uv.x, triangle[out_i].uv.x, t1); uv1.y = vector_math.lerp(triangle[in_i1].uv.y, triangle[out_i].uv.y, t1); uv2.x = vector_math.lerp(triangle[in_i2].uv.x, triangle[out_i].uv.x, t2); uv2.y = vector_math.lerp(triangle[in_i2].uv.y, triangle[out_i].uv.y, t2); //result.triangle0[out_i].color = color1; //result.triangle1[in_i1].color = color1; //result.triangle1[out_i].color = color2; result.triangle0[out_i].pos = pos1; result.triangle1[in_i1].pos = pos1; result.triangle1[out_i].pos = pos2; result.triangle0[out_i].uv = uv1; result.triangle1[in_i1].uv = uv1; result.triangle1[out_i].uv = uv2; result.count = 2; } else if (out_count == 2) { result.count = 1; var in_i: u64 = 0; if (t0_out) { in_i = 1; if (t1_out) in_i = 2; } const out_i1 = (in_i + 1) % 3; const out_i2 = (in_i + 2) % 3; var t1: f32 = 0.0; var t2: f32 = 0.0; const pos1 = vector_math.lineIntersectPlaneT(triangle[out_i1].pos, triangle[in_i].pos, plane, &t1); const pos2 = vector_math.lineIntersectPlaneT(triangle[out_i2].pos, triangle[in_i].pos, plane, &t2); //const color1 = vector_math.Color_lerp(triangle[out_i1].color, triangle[in_i].color, t1); //const color2 = vector_math.Color_lerp(triangle[out_i2].color, triangle[in_i].color, t2); var uv1 = Vec2{}; var uv2 = Vec2{}; uv1.x = vector_math.lerp(triangle[out_i1].uv.x, triangle[in_i].uv.x, t1); uv1.y = vector_math.lerp(triangle[out_i1].uv.y, triangle[in_i].uv.y, t1); uv2.x = vector_math.lerp(triangle[out_i2].uv.x, triangle[in_i].uv.x, t2); uv2.y = vector_math.lerp(triangle[out_i2].uv.y, triangle[in_i].uv.y, t2); //result.triangle0[out_i1].color = color1; //result.triangle0[out_i2].color = color2; result.triangle0[out_i1].pos = pos1; result.triangle0[out_i2].pos = pos2; result.triangle0[out_i1].uv = uv1; result.triangle0[out_i2].uv = uv2; } else if (out_count == 3) { result.count = 0; } return result; } /// Creates a mesh made with quads with a given size. vertex colors are random pub fn createQuadMesh(al: *Allocator, size_x: u64, size_y: u64, center_x: f32, center_y: f32, texture: Texture, texture_mode: TextureMode) Mesh { var result = Mesh{ .v = al.alloc(Vertex, (size_x + 1) * (size_y + 1)) catch unreachable, .i = al.alloc(u64, size_x * size_y * 6) catch unreachable, .texture = texture, }; // Init Vertex for (result.v) |*v, i| { v.pos.x = @intToFloat(f32, i % (size_x + 1)) - center_x; v.pos.y = @intToFloat(f32, i / (size_x + 1)) - center_y; v.pos.z = 0.0; //v.color.a = 1.0; //v.color.r = randomFloat(f32); //v.color.g = randomFloat(f32); //v.color.b = randomFloat(f32); } if (texture_mode == .Strech) { for (result.v) |*v| { v.uv.x = (v.pos.x + center_x) / @intToFloat(f32, size_x); v.uv.y = 1.0 - (v.pos.y + center_y) / @intToFloat(f32, size_y); } } else if (texture_mode == .Tile) { for (result.v) |*v, i| { const x_i = @intCast(u64, i % (size_x + 1)); const y_i = @intCast(u64, i / (size_x + 1)); v.uv.x = @intToFloat(f32, x_i % 2); v.uv.y = @intToFloat(f32, y_i % 2); } } // Set indexes var index: u64 = 0; var y: u64 = 0; while (y < size_y) : (y += 1) { var x: u64 = 0; while (x < size_x) : (x += 1) { // first triangle var i = x + y * (size_x + 1); result.i[index] = i; index += 1; i = (x + 1) + (y + 1) * (size_x + 1); result.i[index] = i; index += 1; i = x + (y + 1) * (size_x + 1); result.i[index] = i; index += 1; // Second Triangle i = (x + 1) + y * (size_x + 1); result.i[index] = i; index += 1; i = (x + 1) + (y + 1) * (size_x + 1); result.i[index] = i; index += 1; i = x + y * (size_x + 1); result.i[index] = i; index += 1; } } return result; }
src/pixel_draw_module.zig
const wlr = @import("../wlroots.zig"); const wl = @import("wayland").server.wl; pub const TabletTool = extern struct { pub const Type = enum(c_int) { pen = 1, eraser, brush, pencil, airbrush, mouse, lens, totem, }; type: Type, hardware_serial: u64, hardware_wacom: u64, tilt: bool, pressure: bool, distance: bool, rotation: bool, slider: bool, wheel: bool, events: extern struct { destroy: wl.Signal(*TabletTool), }, data: usize, }; pub const Tablet = extern struct { pub const event = struct { pub const Axis = extern struct { device: *wlr.InputDevice, tool: *TabletTool, time_msec: u32, updated_axes: u32, /// From 0..1 x: f64, /// From 0..1 y: f64, /// Relative to last event dx: f64, /// Relative to last event dy: f64, pressure: f64, distance: f64, tilt_x: f64, tilt_y: f64, rotation: f64, slider: f64, wheel_delta: f64, }; pub const Proximity = extern struct { pub const State = enum(c_int) { out, in, }; device: *wlr.InputDevice, tool: *TabletTool, time_msec: u32, x: f64, y: f64, state: Proximity.State, }; pub const Tip = extern struct { pub const State = enum(c_int) { up, down, }; device: *wlr.InputDevice, tool: *TabletTool, time_msec: u32, x: f64, y: f64, state: Tip.State, }; pub const Button = extern struct { device: *wlr.InputDevice, tool: *TabletTool, time_msec: u32, x: f64, y: f64, state: wl.Pointer.ButtonState, }; }; const Impl = opaque {}; impl: *const Impl, events: extern struct { axis: wl.Signal(*event.Axis), proximity: wl.Signal(*event.Proximity), tip: wl.Signal(*event.Tip), button: wl.Signal(*event.Button), }, name: [*:0]u8, paths: wl.Array, data: usize, };
src/types/tablet_tool.zig
const std = @import("std"); const kernel = @import("kernel.zig"); const print = @import("print.zig"); const threading = @import("threading.zig"); const List = @import("list.zig").List; const memory = @import("memory.zig"); pub const Error = memory.MemoryError; pub const Lock = struct { locked: bool = false, /// Try to set locked to true if it's false. Return true if we couldn't do that. pub fn lock(self: *Lock) bool { return @cmpxchgStrong(bool, &self.locked, false, true, .Acquire, .Monotonic) != null; } /// Try to acquire lock forever pub fn spin_lock(self: *Lock) void { while (@cmpxchgWeak(bool, &self.locked, false, true, .Acquire, .Monotonic) != null) {} } pub fn unlock(self: *Lock) void { if (@cmpxchgStrong(bool, &self.locked, true, false, .Release, .Monotonic) != null) { @panic("Lock.unlock: Already unlocked"); } } }; test "Lock" { var lock = Lock{}; try std.testing.expect(!lock.lock()); try std.testing.expect(lock.lock()); lock.unlock(); try std.testing.expect(!lock.lock()); try std.testing.expect(lock.lock()); lock.unlock(); lock.spin_lock(); try std.testing.expect(lock.lock()); lock.unlock(); } pub fn Semaphore(comptime Type: type) type { return struct { const Self = @This(); lock: Lock = .{}, value: Type = 1, queue: List(threading.Thread.Id) = undefined, pub fn init(self: *Self) void { self.queue = .{.alloc = kernel.alloc}; } pub fn wait(self: *Self) Error!void { self.lock.spin_lock(); if (self.value == 0) { const thread = kernel.threading_mgr.current_thread.?; try self.queue.push_back(thread.id); thread.state = .Wait; self.lock.unlock(); kernel.threading_mgr.yield(); } else { self.value -= 1; self.lock.unlock(); } } pub fn signal(self: *Self) Error!void { self.lock.spin_lock(); self.value += 1; // TODO: Threads that exit with signalling should be done by kernel. while (try self.queue.pop_front()) |tid| { if (kernel.threading_mgr.thread_list.find(tid)) |thread| { thread.state = .Run; break; } } self.lock.unlock(); } }; } var system_test_lock_1 = Lock{.locked = true}; var system_test_lock_2 = Lock{}; var system_test_semaphore = Semaphore(u8){}; pub fn system_test_thread_a() void { print.string("system_test_thread_a started\n"); if (system_test_lock_2.lock()) @panic("system_test_lock_2 failed to lock lock 2"); system_test_lock_1.spin_lock(); print.string("system_test_thread_a got lock 1, getting semaphore, freeing lock 2...\n"); system_test_lock_2.unlock(); system_test_lock_1.unlock(); system_test_semaphore.wait() catch @panic("system_test_thread_a system_test_semaphore.wait()"); print.string("system_test_thread_a got semaphore\n"); print.string("system_test_thread_a finished\n"); } pub fn system_test_thread_b() void { print.string("system_test_thread_b started, unlocking lock 1 and waiting on lock 2\n"); system_test_semaphore.wait() catch @panic("system_test_thread_b system_test_semaphore.wait()"); system_test_lock_1.unlock(); system_test_lock_2.spin_lock(); print.string("system_test_thread_b got lock 2, releasing semaphore\n"); system_test_lock_2.unlock(); system_test_semaphore.signal() catch @panic("system_test_thread_b system_test_semaphore.signal()"); print.string("system_test_thread_b finished\n"); } pub fn system_tests() !void { system_test_semaphore.init(); var thread_a = threading.Thread{.kernel_mode = true}; try thread_a.init(false); thread_a.entry = @ptrToInt(system_test_thread_a); var thread_b = threading.Thread{.kernel_mode = true}; try thread_b.init(false); thread_b.entry = @ptrToInt(system_test_thread_b); try kernel.threading_mgr.insert_thread(&thread_a); try kernel.threading_mgr.insert_thread(&thread_b); kernel.threading_mgr.wait_for_thread(thread_a.id); kernel.threading_mgr.wait_for_thread(thread_b.id); }
kernel/sync.zig
const builtin = @import("builtin"); const std = @import("std"); const time = std.time; const Timer = time.Timer; const crypto = std.crypto; const KiB = 1024; const MiB = 1024 * KiB; var prng = std.rand.DefaultPrng.init(0); const Crypto = struct { ty: type, name: []const u8, }; const hashes = [_]Crypto{ Crypto{ .ty = crypto.hash.Md5, .name = "md5" }, Crypto{ .ty = crypto.hash.Sha1, .name = "sha1" }, Crypto{ .ty = crypto.hash.sha2.Sha256, .name = "sha256" }, Crypto{ .ty = crypto.hash.sha2.Sha512, .name = "sha512" }, Crypto{ .ty = crypto.hash.sha3.Sha3_256, .name = "sha3-256" }, Crypto{ .ty = crypto.hash.sha3.Sha3_512, .name = "sha3-512" }, Crypto{ .ty = crypto.hash.Gimli, .name = "gimli-hash" }, Crypto{ .ty = crypto.hash.blake2.Blake2s256, .name = "blake2s" }, Crypto{ .ty = crypto.hash.blake2.Blake2b512, .name = "blake2b" }, Crypto{ .ty = crypto.hash.Blake3, .name = "blake3" }, }; pub fn benchmarkHash(comptime Hash: anytype, comptime bytes: comptime_int) !u64 { var h = Hash.init(.{}); var block: [Hash.digest_length]u8 = undefined; prng.random.bytes(block[0..]); var offset: usize = 0; var timer = try Timer.start(); const start = timer.lap(); while (offset < bytes) : (offset += block.len) { h.update(block[0..]); } const end = timer.read(); const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; const throughput = @floatToInt(u64, bytes / elapsed_s); return throughput; } const macs = [_]Crypto{ Crypto{ .ty = crypto.onetimeauth.Poly1305, .name = "poly1305" }, Crypto{ .ty = crypto.auth.hmac.HmacMd5, .name = "hmac-md5" }, Crypto{ .ty = crypto.auth.hmac.HmacSha1, .name = "hmac-sha1" }, Crypto{ .ty = crypto.auth.hmac.sha2.HmacSha256, .name = "hmac-sha256" }, Crypto{ .ty = crypto.auth.hmac.sha2.HmacSha512, .name = "hmac-sha512" }, Crypto{ .ty = crypto.auth.siphash.SipHash64(2, 4), .name = "siphash-2-4" }, Crypto{ .ty = crypto.auth.siphash.SipHash64(1, 3), .name = "siphash-1-3" }, Crypto{ .ty = crypto.auth.siphash.SipHash128(2, 4), .name = "siphash128-2-4" }, Crypto{ .ty = crypto.auth.siphash.SipHash128(1, 3), .name = "siphash128-1-3" }, }; pub fn benchmarkMac(comptime Mac: anytype, comptime bytes: comptime_int) !u64 { std.debug.assert(64 >= Mac.mac_length and 32 >= Mac.minimum_key_length); var in: [1 * MiB]u8 = undefined; prng.random.bytes(in[0..]); var key: [64]u8 = undefined; prng.random.bytes(key[0..]); var offset: usize = 0; var timer = try Timer.start(); const start = timer.lap(); while (offset < bytes) : (offset += in.len) { Mac.create(key[0..], in[0..], key[0..]); } const end = timer.read(); const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; const throughput = @floatToInt(u64, bytes / elapsed_s); return throughput; } const exchanges = [_]Crypto{Crypto{ .ty = crypto.dh.X25519, .name = "x25519" }}; pub fn benchmarkKeyExchange(comptime DhKeyExchange: anytype, comptime exchange_count: comptime_int) !u64 { std.debug.assert(DhKeyExchange.minimum_key_length >= DhKeyExchange.secret_length); var in: [DhKeyExchange.minimum_key_length]u8 = undefined; prng.random.bytes(in[0..]); var out: [DhKeyExchange.minimum_key_length]u8 = undefined; prng.random.bytes(out[0..]); var timer = try Timer.start(); const start = timer.lap(); { var i: usize = 0; while (i < exchange_count) : (i += 1) { _ = DhKeyExchange.create(out[0..], out[0..], in[0..]); } } const end = timer.read(); const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; const throughput = @floatToInt(u64, exchange_count / elapsed_s); return throughput; } const signatures = [_]Crypto{Crypto{ .ty = crypto.sign.Ed25519, .name = "ed25519" }}; pub fn benchmarkSignatures(comptime Signature: anytype, comptime signatures_count: comptime_int) !u64 { var seed: [Signature.seed_length]u8 = undefined; prng.random.bytes(seed[0..]); const msg = [_]u8{0} ** 64; const key_pair = try Signature.createKeyPair(seed); var timer = try Timer.start(); const start = timer.lap(); { var i: usize = 0; while (i < signatures_count) : (i += 1) { _ = try Signature.sign(&msg, key_pair, null); } } const end = timer.read(); const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; const throughput = @floatToInt(u64, signatures_count / elapsed_s); return throughput; } fn usage() void { std.debug.warn( \\throughput_test [options] \\ \\Options: \\ --filter [test-name] \\ --seed [int] \\ --help \\ , .{}); } fn mode(comptime x: comptime_int) comptime_int { return if (builtin.mode == .Debug) x / 64 else x; } pub fn main() !void { const stdout = std.io.getStdOut().outStream(); var buffer: [1024]u8 = undefined; var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); const args = try std.process.argsAlloc(&fixed.allocator); var filter: ?[]u8 = ""; var i: usize = 1; while (i < args.len) : (i += 1) { if (std.mem.eql(u8, args[i], "--mode")) { try stdout.print("{}\n", .{builtin.mode}); return; } else if (std.mem.eql(u8, args[i], "--seed")) { i += 1; if (i == args.len) { usage(); std.os.exit(1); } const seed = try std.fmt.parseUnsigned(u32, args[i], 10); prng.seed(seed); } else if (std.mem.eql(u8, args[i], "--filter")) { i += 1; if (i == args.len) { usage(); std.os.exit(1); } filter = args[i]; } else if (std.mem.eql(u8, args[i], "--help")) { usage(); return; } else { usage(); std.os.exit(1); } } inline for (hashes) |H| { if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) { const throughput = try benchmarkHash(H.ty, mode(32 * MiB)); try stdout.print("{:>11}: {:5} MiB/s\n", .{ H.name, throughput / (1 * MiB) }); } } inline for (macs) |M| { if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) { const throughput = try benchmarkMac(M.ty, mode(128 * MiB)); try stdout.print("{:>11}: {:5} MiB/s\n", .{ M.name, throughput / (1 * MiB) }); } } inline for (exchanges) |E| { if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) { const throughput = try benchmarkKeyExchange(E.ty, mode(1000)); try stdout.print("{:>11}: {:5} exchanges/s\n", .{ E.name, throughput }); } } inline for (signatures) |E| { if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) { const throughput = try benchmarkSignatures(E.ty, mode(1000)); try stdout.print("{:>11}: {:5} signatures/s\n", .{ E.name, throughput }); } } }
lib/std/crypto/benchmark.zig
const builtin = @import("builtin"); const is_test = builtin.is_test; const is_gnu = switch (builtin.abi) { .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => true, else => false, }; const is_mingw = builtin.os == .windows and is_gnu; comptime { const linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Weak; const strong_linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Strong; switch (builtin.arch) { .i386, .x86_64 => @export("__zig_probe_stack", @import("compiler_rt/stack_probe.zig").zig_probe_stack, linkage), else => {}, } @export("__lesf2", @import("compiler_rt/comparesf2.zig").__lesf2, linkage); @export("__ledf2", @import("compiler_rt/comparedf2.zig").__ledf2, linkage); @export("__letf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage); @export("__gesf2", @import("compiler_rt/comparesf2.zig").__gesf2, linkage); @export("__gedf2", @import("compiler_rt/comparedf2.zig").__gedf2, linkage); @export("__getf2", @import("compiler_rt/comparetf2.zig").__getf2, linkage); if (!is_test) { @export("__cmpsf2", @import("compiler_rt/comparesf2.zig").__lesf2, linkage); @export("__cmpdf2", @import("compiler_rt/comparedf2.zig").__ledf2, linkage); @export("__cmptf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage); @export("__eqsf2", @import("compiler_rt/comparesf2.zig").__eqsf2, linkage); @export("__eqdf2", @import("compiler_rt/comparedf2.zig").__eqdf2, linkage); @export("__eqtf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage); @export("__ltsf2", @import("compiler_rt/comparesf2.zig").__ltsf2, linkage); @export("__ltdf2", @import("compiler_rt/comparedf2.zig").__ltdf2, linkage); @export("__lttf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage); @export("__nesf2", @import("compiler_rt/comparesf2.zig").__nesf2, linkage); @export("__nedf2", @import("compiler_rt/comparedf2.zig").__nedf2, linkage); @export("__netf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage); @export("__gtsf2", @import("compiler_rt/comparesf2.zig").__gtsf2, linkage); @export("__gtdf2", @import("compiler_rt/comparedf2.zig").__gtdf2, linkage); @export("__gttf2", @import("compiler_rt/comparetf2.zig").__getf2, linkage); @export("__gnu_h2f_ieee", @import("compiler_rt/extendXfYf2.zig").__extendhfsf2, linkage); @export("__gnu_f2h_ieee", @import("compiler_rt/truncXfYf2.zig").__truncsfhf2, linkage); } @export("__unordsf2", @import("compiler_rt/comparesf2.zig").__unordsf2, linkage); @export("__unorddf2", @import("compiler_rt/comparedf2.zig").__unorddf2, linkage); @export("__unordtf2", @import("compiler_rt/comparetf2.zig").__unordtf2, linkage); @export("__addsf3", @import("compiler_rt/addXf3.zig").__addsf3, linkage); @export("__adddf3", @import("compiler_rt/addXf3.zig").__adddf3, linkage); @export("__addtf3", @import("compiler_rt/addXf3.zig").__addtf3, linkage); @export("__subsf3", @import("compiler_rt/addXf3.zig").__subsf3, linkage); @export("__subdf3", @import("compiler_rt/addXf3.zig").__subdf3, linkage); @export("__subtf3", @import("compiler_rt/addXf3.zig").__subtf3, linkage); @export("__mulsf3", @import("compiler_rt/mulXf3.zig").__mulsf3, linkage); @export("__muldf3", @import("compiler_rt/mulXf3.zig").__muldf3, linkage); @export("__multf3", @import("compiler_rt/mulXf3.zig").__multf3, linkage); @export("__divsf3", @import("compiler_rt/divsf3.zig").__divsf3, linkage); @export("__divdf3", @import("compiler_rt/divdf3.zig").__divdf3, linkage); @export("__ashlti3", @import("compiler_rt/ashlti3.zig").__ashlti3, linkage); @export("__lshrti3", @import("compiler_rt/lshrti3.zig").__lshrti3, linkage); @export("__ashrti3", @import("compiler_rt/ashrti3.zig").__ashrti3, linkage); @export("__floatsidf", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage); @export("__floatsisf", @import("compiler_rt/floatsiXf.zig").__floatsisf, linkage); @export("__floatdidf", @import("compiler_rt/floatdidf.zig").__floatdidf, linkage); @export("__floatsitf", @import("compiler_rt/floatsiXf.zig").__floatsitf, linkage); @export("__floatunsidf", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage); @export("__floatundidf", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage); @export("__floattitf", @import("compiler_rt/floattitf.zig").__floattitf, linkage); @export("__floattidf", @import("compiler_rt/floattidf.zig").__floattidf, linkage); @export("__floattisf", @import("compiler_rt/floattisf.zig").__floattisf, linkage); @export("__floatunditf", @import("compiler_rt/floatunditf.zig").__floatunditf, linkage); @export("__floatunsitf", @import("compiler_rt/floatunsitf.zig").__floatunsitf, linkage); @export("__floatuntitf", @import("compiler_rt/floatuntitf.zig").__floatuntitf, linkage); @export("__floatuntidf", @import("compiler_rt/floatuntidf.zig").__floatuntidf, linkage); @export("__floatuntisf", @import("compiler_rt/floatuntisf.zig").__floatuntisf, linkage); @export("__extenddftf2", @import("compiler_rt/extendXfYf2.zig").__extenddftf2, linkage); @export("__extendsftf2", @import("compiler_rt/extendXfYf2.zig").__extendsftf2, linkage); @export("__extendhfsf2", @import("compiler_rt/extendXfYf2.zig").__extendhfsf2, linkage); @export("__truncsfhf2", @import("compiler_rt/truncXfYf2.zig").__truncsfhf2, linkage); @export("__truncdfhf2", @import("compiler_rt/truncXfYf2.zig").__truncdfhf2, linkage); @export("__trunctfdf2", @import("compiler_rt/truncXfYf2.zig").__trunctfdf2, linkage); @export("__trunctfsf2", @import("compiler_rt/truncXfYf2.zig").__trunctfsf2, linkage); @export("__truncdfsf2", @import("compiler_rt/truncXfYf2.zig").__truncdfsf2, linkage); @export("__extendsfdf2", @import("compiler_rt/extendXfYf2.zig").__extendsfdf2, linkage); @export("__fixunssfsi", @import("compiler_rt/fixunssfsi.zig").__fixunssfsi, linkage); @export("__fixunssfdi", @import("compiler_rt/fixunssfdi.zig").__fixunssfdi, linkage); @export("__fixunssfti", @import("compiler_rt/fixunssfti.zig").__fixunssfti, linkage); @export("__fixunsdfsi", @import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi, linkage); @export("__fixunsdfdi", @import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi, linkage); @export("__fixunsdfti", @import("compiler_rt/fixunsdfti.zig").__fixunsdfti, linkage); @export("__fixunstfsi", @import("compiler_rt/fixunstfsi.zig").__fixunstfsi, linkage); @export("__fixunstfdi", @import("compiler_rt/fixunstfdi.zig").__fixunstfdi, linkage); @export("__fixunstfti", @import("compiler_rt/fixunstfti.zig").__fixunstfti, linkage); @export("__fixdfdi", @import("compiler_rt/fixdfdi.zig").__fixdfdi, linkage); @export("__fixdfsi", @import("compiler_rt/fixdfsi.zig").__fixdfsi, linkage); @export("__fixdfti", @import("compiler_rt/fixdfti.zig").__fixdfti, linkage); @export("__fixsfdi", @import("compiler_rt/fixsfdi.zig").__fixsfdi, linkage); @export("__fixsfsi", @import("compiler_rt/fixsfsi.zig").__fixsfsi, linkage); @export("__fixsfti", @import("compiler_rt/fixsfti.zig").__fixsfti, linkage); @export("__fixtfdi", @import("compiler_rt/fixtfdi.zig").__fixtfdi, linkage); @export("__fixtfsi", @import("compiler_rt/fixtfsi.zig").__fixtfsi, linkage); @export("__fixtfti", @import("compiler_rt/fixtfti.zig").__fixtfti, linkage); @export("__udivmoddi4", @import("compiler_rt/udivmoddi4.zig").__udivmoddi4, linkage); @export("__popcountdi2", @import("compiler_rt/popcountdi2.zig").__popcountdi2, linkage); @export("__muldi3", @import("compiler_rt/muldi3.zig").__muldi3, linkage); @export("__divmoddi4", __divmoddi4, linkage); @export("__divsi3", __divsi3, linkage); @export("__divdi3", __divdi3, linkage); @export("__udivsi3", __udivsi3, linkage); @export("__udivdi3", __udivdi3, linkage); @export("__modsi3", __modsi3, linkage); @export("__moddi3", __moddi3, linkage); @export("__umodsi3", __umodsi3, linkage); @export("__umoddi3", __umoddi3, linkage); @export("__divmodsi4", __divmodsi4, linkage); @export("__udivmodsi4", __udivmodsi4, linkage); @export("__negsf2", @import("compiler_rt/negXf2.zig").__negsf2, linkage); @export("__negdf2", @import("compiler_rt/negXf2.zig").__negdf2, linkage); if (is_arm_arch and !is_arm_64 and !is_test) { @export("__aeabi_unwind_cpp_pr0", __aeabi_unwind_cpp_pr0, strong_linkage); @export("__aeabi_unwind_cpp_pr1", __aeabi_unwind_cpp_pr1, linkage); @export("__aeabi_unwind_cpp_pr2", __aeabi_unwind_cpp_pr2, linkage); @export("__aeabi_lmul", @import("compiler_rt/muldi3.zig").__muldi3, linkage); @export("__aeabi_ldivmod", __aeabi_ldivmod, linkage); @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage); @export("__aeabi_idiv", __divsi3, linkage); @export("__aeabi_idivmod", __aeabi_idivmod, linkage); @export("__aeabi_uidiv", __udivsi3, linkage); @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage); @export("__aeabi_memcpy", __aeabi_memcpy, linkage); @export("__aeabi_memcpy4", __aeabi_memcpy, linkage); @export("__aeabi_memcpy8", __aeabi_memcpy, linkage); @export("__aeabi_memmove", __aeabi_memmove, linkage); @export("__aeabi_memmove4", __aeabi_memmove, linkage); @export("__aeabi_memmove8", __aeabi_memmove, linkage); @export("__aeabi_memset", __aeabi_memset, linkage); @export("__aeabi_memset4", __aeabi_memset, linkage); @export("__aeabi_memset8", __aeabi_memset, linkage); @export("__aeabi_memclr", __aeabi_memclr, linkage); @export("__aeabi_memclr4", __aeabi_memclr, linkage); @export("__aeabi_memclr8", __aeabi_memclr, linkage); @export("__aeabi_memcmp", __aeabi_memcmp, linkage); @export("__aeabi_memcmp4", __aeabi_memcmp, linkage); @export("__aeabi_memcmp8", __aeabi_memcmp, linkage); @export("__aeabi_f2d", @import("compiler_rt/extendXfYf2.zig").__extendsfdf2, linkage); @export("__aeabi_i2d", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage); @export("__aeabi_l2d", @import("compiler_rt/floatdidf.zig").__floatdidf, linkage); @export("__aeabi_ui2d", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage); @export("__aeabi_ul2d", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage); @export("__aeabi_fneg", @import("compiler_rt/negXf2.zig").__negsf2, linkage); @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__negdf2, linkage); @export("__aeabi_fmul", @import("compiler_rt/mulXf3.zig").__mulsf3, linkage); @export("__aeabi_dmul", @import("compiler_rt/mulXf3.zig").__muldf3, linkage); @export("__aeabi_d2h", @import("compiler_rt/truncXfYf2.zig").__truncdfhf2, linkage); @export("__aeabi_f2ulz", @import("compiler_rt/fixunssfdi.zig").__fixunssfdi, linkage); @export("__aeabi_d2ulz", @import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi, linkage); @export("__aeabi_f2lz", @import("compiler_rt/fixsfdi.zig").__fixsfdi, linkage); @export("__aeabi_d2lz", @import("compiler_rt/fixdfdi.zig").__fixdfdi, linkage); @export("__aeabi_d2uiz", @import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi, linkage); @export("__aeabi_h2f", @import("compiler_rt/extendXfYf2.zig").__extendhfsf2, linkage); @export("__aeabi_f2h", @import("compiler_rt/truncXfYf2.zig").__truncsfhf2, linkage); @export("__aeabi_i2f", @import("compiler_rt/floatsiXf.zig").__floatsisf, linkage); @export("__aeabi_d2f", @import("compiler_rt/truncXfYf2.zig").__truncdfsf2, linkage); @export("__aeabi_fadd", @import("compiler_rt/addXf3.zig").__addsf3, linkage); @export("__aeabi_dadd", @import("compiler_rt/addXf3.zig").__adddf3, linkage); @export("__aeabi_fsub", @import("compiler_rt/addXf3.zig").__subsf3, linkage); @export("__aeabi_dsub", @import("compiler_rt/addXf3.zig").__subdf3, linkage); @export("__aeabi_f2uiz", @import("compiler_rt/fixunssfsi.zig").__fixunssfsi, linkage); @export("__aeabi_f2iz", @import("compiler_rt/fixsfsi.zig").__fixsfsi, linkage); @export("__aeabi_d2iz", @import("compiler_rt/fixdfsi.zig").__fixdfsi, linkage); @export("__aeabi_fdiv", @import("compiler_rt/divsf3.zig").__divsf3, linkage); @export("__aeabi_ddiv", @import("compiler_rt/divdf3.zig").__divdf3, linkage); @export("__aeabi_fcmpeq", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpeq, linkage); @export("__aeabi_fcmplt", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmplt, linkage); @export("__aeabi_fcmple", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmple, linkage); @export("__aeabi_fcmpge", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpge, linkage); @export("__aeabi_fcmpgt", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpgt, linkage); @export("__aeabi_fcmpun", @import("compiler_rt/comparesf2.zig").__unordsf2, linkage); @export("__aeabi_dcmpeq", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpeq, linkage); @export("__aeabi_dcmplt", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmplt, linkage); @export("__aeabi_dcmple", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmple, linkage); @export("__aeabi_dcmpge", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpge, linkage); @export("__aeabi_dcmpgt", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpgt, linkage); @export("__aeabi_dcmpun", @import("compiler_rt/comparedf2.zig").__unorddf2, linkage); } if (builtin.os == .windows) { // Default stack-probe functions emitted by LLVM if (is_mingw) { @export("_alloca", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage); @export("___chkstk_ms", @import("compiler_rt/stack_probe.zig").___chkstk_ms, strong_linkage); } else if (!builtin.link_libc) { // This symbols are otherwise exported by MSVCRT.lib @export("_chkstk", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage); @export("__chkstk", @import("compiler_rt/stack_probe.zig").__chkstk, strong_linkage); } if (is_mingw) { @export("__stack_chk_fail", __stack_chk_fail, strong_linkage); @export("__stack_chk_guard", __stack_chk_guard, strong_linkage); } switch (builtin.arch) { .i386 => { // Don't let LLVM apply the stdcall name mangling on those MSVC // builtin functions @export("\x01__alldiv", @import("compiler_rt/aulldiv.zig")._alldiv, strong_linkage); @export("\x01__aulldiv", @import("compiler_rt/aulldiv.zig")._aulldiv, strong_linkage); @export("\x01__allrem", @import("compiler_rt/aullrem.zig")._allrem, strong_linkage); @export("\x01__aullrem", @import("compiler_rt/aullrem.zig")._aullrem, strong_linkage); @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage); @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage); @export("__multi3", @import("compiler_rt/multi3.zig").__multi3, linkage); @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3, linkage); @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4, linkage); @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3, linkage); }, .x86_64 => { // The "ti" functions must use @Vector(2, u64) parameter types to adhere to the ABI // that LLVM expects compiler-rt to have. @export("__divti3", @import("compiler_rt/divti3.zig").__divti3_windows_x86_64, linkage); @export("__modti3", @import("compiler_rt/modti3.zig").__modti3_windows_x86_64, linkage); @export("__multi3", @import("compiler_rt/multi3.zig").__multi3_windows_x86_64, linkage); @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3_windows_x86_64, linkage); @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4_windows_x86_64, linkage); @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3_windows_x86_64, linkage); }, else => {}, } } else { if (builtin.glibc_version != null) { @export("__stack_chk_guard", __stack_chk_guard, linkage); } @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage); @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage); @export("__multi3", @import("compiler_rt/multi3.zig").__multi3, linkage); @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3, linkage); @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4, linkage); @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3, linkage); } @export("__muloti4", @import("compiler_rt/muloti4.zig").__muloti4, linkage); @export("__mulodi4", @import("compiler_rt/mulodi4.zig").__mulodi4, linkage); } const std = @import("std"); const assert = std.debug.assert; const testing = std.testing; const __udivmoddi4 = @import("compiler_rt/udivmoddi4.zig").__udivmoddi4; // Avoid dragging in the runtime safety mechanisms into this .o file, // unless we're trying to test this file. pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { @setCold(true); if (is_test) { std.debug.panic("{}", msg); } else { unreachable; } } extern fn __stack_chk_fail() noreturn { @panic("stack smashing detected"); } extern var __stack_chk_guard: usize = blk: { var buf = [1]u8{0} ** @sizeOf(usize); buf[@sizeOf(usize) - 1] = 255; buf[@sizeOf(usize) - 2] = '\n'; break :blk @bitCast(usize, buf); }; extern fn __aeabi_unwind_cpp_pr0() void { unreachable; } extern fn __aeabi_unwind_cpp_pr1() void { unreachable; } extern fn __aeabi_unwind_cpp_pr2() void { unreachable; } extern fn __divmoddi4(a: i64, b: i64, rem: *i64) i64 { @setRuntimeSafety(is_test); const d = __divdi3(a, b); rem.* = a -% (d *% b); return d; } extern fn __divdi3(a: i64, b: i64) i64 { @setRuntimeSafety(is_test); // Set aside the sign of the quotient. const sign = @bitCast(u64, (a ^ b) >> 63); // Take absolute value of a and b via abs(x) = (x^(x >> 63)) - (x >> 63). const abs_a = (a ^ (a >> 63)) -% (a >> 63); const abs_b = (b ^ (b >> 63)) -% (b >> 63); // Unsigned division const res = __udivmoddi4(@bitCast(u64, abs_a), @bitCast(u64, abs_b), null); // Apply sign of quotient to result and return. return @bitCast(i64, (res ^ sign) -% sign); } extern fn __moddi3(a: i64, b: i64) i64 { @setRuntimeSafety(is_test); // Take absolute value of a and b via abs(x) = (x^(x >> 63)) - (x >> 63). const abs_a = (a ^ (a >> 63)) -% (a >> 63); const abs_b = (b ^ (b >> 63)) -% (b >> 63); // Unsigned division var r: u64 = undefined; _ = __udivmoddi4(@bitCast(u64, abs_a), @bitCast(u64, abs_b), &r); // Apply the sign of the dividend and return. return (@bitCast(i64, r) ^ (a >> 63)) -% (a >> 63); } extern fn __udivdi3(a: u64, b: u64) u64 { @setRuntimeSafety(is_test); return __udivmoddi4(a, b, null); } extern fn __umoddi3(a: u64, b: u64) u64 { @setRuntimeSafety(is_test); var r: u64 = undefined; _ = __udivmoddi4(a, b, &r); return r; } extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct { q: u32, r: u32, } { @setRuntimeSafety(is_test); var result: @typeOf(__aeabi_uidivmod).ReturnType = undefined; result.q = __udivmodsi4(n, d, &result.r); return result; } extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct { q: u64, r: u64, } { @setRuntimeSafety(is_test); var result: @typeOf(__aeabi_uldivmod).ReturnType = undefined; result.q = __udivmoddi4(n, d, &result.r); return result; } extern fn __aeabi_idivmod(n: i32, d: i32) extern struct { q: i32, r: i32, } { @setRuntimeSafety(is_test); var result: @typeOf(__aeabi_idivmod).ReturnType = undefined; result.q = __divmodsi4(n, d, &result.r); return result; } extern fn __aeabi_ldivmod(n: i64, d: i64) extern struct { q: i64, r: i64, } { @setRuntimeSafety(is_test); var result: @typeOf(__aeabi_ldivmod).ReturnType = undefined; result.q = __divmoddi4(n, d, &result.r); return result; } const is_arm_64 = switch (builtin.arch) { builtin.Arch.aarch64, builtin.Arch.aarch64_be, => true, else => false, }; const is_arm_arch = switch (builtin.arch) { builtin.Arch.arm, builtin.Arch.armeb, builtin.Arch.aarch64, builtin.Arch.aarch64_be, builtin.Arch.thumb, builtin.Arch.thumbeb, => true, else => false, }; const is_arm_32 = is_arm_arch and !is_arm_64; const use_thumb_1 = usesThumb1(builtin.arch); fn usesThumb1(arch: builtin.Arch) bool { return switch (arch) { .arm => |sub_arch| switch (sub_arch) { .v6m => true, else => false, }, .armeb => |sub_arch| switch (sub_arch) { .v6m => true, else => false, }, .thumb => |sub_arch| switch (sub_arch) { .v5, .v5te, .v4t, .v6, .v6m, .v6k, => true, else => false, }, .thumbeb => |sub_arch| switch (sub_arch) { .v5, .v5te, .v4t, .v6, .v6m, .v6k, => true, else => false, }, else => false, }; } test "usesThumb1" { testing.expect(usesThumb1(builtin.Arch{ .arm = .v6m })); testing.expect(!usesThumb1(builtin.Arch{ .arm = .v5 })); //etc. testing.expect(usesThumb1(builtin.Arch{ .armeb = .v6m })); testing.expect(!usesThumb1(builtin.Arch{ .armeb = .v5 })); //etc. testing.expect(usesThumb1(builtin.Arch{ .thumb = .v5 })); testing.expect(usesThumb1(builtin.Arch{ .thumb = .v5te })); testing.expect(usesThumb1(builtin.Arch{ .thumb = .v4t })); testing.expect(usesThumb1(builtin.Arch{ .thumb = .v6 })); testing.expect(usesThumb1(builtin.Arch{ .thumb = .v6k })); testing.expect(usesThumb1(builtin.Arch{ .thumb = .v6m })); testing.expect(!usesThumb1(builtin.Arch{ .thumb = .v6t2 })); //etc. testing.expect(usesThumb1(builtin.Arch{ .thumbeb = .v5 })); testing.expect(usesThumb1(builtin.Arch{ .thumbeb = .v5te })); testing.expect(usesThumb1(builtin.Arch{ .thumbeb = .v4t })); testing.expect(usesThumb1(builtin.Arch{ .thumbeb = .v6 })); testing.expect(usesThumb1(builtin.Arch{ .thumbeb = .v6k })); testing.expect(usesThumb1(builtin.Arch{ .thumbeb = .v6m })); testing.expect(!usesThumb1(builtin.Arch{ .thumbeb = .v6t2 })); //etc. testing.expect(!usesThumb1(builtin.Arch{ .aarch64 = .v8 })); testing.expect(!usesThumb1(builtin.Arch{ .aarch64_be = .v8 })); testing.expect(!usesThumb1(builtin.Arch.x86_64)); testing.expect(!usesThumb1(builtin.Arch.riscv32)); //etc. } const use_thumb_1_pre_armv6 = usesThumb1PreArmv6(builtin.arch); fn usesThumb1PreArmv6(arch: builtin.Arch) bool { return switch (arch) { .thumb => |sub_arch| switch (sub_arch) { .v5, .v5te, .v4t => true, else => false, }, .thumbeb => |sub_arch| switch (sub_arch) { .v5, .v5te, .v4t => true, else => false, }, else => false, }; } nakedcc fn __aeabi_memcpy() noreturn { @setRuntimeSafety(false); if (use_thumb_1) { asm volatile ( \\ push {r7, lr} \\ bl memcpy \\ pop {r7, pc} ); } else { asm volatile ( \\ b memcpy ); } unreachable; } nakedcc fn __aeabi_memmove() noreturn { @setRuntimeSafety(false); if (use_thumb_1) { asm volatile ( \\ push {r7, lr} \\ bl memmove \\ pop {r7, pc} ); } else { asm volatile ( \\ b memmove ); } unreachable; } nakedcc fn __aeabi_memset() noreturn { @setRuntimeSafety(false); if (use_thumb_1_pre_armv6) { asm volatile ( \\ eors r1, r2 \\ eors r2, r1 \\ eors r1, r2 \\ push {r7, lr} \\ b memset \\ pop {r7, pc} ); } else if (use_thumb_1) { asm volatile ( \\ mov r3, r1 \\ mov r1, r2 \\ mov r2, r3 \\ push {r7, lr} \\ b memset \\ pop {r7, pc} ); } else { asm volatile ( \\ mov r3, r1 \\ mov r1, r2 \\ mov r2, r3 \\ b memset ); } unreachable; } nakedcc fn __aeabi_memclr() noreturn { @setRuntimeSafety(false); if (use_thumb_1_pre_armv6) { asm volatile ( \\ adds r2, r1, #0 \\ movs r1, #0 \\ push {r7, lr} \\ bl memset \\ pop {r7, pc} ); } else if (use_thumb_1) { asm volatile ( \\ mov r2, r1 \\ movs r1, #0 \\ push {r7, lr} \\ bl memset \\ pop {r7, pc} ); } else { asm volatile ( \\ mov r2, r1 \\ movs r1, #0 \\ b memset ); } unreachable; } nakedcc fn __aeabi_memcmp() noreturn { @setRuntimeSafety(false); if (use_thumb_1) { asm volatile ( \\ push {r7, lr} \\ bl memcmp \\ pop {r7, pc} ); } else { asm volatile ( \\ b memcmp ); } unreachable; } extern fn __divmodsi4(a: i32, b: i32, rem: *i32) i32 { @setRuntimeSafety(is_test); const d = __divsi3(a, b); rem.* = a -% (d * b); return d; } extern fn __udivmodsi4(a: u32, b: u32, rem: *u32) u32 { @setRuntimeSafety(is_test); const d = __udivsi3(a, b); rem.* = @bitCast(u32, @bitCast(i32, a) -% (@bitCast(i32, d) * @bitCast(i32, b))); return d; } extern fn __divsi3(n: i32, d: i32) i32 { @setRuntimeSafety(is_test); // Set aside the sign of the quotient. const sign = @bitCast(u32, (n ^ d) >> 31); // Take absolute value of a and b via abs(x) = (x^(x >> 31)) - (x >> 31). const abs_n = (n ^ (n >> 31)) -% (n >> 31); const abs_d = (d ^ (d >> 31)) -% (d >> 31); // abs(a) / abs(b) const res = @bitCast(u32, abs_n) / @bitCast(u32, abs_d); // Apply sign of quotient to result and return. return @bitCast(i32, (res ^ sign) -% sign); } extern fn __udivsi3(n: u32, d: u32) u32 { @setRuntimeSafety(is_test); const n_uword_bits: c_uint = u32.bit_count; // special cases if (d == 0) return 0; // ?! if (n == 0) return 0; var sr = @bitCast(c_uint, @as(c_int, @clz(u32, d)) - @as(c_int, @clz(u32, n))); // 0 <= sr <= n_uword_bits - 1 or sr large if (sr > n_uword_bits - 1) { // d > r return 0; } if (sr == n_uword_bits - 1) { // d == 1 return n; } sr += 1; // 1 <= sr <= n_uword_bits - 1 // Not a special case var q: u32 = n << @intCast(u5, n_uword_bits - sr); var r: u32 = n >> @intCast(u5, sr); var carry: u32 = 0; while (sr > 0) : (sr -= 1) { // r:q = ((r:q) << 1) | carry r = (r << 1) | (q >> @intCast(u5, n_uword_bits - 1)); q = (q << 1) | carry; // carry = 0; // if (r.all >= d.all) // { // r.all -= d.all; // carry = 1; // } const s = @intCast(i32, d -% r -% 1) >> @intCast(u5, n_uword_bits - 1); carry = @intCast(u32, s & 1); r -= d & @bitCast(u32, s); } q = (q << 1) | carry; return q; } extern fn __modsi3(n: i32, d: i32) i32 { @setRuntimeSafety(is_test); return n -% __divsi3(n, d) *% d; } extern fn __umodsi3(n: u32, d: u32) u32 { @setRuntimeSafety(is_test); return n -% __udivsi3(n, d) *% d; } test "test_umoddi3" { test_one_umoddi3(0, 1, 0); test_one_umoddi3(2, 1, 0); test_one_umoddi3(0x8000000000000000, 1, 0x0); test_one_umoddi3(0x8000000000000000, 2, 0x0); test_one_umoddi3(0xFFFFFFFFFFFFFFFF, 2, 0x1); } fn test_one_umoddi3(a: u64, b: u64, expected_r: u64) void { const r = __umoddi3(a, b); testing.expect(r == expected_r); } test "test_udivsi3" { const cases = [_][3]u32{ [_]u32{ 0x00000000, 0x00000001, 0x00000000, }, [_]u32{ 0x00000000, 0x00000002, 0x00000000, }, [_]u32{ 0x00000000, 0x00000003, 0x00000000, }, [_]u32{ 0x00000000, 0x00000010, 0x00000000, }, [_]u32{ 0x00000000, 0x078644FA, 0x00000000, }, [_]u32{ 0x00000000, 0x0747AE14, 0x00000000, }, [_]u32{ 0x00000000, 0x7FFFFFFF, 0x00000000, }, [_]u32{ 0x00000000, 0x80000000, 0x00000000, }, [_]u32{ 0x00000000, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x00000000, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x00000000, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0x00000001, 0x00000001, 0x00000001, }, [_]u32{ 0x00000001, 0x00000002, 0x00000000, }, [_]u32{ 0x00000001, 0x00000003, 0x00000000, }, [_]u32{ 0x00000001, 0x00000010, 0x00000000, }, [_]u32{ 0x00000001, 0x078644FA, 0x00000000, }, [_]u32{ 0x00000001, 0x0747AE14, 0x00000000, }, [_]u32{ 0x00000001, 0x7FFFFFFF, 0x00000000, }, [_]u32{ 0x00000001, 0x80000000, 0x00000000, }, [_]u32{ 0x00000001, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x00000001, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x00000001, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0x00000002, 0x00000001, 0x00000002, }, [_]u32{ 0x00000002, 0x00000002, 0x00000001, }, [_]u32{ 0x00000002, 0x00000003, 0x00000000, }, [_]u32{ 0x00000002, 0x00000010, 0x00000000, }, [_]u32{ 0x00000002, 0x078644FA, 0x00000000, }, [_]u32{ 0x00000002, 0x0747AE14, 0x00000000, }, [_]u32{ 0x00000002, 0x7FFFFFFF, 0x00000000, }, [_]u32{ 0x00000002, 0x80000000, 0x00000000, }, [_]u32{ 0x00000002, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x00000002, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x00000002, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0x00000003, 0x00000001, 0x00000003, }, [_]u32{ 0x00000003, 0x00000002, 0x00000001, }, [_]u32{ 0x00000003, 0x00000003, 0x00000001, }, [_]u32{ 0x00000003, 0x00000010, 0x00000000, }, [_]u32{ 0x00000003, 0x078644FA, 0x00000000, }, [_]u32{ 0x00000003, 0x0747AE14, 0x00000000, }, [_]u32{ 0x00000003, 0x7FFFFFFF, 0x00000000, }, [_]u32{ 0x00000003, 0x80000000, 0x00000000, }, [_]u32{ 0x00000003, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x00000003, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x00000003, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0x00000010, 0x00000001, 0x00000010, }, [_]u32{ 0x00000010, 0x00000002, 0x00000008, }, [_]u32{ 0x00000010, 0x00000003, 0x00000005, }, [_]u32{ 0x00000010, 0x00000010, 0x00000001, }, [_]u32{ 0x00000010, 0x078644FA, 0x00000000, }, [_]u32{ 0x00000010, 0x0747AE14, 0x00000000, }, [_]u32{ 0x00000010, 0x7FFFFFFF, 0x00000000, }, [_]u32{ 0x00000010, 0x80000000, 0x00000000, }, [_]u32{ 0x00000010, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x00000010, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x00000010, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0x078644FA, 0x00000001, 0x078644FA, }, [_]u32{ 0x078644FA, 0x00000002, 0x03C3227D, }, [_]u32{ 0x078644FA, 0x00000003, 0x028216FE, }, [_]u32{ 0x078644FA, 0x00000010, 0x0078644F, }, [_]u32{ 0x078644FA, 0x078644FA, 0x00000001, }, [_]u32{ 0x078644FA, 0x0747AE14, 0x00000001, }, [_]u32{ 0x078644FA, 0x7FFFFFFF, 0x00000000, }, [_]u32{ 0x078644FA, 0x80000000, 0x00000000, }, [_]u32{ 0x078644FA, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x078644FA, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x078644FA, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0x0747AE14, 0x00000001, 0x0747AE14, }, [_]u32{ 0x0747AE14, 0x00000002, 0x03A3D70A, }, [_]u32{ 0x0747AE14, 0x00000003, 0x026D3A06, }, [_]u32{ 0x0747AE14, 0x00000010, 0x00747AE1, }, [_]u32{ 0x0747AE14, 0x078644FA, 0x00000000, }, [_]u32{ 0x0747AE14, 0x0747AE14, 0x00000001, }, [_]u32{ 0x0747AE14, 0x7FFFFFFF, 0x00000000, }, [_]u32{ 0x0747AE14, 0x80000000, 0x00000000, }, [_]u32{ 0x0747AE14, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x0747AE14, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x0747AE14, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0x7FFFFFFF, 0x00000001, 0x7FFFFFFF, }, [_]u32{ 0x7FFFFFFF, 0x00000002, 0x3FFFFFFF, }, [_]u32{ 0x7FFFFFFF, 0x00000003, 0x2AAAAAAA, }, [_]u32{ 0x7FFFFFFF, 0x00000010, 0x07FFFFFF, }, [_]u32{ 0x7FFFFFFF, 0x078644FA, 0x00000011, }, [_]u32{ 0x7FFFFFFF, 0x0747AE14, 0x00000011, }, [_]u32{ 0x7FFFFFFF, 0x7FFFFFFF, 0x00000001, }, [_]u32{ 0x7FFFFFFF, 0x80000000, 0x00000000, }, [_]u32{ 0x7FFFFFFF, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x7FFFFFFF, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x7FFFFFFF, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0x80000000, 0x00000001, 0x80000000, }, [_]u32{ 0x80000000, 0x00000002, 0x40000000, }, [_]u32{ 0x80000000, 0x00000003, 0x2AAAAAAA, }, [_]u32{ 0x80000000, 0x00000010, 0x08000000, }, [_]u32{ 0x80000000, 0x078644FA, 0x00000011, }, [_]u32{ 0x80000000, 0x0747AE14, 0x00000011, }, [_]u32{ 0x80000000, 0x7FFFFFFF, 0x00000001, }, [_]u32{ 0x80000000, 0x80000000, 0x00000001, }, [_]u32{ 0x80000000, 0xFFFFFFFD, 0x00000000, }, [_]u32{ 0x80000000, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0x80000000, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0xFFFFFFFD, 0x00000001, 0xFFFFFFFD, }, [_]u32{ 0xFFFFFFFD, 0x00000002, 0x7FFFFFFE, }, [_]u32{ 0xFFFFFFFD, 0x00000003, 0x55555554, }, [_]u32{ 0xFFFFFFFD, 0x00000010, 0x0FFFFFFF, }, [_]u32{ 0xFFFFFFFD, 0x078644FA, 0x00000022, }, [_]u32{ 0xFFFFFFFD, 0x0747AE14, 0x00000023, }, [_]u32{ 0xFFFFFFFD, 0x7FFFFFFF, 0x00000001, }, [_]u32{ 0xFFFFFFFD, 0x80000000, 0x00000001, }, [_]u32{ 0xFFFFFFFD, 0xFFFFFFFD, 0x00000001, }, [_]u32{ 0xFFFFFFFD, 0xFFFFFFFE, 0x00000000, }, [_]u32{ 0xFFFFFFFD, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0xFFFFFFFE, 0x00000001, 0xFFFFFFFE, }, [_]u32{ 0xFFFFFFFE, 0x00000002, 0x7FFFFFFF, }, [_]u32{ 0xFFFFFFFE, 0x00000003, 0x55555554, }, [_]u32{ 0xFFFFFFFE, 0x00000010, 0x0FFFFFFF, }, [_]u32{ 0xFFFFFFFE, 0x078644FA, 0x00000022, }, [_]u32{ 0xFFFFFFFE, 0x0747AE14, 0x00000023, }, [_]u32{ 0xFFFFFFFE, 0x7FFFFFFF, 0x00000002, }, [_]u32{ 0xFFFFFFFE, 0x80000000, 0x00000001, }, [_]u32{ 0xFFFFFFFE, 0xFFFFFFFD, 0x00000001, }, [_]u32{ 0xFFFFFFFE, 0xFFFFFFFE, 0x00000001, }, [_]u32{ 0xFFFFFFFE, 0xFFFFFFFF, 0x00000000, }, [_]u32{ 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, }, [_]u32{ 0xFFFFFFFF, 0x00000002, 0x7FFFFFFF, }, [_]u32{ 0xFFFFFFFF, 0x00000003, 0x55555555, }, [_]u32{ 0xFFFFFFFF, 0x00000010, 0x0FFFFFFF, }, [_]u32{ 0xFFFFFFFF, 0x078644FA, 0x00000022, }, [_]u32{ 0xFFFFFFFF, 0x0747AE14, 0x00000023, }, [_]u32{ 0xFFFFFFFF, 0x7FFFFFFF, 0x00000002, }, [_]u32{ 0xFFFFFFFF, 0x80000000, 0x00000001, }, [_]u32{ 0xFFFFFFFF, 0xFFFFFFFD, 0x00000001, }, [_]u32{ 0xFFFFFFFF, 0xFFFFFFFE, 0x00000001, }, [_]u32{ 0xFFFFFFFF, 0xFFFFFFFF, 0x00000001, }, }; for (cases) |case| { test_one_udivsi3(case[0], case[1], case[2]); } } fn test_one_udivsi3(a: u32, b: u32, expected_q: u32) void { const q: u32 = __udivsi3(a, b); testing.expect(q == expected_q); } test "test_divsi3" { const cases = [_][3]i32{ [_]i32{ 0, 1, 0 }, [_]i32{ 0, -1, 0 }, [_]i32{ 2, 1, 2 }, [_]i32{ 2, -1, -2 }, [_]i32{ -2, 1, -2 }, [_]i32{ -2, -1, 2 }, [_]i32{ @bitCast(i32, @as(u32, 0x80000000)), 1, @bitCast(i32, @as(u32, 0x80000000)) }, [_]i32{ @bitCast(i32, @as(u32, 0x80000000)), -1, @bitCast(i32, @as(u32, 0x80000000)) }, [_]i32{ @bitCast(i32, @as(u32, 0x80000000)), -2, 0x40000000 }, [_]i32{ @bitCast(i32, @as(u32, 0x80000000)), 2, @bitCast(i32, @as(u32, 0xC0000000)) }, }; for (cases) |case| { test_one_divsi3(case[0], case[1], case[2]); } } fn test_one_divsi3(a: i32, b: i32, expected_q: i32) void { const q: i32 = __divsi3(a, b); testing.expect(q == expected_q); } test "test_divmodsi4" { const cases = [_][4]i32{ [_]i32{ 0, 1, 0, 0 }, [_]i32{ 0, -1, 0, 0 }, [_]i32{ 2, 1, 2, 0 }, [_]i32{ 2, -1, -2, 0 }, [_]i32{ -2, 1, -2, 0 }, [_]i32{ -2, -1, 2, 0 }, [_]i32{ 7, 5, 1, 2 }, [_]i32{ -7, 5, -1, -2 }, [_]i32{ 19, 5, 3, 4 }, [_]i32{ 19, -5, -3, 4 }, [_]i32{ @bitCast(i32, @as(u32, 0x80000000)), 8, @bitCast(i32, @as(u32, 0xf0000000)), 0 }, [_]i32{ @bitCast(i32, @as(u32, 0x80000007)), 8, @bitCast(i32, @as(u32, 0xf0000001)), -1 }, }; for (cases) |case| { test_one_divmodsi4(case[0], case[1], case[2], case[3]); } } fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) void { var r: i32 = undefined; const q: i32 = __divmodsi4(a, b, &r); testing.expect(q == expected_q and r == expected_r); } test "test_divdi3" { const cases = [_][3]i64{ [_]i64{ 0, 1, 0 }, [_]i64{ 0, -1, 0 }, [_]i64{ 2, 1, 2 }, [_]i64{ 2, -1, -2 }, [_]i64{ -2, 1, -2 }, [_]i64{ -2, -1, 2 }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), 1, @bitCast(i64, @as(u64, 0x8000000000000000)) }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), -1, @bitCast(i64, @as(u64, 0x8000000000000000)) }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), -2, 0x4000000000000000 }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), 2, @bitCast(i64, @as(u64, 0xC000000000000000)) }, }; for (cases) |case| { test_one_divdi3(case[0], case[1], case[2]); } } fn test_one_divdi3(a: i64, b: i64, expected_q: i64) void { const q: i64 = __divdi3(a, b); testing.expect(q == expected_q); } test "test_moddi3" { const cases = [_][3]i64{ [_]i64{ 0, 1, 0 }, [_]i64{ 0, -1, 0 }, [_]i64{ 5, 3, 2 }, [_]i64{ 5, -3, 2 }, [_]i64{ -5, 3, -2 }, [_]i64{ -5, -3, -2 }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), 1, 0 }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), -1, 0 }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), 2, 0 }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), -2, 0 }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), 3, -2 }, [_]i64{ @bitCast(i64, @as(u64, 0x8000000000000000)), -3, -2 }, }; for (cases) |case| { test_one_moddi3(case[0], case[1], case[2]); } } fn test_one_moddi3(a: i64, b: i64, expected_r: i64) void { const r: i64 = __moddi3(a, b); testing.expect(r == expected_r); } test "test_modsi3" { const cases = [_][3]i32{ [_]i32{ 0, 1, 0 }, [_]i32{ 0, -1, 0 }, [_]i32{ 5, 3, 2 }, [_]i32{ 5, -3, 2 }, [_]i32{ -5, 3, -2 }, [_]i32{ -5, -3, -2 }, [_]i32{ @bitCast(i32, @intCast(u32, 0x80000000)), 1, 0x0 }, [_]i32{ @bitCast(i32, @intCast(u32, 0x80000000)), 2, 0x0 }, [_]i32{ @bitCast(i32, @intCast(u32, 0x80000000)), -2, 0x0 }, [_]i32{ @bitCast(i32, @intCast(u32, 0x80000000)), 3, -2 }, [_]i32{ @bitCast(i32, @intCast(u32, 0x80000000)), -3, -2 }, }; for (cases) |case| { test_one_modsi3(case[0], case[1], case[2]); } } fn test_one_modsi3(a: i32, b: i32, expected_r: i32) void { const r: i32 = __modsi3(a, b); testing.expect(r == expected_r); } test "test_umodsi3" { const cases = [_][3]u32{ [_]u32{ 0x00000000, 0x00000001, 0x00000000 }, [_]u32{ 0x00000000, 0x00000002, 0x00000000 }, [_]u32{ 0x00000000, 0x00000003, 0x00000000 }, [_]u32{ 0x00000000, 0x00000010, 0x00000000 }, [_]u32{ 0x00000000, 0x078644FA, 0x00000000 }, [_]u32{ 0x00000000, 0x0747AE14, 0x00000000 }, [_]u32{ 0x00000000, 0x7FFFFFFF, 0x00000000 }, [_]u32{ 0x00000000, 0x80000000, 0x00000000 }, [_]u32{ 0x00000000, 0xFFFFFFFD, 0x00000000 }, [_]u32{ 0x00000000, 0xFFFFFFFE, 0x00000000 }, [_]u32{ 0x00000000, 0xFFFFFFFF, 0x00000000 }, [_]u32{ 0x00000001, 0x00000001, 0x00000000 }, [_]u32{ 0x00000001, 0x00000002, 0x00000001 }, [_]u32{ 0x00000001, 0x00000003, 0x00000001 }, [_]u32{ 0x00000001, 0x00000010, 0x00000001 }, [_]u32{ 0x00000001, 0x078644FA, 0x00000001 }, [_]u32{ 0x00000001, 0x0747AE14, 0x00000001 }, [_]u32{ 0x00000001, 0x7FFFFFFF, 0x00000001 }, [_]u32{ 0x00000001, 0x80000000, 0x00000001 }, [_]u32{ 0x00000001, 0xFFFFFFFD, 0x00000001 }, [_]u32{ 0x00000001, 0xFFFFFFFE, 0x00000001 }, [_]u32{ 0x00000001, 0xFFFFFFFF, 0x00000001 }, [_]u32{ 0x00000002, 0x00000001, 0x00000000 }, [_]u32{ 0x00000002, 0x00000002, 0x00000000 }, [_]u32{ 0x00000002, 0x00000003, 0x00000002 }, [_]u32{ 0x00000002, 0x00000010, 0x00000002 }, [_]u32{ 0x00000002, 0x078644FA, 0x00000002 }, [_]u32{ 0x00000002, 0x0747AE14, 0x00000002 }, [_]u32{ 0x00000002, 0x7FFFFFFF, 0x00000002 }, [_]u32{ 0x00000002, 0x80000000, 0x00000002 }, [_]u32{ 0x00000002, 0xFFFFFFFD, 0x00000002 }, [_]u32{ 0x00000002, 0xFFFFFFFE, 0x00000002 }, [_]u32{ 0x00000002, 0xFFFFFFFF, 0x00000002 }, [_]u32{ 0x00000003, 0x00000001, 0x00000000 }, [_]u32{ 0x00000003, 0x00000002, 0x00000001 }, [_]u32{ 0x00000003, 0x00000003, 0x00000000 }, [_]u32{ 0x00000003, 0x00000010, 0x00000003 }, [_]u32{ 0x00000003, 0x078644FA, 0x00000003 }, [_]u32{ 0x00000003, 0x0747AE14, 0x00000003 }, [_]u32{ 0x00000003, 0x7FFFFFFF, 0x00000003 }, [_]u32{ 0x00000003, 0x80000000, 0x00000003 }, [_]u32{ 0x00000003, 0xFFFFFFFD, 0x00000003 }, [_]u32{ 0x00000003, 0xFFFFFFFE, 0x00000003 }, [_]u32{ 0x00000003, 0xFFFFFFFF, 0x00000003 }, [_]u32{ 0x00000010, 0x00000001, 0x00000000 }, [_]u32{ 0x00000010, 0x00000002, 0x00000000 }, [_]u32{ 0x00000010, 0x00000003, 0x00000001 }, [_]u32{ 0x00000010, 0x00000010, 0x00000000 }, [_]u32{ 0x00000010, 0x078644FA, 0x00000010 }, [_]u32{ 0x00000010, 0x0747AE14, 0x00000010 }, [_]u32{ 0x00000010, 0x7FFFFFFF, 0x00000010 }, [_]u32{ 0x00000010, 0x80000000, 0x00000010 }, [_]u32{ 0x00000010, 0xFFFFFFFD, 0x00000010 }, [_]u32{ 0x00000010, 0xFFFFFFFE, 0x00000010 }, [_]u32{ 0x00000010, 0xFFFFFFFF, 0x00000010 }, [_]u32{ 0x078644FA, 0x00000001, 0x00000000 }, [_]u32{ 0x078644FA, 0x00000002, 0x00000000 }, [_]u32{ 0x078644FA, 0x00000003, 0x00000000 }, [_]u32{ 0x078644FA, 0x00000010, 0x0000000A }, [_]u32{ 0x078644FA, 0x078644FA, 0x00000000 }, [_]u32{ 0x078644FA, 0x0747AE14, 0x003E96E6 }, [_]u32{ 0x078644FA, 0x7FFFFFFF, 0x078644FA }, [_]u32{ 0x078644FA, 0x80000000, 0x078644FA }, [_]u32{ 0x078644FA, 0xFFFFFFFD, 0x078644FA }, [_]u32{ 0x078644FA, 0xFFFFFFFE, 0x078644FA }, [_]u32{ 0x078644FA, 0xFFFFFFFF, 0x078644FA }, [_]u32{ 0x0747AE14, 0x00000001, 0x00000000 }, [_]u32{ 0x0747AE14, 0x00000002, 0x00000000 }, [_]u32{ 0x0747AE14, 0x00000003, 0x00000002 }, [_]u32{ 0x0747AE14, 0x00000010, 0x00000004 }, [_]u32{ 0x0747AE14, 0x078644FA, 0x0747AE14 }, [_]u32{ 0x0747AE14, 0x0747AE14, 0x00000000 }, [_]u32{ 0x0747AE14, 0x7FFFFFFF, 0x0747AE14 }, [_]u32{ 0x0747AE14, 0x80000000, 0x0747AE14 }, [_]u32{ 0x0747AE14, 0xFFFFFFFD, 0x0747AE14 }, [_]u32{ 0x0747AE14, 0xFFFFFFFE, 0x0747AE14 }, [_]u32{ 0x0747AE14, 0xFFFFFFFF, 0x0747AE14 }, [_]u32{ 0x7FFFFFFF, 0x00000001, 0x00000000 }, [_]u32{ 0x7FFFFFFF, 0x00000002, 0x00000001 }, [_]u32{ 0x7FFFFFFF, 0x00000003, 0x00000001 }, [_]u32{ 0x7FFFFFFF, 0x00000010, 0x0000000F }, [_]u32{ 0x7FFFFFFF, 0x078644FA, 0x00156B65 }, [_]u32{ 0x7FFFFFFF, 0x0747AE14, 0x043D70AB }, [_]u32{ 0x7FFFFFFF, 0x7FFFFFFF, 0x00000000 }, [_]u32{ 0x7FFFFFFF, 0x80000000, 0x7FFFFFFF }, [_]u32{ 0x7FFFFFFF, 0xFFFFFFFD, 0x7FFFFFFF }, [_]u32{ 0x7FFFFFFF, 0xFFFFFFFE, 0x7FFFFFFF }, [_]u32{ 0x7FFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF }, [_]u32{ 0x80000000, 0x00000001, 0x00000000 }, [_]u32{ 0x80000000, 0x00000002, 0x00000000 }, [_]u32{ 0x80000000, 0x00000003, 0x00000002 }, [_]u32{ 0x80000000, 0x00000010, 0x00000000 }, [_]u32{ 0x80000000, 0x078644FA, 0x00156B66 }, [_]u32{ 0x80000000, 0x0747AE14, 0x043D70AC }, [_]u32{ 0x80000000, 0x7FFFFFFF, 0x00000001 }, [_]u32{ 0x80000000, 0x80000000, 0x00000000 }, [_]u32{ 0x80000000, 0xFFFFFFFD, 0x80000000 }, [_]u32{ 0x80000000, 0xFFFFFFFE, 0x80000000 }, [_]u32{ 0x80000000, 0xFFFFFFFF, 0x80000000 }, [_]u32{ 0xFFFFFFFD, 0x00000001, 0x00000000 }, [_]u32{ 0xFFFFFFFD, 0x00000002, 0x00000001 }, [_]u32{ 0xFFFFFFFD, 0x00000003, 0x00000001 }, [_]u32{ 0xFFFFFFFD, 0x00000010, 0x0000000D }, [_]u32{ 0xFFFFFFFD, 0x078644FA, 0x002AD6C9 }, [_]u32{ 0xFFFFFFFD, 0x0747AE14, 0x01333341 }, [_]u32{ 0xFFFFFFFD, 0x7FFFFFFF, 0x7FFFFFFE }, [_]u32{ 0xFFFFFFFD, 0x80000000, 0x7FFFFFFD }, [_]u32{ 0xFFFFFFFD, 0xFFFFFFFD, 0x00000000 }, [_]u32{ 0xFFFFFFFD, 0xFFFFFFFE, 0xFFFFFFFD }, [_]u32{ 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFD }, [_]u32{ 0xFFFFFFFE, 0x00000001, 0x00000000 }, [_]u32{ 0xFFFFFFFE, 0x00000002, 0x00000000 }, [_]u32{ 0xFFFFFFFE, 0x00000003, 0x00000002 }, [_]u32{ 0xFFFFFFFE, 0x00000010, 0x0000000E }, [_]u32{ 0xFFFFFFFE, 0x078644FA, 0x002AD6CA }, [_]u32{ 0xFFFFFFFE, 0x0747AE14, 0x01333342 }, [_]u32{ 0xFFFFFFFE, 0x7FFFFFFF, 0x00000000 }, [_]u32{ 0xFFFFFFFE, 0x80000000, 0x7FFFFFFE }, [_]u32{ 0xFFFFFFFE, 0xFFFFFFFD, 0x00000001 }, [_]u32{ 0xFFFFFFFE, 0xFFFFFFFE, 0x00000000 }, [_]u32{ 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFE }, [_]u32{ 0xFFFFFFFF, 0x00000001, 0x00000000 }, [_]u32{ 0xFFFFFFFF, 0x00000002, 0x00000001 }, [_]u32{ 0xFFFFFFFF, 0x00000003, 0x00000000 }, [_]u32{ 0xFFFFFFFF, 0x00000010, 0x0000000F }, [_]u32{ 0xFFFFFFFF, 0x078644FA, 0x002AD6CB }, [_]u32{ 0xFFFFFFFF, 0x0747AE14, 0x01333343 }, [_]u32{ 0xFFFFFFFF, 0x7FFFFFFF, 0x00000001 }, [_]u32{ 0xFFFFFFFF, 0x80000000, 0x7FFFFFFF }, [_]u32{ 0xFFFFFFFF, 0xFFFFFFFD, 0x00000002 }, [_]u32{ 0xFFFFFFFF, 0xFFFFFFFE, 0x00000001 }, [_]u32{ 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000 }, }; for (cases) |case| { test_one_umodsi3(case[0], case[1], case[2]); } } fn test_one_umodsi3(a: u32, b: u32, expected_r: u32) void { const r: u32 = __umodsi3(a, b); testing.expect(r == expected_r); }
lib/std/special/compiler_rt.zig
const std = @import("../std.zig"); const net = std.net; const mem = std.mem; const testing = std.testing; test "parse and render IPv6 addresses" { var buffer: [100]u8 = undefined; const ips = [_][]const u8{ "fc00:e968:6179::de52:7100", "fc00:db20:35b:7399::5", "::1", "::", "2001:db8::", "::1234:5678", "2001:db8::1234:5678", "FFfdf8:f53e:61e4::18%1234", "::ffff:192.168.127.12", }; const printed = [_][]const u8{ "fdf8:f53e:61e4::18", "fdf8:f53e:61e4::18", "::1", "::", "2001:db8::", "::1234:5678", "2001:db8::1234:5678", "fdf8:f53e:61e4::18", "::ffff:192.168.127.12", }; for (ips) |ip, i| { var addr = net.IpAddress.parseIp6(ip, 0) catch unreachable; var newIp = std.fmt.bufPrint(buffer[0..], "{}", addr) catch unreachable; std.testing.expect(std.mem.eql(u8, printed[i], newIp[1 .. newIp.len - 3])); } testing.expectError(error.InvalidCharacter, net.IpAddress.parseIp6(":::", 0)); testing.expectError(error.Overflow, net.IpAddress.parseIp6("FF001::FB", 0)); testing.expectError(error.InvalidCharacter, net.IpAddress.parseIp6("fc00:db20:35b:7399::5:zig", 0)); testing.expectError(error.InvalidEnd, net.IpAddress.parseIp6("fc00:e968:6179::de52:7100:", 0)); testing.expectError(error.Incomplete, net.IpAddress.parseIp6("FF01:", 0)); testing.expectError(error.InvalidIpv4Mapping, net.IpAddress.parseIp6("::123.123.123.123", 0)); } test "parse and render IPv4 addresses" { var buffer: [18]u8 = undefined; for ([_][]const u8{ "0.0.0.0", "255.255.255.255", "172.16.31.10", "172.16.31.10", "127.0.0.1", }) |ip| { var addr = net.IpAddress.parseIp4(ip, 0) catch unreachable; var newIp = std.fmt.bufPrint(buffer[0..], "{}", addr) catch unreachable; std.testing.expect(std.mem.eql(u8, ip, newIp[0 .. newIp.len - 2])); } testing.expectError(error.Overflow, net.IpAddress.parseIp4("256.0.0.1", 0)); testing.expectError(error.InvalidCharacter, net.IpAddress.parseIp4("x.0.0.1", 0)); testing.expectError(error.InvalidEnd, net.IpAddress.parseIp4("127.0.0.1.1", 0)); testing.expectError(error.Incomplete, net.IpAddress.parseIp4("127.0.0.", 0)); testing.expectError(error.InvalidCharacter, net.IpAddress.parseIp4("100..0.1", 0)); } test "resolve DNS" { if (std.builtin.os == .windows) { // DNS resolution not implemented on Windows yet. return error.SkipZigTest; } var buf: [1000 * 10]u8 = undefined; const a = &std.heap.FixedBufferAllocator.init(&buf).allocator; const address_list = net.getAddressList(a, "example.com", 80) catch |err| switch (err) { // The tests are required to work even when there is no Internet connection, // so some of these errors we must accept and skip the test. error.UnknownHostName => return error.SkipZigTest, error.TemporaryNameServerFailure => return error.SkipZigTest, else => return err, }; address_list.deinit(); } test "listen on a port, send bytes, receive bytes" { if (std.builtin.os != .linux) { // TODO build abstractions for other operating systems return error.SkipZigTest; } if (std.io.mode != .evented) { // TODO add ability to run tests in non-blocking I/O mode return error.SkipZigTest; } // TODO doing this at comptime crashed the compiler const localhost = net.IpAddress.parse("127.0.0.1", 0); var server = net.TcpServer.init(net.TcpServer.Options{}); defer server.deinit(); try server.listen(localhost); var server_frame = async testServer(&server); var client_frame = async testClient(server.listen_address); try await server_frame; try await client_frame; } fn testClient(addr: net.IpAddress) anyerror!void { const socket_file = try net.tcpConnectToAddress(addr); defer socket_file.close(); var buf: [100]u8 = undefined; const len = try socket_file.read(&buf); const msg = buf[0..len]; testing.expect(mem.eql(u8, msg, "hello from server\n")); } fn testServer(server: *net.TcpServer) anyerror!void { var client_file = try server.accept(); const stream = &client_file.outStream().stream; try stream.print("hello from server\n"); }
lib/std/net/test.zig
const Mir = @This(); const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const bits = @import("bits.zig"); const Air = @import("../../Air.zig"); const CodeGen = @import("CodeGen.zig"); const Register = bits.Register; instructions: std.MultiArrayList(Inst).Slice, /// The meaning of this data is determined by `Inst.Tag` value. extra: []const u32, pub const Inst = struct { tag: Tag, ops: Ops, /// The meaning of this depends on `tag` and `ops`. data: Data, pub const Tag = enum(u16) { /// ops flags: form: /// 0b00 reg1, reg2 /// 0b00 reg1, imm32 /// 0b01 reg1, [reg2 + imm32] /// 0b01 reg1, [ds:imm32] /// 0b10 [reg1 + imm32], reg2 /// Notes: /// * If reg2 is `none` then it means Data field `imm` is used as the immediate. /// * When two imm32 values are required, Data field `payload` points at `ImmPair`. adc, /// ops flags: form: /// 0b00 byte ptr [reg1 + imm32], imm8 /// 0b01 word ptr [reg1 + imm32], imm16 /// 0b10 dword ptr [reg1 + imm32], imm32 /// 0b11 qword ptr [reg1 + imm32], imm32 (sign-extended to imm64) adc_mem_imm, /// form: reg1, [reg2 + scale*rcx + imm32] /// ops flags scale /// 0b00 1 /// 0b01 2 /// 0b10 4 /// 0b11 8 adc_scale_src, /// form: [reg1 + scale*rax + imm32], reg2 /// form: [reg1 + scale*rax + 0], imm32 /// ops flags scale /// 0b00 1 /// 0b01 2 /// 0b10 4 /// 0b11 8 /// Notes: /// * If reg2 is `none` then it means Data field `imm` is used as the immediate. adc_scale_dst, /// form: [reg1 + scale*rax + imm32], imm32 /// ops flags scale /// 0b00 1 /// 0b01 2 /// 0b10 4 /// 0b11 8 /// Notes: /// * Data field `payload` points at `ImmPair`. adc_scale_imm, /// ops flags: form: /// 0b00 byte ptr [reg1 + rax + imm32], imm8 /// 0b01 word ptr [reg1 + rax + imm32], imm16 /// 0b10 dword ptr [reg1 + rax + imm32], imm32 /// 0b11 qword ptr [reg1 + rax + imm32], imm32 (sign-extended to imm64) adc_mem_index_imm, // The following instructions all have the same encoding as `adc`. add, add_mem_imm, add_scale_src, add_scale_dst, add_scale_imm, add_mem_index_imm, sub, sub_mem_imm, sub_scale_src, sub_scale_dst, sub_scale_imm, sub_mem_index_imm, xor, xor_mem_imm, xor_scale_src, xor_scale_dst, xor_scale_imm, xor_mem_index_imm, @"and", and_mem_imm, and_scale_src, and_scale_dst, and_scale_imm, and_mem_index_imm, @"or", or_mem_imm, or_scale_src, or_scale_dst, or_scale_imm, or_mem_index_imm, rol, rol_mem_imm, rol_scale_src, rol_scale_dst, rol_scale_imm, rol_mem_index_imm, ror, ror_mem_imm, ror_scale_src, ror_scale_dst, ror_scale_imm, ror_mem_index_imm, rcl, rcl_mem_imm, rcl_scale_src, rcl_scale_dst, rcl_scale_imm, rcl_mem_index_imm, rcr, rcr_mem_imm, rcr_scale_src, rcr_scale_dst, rcr_scale_imm, rcr_mem_index_imm, sbb, sbb_mem_imm, sbb_scale_src, sbb_scale_dst, sbb_scale_imm, sbb_mem_index_imm, cmp, cmp_mem_imm, cmp_scale_src, cmp_scale_dst, cmp_scale_imm, cmp_mem_index_imm, mov, mov_mem_imm, mov_scale_src, mov_scale_dst, mov_scale_imm, mov_mem_index_imm, /// ops flags: form: /// 0b00 reg1, reg2, /// 0b01 reg1, byte ptr [reg2 + imm32] /// 0b10 reg1, word ptr [reg2 + imm32] /// 0b11 reg1, dword ptr [reg2 + imm32] mov_sign_extend, /// ops flags: form: /// 0b00 reg1, reg2 /// 0b01 reg1, byte ptr [reg2 + imm32] /// 0b10 reg1, word ptr [reg2 + imm32] mov_zero_extend, /// ops flags: form: /// 0b00 reg1, [reg2 + imm32] /// 0b00 reg1, [ds:imm32] /// 0b01 reg1, [rip + imm32] /// 0b10 reg1, [reg2 + rcx + imm32] lea, /// ops flags: form: /// 0b00 reg1, [rip + reloc] // via GOT emits X86_64_RELOC_GOT relocation /// 0b01 reg1, [rip + reloc] // direct load emits X86_64_RELOC_SIGNED relocation /// Notes: /// * `Data` contains `load_reloc` lea_pie, /// ops flags: form: /// 0b00 reg1, 1 /// 0b01 reg1, .cl /// 0b10 reg1, imm8 /// Notes: /// * If flags == 0b10, uses `imm`. shl, shl_mem_imm, shl_scale_src, shl_scale_dst, shl_scale_imm, shl_mem_index_imm, sal, sal_mem_imm, sal_scale_src, sal_scale_dst, sal_scale_imm, sal_mem_index_imm, shr, shr_mem_imm, shr_scale_src, shr_scale_dst, shr_scale_imm, shr_mem_index_imm, sar, sar_mem_imm, sar_scale_src, sar_scale_dst, sar_scale_imm, sar_mem_index_imm, /// ops flags: form: /// 0b00 reg1 /// 0b00 byte ptr [reg2 + imm32] /// 0b01 word ptr [reg2 + imm32] /// 0b10 dword ptr [reg2 + imm32] /// 0b11 qword ptr [reg2 + imm32] imul, idiv, mul, div, /// ops flags: form: /// 0b00 AX <- AL /// 0b01 DX:AX <- AX /// 0b10 EDX:EAX <- EAX /// 0b11 RDX:RAX <- RAX cwd, /// ops flags: form: /// 0b00 reg1, reg2 /// 0b01 reg1, [reg2 + imm32] /// 0b01 reg1, [imm32] if reg2 is none /// 0b10 reg1, reg2, imm32 /// 0b11 reg1, [reg2 + imm32], imm32 imul_complex, /// ops flags: form: /// 0bX0 reg1, imm64 /// 0bX1 rax, moffs64 /// Notes: /// * If reg1 is 64-bit, the immediate is 64-bit and stored /// within extra data `Imm64`. /// * For 0bX1, reg1 (or reg2) need to be /// a version of rax. If reg1 == .none, then reg2 == .rax, /// or vice versa. /// TODO handle scaling movabs, /// ops flags: form: /// 0b00 word ptr [reg1 + imm32] /// 0b01 dword ptr [reg1 + imm32] /// 0b10 qword ptr [reg1 + imm32] /// Notes: /// * source is always ST(0) /// * only supports memory operands as destination fisttp, /// ops flags: form: /// 0b01 dword ptr [reg1 + imm32] /// 0b10 qword ptr [reg1 + imm32] fld, /// ops flags: form: /// 0b00 inst /// 0b01 reg1 /// 0b01 [imm32] if reg1 is none /// 0b10 [reg1 + imm32] jmp, call, /// ops flags: /// 0b00 gte /// 0b01 gt /// 0b10 lt /// 0b11 lte cond_jmp_greater_less, cond_set_byte_greater_less, /// ops flags: /// 0b00 above or equal /// 0b01 above /// 0b10 below /// 0b11 below or equal cond_jmp_above_below, cond_set_byte_above_below, /// ops flags: /// 0bX0 ne /// 0bX1 eq cond_jmp_eq_ne, cond_set_byte_eq_ne, /// ops flags: /// 0b00 reg1, reg2, /// 0b01 reg1, word ptr [reg2 + imm] /// 0b10 reg1, dword ptr [reg2 + imm] /// 0b11 reg1, qword ptr [reg2 + imm] cond_mov_eq, cond_mov_lt, cond_mov_below, /// ops flags: /// 0b00 reg1 if OF = 1 /// 0b01 reg1 if OF = 0 /// 0b10 reg1 if CF = 1 /// 0b11 reg1 if CF = 0 cond_set_byte_overflow, /// ops flags: form: /// 0b00 reg1 /// 0b01 [reg1 + imm32] /// 0b10 imm32 /// Notes: /// * If 0b10 is specified and the tag is push, pushes immediate onto the stack /// using the mnemonic PUSH imm32. push, pop, /// ops flags: form: /// 0b00 retf imm16 /// 0b01 retf /// 0b10 retn imm16 /// 0b11 retn ret, /// Fast system call syscall, /// ops flags: form: /// 0b00 reg1, imm32 if reg2 == .none /// 0b00 reg1, reg2 /// TODO handle more cases @"test", /// Breakpoint form: /// 0b00 int3 interrupt, /// Nop nop, /// SSE instructions /// ops flags: form: /// 0b00 reg1, qword ptr [reg2 + imm32] /// 0b01 qword ptr [reg1 + imm32], reg2 /// 0b10 reg1, reg2 mov_f64_sse, mov_f32_sse, /// ops flags: form: /// 0b00 reg1, reg2 add_f64_sse, add_f32_sse, /// ops flags: form: /// 0b00 reg1, reg2 cmp_f64_sse, cmp_f32_sse, /// AVX instructions /// ops flags: form: /// 0b00 reg1, qword ptr [reg2 + imm32] /// 0b01 qword ptr [reg1 + imm32], reg2 /// 0b10 reg1, reg1, reg2 mov_f64_avx, mov_f32_avx, /// ops flags: form: /// 0b00 reg1, reg1, reg2 add_f64_avx, add_f32_avx, /// ops flags: form: /// 0b00 reg1, reg1, reg2 cmp_f64_avx, cmp_f32_avx, /// Pseudo-instructions /// call extern function /// Notes: /// * target of the call is stored as `extern_fn` in `Data` union. call_extern, /// end of prologue dbg_prologue_end, /// start of epilogue dbg_epilogue_begin, /// update debug line dbg_line, /// push registers from the callee_preserved_regs /// data is the bitfield of which regs to push /// for example on x86_64, the callee_preserved_regs are [_]Register{ .rcx, .rsi, .rdi, .r8, .r9, .r10, .r11 }; }; /// so to push rcx and r8 one would make data 0b00000000_00000000_00000000_00001001 (the first and fourth bits are set) /// ops is unused push_regs_from_callee_preserved_regs, /// pop registers from the callee_preserved_regs /// data is the bitfield of which regs to pop /// for example on x86_64, the callee_preserved_regs are [_]Register{ .rcx, .rsi, .rdi, .r8, .r9, .r10, .r11 }; }; /// so to pop rcx and r8 one would make data 0b00000000_00000000_00000000_00001001 (the first and fourth bits are set) /// ops is unused pop_regs_from_callee_preserved_regs, }; /// The position of an MIR instruction within the `Mir` instructions array. pub const Index = u32; pub const Ops = packed struct { reg1: u7, reg2: u7, flags: u2, pub fn encode(vals: struct { reg1: Register = .none, reg2: Register = .none, flags: u2 = 0b00, }) Ops { return .{ .reg1 = @enumToInt(vals.reg1), .reg2 = @enumToInt(vals.reg2), .flags = vals.flags, }; } pub fn decode(ops: Ops) struct { reg1: Register, reg2: Register, flags: u2, } { return .{ .reg1 = @intToEnum(Register, ops.reg1), .reg2 = @intToEnum(Register, ops.reg2), .flags = ops.flags, }; } }; /// All instructions have a 4-byte payload, which is contained within /// this union. `Tag` determines which union field is active, as well as /// how to interpret the data within. pub const Data = union { /// Another instruction. inst: Index, /// A 32-bit immediate value. imm: u32, /// An extern function. extern_fn: struct { /// Index of the containing atom. atom_index: u32, /// Index into the linker's string table. sym_name: u32, }, /// PIE load relocation. load_reloc: struct { /// Index of the containing atom. atom_index: u32, /// Index into the linker's symbol table. sym_index: u32, }, /// Index into `extra`. Meaning of what can be found there is context-dependent. payload: u32, }; // Make sure we don't accidentally make instructions bigger than expected. // Note that in Debug builds, Zig is allowed to insert a secret field for safety checks. comptime { if (builtin.mode != .Debug) { assert(@sizeOf(Data) == 8); } } }; pub const RegsToPushOrPop = struct { regs: u32, disp: u32, }; pub const ImmPair = struct { dest_off: u32, operand: u32, }; pub const Imm64 = struct { msb: u32, lsb: u32, pub fn encode(v: u64) Imm64 { return .{ .msb = @truncate(u32, v >> 32), .lsb = @truncate(u32, v), }; } pub fn decode(imm: Imm64) u64 { var res: u64 = 0; res |= (@intCast(u64, imm.msb) << 32); res |= @intCast(u64, imm.lsb); return res; } }; pub const DbgLineColumn = struct { line: u32, column: u32, }; pub fn deinit(mir: *Mir, gpa: std.mem.Allocator) void { mir.instructions.deinit(gpa); gpa.free(mir.extra); mir.* = undefined; } pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end: usize } { const fields = std.meta.fields(T); var i: usize = index; var result: T = undefined; inline for (fields) |field| { @field(result, field.name) = switch (field.field_type) { u32 => mir.extra[i], i32 => @bitCast(i32, mir.extra[i]), else => @compileError("bad field type"), }; i += 1; } return .{ .data = result, .end = i, }; }
src/arch/x86_64/Mir.zig
const kernel = @import("../../kernel.zig"); const virtio = @import("virtio.zig"); const MMIO = virtio.MMIO; const SplitQueue = virtio.SplitQueue; const Descriptor = virtio.Descriptor; const Graphics = kernel.graphics; const log = kernel.log.scoped(.VirtioGPU); const TODO = kernel.TODO; const GenericDriver = kernel.driver; const Driver = @This(); graphics: Graphics, // TODO: organize this mess mmio: *volatile MMIO, control_queue: *volatile SplitQueue, cursor_queue: *volatile SplitQueue, pmode: ResponseDisplayInfo.Display, request_counters: [11]u64, framebuffer_id: u32, pending_display_info_request: bool, pub const Initialization = struct { pub const Context = u64; pub const Error = error{ allocation_failure, }; pub fn callback(allocate: GenericDriver.AllocationCallback, mmio_address: Context) Error!*Driver { kernel.arch.Virtual.map(mmio_address, 1); const driver_allocation = allocate(@sizeOf(Driver)) orelse return Error.allocation_failure; const driver = @intToPtr(*Driver, driver_allocation); driver.graphics.type = .virtio; // Have to manually set the initialization driver here to get it from the interrupt initialization_driver = driver; driver.mmio = @intToPtr(*volatile MMIO, mmio_address); driver.mmio.init(GPUFeature); driver.control_queue = driver.mmio.add_queue_to_device(0); driver.cursor_queue = driver.mmio.add_queue_to_device(1); // TODO: stop hardcoding interrupt number const interrupt = kernel.arch.Interrupts.Interrupt{ .handler = handler, .pending_operations_handler = pending_operations_handler, }; interrupt.register(7); driver.mmio.set_driver_initialized(); driver.pending_display_info_request = true; driver.request_display_info(); driver.resize_display(); //const framebuffer = @intToPtr([*]u32, framebuffer_allocation.virtual)[0..framebuffer_pixel_count]; //for (framebuffer) |*pixel| { //pixel.* = 0xffffffff; //} log.debug("GPU driver initialized", .{}); return driver; } }; fn resize_display(driver: *Driver) void { driver.create_resource_2d(); driver.attach_backing(); driver.set_scanout(); for (driver.graphics.framebuffer.buffer[0 .. driver.graphics.framebuffer.width * driver.graphics.framebuffer.height]) |*p| { p.* = 0xffffffff; } driver.send_and_flush_framebuffer(); } const AttachBackingDescriptor = struct { attach: ResourceAttachBacking, entry: MemoryEntry, }; fn attach_backing(driver: *Driver) void { const framebuffer_pixel_count = driver.pmode.rect.width * driver.pmode.rect.height; const framebuffer_size = @sizeOf(u32) * framebuffer_pixel_count; const framebuffer_allocation = kernel.heap.allocate(framebuffer_size, true, true) orelse @panic("unable to allocate framebuffer"); driver.graphics.framebuffer = Graphics.Framebuffer{ .buffer = @intToPtr([*]u32, framebuffer_allocation.virtual), .width = driver.pmode.rect.width, .height = driver.pmode.rect.height, .cursor = Graphics.Point{ .x = 0, .y = 0 }, }; log.debug("New framebuffer address: 0x{x}", .{@ptrToInt(driver.graphics.framebuffer.buffer)}); const backing_allocation = kernel.heap.allocate(@sizeOf(AttachBackingDescriptor), true, true) orelse @panic("unable to allocate backing"); const backing_descriptor = @intToPtr(*volatile AttachBackingDescriptor, backing_allocation.virtual); backing_descriptor.* = AttachBackingDescriptor{ .attach = ResourceAttachBacking{ .header = ControlHeader{ .type = ControlType.cmd_resource_attach_backing, .flags = 0, .fence_id = 0, .context_id = 0, .padding = 0, }, .resource_id = driver.framebuffer_id, .entry_count = 1, }, .entry = MemoryEntry{ .address = framebuffer_allocation.physical, .length = framebuffer_size, .padding = 0, } }; // TODO: fix double allocation driver.send_request_and_wait(backing_descriptor, null); } fn set_scanout(driver: *Driver) void { var set_scanout_descriptor = kernel.zeroes(SetScanout); set_scanout_descriptor.header.type = ControlType.cmd_set_scanout; set_scanout_descriptor.rect = driver.pmode.rect; set_scanout_descriptor.resource_id = driver.framebuffer_id; driver.send_request_and_wait(set_scanout_descriptor, null); } fn create_resource_2d(driver: *Driver) void { var create = kernel.zeroes(ResourceCreate2D); create.header.type = ControlType.cmd_resource_create_2d; create.format = Format.R8G8B8A8_UNORM; driver.framebuffer_id +%= 1; create.resource_id = driver.framebuffer_id; log.debug("Resource id: {}", .{create.resource_id}); create.width = driver.pmode.rect.width; create.height = driver.pmode.rect.height; driver.send_request_and_wait(create, null); } fn pending_operations_handler() void { const driver = if (Graphics.drivers.len > 0) @ptrCast(*Driver, Graphics.drivers[0]) else initialization_driver; var device_status = driver.mmio.device_status; //log.debug("Device status: {}", .{device_status}); if (device_status.contains(.failed) or device_status.contains(.device_needs_reset)) { kernel.panic("Unrecoverable device status: {}", .{device_status}); } //const interrupt_status = driver.mmio.interrupt_status; //log.debug("Interrupt status: {}", .{interrupt_status}); const old = driver.pmode; kernel.assert(@src(), old.rect.width == driver.graphics.framebuffer.width); kernel.assert(@src(), old.rect.height == driver.graphics.framebuffer.height); driver.request_display_info(); const new = driver.pmode; log.debug("Old: {}, {}. New: {}, {}", .{ old.rect.width, old.rect.height, new.rect.width, new.rect.height }); if (old.rect.width != new.rect.width or old.rect.height != new.rect.height) { driver.resize_display(); } } fn request_display_info(driver: *Driver) void { kernel.assert(@src(), driver.pending_display_info_request); var header = kernel.zeroes(ControlHeader); header.type = ControlType.cmd_get_display_info; driver.send_request_and_wait(header, ResponseDisplayInfo); driver.pending_display_info_request = false; } fn transfer_to_host(driver: *Driver) void { var transfer_to_host_descriptor = kernel.zeroes(TransferControlToHost2D); transfer_to_host_descriptor.header.type = ControlType.cmd_transfer_to_host_2d; transfer_to_host_descriptor.rect = driver.pmode.rect; transfer_to_host_descriptor.resource_id = driver.framebuffer_id; driver.send_request_and_wait(transfer_to_host_descriptor, null); } fn flush(driver: *Driver) void { var flush_operation = kernel.zeroes(ResourceFlush); flush_operation.header.type = ControlType.cmd_resource_flush; flush_operation.rect = driver.pmode.rect; flush_operation.resource_id = driver.framebuffer_id; driver.send_request_and_wait(flush_operation, null); log.debug("Flush processed successfully", .{}); } const Configuration = struct { events_read: Event, events_clear: Event, scanout_count: u32, reserved: u32, }; const Event = kernel.Bitflag(true, enum(u32) { display = 0, }); const GPUFeature = enum(u6) { virgl_3d_mode = 0, edid = 1, }; const ControlType = enum(u32) { // 2D cmd_get_display_info = 0x0100, cmd_resource_create_2d, cmd_resource_unref, cmd_set_scanout, cmd_resource_flush, cmd_transfer_to_host_2d, cmd_resource_attach_backing, cmd_resource_detach_backing, cmd_get_capset_info, cmd_get_capset, cmd_get_edid, // cursor cmd_update_cursor = 0x0300, cmd_move_cursor, // success responses resp_ok_nodata = 0x1100, resp_ok_display_info, resp_ok_capset_info, resp_ok_capset, resp_ok_edid, // error responses resp_err_unspec = 0x1200, resp_err_out_of_memory, resp_err_invalid_scanout_id, resp_err_invalid_resource_id, resp_err_invalid_context_id, resp_err_invalid_parameter, fn get_request_counter_index(control_type: ControlType) u64 { kernel.assert(@src(), @enumToInt(control_type) < @enumToInt(ControlType.cmd_update_cursor)); return @enumToInt(control_type) - @enumToInt(ControlType.cmd_get_display_info); } }; const Flag = enum(u32) { fence = 1 << 0, }; const ControlHeader = struct { type: ControlType, flags: u32, fence_id: u64, context_id: u32, padding: u32, }; const max_scanouts = 16; const Rect = struct { x: u32, y: u32, width: u32, height: u32, }; const ResponseDisplayInfo = struct { header: ControlHeader, pmodes: [max_scanouts]Display, const Display = struct { rect: Rect, enabled: u32, flags: u32, }; }; const Format = enum(u32) { B8G8R8A8_UNORM = 1, B8G8R8X8_UNORM = 2, A8R8G8B8_UNORM = 3, X8R8G8B8_UNORM = 4, R8G8B8A8_UNORM = 67, X8B8G8R8_UNORM = 68, A8B8G8R8_UNORM = 121, R8G8B8X8_UNORM = 134, }; const ResourceCreate2D = struct { header: ControlHeader, resource_id: u32, format: Format, width: u32, height: u32, }; const MemoryEntry = struct { address: u64, length: u32, padding: u32, }; const ResourceAttachBacking = struct { header: ControlHeader, resource_id: u32, entry_count: u32, // TODO: variable-length array afterwards inline fn set_entry(self: *volatile @This(), index: u64, entry: MemoryEntry) void { const entry_ptr = @intToPtr(*MemoryEntry, @ptrToInt(self) + @sizeOf(@This()) + (@sizeOf(MemoryEntry) * index)); entry_ptr.* = entry; } }; const SetScanout = struct { header: ControlHeader, rect: Rect, scanout_id: u32, resource_id: u32, }; const TransferControlToHost2D = struct { header: ControlHeader, rect: Rect, offset: u64, resource_id: u32, padding: u32, }; const ResourceFlush = struct { header: ControlHeader, rect: Rect, resource_id: u32, padding: u32, }; pub fn send_and_flush_framebuffer(driver: *Driver) void { driver.transfer_to_host(); driver.flush(); } pub fn operate(driver: *Driver, request_bytes: []const u8, response_size: u32) void { const request = kernel.heap.allocate(request_bytes.len, true, true) orelse @panic("unable to allocate memory for gpu request"); kernel.copy(u8, @intToPtr([*]u8, request.virtual)[0..request_bytes.len], request_bytes); var descriptor1: u16 = 0; var descriptor2: u16 = 0; driver.control_queue.push_descriptor(&descriptor2).* = Descriptor{ .address = (kernel.heap.allocate(response_size, true, true) orelse @panic("unable to get memory for gpu response")).physical, .flags = @enumToInt(Descriptor.Flag.write_only), .length = response_size, .next = 0, }; driver.control_queue.push_descriptor(&descriptor1).* = Descriptor{ .address = request.physical, .flags = @enumToInt(Descriptor.Flag.next), .length = @intCast(u32, request_bytes.len), .next = descriptor2, }; driver.control_queue.push_available(descriptor1); driver.mmio.notify_queue(); } fn handler() u64 { // TODO: use more than one driver const driver = if (Graphics.drivers.len > 0) @ptrCast(*Driver, Graphics.drivers[0]) else initialization_driver; var device_status = driver.mmio.device_status; log.debug("Device status: {}", .{device_status}); if (device_status.contains(.failed) or device_status.contains(.device_needs_reset)) { kernel.panic("Unrecoverable device status: {}", .{device_status}); } const interrupt_status = driver.mmio.interrupt_status; log.debug("Interrupt status: {}", .{interrupt_status}); var operations_pending: u64 = 0; if (interrupt_status.contains(.configuration_change)) { const configuration = @intToPtr(*volatile Configuration, @ptrToInt(driver.mmio) + MMIO.configuration_offset); const events_read = configuration.events_read; if (events_read.contains(.display)) { // TODO: check if all events are handled to write the proper bitmask configuration.events_clear = events_read; operations_pending += 1; driver.pending_display_info_request = true; } else { @panic("corrupted notification"); } } else { const descriptor = driver.control_queue.pop_used() orelse { if (device_status.contains(.failed) or device_status.contains(.device_needs_reset)) { kernel.panic("Unrecoverable device status: {}", .{device_status}); } kernel.panic("virtio GPU descriptor corrupted", .{}); }; const header = @intToPtr(*volatile ControlHeader, kernel.arch.Virtual.AddressSpace.physical_to_virtual(descriptor.address)); const request_descriptor = driver.control_queue.get_descriptor(descriptor.next) orelse @panic("unable to request descriptor"); handle_ex(driver, header, request_descriptor); } // TODO: check if all events are handled to write the proper bitmask driver.mmio.interrupt_ack = interrupt_status.bits; return operations_pending; } fn handle_ex(driver: *Driver, header: *volatile ControlHeader, request_descriptor: *volatile Descriptor) void { const control_header = @intToPtr(*ControlHeader, kernel.arch.Virtual.AddressSpace.physical_to_virtual(request_descriptor.address)); switch (header.type) { .cmd_get_display_info => { if (control_header.type != ControlType.resp_ok_display_info) { kernel.panic("Unable to process {s} request successfully: {s}", .{ @tagName(header.type), @tagName(control_header.type) }); } const display_info = @ptrCast(*ResponseDisplayInfo, control_header).*; log.debug("Display info changed", .{}); for (display_info.pmodes) |pmode_it, i| { if (pmode_it.enabled != 0) log.debug("[{}] pmode: {}", .{ i, pmode_it }); } driver.pmode = display_info.pmodes[0]; }, else => { if (control_header.type != ControlType.resp_ok_nodata) { kernel.panic("Unable to process {s} request successfully: {s}", .{ @tagName(header.type), @tagName(control_header.type) }); } }, } const request_counter_index = header.type.get_request_counter_index(); driver.request_counters[request_counter_index] +%= 1; } fn send_request_and_wait(driver: *Driver, request_descriptor: anytype, comptime ResponseType: ?type) void { var request_bytes: []const u8 = undefined; var control_header_type: ControlType = undefined; switch (@typeInfo(@TypeOf(request_descriptor))) { .Pointer => { control_header_type = @ptrCast(*const ControlHeader, request_descriptor).type; request_bytes = kernel.as_bytes(request_descriptor); }, else => { control_header_type = @ptrCast(*const ControlHeader, &request_descriptor).type; request_bytes = kernel.as_bytes(&request_descriptor); }, } const response_size = if (ResponseType) |RT| @sizeOf(RT) else @sizeOf(ControlHeader); log.debug("Sending {s}, Request size: {}. Response size: {}", .{ @tagName(control_header_type), request_bytes.len, response_size }); const request_counter_index = control_header_type.get_request_counter_index(); const request_counter = driver.request_counters[request_counter_index] +% 1; driver.operate(request_bytes, response_size); while (driver.request_counters[request_counter_index] != request_counter) { kernel.spinloop_hint(); } log.debug("{s} #{} processed successfully", .{ @tagName(control_header_type), request_counter }); } var initialization_driver: *Driver = undefined;
src/kernel/arch/riscv64/virtio_gpu.zig
const std = @import("std"); const lex = @import("zua").lex; // this import relies on addPackagePath in ../build.zig const Timer = std.time.Timer; const hash_map = std.hash_map; // Benchmarking for the Zua lexer // Expects @import("build_options").fuzz_lex_inputs_dir to be a path to // a directory containing a corpus of inputs to test. Such a corpus can // be obtained from https://github.com/squeek502/fuzzing-lua var timer: Timer = undefined; const build_options = @import("build_options"); const inputs_dir_path = build_options.fuzzed_lex_inputs_dir; test "bench fuzz_llex inputs" { var arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena_allocator.deinit(); var allocator = arena_allocator.allocator(); timer = try Timer.start(); var inputs_dir = try std.fs.cwd().openDir(inputs_dir_path, .{ .iterate = true }); defer inputs_dir.close(); std.debug.print("Mode: {}\n", .{@import("builtin").mode}); var n: usize = 0; var time: u64 = 0; const num_iterations = 1000; var inputs_iterator = inputs_dir.iterate(); while (try inputs_iterator.next()) |entry| { if (entry.kind != .File) continue; const contents = try inputs_dir.readFileAlloc(allocator, entry.name, std.math.maxInt(usize)); defer allocator.free(contents); beginMeasure(); var iteration: usize = 0; while (iteration < num_iterations) : (iteration += 1) { var lexer = lex.Lexer.init(contents, "bench"); while (true) { const token = lexer.next() catch { break; }; if (token.id == lex.Token.Id.eof) { break; } } } time += endMeasure(num_iterations); n += 1; } std.debug.print("Lexed {} files in {}ns ({d}ms)\n", .{ n, time, @intToFloat(f64, time) / (std.time.ns_per_s / std.time.ms_per_s) }); } fn beginMeasure() void { timer.reset(); } fn endMeasure(iterations: usize) u64 { const elapsed_ns = timer.read(); return elapsed_ns / iterations; }
test/bench_lex.zig
const std = @import("std"); const IOPort = @import("../IOPort.zig"); const SerialPortConsole = @This(); pub const ForegroundColor = enum(u32) { default = 39, black = 30, red = 31, green = 32, yellow = 33, blue = 34, magenta = 35, cyan = 36, light_gray = 37, gray = 90, light_red = 91, light_green = 92, light_yellow = 93, light_blue = 94, light_magenta = 95, light_cyan = 96, white = 97, }; pub const BackgroundColor = enum(u32) { default = 49, black = 40, red = 41, green = 42, yellow = 43, blue = 44, magenta = 45, cyan = 46, light_gray = 47, gray = 100, light_red = 101, light_green = 102, light_yellow = 103, light_blue = 104, light_magenta = 105, light_cyan = 106, white = 107, }; data_or_baud_lsb_register: IOPort, interrupt_enable_or_baud_msb_register: IOPort, interrupt_identification_and_fifo_control_register: IOPort, line_control_register: IOPort, modem_control_register: IOPort, line_status_register: IOPort, modem_status_register: IOPort, scratch_register: IOPort, fn enable_dlab(self: *const SerialPortConsole) void { self.line_control_register.write_byte(self.line_control_register.read_byte() | 0x80); } fn disable_dlab(self: *const SerialPortConsole) void { self.line_control_register.write_byte(self.line_control_register.read_byte() & ~@intCast(u8, 0x80)); } fn set_baud_divider(self: *const SerialPortConsole) void { // Set baud divider to 1, so that we get full 115200bps. self.enable_dlab(); self.data_or_baud_lsb_register.write_byte(1); self.interrupt_enable_or_baud_msb_register.write_byte(0); self.disable_dlab(); } fn set_line_control(self: *const SerialPortConsole) void { // 8-bit data, 1 stop bit, no parity self.line_control_register.write_byte(0x03); } fn disable_interrupt(self: *const SerialPortConsole) void { self.interrupt_enable_or_baud_msb_register.write_byte(0x00); } fn is_transmitter_empty(self: *const SerialPortConsole) bool { return (self.line_status_register.read_byte() & 0x40) == 0x40; } fn is_data_ready(self: *const SerialPortConsole) bool { return (self.line_status_register.read_byte() & 0x01) == 0x01; } pub fn write_character(self: *const SerialPortConsole, character: u8) void { while (!self.is_transmitter_empty()) {} self.data_or_baud_lsb_register.write_byte(character); } pub fn write_string(self: *const SerialPortConsole, string: []const u8) void { for (string) |character| { self.write_character(character); } } pub fn clear_and_reset_cursor(self: *const SerialPortConsole) void { // \x1b[2J -> Clears the screen. // \x1b[H -> Sets cursor position to (1, 1), which is top left. self.write_string("\x1b[2J\x1b[H"); } fn writer_write(context: *const SerialPortConsole, string: []const u8) error{}!usize { context.write_string(string); return string.len; } pub const Writer = std.io.Writer(*const SerialPortConsole, error{}, writer_write); fn writer(self: *const SerialPortConsole) Writer { return .{ .context = self }; } pub fn set_background_color(self: *const SerialPortConsole, background_color: BackgroundColor) void { try std.fmt.format(self.writer(), "\x1b[{}m", .{@enumToInt(background_color)}); } pub fn set_foreground_color(self: *const SerialPortConsole, foreground_color: ForegroundColor) void { try std.fmt.format(self.writer(), "\x1b[{}m", .{@enumToInt(foreground_color)}); } pub fn read_character(self: *const SerialPortConsole) u8 { while (!self.is_data_ready()) {} return self.data_or_baud_lsb_register.read_byte(); } fn initialize(port_base_address: u16) SerialPortConsole { var port = SerialPortConsole{ .data_or_baud_lsb_register = .{ .port_number = port_base_address + 0 }, .interrupt_enable_or_baud_msb_register = .{ .port_number = port_base_address + 1 }, .interrupt_identification_and_fifo_control_register = .{ .port_number = port_base_address + 2 }, .line_control_register = .{ .port_number = port_base_address + 3 }, .modem_control_register = .{ .port_number = port_base_address + 4 }, .line_status_register = .{ .port_number = port_base_address + 5 }, .modem_status_register = .{ .port_number = port_base_address + 6 }, .scratch_register = .{ .port_number = port_base_address + 7 }, }; port.disable_interrupt(); port.set_baud_divider(); port.set_line_control(); return port; } pub fn com1() SerialPortConsole { return initialize(0x3f8); }
kernel/console/SerialPortConsole.zig
const std = @import("std"); const c = @import("common/c.zig"); // records and plays back keypresses. press the button once to start recording, // press again to stop recording and play back in a loop what was recorded, // press a third time to turn it off. // one problem is that if you're playing along to the playback, your notes will // also get cut off every time it loops. but i don't care to fix it. this // feature was mostly intended so that you can leave something playing while // you tweak instrument parameters. it will probably be eventually be replaced // by a proper music tracking system. // also, i think it has problems if you press a key that is already down // according to the playback. it's possible to lose the note up event and the // note will keep playing after you let go. but again i think it's good enough. pub const Recorder = struct { pub const State = union(enum) { idle, recording: struct { start_time: f32, }, playing: struct { start_time: f32, duration: f32, note_index: usize, looping: bool, }, }; pub const Note = struct { key: i32, down: bool, time: f32, }; pub const GetNoteResult = struct { key: i32, down: bool, }; pub const max_notes = 5000; pub const max_keys_held = 50; state: State, notes: [max_notes]Note, num_notes: usize, keys_held: [max_keys_held]i32, num_keys_held: usize, drain_keys_held: bool, fn getTime() f32 { return @intToFloat(f32, c.SDL_GetTicks()) / 1000.0; } pub fn init() Recorder { return Recorder{ .state = .idle, .notes = undefined, .num_notes = 0, .keys_held = undefined, .num_keys_held = 0, .drain_keys_held = false, }; } pub fn cycleMode(self: *Recorder) void { self.drain_keys_held = true; } pub fn recordEvent(self: *Recorder, key: i32, down: bool) void { const r = switch (self.state) { .recording => |r| r, else => return, }; if (self.num_notes == max_notes) return; self.notes[self.num_notes] = .{ .key = key, .down = down, .time = getTime() - r.start_time, }; self.num_notes += 1; return; } pub fn trackEvent(self: *Recorder, key: i32, down: bool) void { if (down) { for (self.keys_held[0..self.num_keys_held]) |key_held| { if (key_held == key) break; } else if (self.num_keys_held < max_keys_held) { self.keys_held[self.num_keys_held] = key; self.num_keys_held += 1; } } else { if (std.mem.indexOfScalar(i32, self.keys_held[0..self.num_keys_held], key)) |index| { var i = index; while (i < self.num_keys_held - 1) : (i += 1) { self.keys_held[i] = self.keys_held[i + 1]; } self.num_keys_held -= 1; } } } pub fn getNote(self: *Recorder) ?GetNoteResult { if (self.drain_keys_held) { if (self.num_keys_held > 0) { self.num_keys_held -= 1; return GetNoteResult{ .key = self.keys_held[self.num_keys_held], .down = false, }; } self.drain_keys_held = false; switch (self.state) { .idle => { self.state = .{ .recording = .{ .start_time = getTime(), }, }; self.num_notes = 0; }, .recording => |r| { self.state = .{ .playing = .{ .start_time = getTime(), .duration = getTime() - r.start_time, .note_index = 0, .looping = false, }, }; }, .playing => |*p| { if (p.looping) { p.looping = false; } else { self.state = .idle; } }, } } const p = switch (self.state) { .playing => |*p| p, else => return null, }; const time = getTime() - p.start_time; if (time >= p.duration) { p.note_index = 0; p.start_time = getTime(); p.looping = true; self.drain_keys_held = true; } if (p.note_index < self.num_notes) { const note = self.notes[p.note_index]; if (note.time <= time) { p.note_index += 1; return GetNoteResult{ .key = note.key, .down = note.down, }; } } return null; } };
examples/recorder.zig
const std = @import("std"); const builtin = @import("builtin"); const os = @import("os.zig"); const utils = @import("utils.zig"); const Elf = utils.Elf; const Paging = utils.Paging; const io = @import("io.zig"); const Serial = io.Serial; const mm = @import("mm.zig"); const isr = @import("isr.zig"); const display = @intToPtr([*]volatile u16, 0xb8000); const tc = @import("term_color.zig"); export var serialboot_mode: bool = false; export var ataboot_mode: bool = false; // Kernel offset in `image.bin` // From 'tools/gen_image.py' const KERNEL_OFFSET = 1024 * 512; export fn main(arg: u32) align(16) callconv(.C) noreturn { // "Zig" display[80 + 0] = 0x0a5a; display[80 + 1] = 0x0a69; display[80 + 2] = 0x0a67; os.init() catch { @panic("OS init error!"); }; interrupt_test(); isr.init(); Paging.init(mm.GlobalAllocator) catch @panic("Paging init error!"); if (is_ok(arg)) { // "OK" display[160 + 0] = 0x0f4f; display[160 + 1] = 0x0f4b; const out = Serial.writer(); out.print(tc.GREEN ++ "OK\n" ++ tc.RESET, .{}) catch {}; } while (true) { const out = Serial.writer(); if (serialboot_mode) { defer serialboot_mode = false; asm volatile ("cli"); // Boot from 'COM2' const port = 1; const allocator = mm.GlobalAllocator; const buf = utils.serialboot(allocator, port) catch |err| { const msg = tc.RED ++ "serialboot {}.\n" ++ tc.RESET; out.print(msg, .{err}) catch {}; continue; }; defer allocator.free(buf); out.print("serialboot is done: {*} {} bytes.\n", .{buf.ptr, buf.len}) catch {}; const r = execElf(buf, out) catch |err| { const msg = tc.RED ++ "ELF exec {}.\n" ++ tc.RESET; out.print(msg, .{err}) catch {}; continue; }; const msg = tc.GREEN ++ "Exit code: 0x{x}\n" ++ tc.RESET; out.print(msg, .{r}) catch {}; } if (ataboot_mode) { defer ataboot_mode = false; asm volatile ("cli"); const allocator = mm.GlobalAllocator; const buf = utils.ataboot(allocator, KERNEL_OFFSET) catch |err| { const msg = tc.RED ++ "ataboot {}.\n" ++ tc.RESET; out.print(msg, .{err}) catch {}; continue; }; defer allocator.free(buf); out.print("ataboot is done: {*} {} bytes.\n", .{buf.ptr, buf.len}) catch {}; const r = execElf(buf, out) catch |err| { const msg = tc.RED ++ "ELF exec {}.\n" ++ tc.RESET; out.print(msg, .{err}) catch {}; continue; }; const msg = tc.GREEN ++ "Exit code: 0x{x}\n" ++ tc.RESET; out.print(msg, .{r}) catch {}; } out.print(tc.MAGENTA ++ "CPU halt.\n" ++ tc.RESET, .{}) catch {}; asm volatile ("sti"); asm volatile ("hlt"); } } fn execElf(buf: []const u8, out: anytype) !u32 { var arena = std.heap.ArenaAllocator.init(mm.GlobalAllocator); defer arena.deinit(); const allocator = &arena.allocator; // Load elf const prog = try Elf.load(allocator, buf); try out.print("Entrypoint: 0x{x:0>8}\n", .{prog.entry}); // Map `prog` to virtual memory for (prog.pages) |*p| { try out.print("Page: {}\n", .{p}); p.map(allocator) catch @panic("Page mapping error."); } Paging.loadPD(); // Execute const r = asm volatile ("call *%[entry]" : [ret] "={eax}" (-> u32) : [entry] "{eax}" (prog.entry) : "eax", "memory" ); // Clear virtual memory, except first 4 MiB Paging.clearPD(); return r; } fn interrupt_test() void { var buf = [4]u32 {1, 2, 3, 4}; asm volatile ("int $0" :: [arg1] "{eax}" (buf[0]), [arg2] "{ecx}" (buf[1]), [arg3] "{edx}" (buf[2]), [arg4] "{ebx}" (buf[3]) : "memory"); } fn is_ok(arg: u32) bool { return arg == 0x12345678; } pub fn panic(msg: []const u8, bt: ?*std.builtin.StackTrace) noreturn { // display "PANIC!" display[0] = 0x0c50; display[1] = 0x0c41; display[2] = 0x0c4e; display[3] = 0x0c49; display[4] = 0x0c43; display[5] = 0x0c21; const out = Serial.writer(); out.print(tc.RED ++ "PANIC \"{s}\"\n" ++ tc.RESET, .{ msg, }) catch {}; while(true) { asm volatile ("hlt"); } }
src/main.zig
//-------------------------------------------------------------------------------- // Section: Types (15) //-------------------------------------------------------------------------------- pub const SystemInterruptTime = extern struct { value: u64, }; pub const PresentationTransform = extern struct { M11: f32, M12: f32, M21: f32, M22: f32, M31: f32, M32: f32, }; pub const PresentStatisticsKind = enum(i32) { PresentStatus = 1, CompositionFrame = 2, IndependentFlipFrame = 3, }; pub const PresentStatisticsKind_PresentStatus = PresentStatisticsKind.PresentStatus; pub const PresentStatisticsKind_CompositionFrame = PresentStatisticsKind.CompositionFrame; pub const PresentStatisticsKind_IndependentFlipFrame = PresentStatisticsKind.IndependentFlipFrame; const IID_IPresentationBuffer_Value = @import("../zig.zig").Guid.initString("2e217d3a-5abb-4138-9a13-a775593c89ca"); pub const IID_IPresentationBuffer = &IID_IPresentationBuffer_Value; pub const IPresentationBuffer = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetAvailableEvent: fn( self: *const IPresentationBuffer, availableEventHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, IsAvailable: fn( self: *const IPresentationBuffer, isAvailable: ?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationBuffer_GetAvailableEvent(self: *const T, availableEventHandle: ?*?HANDLE) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationBuffer.VTable, self.vtable).GetAvailableEvent(@ptrCast(*const IPresentationBuffer, self), availableEventHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationBuffer_IsAvailable(self: *const T, isAvailable: ?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationBuffer.VTable, self.vtable).IsAvailable(@ptrCast(*const IPresentationBuffer, self), isAvailable); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IPresentationContent_Value = @import("../zig.zig").Guid.initString("5668bb79-3d8e-415c-b215-f38020f2d252"); pub const IID_IPresentationContent = &IID_IPresentationContent_Value; pub const IPresentationContent = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetTag: fn( self: *const IPresentationContent, tag: usize, ) callconv(@import("std").os.windows.WINAPI) void, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationContent_SetTag(self: *const T, tag: usize) callconv(.Inline) void { return @ptrCast(*const IPresentationContent.VTable, self.vtable).SetTag(@ptrCast(*const IPresentationContent, self), tag); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IPresentationSurface_Value = @import("../zig.zig").Guid.initString("956710fb-ea40-4eba-a3eb-4375a0eb4edc"); pub const IID_IPresentationSurface = &IID_IPresentationSurface_Value; pub const IPresentationSurface = extern struct { pub const VTable = extern struct { base: IPresentationContent.VTable, SetBuffer: fn( self: *const IPresentationSurface, presentationBuffer: ?*IPresentationBuffer, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetColorSpace: fn( self: *const IPresentationSurface, colorSpace: DXGI_COLOR_SPACE_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetAlphaMode: fn( self: *const IPresentationSurface, alphaMode: DXGI_ALPHA_MODE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetSourceRect: fn( self: *const IPresentationSurface, sourceRect: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetTransform: fn( self: *const IPresentationSurface, transform: ?*PresentationTransform, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RestrictToOutput: fn( self: *const IPresentationSurface, output: ?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetDisableReadback: fn( self: *const IPresentationSurface, value: u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetLetterboxingMargins: fn( self: *const IPresentationSurface, leftLetterboxSize: f32, topLetterboxSize: f32, rightLetterboxSize: f32, bottomLetterboxSize: f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPresentationContent.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationSurface_SetBuffer(self: *const T, presentationBuffer: ?*IPresentationBuffer) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationSurface.VTable, self.vtable).SetBuffer(@ptrCast(*const IPresentationSurface, self), presentationBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationSurface_SetColorSpace(self: *const T, colorSpace: DXGI_COLOR_SPACE_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationSurface.VTable, self.vtable).SetColorSpace(@ptrCast(*const IPresentationSurface, self), colorSpace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationSurface_SetAlphaMode(self: *const T, alphaMode: DXGI_ALPHA_MODE) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationSurface.VTable, self.vtable).SetAlphaMode(@ptrCast(*const IPresentationSurface, self), alphaMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationSurface_SetSourceRect(self: *const T, sourceRect: ?*const RECT) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationSurface.VTable, self.vtable).SetSourceRect(@ptrCast(*const IPresentationSurface, self), sourceRect); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationSurface_SetTransform(self: *const T, transform: ?*PresentationTransform) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationSurface.VTable, self.vtable).SetTransform(@ptrCast(*const IPresentationSurface, self), transform); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationSurface_RestrictToOutput(self: *const T, output: ?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationSurface.VTable, self.vtable).RestrictToOutput(@ptrCast(*const IPresentationSurface, self), output); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationSurface_SetDisableReadback(self: *const T, value: u8) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationSurface.VTable, self.vtable).SetDisableReadback(@ptrCast(*const IPresentationSurface, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationSurface_SetLetterboxingMargins(self: *const T, leftLetterboxSize: f32, topLetterboxSize: f32, rightLetterboxSize: f32, bottomLetterboxSize: f32) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationSurface.VTable, self.vtable).SetLetterboxingMargins(@ptrCast(*const IPresentationSurface, self), leftLetterboxSize, topLetterboxSize, rightLetterboxSize, bottomLetterboxSize); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IPresentStatistics_Value = @import("../zig.zig").Guid.initString("b44b8bda-7282-495d-9dd7-ceadd8b4bb86"); pub const IID_IPresentStatistics = &IID_IPresentStatistics_Value; pub const IPresentStatistics = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetPresentId: fn( self: *const IPresentStatistics, ) callconv(@import("std").os.windows.WINAPI) u64, GetKind: fn( self: *const IPresentStatistics, ) callconv(@import("std").os.windows.WINAPI) PresentStatisticsKind, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentStatistics_GetPresentId(self: *const T) callconv(.Inline) u64 { return @ptrCast(*const IPresentStatistics.VTable, self.vtable).GetPresentId(@ptrCast(*const IPresentStatistics, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentStatistics_GetKind(self: *const T) callconv(.Inline) PresentStatisticsKind { return @ptrCast(*const IPresentStatistics.VTable, self.vtable).GetKind(@ptrCast(*const IPresentStatistics, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IPresentationManager_Value = @import("../zig.zig").Guid.initString("fb562f82-6292-470a-88b1-843661e7f20c"); pub const IID_IPresentationManager = &IID_IPresentationManager_Value; pub const IPresentationManager = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, AddBufferFromResource: fn( self: *const IPresentationManager, resource: ?*IUnknown, presentationBuffer: ?*?*IPresentationBuffer, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreatePresentationSurface: fn( self: *const IPresentationManager, compositionSurfaceHandle: ?HANDLE, presentationSurface: ?*?*IPresentationSurface, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetNextPresentId: fn( self: *const IPresentationManager, ) callconv(@import("std").os.windows.WINAPI) u64, SetTargetTime: fn( self: *const IPresentationManager, targetTime: SystemInterruptTime, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetPreferredPresentDuration: fn( self: *const IPresentationManager, preferredDuration: SystemInterruptTime, deviationTolerance: SystemInterruptTime, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ForceVSyncInterrupt: fn( self: *const IPresentationManager, forceVsyncInterrupt: u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Present: fn( self: *const IPresentationManager, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPresentRetiringFence: fn( self: *const IPresentationManager, riid: ?*const Guid, fence: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CancelPresentsFrom: fn( self: *const IPresentationManager, presentIdToCancelFrom: u64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetLostEvent: fn( self: *const IPresentationManager, lostEventHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPresentStatisticsAvailableEvent: fn( self: *const IPresentationManager, presentStatisticsAvailableEventHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnablePresentStatisticsKind: fn( self: *const IPresentationManager, presentStatisticsKind: PresentStatisticsKind, enabled: u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetNextPresentStatistics: fn( self: *const IPresentationManager, nextPresentStatistics: ?*?*IPresentStatistics, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_AddBufferFromResource(self: *const T, resource: ?*IUnknown, presentationBuffer: ?*?*IPresentationBuffer) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).AddBufferFromResource(@ptrCast(*const IPresentationManager, self), resource, presentationBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_CreatePresentationSurface(self: *const T, compositionSurfaceHandle: ?HANDLE, presentationSurface: ?*?*IPresentationSurface) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).CreatePresentationSurface(@ptrCast(*const IPresentationManager, self), compositionSurfaceHandle, presentationSurface); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_GetNextPresentId(self: *const T) callconv(.Inline) u64 { return @ptrCast(*const IPresentationManager.VTable, self.vtable).GetNextPresentId(@ptrCast(*const IPresentationManager, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_SetTargetTime(self: *const T, targetTime: SystemInterruptTime) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).SetTargetTime(@ptrCast(*const IPresentationManager, self), targetTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_SetPreferredPresentDuration(self: *const T, preferredDuration: SystemInterruptTime, deviationTolerance: SystemInterruptTime) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).SetPreferredPresentDuration(@ptrCast(*const IPresentationManager, self), preferredDuration, deviationTolerance); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_ForceVSyncInterrupt(self: *const T, forceVsyncInterrupt: u8) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).ForceVSyncInterrupt(@ptrCast(*const IPresentationManager, self), forceVsyncInterrupt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_Present(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).Present(@ptrCast(*const IPresentationManager, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_GetPresentRetiringFence(self: *const T, riid: ?*const Guid, fence: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).GetPresentRetiringFence(@ptrCast(*const IPresentationManager, self), riid, fence); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_CancelPresentsFrom(self: *const T, presentIdToCancelFrom: u64) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).CancelPresentsFrom(@ptrCast(*const IPresentationManager, self), presentIdToCancelFrom); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_GetLostEvent(self: *const T, lostEventHandle: ?*?HANDLE) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).GetLostEvent(@ptrCast(*const IPresentationManager, self), lostEventHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_GetPresentStatisticsAvailableEvent(self: *const T, presentStatisticsAvailableEventHandle: ?*?HANDLE) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).GetPresentStatisticsAvailableEvent(@ptrCast(*const IPresentationManager, self), presentStatisticsAvailableEventHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_EnablePresentStatisticsKind(self: *const T, presentStatisticsKind: PresentStatisticsKind, enabled: u8) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).EnablePresentStatisticsKind(@ptrCast(*const IPresentationManager, self), presentStatisticsKind, enabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationManager_GetNextPresentStatistics(self: *const T, nextPresentStatistics: ?*?*IPresentStatistics) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationManager.VTable, self.vtable).GetNextPresentStatistics(@ptrCast(*const IPresentationManager, self), nextPresentStatistics); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IPresentationFactory_Value = @import("../zig.zig").Guid.initString("8fb37b58-1d74-4f64-a49c-1f97a80a2ec0"); pub const IID_IPresentationFactory = &IID_IPresentationFactory_Value; pub const IPresentationFactory = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, IsPresentationSupported: fn( self: *const IPresentationFactory, ) callconv(@import("std").os.windows.WINAPI) u8, IsPresentationSupportedWithIndependentFlip: fn( self: *const IPresentationFactory, ) callconv(@import("std").os.windows.WINAPI) u8, CreatePresentationManager: fn( self: *const IPresentationFactory, ppPresentationManager: ?*?*IPresentationManager, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationFactory_IsPresentationSupported(self: *const T) callconv(.Inline) u8 { return @ptrCast(*const IPresentationFactory.VTable, self.vtable).IsPresentationSupported(@ptrCast(*const IPresentationFactory, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationFactory_IsPresentationSupportedWithIndependentFlip(self: *const T) callconv(.Inline) u8 { return @ptrCast(*const IPresentationFactory.VTable, self.vtable).IsPresentationSupportedWithIndependentFlip(@ptrCast(*const IPresentationFactory, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentationFactory_CreatePresentationManager(self: *const T, ppPresentationManager: ?*?*IPresentationManager) callconv(.Inline) HRESULT { return @ptrCast(*const IPresentationFactory.VTable, self.vtable).CreatePresentationManager(@ptrCast(*const IPresentationFactory, self), ppPresentationManager); } };} pub usingnamespace MethodMixin(@This()); }; pub const PresentStatus = enum(i32) { Queued = 0, Skipped = 1, Canceled = 2, }; pub const PresentStatus_Queued = PresentStatus.Queued; pub const PresentStatus_Skipped = PresentStatus.Skipped; pub const PresentStatus_Canceled = PresentStatus.Canceled; const IID_IPresentStatusPresentStatistics_Value = @import("../zig.zig").Guid.initString("c9ed2a41-79cb-435e-964e-c8553055420c"); pub const IID_IPresentStatusPresentStatistics = &IID_IPresentStatusPresentStatistics_Value; pub const IPresentStatusPresentStatistics = extern struct { pub const VTable = extern struct { base: IPresentStatistics.VTable, GetCompositionFrameId: fn( self: *const IPresentStatusPresentStatistics, ) callconv(@import("std").os.windows.WINAPI) u64, GetPresentStatus: fn( self: *const IPresentStatusPresentStatistics, ) callconv(@import("std").os.windows.WINAPI) PresentStatus, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPresentStatistics.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentStatusPresentStatistics_GetCompositionFrameId(self: *const T) callconv(.Inline) u64 { return @ptrCast(*const IPresentStatusPresentStatistics.VTable, self.vtable).GetCompositionFrameId(@ptrCast(*const IPresentStatusPresentStatistics, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPresentStatusPresentStatistics_GetPresentStatus(self: *const T) callconv(.Inline) PresentStatus { return @ptrCast(*const IPresentStatusPresentStatistics.VTable, self.vtable).GetPresentStatus(@ptrCast(*const IPresentStatusPresentStatistics, self)); } };} pub usingnamespace MethodMixin(@This()); }; pub const CompositionFrameInstanceKind = enum(i32) { ComposedOnScreen = 0, ScanoutOnScreen = 1, ComposedToIntermediate = 2, }; pub const CompositionFrameInstanceKind_ComposedOnScreen = CompositionFrameInstanceKind.ComposedOnScreen; pub const CompositionFrameInstanceKind_ScanoutOnScreen = CompositionFrameInstanceKind.ScanoutOnScreen; pub const CompositionFrameInstanceKind_ComposedToIntermediate = CompositionFrameInstanceKind.ComposedToIntermediate; pub const CompositionFrameDisplayInstance = extern struct { displayAdapterLUID: LUID, displayVidPnSourceId: u32, displayUniqueId: u32, renderAdapterLUID: LUID, instanceKind: CompositionFrameInstanceKind, finalTransform: PresentationTransform, requiredCrossAdapterCopy: u8, colorSpace: DXGI_COLOR_SPACE_TYPE, }; const IID_ICompositionFramePresentStatistics_Value = @import("../zig.zig").Guid.initString("ab41d127-c101-4c0a-911d-f9f2e9d08e64"); pub const IID_ICompositionFramePresentStatistics = &IID_ICompositionFramePresentStatistics_Value; pub const ICompositionFramePresentStatistics = extern struct { pub const VTable = extern struct { base: IPresentStatistics.VTable, GetContentTag: fn( self: *const ICompositionFramePresentStatistics, ) callconv(@import("std").os.windows.WINAPI) usize, GetCompositionFrameId: fn( self: *const ICompositionFramePresentStatistics, ) callconv(@import("std").os.windows.WINAPI) u64, GetDisplayInstanceArray: fn( self: *const ICompositionFramePresentStatistics, displayInstanceArrayCount: ?*u32, displayInstanceArray: ?*const ?*CompositionFrameDisplayInstance, ) callconv(@import("std").os.windows.WINAPI) void, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPresentStatistics.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICompositionFramePresentStatistics_GetContentTag(self: *const T) callconv(.Inline) usize { return @ptrCast(*const ICompositionFramePresentStatistics.VTable, self.vtable).GetContentTag(@ptrCast(*const ICompositionFramePresentStatistics, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICompositionFramePresentStatistics_GetCompositionFrameId(self: *const T) callconv(.Inline) u64 { return @ptrCast(*const ICompositionFramePresentStatistics.VTable, self.vtable).GetCompositionFrameId(@ptrCast(*const ICompositionFramePresentStatistics, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICompositionFramePresentStatistics_GetDisplayInstanceArray(self: *const T, displayInstanceArrayCount: ?*u32, displayInstanceArray: ?*const ?*CompositionFrameDisplayInstance) callconv(.Inline) void { return @ptrCast(*const ICompositionFramePresentStatistics.VTable, self.vtable).GetDisplayInstanceArray(@ptrCast(*const ICompositionFramePresentStatistics, self), displayInstanceArrayCount, displayInstanceArray); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IIndependentFlipFramePresentStatistics_Value = @import("../zig.zig").Guid.initString("8c93be27-ad94-4da0-8fd4-2413132d124e"); pub const IID_IIndependentFlipFramePresentStatistics = &IID_IIndependentFlipFramePresentStatistics_Value; pub const IIndependentFlipFramePresentStatistics = extern struct { pub const VTable = extern struct { base: IPresentStatistics.VTable, GetOutputAdapterLUID: fn( self: *const IIndependentFlipFramePresentStatistics, ) callconv(@import("std").os.windows.WINAPI) LUID, GetOutputVidPnSourceId: fn( self: *const IIndependentFlipFramePresentStatistics, ) callconv(@import("std").os.windows.WINAPI) u32, GetContentTag: fn( self: *const IIndependentFlipFramePresentStatistics, ) callconv(@import("std").os.windows.WINAPI) usize, GetDisplayedTime: fn( self: *const IIndependentFlipFramePresentStatistics, ) callconv(@import("std").os.windows.WINAPI) SystemInterruptTime, GetPresentDuration: fn( self: *const IIndependentFlipFramePresentStatistics, ) callconv(@import("std").os.windows.WINAPI) SystemInterruptTime, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPresentStatistics.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IIndependentFlipFramePresentStatistics_GetOutputAdapterLUID(self: *const T) callconv(.Inline) LUID { return @ptrCast(*const IIndependentFlipFramePresentStatistics.VTable, self.vtable).GetOutputAdapterLUID(@ptrCast(*const IIndependentFlipFramePresentStatistics, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IIndependentFlipFramePresentStatistics_GetOutputVidPnSourceId(self: *const T) callconv(.Inline) u32 { return @ptrCast(*const IIndependentFlipFramePresentStatistics.VTable, self.vtable).GetOutputVidPnSourceId(@ptrCast(*const IIndependentFlipFramePresentStatistics, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IIndependentFlipFramePresentStatistics_GetContentTag(self: *const T) callconv(.Inline) usize { return @ptrCast(*const IIndependentFlipFramePresentStatistics.VTable, self.vtable).GetContentTag(@ptrCast(*const IIndependentFlipFramePresentStatistics, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IIndependentFlipFramePresentStatistics_GetDisplayedTime(self: *const T) callconv(.Inline) SystemInterruptTime { return @ptrCast(*const IIndependentFlipFramePresentStatistics.VTable, self.vtable).GetDisplayedTime(@ptrCast(*const IIndependentFlipFramePresentStatistics, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IIndependentFlipFramePresentStatistics_GetPresentDuration(self: *const T) callconv(.Inline) SystemInterruptTime { return @ptrCast(*const IIndependentFlipFramePresentStatistics.VTable, self.vtable).GetPresentDuration(@ptrCast(*const IIndependentFlipFramePresentStatistics, self)); } };} pub usingnamespace MethodMixin(@This()); }; //-------------------------------------------------------------------------------- // Section: Functions (1) //-------------------------------------------------------------------------------- pub extern "dcomp" fn CreatePresentationFactory( d3dDevice: ?*IUnknown, riid: ?*const Guid, presentationFactory: ?*?*anyopaque, ) 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 (8) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const DXGI_ALPHA_MODE = @import("../graphics/dxgi/common.zig").DXGI_ALPHA_MODE; const DXGI_COLOR_SPACE_TYPE = @import("../graphics/dxgi/common.zig").DXGI_COLOR_SPACE_TYPE; const HANDLE = @import("../foundation.zig").HANDLE; const HRESULT = @import("../foundation.zig").HRESULT; const IUnknown = @import("../system/com.zig").IUnknown; const LUID = @import("../foundation.zig").LUID; const RECT = @import("../foundation.zig").RECT; 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/graphics/composition_swapchain.zig
// @imports imports a package or a Zig file into a namespace: const std = @import("std"); // @c_import imports C source/header files (included with @c_include) into a // namespace: const c = @c_import( @c_include("time.h"), @c_include("errno.h") ); pub fn main(args: [][]u8) -> %void { // Builtins are functions provided by the Zig compiler. They help you // when writing code, allowing you to test conditions at compile time (such // as target operating system, architecture, compile variables...), and // abstracts you from platform-specific details such as memory managing // and type information. There are lots of builtins, and hopefully you will // see how you can take advantage of them. // Practical example: load a file into an []u8 with @embed_file: var readme : []u8 = undefined; readme = @embed_file("../README.md"); %%std.io.stdout.printf(readme); // @typeof will give you the type of an identifier: std.assert(@typeof(readme) == []u8); // Compile error if it isn't true // @sizeof will give you the size of a type in bytes: %%std.io.stdout.print_u64(@sizeof(u64)); %%std.io.stdout.printf(" is the size of 'u64' in bytes.\n"); // With @compile_var, you can vary your code based on specific parameters: // target platform, type of build or, in the future, custom variables: switch (@compile_var("os")) { macosx => %%std.io.stdout.printf("You're on OS X!\n"), freebsd => %%std.io.stdout.printf("You're on FreeBSD!\n"), linux => %%std.io.stdout.printf("You're on Linux!\n"), else => %%std.io.stdout.printf("You're on a weird OS...\n"), }; switch (@compile_var("arch")) { armv7 => %%std.io.stdout.printf("You're on a armv7!\n"), i386 => %%std.io.stdout.printf("You're on i386!\n"), x86_64 => %%std.io.stdout.printf("You're on x86_64!\n"), else => %%std.io.stdout.printf("You have a weird arch\n"), }; // @err_name will return the string representation of an error %%std.io.stdout.printf(@err_name(error.SigInterrupt)); %%std.io.stdout.printf("\n"); // @max_value and @min_value will give you the limits of an integer type %%std.io.stdout.print_u64(@max_value(u64)); %%std.io.stdout.printf(" is the max value of an u64 (in your machine).\n"); %%std.io.stdout.print_u64(@min_value(u64)); %%std.io.stdout.printf(" is the min value of an u64 (in your machine).\n"); // There are loads of builtins, and only the basic ones are covered here. // If you want to get into the most specific ones, take a look at // doc/langref.md in the Zig repository // More useful examples: // src/unreachable_type.zig // src/error_type.zig }
src/builtins.zig
const __floattidf = @import("floattidf.zig").__floattidf; const assert = @import("std").debug.assert; fn test__floattidf(a: i128, expected: f64) void { const x = __floattidf(a); assert(x == expected); } test "floattidf" { test__floattidf(0, 0.0); test__floattidf(1, 1.0); test__floattidf(2, 2.0); test__floattidf(20, 20.0); test__floattidf(-1, -1.0); test__floattidf(-2, -2.0); test__floattidf(-20, -20.0); test__floattidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62); test__floattidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62); test__floattidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62); test__floattidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62); test__floattidf(make_ti(0x8000008000000000, 0), -0x1.FFFFFEp+126); test__floattidf(make_ti(0x8000000000000800, 0), -0x1.FFFFFFFFFFFFEp+126); test__floattidf(make_ti(0x8000010000000000, 0), -0x1.FFFFFCp+126); test__floattidf(make_ti(0x8000000000001000, 0), -0x1.FFFFFFFFFFFFCp+126); test__floattidf(make_ti(0x8000000000000000, 0), -0x1.000000p+127); test__floattidf(make_ti(0x8000000000000001, 0), -0x1.000000p+127); test__floattidf(0x0007FB72E8000000, 0x1.FEDCBAp+50); test__floattidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50); test__floattidf(0x0007FB72EB000000, 0x1.FEDCBACp+50); test__floattidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50); test__floattidf(0x0007FB72EC000000, 0x1.FEDCBBp+50); test__floattidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50); test__floattidf(0x0007FB72E6000000, 0x1.FEDCB98p+50); test__floattidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50); test__floattidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50); test__floattidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50); test__floattidf(0x0007FB72E4000000, 0x1.FEDCB9p+50); test__floattidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57); test__floattidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57); test__floattidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57); test__floattidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57); test__floattidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57); test__floattidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57); test__floattidf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496Dp+121); test__floattidf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496Ep+121); test__floattidf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496Fp+121); test__floattidf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496Fp+121); test__floattidf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496Fp+121); test__floattidf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121); } fn make_ti(high: u64, low: u64) i128 { var result: u128 = high; result <<= 64; result |= low; return @bitCast(i128, result); }
std/special/compiler_rt/floattidf_test.zig
const std = @import("std"); const mem = std.mem; const json = std.json; const testing = std.testing; const assert = std.debug.assert; const testUtil = @import("util.zig"); const log = @import("../src/md/log.zig"); const Token = @import("../src/md/token.zig").Token; const TokenId = @import("../src/md/token.zig").TokenId; const Lexer = @import("../src/md/lexer.zig").Lexer; const Parser = @import("../src/md/parse.zig").Parser; var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); const allocator = &arena.allocator; // "markdown": "# foo\n## foo\n### foo\n#### foo\n##### foo\n###### foo\n", // "html": "<h1>foo</h1>\n<h2>foo</h2>\n<h3>foo</h3>\n<h4>foo</h4>\n<h5>foo</h5>\n<h6>foo</h6>\n", test "Test Example 032" { const testNumber: u8 = 32; const parserInput = try testUtil.getTest(allocator, testNumber, testUtil.TestKey.markdown); testUtil.dumpTest(parserInput); var p = Parser.init(allocator); defer p.deinit(); _ = try p.parse(parserInput); log.Debug("Testing lexer"); const expectLexerJson = @embedFile("expect/03-section-atx-headings/testl_032.json"); if (try testUtil.compareJsonExpect(allocator, expectLexerJson, p.lex.tokens.items)) |ajson| { // log.Errorf("LEXER TEST FAILED! lexer tokens (in json):\n{}\n", .{ajson}); std.os.exit(1); } log.Debug("Testing parser"); const expectParserJson = @embedFile("expect/03-section-atx-headings/testp_032.json"); if (try testUtil.compareJsonExpect(allocator, expectParserJson, p.root.items)) |ajson| { // log.Errorf("PARSER TEST FAILED! parser tree (in json):\n{}\n", .{ajson}); std.os.exit(1); } log.Debug("Testing html translator"); const expectHtml = try testUtil.getTest(allocator, testNumber, testUtil.TestKey.html); defer allocator.free(expectHtml); if (try testUtil.compareHtmlExpect(allocator, expectHtml, &p.root)) |ahtml| { // log.Errorf("HTML TRANSLATE TEST FAILED! html:\n{}\n", .{ahtml}); std.os.exit(1); } }
test/section_atx_headings.zig
const std = @import("std"); const builtin = @import("builtin"); const warn = std.debug.warn; pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { std.os.exit(0xF); } fn pow(base: usize, exp: usize) usize { var x: usize = base; var i: usize = 1; while (i < exp) : (i += 1) { x *= base; } return x; } export fn add(a: i32, b: i32) callconv(.C) i32 { return a + b; } export fn printing(buf: [*]const u8, len: usize) callconv(.C) void { var s = buf[0..len]; warn("Zig says: {}\n", .{s}); } fn itoa(comptime N: type, n: N, buff: []u8) void { @setRuntimeSafety(false); comptime var UNROLL_MAX: usize = 4; comptime var DIV_CONST: usize = comptime pow(10, UNROLL_MAX); var num = n; var len = buff.len; while (len >= UNROLL_MAX) : (num = std.math.divTrunc(N, num, DIV_CONST) catch return) { comptime var DIV10: N = 1; comptime var CURRENT: usize = 0; // Write digits backwards into the buffer inline while (CURRENT != UNROLL_MAX) : ({ CURRENT += 1; DIV10 *= 10; }) { var q = std.math.divTrunc(N, num, DIV10) catch break; var r = @truncate(u8, std.math.mod(N, q, 10) catch break) + 48; buff[len - CURRENT - 1] = r; } len -= UNROLL_MAX; } // On an empty buffer, this will wrapparoo to 0xfffff len -%= 1; // Stops at 0xfffff while (len != std.math.maxInt(usize)) : (len -%= 1) { var q: N = std.math.divTrunc(N, num, 10) catch break; var r: u8 = @truncate(u8, std.math.mod(N, num, 10) catch break) + 48; buff[len] = r; num = q; } } export fn itoa_u64(n: u64, noalias buff: [*]u8, len: usize) callconv(.C) void { @setRuntimeSafety(false); var slice = buff[0..len]; itoa(u64, n, slice); } test "empty buff" { var small_buff: []u8 = &[_]u8{}; var small: u64 = 100; _ = itoa_u64(small, small_buff.ptr, small_buff.len); } test "small buff" { const assert = @import("std").debug.assert; const mem = @import("std").mem; comptime var small_buff = [_]u8{10} ** 3; comptime var small: u64 = 100; // Should only run the 2nd while-loop, which is kinda like a fixup loop. comptime itoa_u64(small, &small_buff, small_buff.len); assert(mem.eql(u8, &small_buff, "100")); } test "big buff" { const assert = @import("std").debug.assert; const mem = @import("std").mem; comptime var big_buff = [_]u8{0} ** 10; comptime var big: u64 = 1234123412; comptime itoa_u64(big, &big_buff, big_buff.len); assert(mem.eql(u8, &big_buff, "1234123412")); } test "unroll count buf" { const assert = @import("std").debug.assert; const mem = @import("std").mem; comptime var small_buff = [_]u8{10} ** 4; comptime var small: u64 = 1000; // Should only run the 2nd while-loop, which is kinda like a fixup loop. comptime itoa_u64(small, &small_buff, small_buff.len); assert(mem.eql(u8, &small_buff, "1000")); }
zig/src/zig.zig
const __floatuntidf = @import("floatuntidf.zig").__floatuntidf; const testing = @import("std").testing; fn test__floatuntidf(a: u128, expected: f64) !void { const x = __floatuntidf(a); try testing.expect(x == expected); } test "floatuntidf" { try test__floatuntidf(0, 0.0); try test__floatuntidf(1, 1.0); try test__floatuntidf(2, 2.0); try test__floatuntidf(20, 20.0); try test__floatuntidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62); try test__floatuntidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62); try test__floatuntidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62); try test__floatuntidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62); try test__floatuntidf(make_ti(0x8000008000000000, 0), 0x1.000001p+127); try test__floatuntidf(make_ti(0x8000000000000800, 0), 0x1.0000000000001p+127); try test__floatuntidf(make_ti(0x8000010000000000, 0), 0x1.000002p+127); try test__floatuntidf(make_ti(0x8000000000001000, 0), 0x1.0000000000002p+127); try test__floatuntidf(make_ti(0x8000000000000000, 0), 0x1.000000p+127); try test__floatuntidf(make_ti(0x8000000000000001, 0), 0x1.0000000000000002p+127); try test__floatuntidf(0x0007FB72E8000000, 0x1.FEDCBAp+50); try test__floatuntidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50); try test__floatuntidf(0x0007FB72EB000000, 0x1.FEDCBACp+50); try test__floatuntidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50); try test__floatuntidf(0x0007FB72EC000000, 0x1.FEDCBBp+50); try test__floatuntidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50); try test__floatuntidf(0x0007FB72E6000000, 0x1.FEDCB98p+50); try test__floatuntidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50); try test__floatuntidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50); try test__floatuntidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50); try test__floatuntidf(0x0007FB72E4000000, 0x1.FEDCB9p+50); try test__floatuntidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57); try test__floatuntidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57); try test__floatuntidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57); try test__floatuntidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57); try test__floatuntidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57); try test__floatuntidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57); try test__floatuntidf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496Dp+121); try test__floatuntidf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496Ep+121); try test__floatuntidf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496Fp+121); try test__floatuntidf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496Fp+121); try test__floatuntidf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496Fp+121); try test__floatuntidf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121); } fn make_ti(high: u64, low: u64) u128 { var result: u128 = high; result <<= 64; result |= low; return result; }
lib/std/special/compiler_rt/floatuntidf_test.zig
const std = @import("std"); const proto_pkg = std.build.Pkg{ .name = "proto", .path = .{ .path = "src/proto/proto.zig" }, .dependencies = &[_]std.build.Pkg{}, }; const gdb_pkg = std.build.Pkg{ .name = "gdb", .path = .{ .path = "src/lib/gdb.zig" }, .dependencies = &[_]std.build.Pkg{}, }; const host_pkg = std.build.Pkg{ .name = "host", .path = .{ .path = "src/host/host.zig" }, .dependencies = &[_]std.build.Pkg{ proto_pkg, }, }; fn buildArmHostEL(b: *std.build.Builder, el: usize) !void { const exec = b.addExecutable(b.fmt("host_aarch64_EL{d}", .{el}), "src/host/arch/aarch64/main.zig"); const options = b.addOptions(); options.addOption(usize, "debugger_el", el); exec.addPackage(options.getPackage("build_options")); exec.code_model = .tiny; exec.setLinkerScriptPath(.{.path = "src/host/arch/aarch64/linker.ld"}); exec.setMainPkgPath("src/"); exec.setBuildMode(.ReleaseSmall); exec.addPackage(host_pkg); exec.addPackage(proto_pkg); var disabled_features = std.Target.Cpu.Feature.Set.empty; var enabled_feautres = std.Target.Cpu.Feature.Set.empty; { const features = std.Target.aarch64.Feature; disabled_features.addFeature(@enumToInt(features.fp_armv8)); disabled_features.addFeature(@enumToInt(features.crypto)); disabled_features.addFeature(@enumToInt(features.neon)); } exec.setTarget(.{ .cpu_arch = .aarch64, .os_tag = .freestanding, .abi = .none, .cpu_features_sub = disabled_features, .cpu_features_add = enabled_feautres, }); exec.install(); const blob_step = exec.installRaw(b.fmt("host_aarch64_EL{d}.bin", .{el}), .{ .format = .bin, .only_section_name = ".blob", .pad_to_size = 0x1000, }); b.default_step.dependOn(&exec.install_step.?.step); b.default_step.dependOn(&blob_step.step); const build_step = b.step(b.fmt("host-aarch64-EL{d}", .{el}), b.fmt("Build the aarch64 host for EL{d}", .{el})); build_step.dependOn(&blob_step.step); } fn buildClient(b: *std.build.Builder, target_arch: std.Target.Cpu.Arch) !void { // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which // means any target is allowed, and the default is native. Other options // for restricting supported target set are available. const target = b.standardTargetOptions(.{}); // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const mode = b.standardReleaseOptions(); const platform_pkg = std.build.Pkg{ .name = "platform", .path = .{ .path = b.fmt("src/client/{s}.zig", .{@tagName(target_arch)}) }, .dependencies = &[_]std.build.Pkg{ gdb_pkg, proto_pkg, }, }; const client = b.addExecutable( b.fmt("client_{s}", .{@tagName(target_arch)}), "src/client/main.zig", ); client.setTarget(target); client.setBuildMode(mode); client.install(); client.addPackage(gdb_pkg); client.addPackage(proto_pkg); client.addPackage(platform_pkg); b.default_step.dependOn(&client.step); const run_cmd = client.run(); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } const run_step = b.step(b.fmt("run-{s}", .{@tagName(target_arch)}), b.fmt("Run the {s} client", .{@tagName(target_arch)})); run_step.dependOn(&run_cmd.step); } fn buildArm(b: *std.build.Builder) !void { try buildArmHostEL(b, 1); try buildArmHostEL(b, 2); try buildArmHostEL(b, 3); try buildClient(b, .aarch64); } pub fn build(b: *std.build.Builder) !void { try buildArm(b); }
build.zig
const std = @import("std"); const log = @import("log.zig"); fn findModule(comptime module_name: []const u8) ?[]const u8 { var mem: ?[]const u8 = null; switch (@import("builtin").os.tag) { .linux => std.os.dl_iterate_phdr(&mem, error{}, struct { fn cb(info: *std.os.dl_phdr_info, size: usize, ctx: *?[]const u8) error{}!void { _ = size; if (std.mem.endsWith(u8, std.mem.span(info.dlpi_name).?, "/" ++ module_name ++ ".so")) { const base: usize = info.dlpi_addr + info.dlpi_phdr[0].p_paddr; ctx.* = @intToPtr([*]const u8, base)[0..info.dlpi_phdr[0].p_memsz]; } } }.cb) catch |err| switch (err) {}, .windows => { // Fucking hell Microsoft, why is this so hard const windows = std.os.windows; const process_handle = windows.kernel32.GetCurrentProcess(); var modules: [512]windows.HMODULE = undefined; var bytes: windows.DWORD = undefined; if (windows.kernel32.K32EnumProcessModules( process_handle, &modules, modules.len * @sizeOf(windows.DWORD), &bytes, ) == 0) bytes = 0; const nmods = bytes / @sizeOf(windows.DWORD); for (modules[0..nmods]) |module| { var name_buf: [std.c.PATH_MAX:0]u8 = undefined; const name_len = windows.kernel32.K32GetModuleFileNameExA( process_handle, module, &name_buf, std.c.PATH_MAX, ); if (name_len < 0) continue; var info: windows.MODULEINFO = undefined; if (windows.kernel32.K32GetModuleInformation( process_handle, module, &info, @sizeOf(@TypeOf(info)), ) == 0) continue; if (std.mem.endsWith(u8, name_buf[0..name_len], "\\" ++ module_name ++ ".dll")) { mem = @ptrCast([*]const u8, info.lpBaseOfDll)[0..info.SizeOfImage]; } } }, else => @compileError("Unsupported OS"), } return mem; } pub fn getVersion() ?u16 { if (findModule("engine")) |engine| { if (std.mem.indexOf(u8, engine, "Exe build:")) |idx| { const date_str = engine[idx + 20 .. idx + 31]; const mons = [_][]const u8{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", }; const mon_days = [_]u8{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, }; var d: u8 = 0; var m: u8 = 0; var y: u16 = 0; while (m < 11) : (m += 1) { if (std.mem.eql(u8, date_str[0..3], mons[m])) break; d += mon_days[m]; } if (date_str[4] == ' ') { d += (date_str[5] - '0') - 1; } else { d += (date_str[4] - '0') * 10 + (date_str[5] - '0') - 1; } y = (std.fmt.parseInt(u16, date_str[7..11], 10) catch 0) - 1900; var build_num = @floatToInt(u16, @intToFloat(f32, y - 1) * 365.25); build_num += d; if (y % 4 == 0 and m > 1) build_num += 1; build_num -= 35739; return build_num; } } return null; }
src/version.zig
pub const base = @import("windows.zig"); pub const dwrite = @import("dwrite.zig"); pub const dxgi = @import("dxgi.zig"); pub const d3d11 = @import("d3d11.zig"); pub const d3d11d = @import("d3d11sdklayers.zig"); pub const d3d12 = @import("d3d12.zig"); pub const d3d12d = @import("d3d12sdklayers.zig"); pub const d3d = @import("d3dcommon.zig"); pub const d2d1 = @import("d2d1.zig"); pub const d3d11on12 = @import("d3d11on12.zig"); pub const wic = @import("wincodec.zig"); pub const wasapi = @import("wasapi.zig"); pub const directml = @import("directml.zig"); pub const mf = @import("mf.zig"); pub const xaudio2 = @import("xaudio2.zig"); pub const xaudio2fx = @import("xaudio2fx.zig"); pub const xapo = @import("xapo.zig"); /// Disclaimer: You should probably precompile your shaders with dxc and not use d3dcompiler! pub const d3dcompiler = @import("d3dcompiler.zig"); const HRESULT = base.HRESULT; const S_OK = base.S_OK; const std = @import("std"); const panic = std.debug.panic; const assert = std.debug.assert; // TODO: Handle more error codes from https://docs.microsoft.com/en-us/windows/win32/com/com-error-codes-10 pub const HResultError = base.Error || dxgi.Error || d3d12.Error || d3d11.Error || wasapi.Error || dwrite.Error || xapo.Error || base.MiscError; pub fn hrPanic(err: HResultError) noreturn { panic( "HRESULT error detected (0x{x}, {}).", .{ @bitCast(c_ulong, errorToHRESULT(err)), err }, ); } pub inline fn hrPanicOnFail(hr: HRESULT) void { if (hr != S_OK) { hrPanic(hrToError(hr)); } } pub inline fn hrErrorOnFail(hr: HRESULT) HResultError!void { if (hr != S_OK) { return hrToError(hr); } } pub fn hrToError(hr: HRESULT) HResultError { assert(hr != S_OK); return switch (hr) { // base.E_UNEXPECTED => base.Error.UNEXPECTED, base.E_NOTIMPL => base.Error.NOTIMPL, base.E_OUTOFMEMORY => base.Error.OUTOFMEMORY, base.E_INVALIDARG => base.Error.INVALIDARG, base.E_POINTER => base.Error.POINTER, base.E_HANDLE => base.Error.HANDLE, base.E_ABORT => base.Error.ABORT, base.E_FAIL => base.Error.FAIL, base.E_ACCESSDENIED => base.Error.ACCESSDENIED, // dxgi.ERROR_ACCESS_DENIED => dxgi.Error.ACCESS_DENIED, dxgi.ERROR_ACCESS_LOST => dxgi.Error.ACCESS_LOST, dxgi.ERROR_ALREADY_EXISTS => dxgi.Error.ALREADY_EXISTS, dxgi.ERROR_CANNOT_PROTECT_CONTENT => dxgi.Error.CANNOT_PROTECT_CONTENT, dxgi.ERROR_DEVICE_HUNG => dxgi.Error.DEVICE_HUNG, dxgi.ERROR_DEVICE_REMOVED => dxgi.Error.DEVICE_REMOVED, dxgi.ERROR_DEVICE_RESET => dxgi.Error.DEVICE_RESET, dxgi.ERROR_DRIVER_INTERNAL_ERROR => dxgi.Error.DRIVER_INTERNAL_ERROR, dxgi.ERROR_FRAME_STATISTICS_DISJOINT => dxgi.Error.FRAME_STATISTICS_DISJOINT, dxgi.ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE => dxgi.Error.GRAPHICS_VIDPN_SOURCE_IN_USE, dxgi.ERROR_INVALID_CALL => dxgi.Error.INVALID_CALL, dxgi.ERROR_MORE_DATA => dxgi.Error.MORE_DATA, dxgi.ERROR_NAME_ALREADY_EXISTS => dxgi.Error.NAME_ALREADY_EXISTS, dxgi.ERROR_NONEXCLUSIVE => dxgi.Error.NONEXCLUSIVE, dxgi.ERROR_NOT_CURRENTLY_AVAILABLE => dxgi.Error.NOT_CURRENTLY_AVAILABLE, dxgi.ERROR_NOT_FOUND => dxgi.Error.NOT_FOUND, dxgi.ERROR_REMOTE_CLIENT_DISCONNECTED => dxgi.Error.REMOTE_CLIENT_DISCONNECTED, dxgi.ERROR_REMOTE_OUTOFMEMORY => dxgi.Error.REMOTE_OUTOFMEMORY, dxgi.ERROR_RESTRICT_TO_OUTPUT_STALE => dxgi.Error.RESTRICT_TO_OUTPUT_STALE, dxgi.ERROR_SDK_COMPONENT_MISSING => dxgi.Error.SDK_COMPONENT_MISSING, dxgi.ERROR_SESSION_DISCONNECTED => dxgi.Error.SESSION_DISCONNECTED, dxgi.ERROR_UNSUPPORTED => dxgi.Error.UNSUPPORTED, dxgi.ERROR_WAIT_TIMEOUT => dxgi.Error.WAIT_TIMEOUT, dxgi.ERROR_WAS_STILL_DRAWING => dxgi.Error.WAS_STILL_DRAWING, // d3d12.ERROR_ADAPTER_NOT_FOUND => d3d12.Error.ADAPTER_NOT_FOUND, d3d12.ERROR_DRIVER_VERSION_MISMATCH => d3d12.Error.DRIVER_VERSION_MISMATCH, // d3d11.ERROR_FILE_NOT_FOUND => d3d11.Error.FILE_NOT_FOUND, d3d11.ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS => d3d11.Error.TOO_MANY_UNIQUE_STATE_OBJECTS, d3d11.ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS => d3d11.Error.TOO_MANY_UNIQUE_VIEW_OBJECTS, d3d11.ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD => d3d11.Error.DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD, // wasapi.AUDCLNT_E_NOT_INITIALIZED => wasapi.Error.NOT_INITIALIZED, wasapi.AUDCLNT_E_ALREADY_INITIALIZED => wasapi.Error.ALREADY_INITIALIZED, wasapi.AUDCLNT_E_WRONG_ENDPOINT_TYPE => wasapi.Error.WRONG_ENDPOINT_TYPE, wasapi.AUDCLNT_E_DEVICE_INVALIDATED => wasapi.Error.DEVICE_INVALIDATED, wasapi.AUDCLNT_E_NOT_STOPPED => wasapi.Error.NOT_STOPPED, wasapi.AUDCLNT_E_BUFFER_TOO_LARGE => wasapi.Error.BUFFER_TOO_LARGE, wasapi.AUDCLNT_E_OUT_OF_ORDER => wasapi.Error.OUT_OF_ORDER, wasapi.AUDCLNT_E_UNSUPPORTED_FORMAT => wasapi.Error.UNSUPPORTED_FORMAT, wasapi.AUDCLNT_E_INVALID_SIZE => wasapi.Error.INVALID_SIZE, wasapi.AUDCLNT_E_DEVICE_IN_USE => wasapi.Error.DEVICE_IN_USE, wasapi.AUDCLNT_E_BUFFER_OPERATION_PENDING => wasapi.Error.BUFFER_OPERATION_PENDING, wasapi.AUDCLNT_E_THREAD_NOT_REGISTERED => wasapi.Error.THREAD_NOT_REGISTERED, wasapi.AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED => wasapi.Error.EXCLUSIVE_MODE_NOT_ALLOWED, wasapi.AUDCLNT_E_ENDPOINT_CREATE_FAILED => wasapi.Error.ENDPOINT_CREATE_FAILED, wasapi.AUDCLNT_E_SERVICE_NOT_RUNNING => wasapi.Error.SERVICE_NOT_RUNNING, wasapi.AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED => wasapi.Error.EVENTHANDLE_NOT_EXPECTED, wasapi.AUDCLNT_E_EXCLUSIVE_MODE_ONLY => wasapi.Error.EXCLUSIVE_MODE_ONLY, wasapi.AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL => wasapi.Error.BUFDURATION_PERIOD_NOT_EQUAL, wasapi.AUDCLNT_E_EVENTHANDLE_NOT_SET => wasapi.Error.EVENTHANDLE_NOT_SET, wasapi.AUDCLNT_E_INCORRECT_BUFFER_SIZE => wasapi.Error.INCORRECT_BUFFER_SIZE, wasapi.AUDCLNT_E_BUFFER_SIZE_ERROR => wasapi.Error.BUFFER_SIZE_ERROR, wasapi.AUDCLNT_E_CPUUSAGE_EXCEEDED => wasapi.Error.CPUUSAGE_EXCEEDED, wasapi.AUDCLNT_E_BUFFER_ERROR => wasapi.Error.BUFFER_ERROR, wasapi.AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED => wasapi.Error.BUFFER_SIZE_NOT_ALIGNED, wasapi.AUDCLNT_E_INVALID_DEVICE_PERIOD => wasapi.Error.INVALID_DEVICE_PERIOD, // dwrite.E_FILEFORMAT => dwrite.Error.E_FILEFORMAT, // xapo.E_FORMAT_UNSUPPORTED => xapo.Error.E_FORMAT_UNSUPPORTED, // base.E_FILE_NOT_FOUND => base.MiscError.E_FILE_NOT_FOUND, base.S_FALSE => base.MiscError.S_FALSE, // treat unknown error return codes as E_FAIL else => blk: { std.debug.print("HRESULT error 0x{x} not recognized treating as E_FAIL.", .{@bitCast(c_ulong, hr)}); break :blk base.Error.FAIL; }, }; } pub fn errorToHRESULT(err: HResultError) HRESULT { return switch (err) { base.Error.UNEXPECTED => base.E_UNEXPECTED, base.Error.NOTIMPL => base.E_NOTIMPL, base.Error.OUTOFMEMORY => base.E_OUTOFMEMORY, base.Error.INVALIDARG => base.E_INVALIDARG, base.Error.POINTER => base.E_POINTER, base.Error.HANDLE => base.E_HANDLE, base.Error.ABORT => base.E_ABORT, base.Error.FAIL => base.E_FAIL, base.Error.ACCESSDENIED => base.E_ACCESSDENIED, // dxgi.Error.ACCESS_DENIED => dxgi.ERROR_ACCESS_DENIED, dxgi.Error.ACCESS_LOST => dxgi.ERROR_ACCESS_LOST, dxgi.Error.ALREADY_EXISTS => dxgi.ERROR_ALREADY_EXISTS, dxgi.Error.CANNOT_PROTECT_CONTENT => dxgi.ERROR_CANNOT_PROTECT_CONTENT, dxgi.Error.DEVICE_HUNG => dxgi.ERROR_DEVICE_HUNG, dxgi.Error.DEVICE_REMOVED => dxgi.ERROR_DEVICE_REMOVED, dxgi.Error.DEVICE_RESET => dxgi.ERROR_DEVICE_RESET, dxgi.Error.DRIVER_INTERNAL_ERROR => dxgi.ERROR_DRIVER_INTERNAL_ERROR, dxgi.Error.FRAME_STATISTICS_DISJOINT => dxgi.ERROR_FRAME_STATISTICS_DISJOINT, dxgi.Error.GRAPHICS_VIDPN_SOURCE_IN_USE => dxgi.ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE, dxgi.Error.INVALID_CALL => dxgi.ERROR_INVALID_CALL, dxgi.Error.MORE_DATA => dxgi.ERROR_MORE_DATA, dxgi.Error.NAME_ALREADY_EXISTS => dxgi.ERROR_NAME_ALREADY_EXISTS, dxgi.Error.NONEXCLUSIVE => dxgi.ERROR_NONEXCLUSIVE, dxgi.Error.NOT_CURRENTLY_AVAILABLE => dxgi.ERROR_NOT_CURRENTLY_AVAILABLE, dxgi.Error.NOT_FOUND => dxgi.ERROR_NOT_FOUND, dxgi.Error.REMOTE_CLIENT_DISCONNECTED => dxgi.ERROR_REMOTE_CLIENT_DISCONNECTED, dxgi.Error.REMOTE_OUTOFMEMORY => dxgi.ERROR_REMOTE_OUTOFMEMORY, dxgi.Error.RESTRICT_TO_OUTPUT_STALE => dxgi.ERROR_RESTRICT_TO_OUTPUT_STALE, dxgi.Error.SDK_COMPONENT_MISSING => dxgi.ERROR_SDK_COMPONENT_MISSING, dxgi.Error.SESSION_DISCONNECTED => dxgi.ERROR_SESSION_DISCONNECTED, dxgi.Error.UNSUPPORTED => dxgi.ERROR_UNSUPPORTED, dxgi.Error.WAIT_TIMEOUT => dxgi.ERROR_WAIT_TIMEOUT, dxgi.Error.WAS_STILL_DRAWING => dxgi.ERROR_WAS_STILL_DRAWING, // d3d12.Error.ADAPTER_NOT_FOUND => d3d12.ERROR_ADAPTER_NOT_FOUND, d3d12.Error.DRIVER_VERSION_MISMATCH => d3d12.ERROR_DRIVER_VERSION_MISMATCH, d3d11.Error.FILE_NOT_FOUND => d3d11.ERROR_FILE_NOT_FOUND, d3d11.Error.TOO_MANY_UNIQUE_STATE_OBJECTS => d3d11.ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS, d3d11.Error.TOO_MANY_UNIQUE_VIEW_OBJECTS => d3d11.ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS, d3d11.Error.DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD => d3d11.ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD, // wasapi.Error.NOT_INITIALIZED => wasapi.AUDCLNT_E_NOT_INITIALIZED, wasapi.Error.ALREADY_INITIALIZED => wasapi.AUDCLNT_E_ALREADY_INITIALIZED, wasapi.Error.WRONG_ENDPOINT_TYPE => wasapi.AUDCLNT_E_WRONG_ENDPOINT_TYPE, wasapi.Error.DEVICE_INVALIDATED => wasapi.AUDCLNT_E_DEVICE_INVALIDATED, wasapi.Error.NOT_STOPPED => wasapi.AUDCLNT_E_NOT_STOPPED, wasapi.Error.BUFFER_TOO_LARGE => wasapi.AUDCLNT_E_BUFFER_TOO_LARGE, wasapi.Error.OUT_OF_ORDER => wasapi.AUDCLNT_E_OUT_OF_ORDER, wasapi.Error.UNSUPPORTED_FORMAT => wasapi.AUDCLNT_E_UNSUPPORTED_FORMAT, wasapi.Error.INVALID_SIZE => wasapi.AUDCLNT_E_INVALID_SIZE, wasapi.Error.DEVICE_IN_USE => wasapi.AUDCLNT_E_DEVICE_IN_USE, wasapi.Error.BUFFER_OPERATION_PENDING => wasapi.AUDCLNT_E_BUFFER_OPERATION_PENDING, wasapi.Error.THREAD_NOT_REGISTERED => wasapi.AUDCLNT_E_THREAD_NOT_REGISTERED, wasapi.Error.EXCLUSIVE_MODE_NOT_ALLOWED => wasapi.AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED, wasapi.Error.ENDPOINT_CREATE_FAILED => wasapi.AUDCLNT_E_ENDPOINT_CREATE_FAILED, wasapi.Error.SERVICE_NOT_RUNNING => wasapi.AUDCLNT_E_SERVICE_NOT_RUNNING, wasapi.Error.EVENTHANDLE_NOT_EXPECTED => wasapi.AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED, wasapi.Error.EXCLUSIVE_MODE_ONLY => wasapi.AUDCLNT_E_EXCLUSIVE_MODE_ONLY, wasapi.Error.BUFDURATION_PERIOD_NOT_EQUAL => wasapi.AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL, wasapi.Error.EVENTHANDLE_NOT_SET => wasapi.AUDCLNT_E_EVENTHANDLE_NOT_SET, wasapi.Error.INCORRECT_BUFFER_SIZE => wasapi.AUDCLNT_E_INCORRECT_BUFFER_SIZE, wasapi.Error.BUFFER_SIZE_ERROR => wasapi.AUDCLNT_E_BUFFER_SIZE_ERROR, wasapi.Error.CPUUSAGE_EXCEEDED => wasapi.AUDCLNT_E_CPUUSAGE_EXCEEDED, wasapi.Error.BUFFER_ERROR => wasapi.AUDCLNT_E_BUFFER_ERROR, wasapi.Error.BUFFER_SIZE_NOT_ALIGNED => wasapi.AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED, wasapi.Error.INVALID_DEVICE_PERIOD => wasapi.AUDCLNT_E_INVALID_DEVICE_PERIOD, // dwrite.Error.E_FILEFORMAT => dwrite.E_FILEFORMAT, // xapo.Error.E_FORMAT_UNSUPPORTED => xapo.E_FORMAT_UNSUPPORTED, // base.MiscError.E_FILE_NOT_FOUND => base.E_FILE_NOT_FOUND, base.MiscError.S_FALSE => base.S_FALSE, }; } fn thisDir() []const u8 { return std.fs.path.dirname(@src().file) orelse "."; }
modules/platform/vendored/zwin32/src/zwin32.zig
const std = @import("std"); const fmt = std.fmt; const io = std.io; const path = std.fs.path; const Allocator = std.mem.Allocator; const Datablock = @import("datablock.zig").Datablock; const DatasetAttributes = @import("dataset_attributes.zig").DatasetAttributes; const DataType = @import("dataset_attributes.zig").DataType; const Compression = @import("dataset_attributes.zig").Compression; const CompressionType = @import("dataset_attributes.zig").CompressionType; const util = @import("util.zig"); /// interacts with N5 on a local filesystem. pub const Fs = @This(); allocator: Allocator, basePath: []const u8, pub fn init(allocator: Allocator, basePath: []const u8) !Fs { var data_path = try path.join(allocator, &.{ basePath, "data.n5" }); errdefer allocator.free(data_path); // Catch the error here if dir does not exist and create it. // It means that the Fs in used for writing. var dir: std.fs.Dir = undefined; dir = std.fs.openDirAbsolute(data_path, .{}) catch |err| blk: { if (err == std.fs.Dir.OpenError.FileNotFound) { try dir.makePath(data_path); dir = try std.fs.openDirAbsolute(data_path, .{}); break :blk dir; } else return err; }; defer dir.close(); return Fs{ .allocator = allocator, .basePath = data_path, }; } pub fn deinit(self: Fs) void { self.allocator.free(self.basePath); } /// returns the datablock at the provided coordinates. pub fn getBlock( self: Fs, datasetPath: []const u8, gridPosition: []i64, attributes: DatasetAttributes(std.fs.File), ) !Datablock(std.fs.File) { var dataset_full_path = try path.join(self.allocator, &.{ self.basePath, datasetPath }); defer self.allocator.free(dataset_full_path); var datablock_path = try self.datablockPath(dataset_full_path, gridPosition); defer self.allocator.free(datablock_path); // catch the error and create the file for the writer. var fd: std.fs.File = undefined; fd = std.fs.openFileAbsolute(datablock_path, .{}) catch |err| blk: { if (err == std.fs.Dir.OpenError.FileNotFound) { fd = try std.fs.createFileAbsolute(datablock_path, .{}); break :blk fd; } else return err; }; return Datablock(std.fs.File).init(self.allocator, fd, dataset_full_path, gridPosition, attributes); } fn datablockPath(self: Fs, datasetPath: []u8, gridPosition: []i64) ![]u8 { var gps = try self.allocator.alloc([]u8, gridPosition.len + 1); defer { // gps[0] is already freed by the caller var i: u8 = 1; while (i < gps.len) : (i += 1) { self.allocator.free(gps[i]); } self.allocator.free(gps); } gps[0] = datasetPath; for (gridPosition) |gp, i| { const gp_str = try fmt.allocPrint(self.allocator, "{d}", .{gp}); defer self.allocator.free(gp_str); gps[i + 1] = try self.allocator.alloc(u8, gp_str.len); std.mem.copy(u8, gps[i + 1], gp_str); } var full_path = try path.join(self.allocator, gps); defer self.allocator.free(full_path); var final_path = try self.allocator.alloc(u8, full_path.len); std.mem.copy(u8, final_path, full_path); return final_path; } pub fn datasetAttributes(self: Fs, datasetPath: []const u8) !DatasetAttributes(std.fs.File) { var attr_full_path = try path.join(self.allocator, &.{ self.basePath, datasetPath }); defer self.allocator.free(attr_full_path); return DatasetAttributes(std.fs.File).init(self.allocator, attr_full_path); } test "init" { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); comptime var buff_size = util.pathBufferSize(); var path_buffer: [buff_size]u8 = undefined; var full_path = try std.fs.realpath("testdata/lynx_lz4", &path_buffer); var n5_path = try path.join(allocator, &.{ full_path, "data.n5" }); var fs = try Fs.init(allocator, full_path); _ = try std.fs.openDirAbsolute(n5_path, .{}); fs.deinit(); allocator.free(n5_path); try std.testing.expect(!gpa.deinit()); } test "init new folder" { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); comptime var buff_size = util.pathBufferSize(); var path_buffer: [buff_size]u8 = undefined; var full_path = try std.fs.realpath("testdata", &path_buffer); var data_path = try path.join(allocator, &.{ full_path, "banana" }); var dir: std.fs.Dir = undefined; try dir.deleteTree(data_path); var n5_path = try path.join(allocator, &.{ data_path, "data.n5" }); var fs = try Fs.init(allocator, data_path); dir = try std.fs.openDirAbsolute(n5_path, .{}); fs.deinit(); dir.close(); try dir.deleteTree(data_path); allocator.free(n5_path); allocator.free(data_path); try std.testing.expect(!gpa.deinit()); } test "read lz4" { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); comptime var buff_size = util.pathBufferSize(); var path_buffer: [buff_size]u8 = undefined; var full_path = try std.fs.realpath("testdata/lynx_lz4", &path_buffer); var fs = try Fs.init(allocator, full_path); errdefer fs.deinit(); var attr = try fs.datasetAttributes("0/0"); errdefer attr.deinit(); var grid_position = [_]i64{ 0, 0, 0, 0, 0 }; var d_block = try fs.getBlock("0/0", &grid_position, attr); errdefer d_block.deinit(); var out = std.io.getStdOut(); var buf = try allocator.alloc(u8, d_block.len); errdefer allocator.free(buf); _ = try d_block.reader().read(buf); try out.writeAll(buf); std.debug.print("\n", .{}); allocator.free(buf); d_block.deinit(); attr.deinit(); fs.deinit(); try std.testing.expect(!gpa.deinit()); } // test "write lz4" { // var gpa = std.heap.GeneralPurposeAllocator(.{}){}; // const allocator = gpa.allocator(); // // comptime var buff_size = util.pathBufferSize(); // var path_buffer: [buff_size]u8 = undefined; // var full_path = try std.fs.realpath("testdata/lynx_lz4", &path_buffer); // var fs = try Fs.init(allocator, full_path); // errdefer fs.deinit(); // // var attr = try fs.datasetAttributes("0/0"); // errdefer attr.deinit(); // // var grid_position = [_]i64{ 0, 0, 0, 0, 0 }; // // var d_block = try fs.getBlock("0/0", &grid_position, attr); // errdefer d_block.deinit(); // var buf_r = try allocator.alloc(u8, d_block.len); // errdefer allocator.free(buf_r); // _ = try d_block.reader().read(buf_r); // // grid_position[4] = 1; // // var d_block_w = try fs.getBlock("0/0", &grid_position, attr); // // errdefer d_block_w.deinit(); // //var file_path_buffer: [buff_size]u8 = undefined; // //var file_full_path = try std.fs.realpath("testdata/lynx_lz4/data.n5/0/0/0/0/0/0/1", &file_path_buffer); // // defer std.fs.deleteFileAbsolute(file_full_path) catch unreachable; // _ = try d_block_w.writer(0).write(buf_r); // d_block_w.deinit(); // // // var d_block_r2 = try fs.getBlock("0/0", &grid_position, attr); // // errdefer d_block_r2.deinit(); // // var buf_w = try allocator.alloc(u8, d_block_r2.len); // // errdefer allocator.free(buf_w); // // _ = try d_block_r2.reader().read(buf_w); // // try std.testing.expect(buf_w.len == buf_r.len); // // allocator.free(buf_r); // //allocator.free(buf_w); // //d_block_r2.deinit(); // d_block.deinit(); // attr.deinit(); // fs.deinit(); // try std.testing.expect(!gpa.deinit()); // }
src/Fs.zig
const std = @import("std"); const core = @import("core.zig"); const terminal = @import("terminal.zig"); const vt100 = @import("vt100.zig"); 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 testing = std.testing; const unicode = std.unicode; const Editor = core.Editor; const Location = core.Location; // TODO: This is just something i put together real quick. I was playing around // with having a gui tree without an allocations of dynamic dispatch. // It's not super clean, but it works. I think this idea could be refined. // I should probably replace this with a more proper gui solution. pub const Size = struct { width: usize = 0, height: usize = 0, }; pub const Range = struct { min: Size = Size{}, max: Size = Size{}, pub fn fixed(size: Size) Range { return Range{ .min = size, .max = size, }; } pub fn flexible(size: Size) Range { return Range{ .min = size, .max = Size{ .width = math.maxInt(usize), .height = math.maxInt(usize), }, }; } }; pub const Orientation = enum { Horizontal, Vertical, }; pub fn Stack(comptime Children: type) type { return struct { const Id = Children; orientation: Orientation, children: Children, pub fn range(s: @This()) Range { const children = switch (@typeInfo(Children)) { .Pointer => |ptr| @typeInfo(ptr.child_type).Struct.fields, .Struct => |str| str.fields, else => @compileError("TODO: Handle array and slice here too"), }; var res = Range{}; switch (s.orientation) { .Horizontal => { inline for (children) |field| { const child = &@field(s.children, field.name); const child_range = child.range(); res.min.width = math.add(usize, res.min.width, child_range.min.width) catch math.maxInt(usize); res.min.height = math.max(child_range.min.height, res.min.height); res.max.width = math.add(usize, res.max.width, child_range.max.width) catch math.maxInt(usize); res.max.height = math.max(child_range.max.height, res.max.height); } }, .Vertical => { inline for (children) |field| { const child = &@field(s.children, field.name); const child_range = child.range(); res.min.height = math.add(usize, res.min.height, child_range.min.height) catch math.maxInt(usize); res.min.width = math.max(child_range.min.width, res.min.width); res.max.height = math.add(usize, res.max.height, child_range.max.height) catch math.maxInt(usize); res.max.width = math.max(child_range.max.width, res.max.width); } }, } return res; } }; } pub fn stack(orientation: Orientation, children: var) Stack(@TypeOf(children)) { return Stack(@TypeOf(children)){ .orientation = orientation, .children = children, }; } pub fn Float(comptime Children: type) type { return struct { const Id = Children; children: Children, pub fn range(s: @This()) Range { const children = switch (@typeInfo(Children)) { .Pointer => |ptr| @typeInfo(ptr.child_type).Struct.fields, .Struct => |str| str.fields, else => @compileError("TODO: Handle array and slice here too"), }; var res = Range{}; inline for (children) |field| { const child = &@field(s.children, field.name); const child_range = child.range(); res.min.width = math.max(child_range.min.width, res.min.width); res.min.height = math.max(child_range.min.height, res.min.height); res.max.width = math.max(child_range.max.width, res.max.width); res.max.height = math.max(child_range.max.height, res.max.height); } return res; } }; } pub fn float(children: var) Float(@TypeOf(children)) { return Float(@TypeOf(children)){ .children = children, }; } pub const Empty = struct { pub fn range(em: @This()) Range { return Range.flexible(Size{}); } }; pub const Label = struct { str: []const u8, alignment: Alignment, pub const Alignment = enum { Left, Center, Right, }; pub fn range(t: @This()) Range { var res = Size{}; var it = mem.split(t.str, "\n"); while (it.next()) |line| : (res.height += 1) { var line_len: usize = 0; var i: usize = 0; while (i < line.len) : (line_len += 1) i += unicode.utf8ByteSequenceLength(line[i]) catch 1; res.width = math.max(res.width, line_len); } return Range.fixed(res); } }; pub fn label(alignment: Label.Alignment, str: []const u8) Label { return Label{ .alignment = alignment, .str = str, }; } pub const IntFormat = struct { Int: type, format: []const u8, }; pub fn Int(comptime format: IntFormat) type { return struct { const int_format = format; int: int_format.Int, pub fn range(i: @This()) Range { var cos = io.countingOutStream(io.null_out_stream); cos.outStream().print("{" ++ int_format.format ++ "}", .{i.int}) catch unreachable; return Range.fixed(Size{ .height = 1, .width = cos.bytes_written, }); } }; } pub fn int(comptime format: []const u8, i: var) Int(IntFormat{ .Int = @TypeOf(i), .format = format, }) { return Int(IntFormat{ .Int = @TypeOf(i), .format = format }){ .int = i, }; } pub const ValueFormat = struct { Type: type, format: []const u8, }; pub fn Value(comptime format: ValueFormat) type { return struct { const value_format = format; value: value_format.Type, pub fn range(v: @This()) Range { var buf: [1024 * 8]u8 = undefined; const str = fmt.bufPrint(&buf, "{" ++ value_format.format ++ "}", .{v.value}) catch unreachable; const label_view = label(.Left, str); return label_view.range(); } }; } pub fn value(comptime format: []const u8, v: var) Value(ValueFormat{ .Type = @TypeOf(v), .format = format }) { return Value(ValueFormat{ .Type = @TypeOf(v), .format = format }){ .value = v, }; } pub fn Center(comptime Child: type) type { return struct { const Id = Child; child: Child, pub fn range(c: @This()) Range { return Range.flexible(c.child.range().min); } }; } pub fn center(child: var) Center(@TypeOf(child)) { return Center(@TypeOf(child)){ .child = child }; } fn RightResult(comptime T: type) type { return Stack(struct { _0: CustomRange(Empty), child: T, }); } pub fn right(child: var) RightResult(@TypeOf(child)) { const Result = RightResult(@TypeOf(child)); var range = Range.flexible(Size{}); range.max.height = 0; return stack(.Horizontal, Result.Id{ ._0 = customRange(range, Empty{}), .child = child, }); } pub fn Background(comptime Child: type) type { return struct { const Id = Child; child: Child, background: Terminal.Color, pub fn range(b: @This()) Range { return b.child.range(); } }; } pub fn background(color: Terminal.Color, child: var) Background(@TypeOf(child)) { return Background(@TypeOf(child)){ .child = child, .background = color, }; } pub fn Foreground(comptime Child: type) type { return struct { const Id = Child; child: Child, foreground: Terminal.Color, pub fn range(b: @This()) Range { return b.child.range(); } }; } pub fn foreground(color: Terminal.Color, child: var) Foreground(@TypeOf(child)) { return Foreground(@TypeOf(child)){ .child = child, .foreground = color, }; } pub fn Attributes(comptime Child: type) type { return struct { const Id = Child; child: Child, attributes: Terminal.Attribute, pub fn range(b: @This()) Range { return b.child.range(); } }; } pub fn attributes(attr: Terminal.Attribute, child: var) Attributes(@TypeOf(child)) { return Attributes(@TypeOf(child)){ .child = child, .attributes = attr, }; } pub fn Clear(comptime Child: type) type { return struct { const Id = Child; child: Child, pub fn range(b: @This()) Range { return b.child.range(); } }; } pub fn clear(child: var) Clear(@TypeOf(child)) { return Clear(@TypeOf(child)){ .child = child, }; } pub const Visibility = enum { Show, Hide, }; pub fn Visible(comptime Child: type) type { return struct { const Id = Child; visibility: Visibility, child: Child, pub fn range(v: @This()) Range { return switch (v.visibility) { .Show => v.child.range(), .Hide => Range{}, }; } }; } pub fn visible(visibility: Visibility, child: var) Visible(@TypeOf(child)) { return Visible(@TypeOf(child)){ .visibility = visibility, .child = child, }; } pub fn Box(comptime Child: type) type { return struct { const Id = Child; child: Child, pub fn range(b: @This()) Range { var res = b.child.range(); res.min.width = math.add(usize, res.min.width, 2) catch math.maxInt(usize); res.min.height = math.add(usize, res.min.height, 2) catch math.maxInt(usize); res.max.width = math.add(usize, res.max.width, 2) catch math.maxInt(usize); res.max.height = math.add(usize, res.max.height, 2) catch math.maxInt(usize); return res; } }; } pub fn box(child: var) Box(@TypeOf(child)) { return Box(@TypeOf(child)){ .child = child, }; } pub fn CustomRange(comptime Child: type) type { return struct { const Id = Child; r: Range, child: Child, pub fn range(f: @This()) Range { return f.r; } }; } pub fn customRange(range: Range, child: var) CustomRange(@TypeOf(child)) { return CustomRange(@TypeOf(child)){ .r = range, .child = child, }; } pub const TextView = struct { line_loc: Location = Location{}, column: usize = 0, line_numbers: bool, text: core.Text, pub fn update(view: *TextView, text_size: Size) void { const content = view.text.content; const main_cursor_loc = view.text.mainCursor().index; const line_len = main_cursor_loc.lineLen(view.text.content); const main_column = math.min(line_len, main_cursor_loc.column); // If cursor moved out of the left of the screen, adjust screen // left to the cursors column. view.column = math.min(view.column, main_column); // If cursor moved out of the right of the screen, adjust screen // right until cursor is on the last visable column. const last_visable_column = math.sub(usize, text_size.width, 1) catch 0; const new_start_column = math.sub(usize, main_column, last_visable_column) catch 0; view.column = math.max(view.column, new_start_column); // If cursor moved out of the top of the screen, adjust screen // up to the cursors line. var line = view.line_loc.line; line = math.min(line, main_cursor_loc.line); // If cursor moved out of the buttom of the screen, adjust screen // down until cursor is on the last visable line. const last_visable_line = math.sub(usize, text_size.height, 1) catch 0; const new_start_line = math.sub(usize, main_cursor_loc.line, last_visable_line) catch 0; line = math.max(line, new_start_line); // Get the new line location of the screen. view.line_loc = main_cursor_loc.moveToLine(line, content); view.line_loc.index = view.line_loc.lineStart(view.text.content); view.line_loc.column = 0; } pub fn range(t: @This()) Range { return Range.flexible(Size{}); } }; pub fn textView(line_numbers: bool, text: core.Text) TextView { return TextView{ .line_numbers = line_numbers, .text = text }; } fn digits(n: var) usize { var tmp = n; var res: usize = 1; while (tmp >= 10) : (res += 1) tmp /= 10; return res; } test "digits" { testing.expectEqual(@as(usize, 1), digits(@as(usize, 0))); testing.expectEqual(@as(usize, 1), digits(@as(usize, 9))); testing.expectEqual(@as(usize, 2), digits(@as(usize, 10))); testing.expectEqual(@as(usize, 2), digits(@as(usize, 99))); testing.expectEqual(@as(usize, 3), digits(@as(usize, 100))); testing.expectEqual(@as(usize, 3), digits(@as(usize, 999))); } pub const Terminal = struct { const Pos = struct { x: usize = 0, y: usize = 0, }; cells: []Cell = &[_]Cell{}, cell_size: Size = Size{}, allocator: *mem.Allocator, top_left: Pos = Pos{}, bot_right: Pos = Pos{}, const Cell = struct { char: u21 = ' ', foreground: Color = .Reset, background: Color = .Reset, attributes: Attribute = .Reset, }; const Color = enum(u8) { Reset, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, BrightBlack, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite, }; const Attribute = enum(u8) { Reset, Bold, Underscore, Blink, Negative, }; pub fn deinit(term: *Terminal) void { term.allocator.free(term.cells); term.* = undefined; } pub fn update(term: *Terminal, new_size: Size) !void { const cells = new_size.width * new_size.height; if (term.cells.len < cells) { // We we don't have enough space to represent the new terminal size, then // we need to reallocate term.cells = try term.allocator.realloc(term.cells, cells); } mem.set(Cell, term.cells, Cell{}); term.cell_size = new_size; term.bot_right = Pos{ .x = new_size.width, .y = new_size.height, }; } pub fn draw(term: Terminal, view: var) void { const V = @TypeOf(view).Child; const term_size = term.size(); const view_range = view.range(); var new = term; new.bot_right = Pos{ .x = new.top_left.x + math.min(term_size.width, view_range.max.width), .y = new.top_left.y + math.min(term_size.height, view_range.max.height), }; if (V == Empty) return; if (V == Label) return new.drawLabel(view.*); if (V == TextView) return new.drawText(view); if (@hasDecl(V, "Id")) { const Id = V.Id; if (Stack(Id) == V) return new.drawStack(view); if (Float(Id) == V) return new.drawFloat(view); if (Center(Id) == V) return new.drawCenter(view); if (CustomRange(Id) == V) return new.draw(&view.child); if (Background(Id) == V) return new.drawBackground(view); if (Foreground(Id) == V) return new.drawForeground(view); if (Attributes(Id) == V) return new.drawAttributes(view); if (Clear(Id) == V) return new.drawClear(view); if (Visible(Id) == V) return new.drawVisible(view); if (Box(Id) == V) return new.drawBox(view); } if (@hasDecl(V, "int_format")) { const int_format = V.int_format; if (Int(int_format) == V) return new.drawInt(view.*); } if (@hasDecl(V, "value_format")) { const value_format = V.value_format; if (Value(value_format) == V) return new.drawValue(view.*); } @compileError("Unsupported view: " ++ @typeName(V)); } fn drawLabel(term: Terminal, view: Label) void { const term_size = term.size(); var l: usize = 0; var it = mem.split(view.str, "\n"); while (it.next()) |line_str| : (l += 1) { if (term_size.height <= l) break; const cells = term.line(l); var line_len: usize = 0; var i: usize = 0; while (i < line_str.len) : (line_len += 1) i += unicode.utf8ByteSequenceLength(line_str[i]) catch 1; var c: usize = switch (view.alignment) { .Left => 0, .Center => (math.sub(usize, term_size.width, line_len) catch 0) / 2, .Right => math.sub(usize, term_size.width, line_len) catch 0, }; var skip: usize = switch (view.alignment) { .Left => 0, .Center => (math.sub(usize, line_len, term_size.width) catch 0) / 2, .Right => math.sub(usize, line_len, term_size.width) catch 0, }; i = 0; while (skip != 0) : (skip -= 1) i += unicode.utf8ByteSequenceLength(line_str[i]) catch 1; while (i < line_str.len) : (c += 1) { if (term_size.width <= c) break; if (unicode.utf8ByteSequenceLength(line_str[i])) |len| { if (unicode.utf8Decode(line_str[i..][0..len])) |char| { cells[c].char = char; } else |_| { cells[c].background = .Red; cells[c].char = '?'; } i += len; } else |_| { i += 1; cells[c].background = .Red; cells[c].char = '?'; } } } } fn drawInt(term: Terminal, view: var) void { var buf: [1024]u8 = undefined; const str = fmt.bufPrint(&buf, "{" ++ @TypeOf(view).int_format.format ++ "}", .{view.int}) catch unreachable; const label_view = label(.Left, str); term.draw(&label_view); } fn drawValue(term: Terminal, view: var) void { var buf: [1024 * 8]u8 = undefined; const str = fmt.bufPrint(&buf, "{" ++ @TypeOf(view).value_format.format ++ "}", .{view.value}) catch unreachable; const label_view = label(.Left, str); term.draw(&label_view); } fn drawStack(term: Terminal, view: var) void { switch (view.orientation) { .Horizontal => term.drawStackHelper(view, .Horizontal), .Vertical => term.drawStackHelper(view, .Vertical), } } fn drawStackHelper(term: Terminal, view: var, comptime orientation: Orientation) void { const children = switch (@typeInfo(@TypeOf(view).Child.Id)) { .Pointer => |ptr| @typeInfo(ptr.child_type).Struct.fields, .Struct => |s| s.fields, else => @compileError("TODO: Handle array and slice here too"), }; const x_or_y = switch (orientation) { .Horizontal => "x", .Vertical => "y", }; const w_or_h = switch (orientation) { .Horizontal => "width", .Vertical => "height", }; const term_size = @field(term.size(), w_or_h); var total_size: usize = 0; var sizes: [children.len]usize = undefined; inline for (children) |field, i| { const child = @field(view.children, field.name); const min = @field(child.range().min, w_or_h); sizes[i] = min; total_size += sizes[i]; } { comptime var i: usize = sizes.len; inline while (i != 0) : (i -= 1) { const j = i - 1; if (total_size < term_size) { const child = @field(view.children, children[j].name); const max = @field(child.range().max, w_or_h); total_size -= sizes[j]; sizes[j] = math.min(term_size - total_size, max); total_size += sizes[j]; } } } var new_term = term; inline for (children) |field, i| { const child = &@field(view.children, field.name); const term_bot_right = @field(term.bot_right, x_or_y); const new_term_top_left = @field(new_term.top_left, x_or_y); @field(new_term.bot_right, x_or_y) = math.min(term_bot_right, new_term_top_left + sizes[i]); new_term.draw(child); @field(new_term.top_left, x_or_y) = @field(new_term.bot_right, x_or_y); } } fn drawFloat(term: Terminal, view: var) void { const children = switch (@typeInfo(@TypeOf(view).Child.Id)) { .Pointer => |ptr| @typeInfo(ptr.child_type).Struct.fields, .Struct => |s| s.fields, else => @compileError("TODO: Handle array and slice here too"), }; inline for (children) |field, i| { const child = &@field(view.children, field.name); term.draw(child); } } fn drawCenter(term: Terminal, view: var) void { const term_size = term.size(); const view_range = view.range(); const pad = Size{ .width = (math.sub(usize, term_size.width, view_range.min.width) catch 0) / 2, .height = (math.sub(usize, term_size.height, view_range.min.height) catch 0) / 2, }; var new = term; new.top_left.x += pad.width; new.top_left.y += pad.height; new.bot_right.x = math.min(term.top_left.x + term_size.width, new.top_left.x + view_range.min.width); new.bot_right.y = math.min(term.top_left.y + term_size.height, new.top_left.y + view_range.min.height); new.draw(&view.child); } fn drawBackground(term: Terminal, view: var) void { const term_size = term.size(); var i: usize = 0; while (i < term_size.height) : (i += 1) { const cells = term.line(i); for (cells) |*cell| cell.background = view.background; } term.draw(&view.child); } fn drawForeground(term: Terminal, view: var) void { const term_size = term.size(); var i: usize = 0; while (i < term_size.height) : (i += 1) { const cells = term.line(i); for (cells) |*cell| cell.foreground = view.foreground; } term.draw(&view.child); } fn drawAttributes(term: Terminal, view: var) void { const term_size = term.size(); var i: usize = 0; while (i < term_size.height) : (i += 1) { const cells = term.line(i); for (cells) |*cell| cell.attributes = view.attributes; } term.draw(&view.child); } fn drawClear(term: Terminal, view: var) void { const term_size = term.size(); var i: usize = 0; while (i < term_size.height) : (i += 1) { const cells = term.line(i); for (cells) |*cell| cell.* = Cell{}; } term.draw(&view.child); } fn drawVisible(term: Terminal, view: var) void { switch (view.visibility) { .Show => term.draw(&view.child), .Hide => {}, } } fn drawBox(term: Terminal, view: var) void { const term_size = term.size(); var y: usize = 0; while (y < term_size.height) : (y += 1) { const cells = term.line(y); for (cells) |*cell, x| { if (x == 0 and y == 0) { cell.char = comptime unicode.utf8Decode("┏") catch unreachable; } else if (x == 0 and y == term_size.height - 1) { cell.char = comptime unicode.utf8Decode("┗") catch unreachable; } else if (x == term_size.width - 1 and y == term_size.height - 1) { cell.char = comptime unicode.utf8Decode("┛") catch unreachable; } else if (x == term_size.width - 1 and y == 0) { cell.char = comptime unicode.utf8Decode("┓") catch unreachable; } else if (x == 0) { cell.char = comptime unicode.utf8Decode("┃") catch unreachable; } else if (x == term_size.width - 1) { cell.char = comptime unicode.utf8Decode("┃") catch unreachable; } else if (y == 0) { cell.char = comptime unicode.utf8Decode("━") catch unreachable; } else if (y == term_size.height - 1) { cell.char = comptime unicode.utf8Decode("━") catch unreachable; } } } var new_term = term; new_term.top_left.x += 1; new_term.top_left.y += 1; new_term.bot_right.x -= 1; new_term.bot_right.y -= 1; new_term.draw(&view.child); } fn drawText(term: Terminal, view: *TextView) void { // First, we update with this terms size so that the line // numbers will start at the correct place var new_term = term; view.update(new_term.size()); if (view.line_numbers) { const term_size = new_term.size(); const last = view.line_loc.line + term_size.height; const width = digits(last); new_term.bot_right.x = new_term.top_left.x + width; var i: usize = 0; while (i < term_size.height) : (i += 1) { const digit = view.line_loc.line + i + 1; const line_num = foreground(.BrightBlack, right(int("", digit))); new_term.top_left.y = term.top_left.y + i; new_term.bot_right.y = new_term.top_left.y + 1; new_term.draw(&line_num); } new_term = term; new_term.top_left.x += width + 1; } // Later, we then update again so that we take into account // the missing space line numbers take up. const term_size = new_term.size(); view.update(term_size); const text = view.text; const first_line = view.line_loc; var curr_line = first_line; outer: while (curr_line.line - first_line.line < term_size.height) : (curr_line = curr_line.nextLine(text.content)) { const i = curr_line.line - first_line.line; const start = curr_line.moveToColumn(view.column, text.content); const cells = new_term.line(i); var it = text.content.iterator(start.index); var j: usize = 0; inner: while (j < cells.len) : (j += 1) { const c = it.next() orelse { curr_line.line += 1; break :outer; }; if (c == '\n') continue :outer; // TODO: Assumes valid Utf8 const len = unicode.utf8ByteSequenceLength(c) catch 1; var buf: [4]u8 = undefined; buf[0] = c; for (buf[1..len]) |*char| char.* = it.next() orelse 0; cells[j].char = unicode.utf8Decode(buf[0..len]) catch '?'; } } // If we still have space on the screen after drawing all lines, then // we just output '~' to indicate that this is not part of the file. var i = curr_line.line - first_line.line; while (i < term_size.height) : (i += 1) { const cells = new_term.line(i); cells[0].char = '~'; cells[0].foreground = .BrightBlack; } var cursors = text.cursors.iterator(0); while (cursors.next()) |curs| { const loc_start = curs.start(); const loc_end = curs.end(); if (loc_start.index == loc_end.index) { // Draw an '_' if the cursor does not select anything. const real_column = math.min(loc_start.lineLen(text.content), loc_start.column); const l = math.sub(usize, loc_start.line, view.line_loc.line) catch continue; const c = math.sub(usize, real_column, view.column) catch continue; if (term_size.height <= l or term_size.width <= c) continue; const cells = new_term.line(l); cells[c].attributes = .Underscore; } else { var line_loc = if (loc_start.index < view.line_loc.index) view.line_loc else loc_start; while (line_loc.line <= loc_end.line) : ({ line_loc = line_loc.nextLine(text.content); line_loc.index = line_loc.lineStart(text.content); line_loc.column = 0; }) { const l = math.sub(usize, line_loc.line, view.line_loc.line) catch continue; if (term_size.height <= l) break; // Draw selection to end of line if we are not one the same // line as loc_end const line_len = line_loc.lineLen(text.content); const loc_end_column = if (line_loc.line == loc_end.line) math.min(line_len, loc_end.column) else line_len + 1; const start = math.sub(usize, math.min(line_len, line_loc.column), view.column) catch 0; const end = math.sub(usize, loc_end_column, view.column) catch 0; const real_end = math.min(term_size.width, end); const cells = new_term.line(l); for (cells[start..real_end]) |*cell| cell.attributes = .Negative; if (line_loc.line == loc_end.line) break; } } } } fn size(term: Terminal) Size { const res = Size{ .width = term.bot_right.x - term.top_left.x, .height = term.bot_right.y - term.top_left.y, }; debug.assert(res.width <= term.cell_size.width); debug.assert(res.height <= term.cell_size.height); return res; } fn line(term: Terminal, l: usize) []Cell { const real = term.top_left.y + l; debug.assert(real < term.bot_right.y); return term.cells[real * term.cell_size.width ..][term.top_left.x..term.bot_right.x]; } pub fn output(term: Terminal, stream: var) !void { var i: usize = 0; var last_cell: Cell = Cell{}; while (i < term.cell_size.height) : (i += 1) { const cells = term.line(i); for (cells) |cell, j| { // Only when color or attributes change do we have to set them. // Setting them for each character would be overkill. if (last_cell.foreground != cell.foreground or last_cell.background != cell.background or last_cell.attributes != cell.attributes) { if (last_cell.attributes != .Reset and cell.attributes != .Reset) try setAttr(stream, .Reset); try setAttr(stream, cell.attributes); try setForeground(stream, cell.foreground); try setBackground(stream, cell.background); last_cell = cell; } var buf: [4]u8 = undefined; const len = try unicode.utf8Encode(cell.char, &buf); try stream.writeAll(buf[0..len]); } // Don't output a newline on the last line. That would create and empty // line at the buttom of the terminal if (i + 1 != term.cell_size.height) try stream.writeAll("\r\n"); } try setAttr(stream, .Reset); try setForeground(stream, .Reset); try setBackground(stream, .Reset); } fn setForeground(stream: var, color: Color) !void { switch (color) { .Reset => try stream.writeAll(vt100.selectGraphicRendition("39")), .Black => try stream.writeAll(vt100.selectGraphicRendition("30")), .Red => try stream.writeAll(vt100.selectGraphicRendition("31")), .Green => try stream.writeAll(vt100.selectGraphicRendition("32")), .Yellow => try stream.writeAll(vt100.selectGraphicRendition("33")), .Blue => try stream.writeAll(vt100.selectGraphicRendition("34")), .Magenta => try stream.writeAll(vt100.selectGraphicRendition("35")), .Cyan => try stream.writeAll(vt100.selectGraphicRendition("36")), .White => try stream.writeAll(vt100.selectGraphicRendition("37")), .BrightBlack => try stream.writeAll(vt100.selectGraphicRendition("90")), .BrightRed => try stream.writeAll(vt100.selectGraphicRendition("91")), .BrightGreen => try stream.writeAll(vt100.selectGraphicRendition("92")), .BrightYellow => try stream.writeAll(vt100.selectGraphicRendition("93")), .BrightBlue => try stream.writeAll(vt100.selectGraphicRendition("94")), .BrightMagenta => try stream.writeAll(vt100.selectGraphicRendition("95")), .BrightCyan => try stream.writeAll(vt100.selectGraphicRendition("96")), .BrightWhite => try stream.writeAll(vt100.selectGraphicRendition("97")), } } fn setBackground(stream: var, color: Color) !void { switch (color) { .Reset => try stream.writeAll(vt100.selectGraphicRendition("49")), .Black => try stream.writeAll(vt100.selectGraphicRendition("40")), .Red => try stream.writeAll(vt100.selectGraphicRendition("41")), .Green => try stream.writeAll(vt100.selectGraphicRendition("42")), .Yellow => try stream.writeAll(vt100.selectGraphicRendition("43")), .Blue => try stream.writeAll(vt100.selectGraphicRendition("44")), .Magenta => try stream.writeAll(vt100.selectGraphicRendition("45")), .Cyan => try stream.writeAll(vt100.selectGraphicRendition("46")), .White => try stream.writeAll(vt100.selectGraphicRendition("47")), .BrightBlack => try stream.writeAll(vt100.selectGraphicRendition("100")), .BrightRed => try stream.writeAll(vt100.selectGraphicRendition("101")), .BrightGreen => try stream.writeAll(vt100.selectGraphicRendition("102")), .BrightYellow => try stream.writeAll(vt100.selectGraphicRendition("103")), .BrightBlue => try stream.writeAll(vt100.selectGraphicRendition("104")), .BrightMagenta => try stream.writeAll(vt100.selectGraphicRendition("105")), .BrightCyan => try stream.writeAll(vt100.selectGraphicRendition("106")), .BrightWhite => try stream.writeAll(vt100.selectGraphicRendition("107")), } } fn setAttr(stream: var, attr: Attribute) !void { switch (attr) { .Reset => try stream.writeAll(vt100.selectGraphicRendition("0")), .Bold => try stream.writeAll(vt100.selectGraphicRendition("1")), .Underscore => try stream.writeAll(vt100.selectGraphicRendition("4")), .Blink => try stream.writeAll(vt100.selectGraphicRendition("5")), .Negative => try stream.writeAll(vt100.selectGraphicRendition("7")), } } }; const full_reset = vt100.selectGraphicRendition("0") ++ vt100.selectGraphicRendition("39") ++ vt100.selectGraphicRendition("49"); // zig fmt: off test "label" { testDraw( "Hello World! \r\n" ++ "Bye World! \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &label(.Left, "Hello World!\nBye World!"), ); testDraw( "Hello World! \r\n" ++ " Bye World! \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &label(.Center, "Hello World!\nBye World!"), ); testDraw( "Hello World! \r\n" ++ " Bye World! \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &label(.Right, "Hello World!\nBye World!"), ); testDraw( "Hello World! Hello World! Hello World! H\r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &label(.Left, "Hello World! Hello World! Hello World! Hello World!"), ); testDraw( "! Hello World! Hello World! Hello World!\r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &label(.Right, "Hello World! Hello World! Hello World! Hello World!"), ); testDraw( " World! Hello World! Hello World! Hello \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &label(.Center, "Hello World! Hello World! Hello World! Hello World!"), ); } test "int" { testDraw( "10 \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &int("", @as(isize, 10)), ); testDraw( "-10 \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &int("", @as(isize, -10)), ); testDraw( "1MB \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &int("B", @as(usize, 1000 * 1000)), ); } test "value" { const S = struct { a: usize, b: usize, pub fn format( self: @This(), comptime form: []const u8, options: std.fmt.FormatOptions, context: var, ) !void { return std.fmt.format( context, "{} {}", .{self.a, self.b }, ); } }; testDraw( "10 12 \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &value("", S{ .a = 10, .b = 12 }), ); } test "stack" { // TODO: When/If Zig gets anonymous array/struct init, then making a stack // will look a lot cleaner: stack(.Vertical, .{ view_a, view_b }); // One could even use names: stack(.Vertical, .{ .top = view_a, .bot = view_b }); testDraw( "HelloWorld! \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &stack(.Horizontal, struct { _0: Label = label(.Left, "Hello"), _1: Label = label(.Left, "World!"), }{}), ); testDraw( "Hello \r\n" ++ "World! \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &stack(.Vertical, struct { _0: Label = label(.Left, "Hello"), _1: Label = label(.Left, "World!"), }{}), ); } test "float" { testDraw( "11CD \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &float(struct { _0: Label = label(.Left, "ABCD"), _1: Label = label(.Left, "11"), }{}), ); } test "center" { testDraw( " \r\n" ++ " \r\n" ++ " Hello World! \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &center(label(.Left, "Hello World!")), ); } test "right" { testDraw( " Hello World!\r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &right(label(.Left, "Hello World!")), ); testDraw( " 2\r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &right(int("", @as(usize, 2))), ); } test "visible" { testDraw( "1MB \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &visible(.Show, int("B", @as(usize, 1000 * 1000))), ); testDraw( " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &visible(.Hide, int("B", @as(usize, 1000 * 1000))), ); } test "box" { testDraw( "┏━━━━┓ \r\n" ++ "┃1000┃ \r\n" ++ "┗━━━━┛ \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &box(int("", @as(usize, 1000))), ); testDraw( "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\r\n" ++ "┃10000000000000000000000000000000000000┃\r\n" ++ "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &box(int("", @as(u128, 100000000000000000000000000000000000009))), ); } // zig fmt: on fn backgStart(comptime num: []const u8) []const u8 { return vt100.selectGraphicRendition("0") ++ vt100.selectGraphicRendition("39") ++ vt100.selectGraphicRendition(num); } fn backg(comptime num: []const u8, comptime str: []const u8) []const u8 { return backgStart(num) ++ str ++ full_reset; } fn foregStart(comptime num: []const u8) []const u8 { return vt100.selectGraphicRendition("0") ++ vt100.selectGraphicRendition(num) ++ vt100.selectGraphicRendition("49"); } fn foreg(comptime num: []const u8, comptime str: []const u8) []const u8 { return foregStart(num) ++ str ++ full_reset; } fn attriStart(comptime num: []const u8) []const u8 { return vt100.selectGraphicRendition(num) ++ vt100.selectGraphicRendition("39") ++ vt100.selectGraphicRendition("49"); } fn attri(comptime num: []const u8, comptime str: []const u8) []const u8 { return attriStart(num) ++ str ++ full_reset; } // zig fmt: off test "background" { testDraw( backg("47", "Hello World") ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &background(.White, label(.Left, "Hello World")), ); testDraw( backg("47", "Hello") ++ "World! \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &stack(.Horizontal, struct { _0: Background(Label) = background(.White, label(.Left, "Hello")), _1: Label = label(.Left, "World!"), }{}), ); } test "foreground" { testDraw( foreg("31", "Hello World") ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &foreground(.Red, label(.Left, "Hello World")), ); testDraw( foreg("31", "Hello") ++ "World! \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &stack(.Horizontal, struct { _0: Foreground(Label) = foreground(.Red, label(.Left, "Hello")), _1: Label = label(.Left, "World!"), }{}), ); } test "attributes" { testDraw( attri("4", "Hello World") ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &attributes(.Underscore, label(.Left, "Hello World")), ); testDraw( attri("4", "Hello") ++ "World! \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &stack(.Horizontal, struct { _0: Attributes(Label) = attributes(.Underscore, label(.Left, "Hello")), _1: Label = label(.Left, "World!"), }{}), ); } test "float" { const blank = comptime clear(customRange(Range.fixed(Size{ .width = 2, .height = 1 }), Empty{})); testDraw( " CD \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " \r\n" ++ " " ++ full_reset, &float(.{ ._0 = label(.Left, "ABCD"), ._1 = blank, }), ); } test "textView" { var buf: [1024 * 2]u8 = undefined; var fba = heap.FixedBufferAllocator.init(&buf); var text = try core.Text.fromString(&fba.allocator, "A\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\n"); testDraw( attri("4", "A") ++ " \r\n" ++ "B \r\n" ++ "C \r\n" ++ "D \r\n" ++ "E \r\n" ++ "F " ++ full_reset, &textView(false, text), ); testDraw( foreg("90", "1") ++ " " ++ attri("4", "A") ++ " \r\n" ++ foreg("90", "2") ++ " B \r\n" ++ foreg("90", "3") ++ " C \r\n" ++ foreg("90", "4") ++ " D \r\n" ++ foreg("90", "5") ++ " E \r\n" ++ foreg("90", "6") ++ " F " ++ full_reset, &textView(true, text), ); text = try text.moveCursors(9, .Both, .Down); testDraw( "E \r\n" ++ "F \r\n" ++ "G \r\n" ++ "H \r\n" ++ "I \r\n" ++ attri("4", "J") ++ " " ++ full_reset, &textView(false, text), ); testDraw( foreg("90", " 5") ++ " E \r\n" ++ foreg("90", " 6") ++ " F \r\n" ++ foreg("90", " 7") ++ " G \r\n" ++ foreg("90", " 8") ++ " H \r\n" ++ foreg("90", " 9") ++ " I \r\n" ++ foreg("90", "10") ++ " " ++ attri("4", "J") ++ " " ++ full_reset, &textView(true, text), ); text = try core.Text.fromString(&fba.allocator, "ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwyz\n:\n"); testDraw( attri("4", "A") ++ "BCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmno\r\n" ++ ": \r\n" ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " " ++ full_reset, &textView(false, text), ); testDraw( foreg("90", "1") ++ " " ++ attri("4", "A") ++ "BCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklm\r\n" ++ foreg("90", "2") ++ " : \r\n" ++ foreg("90", "3") ++ " \r\n" ++ foreg("90", "4") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "5") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "6") ++ " " ++ foreg("90", "~") ++ " " ++ full_reset, &textView(true, text), ); text = try text.moveCursors(40, .Both, .Right); testDraw( "BCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmno" ++ attri("4", "p\r\n") ++ " \r\n" ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " " ++ full_reset, &textView(false, text), ); testDraw( foreg("90", "1") ++ " DEFGHIJKLMNOPQRSTUVWYZabcdefghijklmno" ++ attriStart("4") ++ "p\r\n" ++ foreg("90", "2") ++ " \r\n" ++ foreg("90", "3") ++ " \r\n" ++ foreg("90", "4") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "5") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "6") ++ " " ++ foreg("90", "~") ++ " " ++ full_reset, &textView(true, text), ); text = try text.moveCursors(40, .Both, .Left); text = try text.moveCursors(1, .Index, .Down); testDraw( attri("7", "ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmno\r\n") ++ ": \r\n" ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " " ++ full_reset, &textView(false, text), ); testDraw( foreg("90", "1") ++ " " ++ attriStart("7") ++ "ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklm\r\n" ++ foreg("90", "2") ++ " : \r\n" ++ foreg("90", "3") ++ " \r\n" ++ foreg("90", "4") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "5") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "6") ++ " " ++ foreg("90", "~") ++ " " ++ full_reset, &textView(true, text), ); text = try text.moveCursors(1, .Index, .Up); text = try text.moveCursors(40, .Both, .Right); text = try text.moveCursors(1, .Both, .Down); testDraw( "ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmno\r\n" ++ ":" ++ attri("4", " ") ++ " \r\n" ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " " ++ full_reset, &textView(false, text), ); testDraw( foreg("90", "1") ++ " ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklm\r\n" ++ foreg("90", "2") ++ " :" ++ attri("4", " ") ++ " \r\n" ++ foreg("90", "3") ++ " \r\n" ++ foreg("90", "4") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "5") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "6") ++ " " ++ foreg("90", "~") ++ " " ++ full_reset, &textView(true, text), ); text = try core.Text.fromString(&fba.allocator, "\nss"); text = try text.moveCursors(100, .Both, .Right); text = try text.moveCursors(1, .Index, .Up); testDraw( attri("7", " ") ++ " \r\n" ++ attri("7", "ss") ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "~") ++ " " ++ full_reset, &textView(false, text), ); testDraw( foreg("90", "1") ++ " " ++ attri("7", " ") ++ " \r\n" ++ foreg("90", "2") ++ " " ++ attri("7", "ss") ++ " \r\n" ++ foreg("90", "3") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "4") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "5") ++ " " ++ foreg("90", "~") ++ " \r\n" ++ foreg("90", "6") ++ " " ++ foreg("90", "~") ++ " " ++ full_reset, &textView(true, text), ); } // zig fmt: on fn escape(allocator: *mem.Allocator, str: []const u8) ![]u8 { var buffer = std.ArrayList(u8).init(allocator); var bos = buffer.outStream(); defer buffer.deinit(); for (str) |c| { if (std.ascii.isPrint(c) or std.ascii.isSpace(c)) { try bos.writeByte(c); } else { try bos.print("\\x{x}", .{c}); } } return buffer.toOwnedSlice(); } fn testDraw(expect: []const u8, view: var) void { var buf: [1024 * 8]u8 = undefined; var fba = heap.FixedBufferAllocator.init(&buf); var term = Terminal{ .allocator = &fba.allocator }; term.update(Size{ .width = 40, .height = 6 }) catch unreachable; term.draw(view); var buf2: [1024 * 2]u8 = undefined; var sos = io.fixedBufferStream(&buf2); term.output(sos.outStream()) catch unreachable; if (!mem.eql(u8, expect, sos.getWritten())) { debug.warn("\n######## Expected ########\n", .{}); debug.warn("len: {}\n", .{expect.len}); debug.warn("{}", .{expect}); debug.warn("\n######## Actual ########\n", .{}); debug.warn("len: {}\n", .{sos.getWritten().len}); debug.warn("{}\n", .{sos.getWritten()}); debug.warn("######## Expected (escaped) ########\n", .{}); debug.warn("{}\n", .{escape(&fba.allocator, expect) catch unreachable}); debug.warn("######## Actual (escaped) ########\n", .{}); debug.warn("{}\n", .{escape(&fba.allocator, sos.getWritten()) catch unreachable}); testing.expect(false); } }
src/draw.zig
const std = @import("std"); const io = @import("io.zig"); const Terminal = @import("tty.zig"); fn outportb(port: u16, val: u8) void { io.out(u8, port, val); } fn inportb(port: u16) u8 { return io.in(u8, port); } pub const VgaMode = enum { mode320x200, mode640x480, }; // pub const mode = if (@hasDecl(@import("root"), "vga_mode")) @import("root").vga_mode else VgaMode.mode320x200; pub const mode = VgaMode.mode640x480; pub const Color = switch (mode) { .mode320x200 => u8, .mode640x480 => u4, }; pub const width = switch (mode) { .mode320x200 => 320, .mode640x480 => 640, }; pub const height = switch (mode) { .mode320x200 => 200, .mode640x480 => 480, }; pub fn isInBounds(x: isize, y: isize) bool { return x >= 0 and y >= 0 and x < width and y < height; } fn write_regs(regs: [61]u8) void { var index: usize = 0; var i: u8 = 0; // write MISCELLANEOUS reg outportb(VGA_MISC_WRITE, regs[index]); index += 1; // write SEQUENCER regs i = 0; while (i < VGA_NUM_SEQ_REGS) : (i += 1) { outportb(VGA_SEQ_INDEX, i); outportb(VGA_SEQ_DATA, regs[index]); index += 1; } // unlock CRTC registers outportb(VGA_CRTC_INDEX, 0x03); outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) | 0x80); outportb(VGA_CRTC_INDEX, 0x11); outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) & ~@as(u8, 0x80)); // make sure they remain unlocked // TODO: Reinsert again // regs[0x03] |= 0x80; // regs[0x11] &= ~0x80; // write CRTC regs i = 0; while (i < VGA_NUM_CRTC_REGS) : (i += 1) { outportb(VGA_CRTC_INDEX, i); outportb(VGA_CRTC_DATA, regs[index]); index += 1; } // write GRAPHICS CONTROLLER regs i = 0; while (i < VGA_NUM_GC_REGS) : (i += 1) { outportb(VGA_GC_INDEX, i); outportb(VGA_GC_DATA, regs[index]); index += 1; } // write ATTRIBUTE CONTROLLER regs i = 0; while (i < VGA_NUM_AC_REGS) : (i += 1) { _ = inportb(VGA_INSTAT_READ); outportb(VGA_AC_INDEX, i); outportb(VGA_AC_WRITE, regs[index]); index += 1; } // lock 16-color palette and unblank display _ = inportb(VGA_INSTAT_READ); outportb(VGA_AC_INDEX, 0x20); } pub fn setPlane(plane: u2) void { const pmask: u8 = u8(1) << plane; // set read plane outportb(VGA_GC_INDEX, 4); outportb(VGA_GC_DATA, plane); // set write plane outportb(VGA_SEQ_INDEX, 2); outportb(VGA_SEQ_DATA, pmask); } pub fn init() void { switch (mode) { .mode320x200 => write_regs(g_320x200x256), .mode640x480 => write_regs(g_640x480x16), } // write_regs(g_320x200x256); } fn get_fb_seg() [*]volatile u8 { outportb(VGA_GC_INDEX, 6); const seg = (inportb(VGA_GC_DATA) >> 2) & 3; return @intToPtr([*]volatile u8, switch (@truncate(u2, seg)) { 0, 1 => @as(u32, 0xA0000), 2 => @as(u32, 0xB0000), 3 => @as(u32, 0xB8000), }); } fn vpokeb(off: usize, val: u8) void { get_fb_seg()[off] = val; } fn vpeekb(off: usize) u8 { return get_fb_seg()[off]; } pub fn setPixelDirect(x: usize, y: usize, c: Color) void { switch (mode) { .mode320x200 => { // setPlane(@truncate(u2, 0)); var segment = get_fb_seg(); segment[320 * y + x] = c; }, .mode640x480 => { const wd_in_bytes = 640 / 8; const off = wd_in_bytes * y + x / 8; const px = @truncate(u3, x & 7); var mask: u8 = u8(0x80) >> px; var pmask: u8 = 1; comptime var p: usize = 0; inline while (p < 4) : (p += 1) { setPlane(@truncate(u2, p)); var segment = get_fb_seg(); const src = segment[off]; segment[off] = if ((pmask & c) != 0) src | mask else src & ~mask; pmask <<= 1; } }, } } var backbuffer: [height][width]Color = undefined; pub fn clear(c: Color) void { for (backbuffer) |*row| { for (row) |*pixel| { pixel.* = c; } } } pub fn setPixel(x: usize, y: usize, c: Color) void { backbuffer[y][x] = c; } pub fn getPixel(x: usize, y: usize) Color { return backbuffer[y][x]; } pub fn swapBuffers() void { @setRuntimeSafety(false); @setCold(false); switch (mode) { .mode320x200 => { @intToPtr(*[height][width]Color, 0xA0000).* = backbuffer; }, .mode640x480 => { // const bytes_per_line = 640 / 8; var plane: usize = 0; while (plane < 4) : (plane += 1) { const plane_mask: u8 = u8(1) << @truncate(u3, plane); setPlane(@truncate(u2, plane)); var segment = get_fb_seg(); var offset: usize = 0; var y: usize = 0; while (y < 480) : (y += 1) { var x: usize = 0; while (x < 640) : (x += 8) { // const offset = bytes_per_line * y + (x / 8); var bits: u8 = 0; // unroll for maximum fastness comptime var px: usize = 0; inline while (px < 8) : (px += 1) { const mask = u8(0x80) >> px; const index = backbuffer[y][x + px]; if ((index & plane_mask) != 0) { bits |= mask; } } segment[offset] = bits; offset += 1; } } } }, } } pub const RGB = struct { r: u8, g: u8, b: u8, pub fn init(r: u8, g: u8, b: u8) RGB { return RGB{ .r = r, .g = g, .b = b, }; } pub fn parse(rgb: []const u8) !RGB { if (rgb.len != 7) return error.InvalidLength; if (rgb[0] != '#') return error.InvalidFormat; return RGB{ .r = try std.fmt.parseInt(u8, rgb[1..3], 16), .g = try std.fmt.parseInt(u8, rgb[3..5], 16), .b = try std.fmt.parseInt(u8, rgb[5..7], 16), }; } }; const PALETTE_INDEX = 0x03c8; const PALETTE_DATA = 0x03c9; // see: http://www.brackeen.com/vga/source/bc31/palette.c.html pub fn loadPalette(palette: []const RGB) void { io.out(u8, PALETTE_INDEX, 0); // tell the VGA that palette data is coming. for (palette) |rgb| { io.out(u8, PALETTE_DATA, rgb.r >> 2); // write the data io.out(u8, PALETTE_DATA, rgb.g >> 2); io.out(u8, PALETTE_DATA, rgb.b >> 2); } } pub fn setPaletteEntry(entry: u8, color: RGB) void { io.out(u8, PALETTE_INDEX, entry); // tell the VGA that palette data is coming. io.out(u8, PALETTE_DATA, color.r >> 2); // write the data io.out(u8, PALETTE_DATA, color.g >> 2); io.out(u8, PALETTE_DATA, color.b >> 2); } // see: http://www.brackeen.com/vga/source/bc31/palette.c.html pub fn waitForVSync() void { const INPUT_STATUS = 0x03da; const VRETRACE = 0x08; // wait until done with vertical retrace while ((io.in(u8, INPUT_STATUS) & VRETRACE) != 0) {} // wait until done refreshing while ((io.in(u8, INPUT_STATUS) & VRETRACE) == 0) {} } const VGA_AC_INDEX = 0x3C0; const VGA_AC_WRITE = 0x3C0; const VGA_AC_READ = 0x3C1; const VGA_MISC_WRITE = 0x3C2; const VGA_SEQ_INDEX = 0x3C4; const VGA_SEQ_DATA = 0x3C5; const VGA_DAC_READ_INDEX = 0x3C7; const VGA_DAC_WRITE_INDEX = 0x3C8; const VGA_DAC_DATA = 0x3C9; const VGA_MISC_READ = 0x3CC; const VGA_GC_INDEX = 0x3CE; const VGA_GC_DATA = 0x3CF; // COLOR emulation MONO emulation const VGA_CRTC_INDEX = 0x3D4; // 0x3B4 const VGA_CRTC_DATA = 0x3D5; // 0x3B5 const VGA_INSTAT_READ = 0x3DA; const VGA_NUM_SEQ_REGS = 5; const VGA_NUM_CRTC_REGS = 25; const VGA_NUM_GC_REGS = 9; const VGA_NUM_AC_REGS = 21; const VGA_NUM_REGS = (1 + VGA_NUM_SEQ_REGS + VGA_NUM_CRTC_REGS + VGA_NUM_GC_REGS + VGA_NUM_AC_REGS); const g_40x25_text = [_]u8{ // MISC 0x67, // SEQ 0x03, 0x08, 0x03, 0x00, 0x02, // CRTC 0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0xA0, 0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00, }; const g_40x50_text = [_]u8{ // MISC 0x67, // SEQ 0x03, 0x08, 0x03, 0x00, 0x02, // CRTC 0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00, 0x47, 0x06, 0x07, 0x00, 0x00, 0x04, 0x60, 0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00, }; const g_80x25_text = [_]u8{ // MISC 0x67, // SEQ 0x03, 0x00, 0x03, 0x00, 0x02, // CRTC 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x50, 0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00, }; const g_80x50_text = [_]u8{ // MISC 0x67, // SEQ 0x03, 0x00, 0x03, 0x00, 0x02, // CRTC 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x47, 0x06, 0x07, 0x00, 0x00, 0x01, 0x40, 0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00, }; const g_90x30_text = [_]u8{ // MISC 0xE7, // SEQ 0x03, 0x01, 0x03, 0x00, 0x02, // CRTC 0x6B, 0x59, 0x5A, 0x82, 0x60, 0x8D, 0x0B, 0x3E, 0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xEA, 0x0C, 0xDF, 0x2D, 0x10, 0xE8, 0x05, 0xA3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00, }; const g_90x60_text = [_]u8{ // MISC 0xE7, // SEQ 0x03, 0x01, 0x03, 0x00, 0x02, // CRTC 0x6B, 0x59, 0x5A, 0x82, 0x60, 0x8D, 0x0B, 0x3E, 0x00, 0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0xEA, 0x0C, 0xDF, 0x2D, 0x08, 0xE8, 0x05, 0xA3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00, }; // **************************************************************************** // VGA REGISTER DUMPS FOR VARIOUS GRAPHICS MODES // **************************************************************************** const g_640x480x2 = [_]u8{ // MISC 0xE3, // SEQ 0x03, 0x01, 0x0F, 0x00, 0x06, // CRTC 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x01, 0x00, 0x0F, 0x00, 0x00, }; //**************************************************************************** // *** NOTE: the mode described by g_320x200x4[] // is different from BIOS mode 05h in two ways: // - Framebuffer is at A000:0000 instead of B800:0000 // - Framebuffer is linear (no screwy line-by-line CGA addressing) // **************************************************************************** const g_320x200x4 = [_]u8{ // MISC 0x63, // SEQ 0x03, 0x09, 0x03, 0x00, 0x02, // CRTC 0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF, // AC 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x01, 0x00, 0x03, 0x00, 0x00, }; const g_640x480x16 = [_]u8{ // MISC 0xE3, // SEQ 0x03, 0x01, 0x08, 0x00, 0x06, // CRTC 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x0F, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x01, 0x00, 0x0F, 0x00, 0x00, }; const g_720x480x16 = [_]u8{ // MISC 0xE7, // SEQ 0x03, 0x01, 0x08, 0x00, 0x06, // CRTC 0x6B, 0x59, 0x5A, 0x82, 0x60, 0x8D, 0x0B, 0x3E, 0x00, 0x40, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0xEA, 0x0C, 0xDF, 0x2D, 0x08, 0xE8, 0x05, 0xE3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x0F, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00, 0x00, }; const g_320x200x256 = [_]u8{ // MISC 0x63, // SEQ 0x03, 0x01, 0x0F, 0x00, 0x0E, // CRTC 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00, }; const g_320x200x256_modex = [_]u8{ // MISC 0x63, // SEQ 0x03, 0x01, 0x0F, 0x00, 0x06, // CRTC 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x0E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF, // GC 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF, // AC 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00, };
src/kernel/arch/x86/boot/vga.zig
const util = @import("../sdf_util.zig"); pub const info: util.SdfInfo = .{ .name = "Dodecahedron Edges", .data_size = @sizeOf(Data), .function_definition = function_definition, .enter_command_fn = util.surfaceEnterCommand(Data), .exit_command_fn = util.surfaceExitCommand(Data, exitCommand), .append_mat_check_fn = util.surfaceMatCheckCommand(Data), .sphere_bound_fn = sphereBound, }; pub const Data = struct { radius: f32, edge_radius: f32, mat: usize, }; //https://www.shadertoy.com/view/Mly3R3 const function_definition: []const u8 = \\float sdDodecahedronEdges(vec3 p, float r, float er){ \\ const float J = 0.309016994375; \\ const float K = J+.5; \\ const mat3 R0 = mat3(0.5,-K,J ,K,J,-0.5 ,J,0.5,K ); \\ const mat3 R1 = mat3(K,J,-0.5 ,J,0.5,K ,0.5,-K,J ); \\ const mat3 R2 = mat3(-J,-0.5,K ,0.5,-K,-J ,K,J,0.5 ); \\ const mat3 R3 = mat3(0.587785252292,-K,0.,-0.425325404176,-J,0.850650808352,0.688190960236,0.5,0.525731112119); \\ const float PHI = (1.+sqrt(5.))/2.; \\ const float A = PHI / sqrt( 1. + PHI*PHI ); \\ const float PI = 3.14159265359; \\ const vec3 O3 = vec3(A/3./tan(PI/5.),A/3.,0.63147573033330584); \\ \\ p = R0 * abs(p); \\ p = R1 * abs(p); \\ p = R2 * abs(p); \\ p = R3 * abs(p) - O3 * r; \\ \\ return length(vec3(p.x, max(p.y, 0.), p.z)) - er; \\} \\ ; fn exitCommand(data: *Data, enter_index: usize, cur_point_name: []const u8, allocator: util.std.mem.Allocator) []const u8 { const format: []const u8 = "float d{d} = sdDodecahedronEdges({s}, {d:.5}, {d:.5});"; return util.std.fmt.allocPrint(allocator, format, .{ enter_index, cur_point_name, data.radius, data.edge_radius, }) catch unreachable; } fn sphereBound(buffer: *[]u8, bound: *util.math.sphereBound, children: []util.math.sphereBound) void { _ = children; const data: *Data = @ptrCast(*Data, @alignCast(@alignOf(Data), buffer.ptr)); bound.* = .{ .pos = util.math.Vec3.zeros(), .r = data.radius + data.edge_radius, }; }
src/sdf/surfaces/dodecahedron_edges.zig
pub const WEBAUTHN_API_VERSION_1 = @as(u32, 1); pub const WEBAUTHN_API_VERSION_2 = @as(u32, 2); pub const WEBAUTHN_API_VERSION_3 = @as(u32, 3); pub const WEBAUTHN_API_CURRENT_VERSION = @as(u32, 3); pub const WEBAUTHN_RP_ENTITY_INFORMATION_CURRENT_VERSION = @as(u32, 1); pub const WEBAUTHN_MAX_USER_ID_LENGTH = @as(u32, 64); pub const WEBAUTHN_USER_ENTITY_INFORMATION_CURRENT_VERSION = @as(u32, 1); pub const WEBAUTHN_CLIENT_DATA_CURRENT_VERSION = @as(u32, 1); pub const WEBAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256 = @as(i32, -7); pub const WEBAUTHN_COSE_ALGORITHM_ECDSA_P384_WITH_SHA384 = @as(i32, -35); pub const WEBAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512 = @as(i32, -36); pub const WEBAUTHN_COSE_ALGORITHM_RSASSA_PKCS1_V1_5_WITH_SHA256 = @as(i32, -257); pub const WEBAUTHN_COSE_ALGORITHM_RSASSA_PKCS1_V1_5_WITH_SHA384 = @as(i32, -258); pub const WEBAUTHN_COSE_ALGORITHM_RSASSA_PKCS1_V1_5_WITH_SHA512 = @as(i32, -259); pub const WEBAUTHN_COSE_ALGORITHM_RSA_PSS_WITH_SHA256 = @as(i32, -37); pub const WEBAUTHN_COSE_ALGORITHM_RSA_PSS_WITH_SHA384 = @as(i32, -38); pub const WEBAUTHN_COSE_ALGORITHM_RSA_PSS_WITH_SHA512 = @as(i32, -39); pub const WEBAUTHN_COSE_CREDENTIAL_PARAMETER_CURRENT_VERSION = @as(u32, 1); pub const WEBAUTHN_CREDENTIAL_CURRENT_VERSION = @as(u32, 1); pub const WEBAUTHN_CTAP_TRANSPORT_USB = @as(u32, 1); pub const WEBAUTHN_CTAP_TRANSPORT_NFC = @as(u32, 2); pub const WEBAUTHN_CTAP_TRANSPORT_BLE = @as(u32, 4); pub const WEBAUTHN_CTAP_TRANSPORT_TEST = @as(u32, 8); pub const WEBAUTHN_CTAP_TRANSPORT_INTERNAL = @as(u32, 16); pub const WEBAUTHN_CTAP_TRANSPORT_FLAGS_MASK = @as(u32, 31); pub const WEBAUTHN_CREDENTIAL_EX_CURRENT_VERSION = @as(u32, 1); pub const WEBAUTHN_USER_VERIFICATION_ANY = @as(u32, 0); pub const WEBAUTHN_USER_VERIFICATION_OPTIONAL = @as(u32, 1); pub const WEBAUTHN_USER_VERIFICATION_OPTIONAL_WITH_CREDENTIAL_ID_LIST = @as(u32, 2); pub const WEBAUTHN_USER_VERIFICATION_REQUIRED = @as(u32, 3); pub const WEBAUTHN_AUTHENTICATOR_ATTACHMENT_ANY = @as(u32, 0); pub const WEBAUTHN_AUTHENTICATOR_ATTACHMENT_PLATFORM = @as(u32, 1); pub const WEBAUTHN_AUTHENTICATOR_ATTACHMENT_CROSS_PLATFORM = @as(u32, 2); pub const WEBAUTHN_AUTHENTICATOR_ATTACHMENT_CROSS_PLATFORM_U2F_V2 = @as(u32, 3); pub const WEBAUTHN_USER_VERIFICATION_REQUIREMENT_ANY = @as(u32, 0); pub const WEBAUTHN_USER_VERIFICATION_REQUIREMENT_REQUIRED = @as(u32, 1); pub const WEBAUTHN_USER_VERIFICATION_REQUIREMENT_PREFERRED = @as(u32, 2); pub const WEBAUTHN_USER_VERIFICATION_REQUIREMENT_DISCOURAGED = @as(u32, 3); pub const WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_ANY = @as(u32, 0); pub const WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_NONE = @as(u32, 1); pub const WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_INDIRECT = @as(u32, 2); pub const WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_DIRECT = @as(u32, 3); pub const WEBAUTHN_ENTERPRISE_ATTESTATION_NONE = @as(u32, 0); pub const WEBAUTHN_ENTERPRISE_ATTESTATION_VENDOR_FACILITATED = @as(u32, 1); pub const WEBAUTHN_ENTERPRISE_ATTESTATION_PLATFORM_MANAGED = @as(u32, 2); pub const WEBAUTHN_LARGE_BLOB_SUPPORT_NONE = @as(u32, 0); pub const WEBAUTHN_LARGE_BLOB_SUPPORT_REQUIRED = @as(u32, 1); pub const WEBAUTHN_LARGE_BLOB_SUPPORT_PREFERRED = @as(u32, 2); pub const WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_1 = @as(u32, 1); pub const WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_2 = @as(u32, 2); pub const WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_3 = @as(u32, 3); pub const WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_4 = @as(u32, 4); pub const WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_CURRENT_VERSION = @as(u32, 4); pub const WEBAUTHN_CRED_LARGE_BLOB_OPERATION_NONE = @as(u32, 0); pub const WEBAUTHN_CRED_LARGE_BLOB_OPERATION_GET = @as(u32, 1); pub const WEBAUTHN_CRED_LARGE_BLOB_OPERATION_SET = @as(u32, 2); pub const WEBAUTHN_CRED_LARGE_BLOB_OPERATION_DELETE = @as(u32, 3); pub const WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_1 = @as(u32, 1); pub const WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_2 = @as(u32, 2); pub const WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_3 = @as(u32, 3); pub const WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_4 = @as(u32, 4); pub const WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_5 = @as(u32, 5); pub const WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_CURRENT_VERSION = @as(u32, 5); pub const WEBAUTHN_ATTESTATION_DECODE_NONE = @as(u32, 0); pub const WEBAUTHN_ATTESTATION_DECODE_COMMON = @as(u32, 1); pub const WEBAUTHN_COMMON_ATTESTATION_CURRENT_VERSION = @as(u32, 1); pub const WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_1 = @as(u32, 1); pub const WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_2 = @as(u32, 2); pub const WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_3 = @as(u32, 3); pub const WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_4 = @as(u32, 4); pub const WEBAUTHN_CREDENTIAL_ATTESTATION_CURRENT_VERSION = @as(u32, 4); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_NONE = @as(u32, 0); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_SUCCESS = @as(u32, 1); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_NOT_SUPPORTED = @as(u32, 2); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_INVALID_DATA = @as(u32, 3); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_INVALID_PARAMETER = @as(u32, 4); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_NOT_FOUND = @as(u32, 5); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_MULTIPLE_CREDENTIALS = @as(u32, 6); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_LACK_OF_SPACE = @as(u32, 7); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_PLATFORM_ERROR = @as(u32, 8); pub const WEBAUTHN_CRED_LARGE_BLOB_STATUS_AUTHENTICATOR_ERROR = @as(u32, 9); pub const WEBAUTHN_ASSERTION_VERSION_1 = @as(u32, 1); pub const WEBAUTHN_ASSERTION_VERSION_2 = @as(u32, 2); pub const WEBAUTHN_ASSERTION_CURRENT_VERSION = @as(u32, 2); pub const WS_HTTP_HEADER_MAPPING_COMMA_SEPARATOR = @as(i32, 1); pub const WS_HTTP_HEADER_MAPPING_SEMICOLON_SEPARATOR = @as(i32, 2); pub const WS_HTTP_HEADER_MAPPING_QUOTED_VALUE = @as(i32, 4); pub const WS_HTTP_RESPONSE_MAPPING_STATUS_CODE = @as(i32, 1); pub const WS_HTTP_RESPONSE_MAPPING_STATUS_TEXT = @as(i32, 2); pub const WS_HTTP_REQUEST_MAPPING_VERB = @as(i32, 2); pub const WS_MATCH_URL_DNS_HOST = @as(i32, 1); pub const WS_MATCH_URL_DNS_FULLY_QUALIFIED_HOST = @as(i32, 2); pub const WS_MATCH_URL_NETBIOS_HOST = @as(i32, 4); pub const WS_MATCH_URL_LOCAL_HOST = @as(i32, 8); pub const WS_MATCH_URL_HOST_ADDRESSES = @as(i32, 16); pub const WS_MATCH_URL_THIS_HOST = @as(i32, 31); pub const WS_MATCH_URL_PORT = @as(i32, 32); pub const WS_MATCH_URL_EXACT_PATH = @as(i32, 64); pub const WS_MATCH_URL_PREFIX_PATH = @as(i32, 128); pub const WS_MATCH_URL_NO_QUERY = @as(i32, 256); pub const WS_MUST_UNDERSTAND_HEADER_ATTRIBUTE = @as(i32, 1); pub const WS_RELAY_HEADER_ATTRIBUTE = @as(i32, 2); pub const WS_HTTP_HEADER_AUTH_SCHEME_NONE = @as(i32, 1); pub const WS_HTTP_HEADER_AUTH_SCHEME_BASIC = @as(i32, 2); pub const WS_HTTP_HEADER_AUTH_SCHEME_DIGEST = @as(i32, 4); pub const WS_HTTP_HEADER_AUTH_SCHEME_NTLM = @as(i32, 8); pub const WS_HTTP_HEADER_AUTH_SCHEME_NEGOTIATE = @as(i32, 16); pub const WS_HTTP_HEADER_AUTH_SCHEME_PASSPORT = @as(i32, 32); pub const WS_CERT_FAILURE_CN_MISMATCH = @as(i32, 1); pub const WS_CERT_FAILURE_INVALID_DATE = @as(i32, 2); pub const WS_CERT_FAILURE_UNTRUSTED_ROOT = @as(i32, 4); pub const WS_CERT_FAILURE_WRONG_USAGE = @as(i32, 8); pub const WS_CERT_FAILURE_REVOCATION_OFFLINE = @as(i32, 16); pub const WS_STRUCT_ABSTRACT = @as(i32, 1); pub const WS_STRUCT_IGNORE_TRAILING_ELEMENT_CONTENT = @as(i32, 2); pub const WS_STRUCT_IGNORE_UNHANDLED_ATTRIBUTES = @as(i32, 4); pub const WS_FIELD_POINTER = @as(i32, 1); pub const WS_FIELD_OPTIONAL = @as(i32, 2); pub const WS_FIELD_NILLABLE = @as(i32, 4); pub const WS_FIELD_NILLABLE_ITEM = @as(i32, 8); pub const WS_FIELD_OTHER_NAMESPACE = @as(i32, 16); pub const WS_SERVICE_OPERATION_MESSAGE_NILLABLE_ELEMENT = @as(i32, 1); pub const WS_URL_FLAGS_ALLOW_HOST_WILDCARDS = @as(i32, 1); pub const WS_URL_FLAGS_NO_PATH_COLLAPSE = @as(i32, 2); pub const WS_URL_FLAGS_ZERO_TERMINATE = @as(i32, 4); //-------------------------------------------------------------------------------- // Section: Types (451) //-------------------------------------------------------------------------------- pub const WS_XML_READER = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_XML_WRITER = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_XML_BUFFER = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_CHANNEL = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_OPERATION_CONTEXT = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_ERROR = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_HEAP = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_LISTENER = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_MESSAGE = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_SECURITY_TOKEN = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_SECURITY_CONTEXT = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_SERVICE_HOST = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_SERVICE_PROXY = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_METADATA = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_POLICY = extern struct { placeholder: usize, // TODO: why is this type empty? }; pub const WS_XML_READER_PROPERTY_ID = enum(i32) { MAX_DEPTH = 0, ALLOW_FRAGMENT = 1, MAX_ATTRIBUTES = 2, READ_DECLARATION = 3, CHARSET = 4, ROW = 5, COLUMN = 6, UTF8_TRIM_SIZE = 7, STREAM_BUFFER_SIZE = 8, IN_ATTRIBUTE = 9, STREAM_MAX_ROOT_MIME_PART_SIZE = 10, STREAM_MAX_MIME_HEADERS_SIZE = 11, MAX_MIME_PARTS = 12, ALLOW_INVALID_CHARACTER_REFERENCES = 13, MAX_NAMESPACES = 14, }; pub const WS_XML_READER_PROPERTY_MAX_DEPTH = WS_XML_READER_PROPERTY_ID.MAX_DEPTH; pub const WS_XML_READER_PROPERTY_ALLOW_FRAGMENT = WS_XML_READER_PROPERTY_ID.ALLOW_FRAGMENT; pub const WS_XML_READER_PROPERTY_MAX_ATTRIBUTES = WS_XML_READER_PROPERTY_ID.MAX_ATTRIBUTES; pub const WS_XML_READER_PROPERTY_READ_DECLARATION = WS_XML_READER_PROPERTY_ID.READ_DECLARATION; pub const WS_XML_READER_PROPERTY_CHARSET = WS_XML_READER_PROPERTY_ID.CHARSET; pub const WS_XML_READER_PROPERTY_ROW = WS_XML_READER_PROPERTY_ID.ROW; pub const WS_XML_READER_PROPERTY_COLUMN = WS_XML_READER_PROPERTY_ID.COLUMN; pub const WS_XML_READER_PROPERTY_UTF8_TRIM_SIZE = WS_XML_READER_PROPERTY_ID.UTF8_TRIM_SIZE; pub const WS_XML_READER_PROPERTY_STREAM_BUFFER_SIZE = WS_XML_READER_PROPERTY_ID.STREAM_BUFFER_SIZE; pub const WS_XML_READER_PROPERTY_IN_ATTRIBUTE = WS_XML_READER_PROPERTY_ID.IN_ATTRIBUTE; pub const WS_XML_READER_PROPERTY_STREAM_MAX_ROOT_MIME_PART_SIZE = WS_XML_READER_PROPERTY_ID.STREAM_MAX_ROOT_MIME_PART_SIZE; pub const WS_XML_READER_PROPERTY_STREAM_MAX_MIME_HEADERS_SIZE = WS_XML_READER_PROPERTY_ID.STREAM_MAX_MIME_HEADERS_SIZE; pub const WS_XML_READER_PROPERTY_MAX_MIME_PARTS = WS_XML_READER_PROPERTY_ID.MAX_MIME_PARTS; pub const WS_XML_READER_PROPERTY_ALLOW_INVALID_CHARACTER_REFERENCES = WS_XML_READER_PROPERTY_ID.ALLOW_INVALID_CHARACTER_REFERENCES; pub const WS_XML_READER_PROPERTY_MAX_NAMESPACES = WS_XML_READER_PROPERTY_ID.MAX_NAMESPACES; pub const WS_XML_CANONICALIZATION_ALGORITHM = enum(i32) { EXCLUSIVE_XML_CANONICALIZATION_ALGORITHM = 0, EXCLUSIVE_WITH_COMMENTS_XML_CANONICALIZATION_ALGORITHM = 1, INCLUSIVE_XML_CANONICALIZATION_ALGORITHM = 2, INCLUSIVE_WITH_COMMENTS_XML_CANONICALIZATION_ALGORITHM = 3, }; pub const WS_EXCLUSIVE_XML_CANONICALIZATION_ALGORITHM = WS_XML_CANONICALIZATION_ALGORITHM.EXCLUSIVE_XML_CANONICALIZATION_ALGORITHM; pub const WS_EXCLUSIVE_WITH_COMMENTS_XML_CANONICALIZATION_ALGORITHM = WS_XML_CANONICALIZATION_ALGORITHM.EXCLUSIVE_WITH_COMMENTS_XML_CANONICALIZATION_ALGORITHM; pub const WS_INCLUSIVE_XML_CANONICALIZATION_ALGORITHM = WS_XML_CANONICALIZATION_ALGORITHM.INCLUSIVE_XML_CANONICALIZATION_ALGORITHM; pub const WS_INCLUSIVE_WITH_COMMENTS_XML_CANONICALIZATION_ALGORITHM = WS_XML_CANONICALIZATION_ALGORITHM.INCLUSIVE_WITH_COMMENTS_XML_CANONICALIZATION_ALGORITHM; pub const WS_XML_CANONICALIZATION_PROPERTY_ID = enum(i32) { ALGORITHM = 0, INCLUSIVE_PREFIXES = 1, OMITTED_ELEMENT = 2, OUTPUT_BUFFER_SIZE = 3, }; pub const WS_XML_CANONICALIZATION_PROPERTY_ALGORITHM = WS_XML_CANONICALIZATION_PROPERTY_ID.ALGORITHM; pub const WS_XML_CANONICALIZATION_PROPERTY_INCLUSIVE_PREFIXES = WS_XML_CANONICALIZATION_PROPERTY_ID.INCLUSIVE_PREFIXES; pub const WS_XML_CANONICALIZATION_PROPERTY_OMITTED_ELEMENT = WS_XML_CANONICALIZATION_PROPERTY_ID.OMITTED_ELEMENT; pub const WS_XML_CANONICALIZATION_PROPERTY_OUTPUT_BUFFER_SIZE = WS_XML_CANONICALIZATION_PROPERTY_ID.OUTPUT_BUFFER_SIZE; pub const WS_XML_WRITER_PROPERTY_ID = enum(i32) { MAX_DEPTH = 0, ALLOW_FRAGMENT = 1, MAX_ATTRIBUTES = 2, WRITE_DECLARATION = 3, INDENT = 4, BUFFER_TRIM_SIZE = 5, CHARSET = 6, BUFFERS = 7, BUFFER_MAX_SIZE = 8, BYTES = 9, IN_ATTRIBUTE = 10, MAX_MIME_PARTS_BUFFER_SIZE = 11, INITIAL_BUFFER = 12, ALLOW_INVALID_CHARACTER_REFERENCES = 13, MAX_NAMESPACES = 14, BYTES_WRITTEN = 15, BYTES_TO_CLOSE = 16, COMPRESS_EMPTY_ELEMENTS = 17, EMIT_UNCOMPRESSED_EMPTY_ELEMENTS = 18, }; pub const WS_XML_WRITER_PROPERTY_MAX_DEPTH = WS_XML_WRITER_PROPERTY_ID.MAX_DEPTH; pub const WS_XML_WRITER_PROPERTY_ALLOW_FRAGMENT = WS_XML_WRITER_PROPERTY_ID.ALLOW_FRAGMENT; pub const WS_XML_WRITER_PROPERTY_MAX_ATTRIBUTES = WS_XML_WRITER_PROPERTY_ID.MAX_ATTRIBUTES; pub const WS_XML_WRITER_PROPERTY_WRITE_DECLARATION = WS_XML_WRITER_PROPERTY_ID.WRITE_DECLARATION; pub const WS_XML_WRITER_PROPERTY_INDENT = WS_XML_WRITER_PROPERTY_ID.INDENT; pub const WS_XML_WRITER_PROPERTY_BUFFER_TRIM_SIZE = WS_XML_WRITER_PROPERTY_ID.BUFFER_TRIM_SIZE; pub const WS_XML_WRITER_PROPERTY_CHARSET = WS_XML_WRITER_PROPERTY_ID.CHARSET; pub const WS_XML_WRITER_PROPERTY_BUFFERS = WS_XML_WRITER_PROPERTY_ID.BUFFERS; pub const WS_XML_WRITER_PROPERTY_BUFFER_MAX_SIZE = WS_XML_WRITER_PROPERTY_ID.BUFFER_MAX_SIZE; pub const WS_XML_WRITER_PROPERTY_BYTES = WS_XML_WRITER_PROPERTY_ID.BYTES; pub const WS_XML_WRITER_PROPERTY_IN_ATTRIBUTE = WS_XML_WRITER_PROPERTY_ID.IN_ATTRIBUTE; pub const WS_XML_WRITER_PROPERTY_MAX_MIME_PARTS_BUFFER_SIZE = WS_XML_WRITER_PROPERTY_ID.MAX_MIME_PARTS_BUFFER_SIZE; pub const WS_XML_WRITER_PROPERTY_INITIAL_BUFFER = WS_XML_WRITER_PROPERTY_ID.INITIAL_BUFFER; pub const WS_XML_WRITER_PROPERTY_ALLOW_INVALID_CHARACTER_REFERENCES = WS_XML_WRITER_PROPERTY_ID.ALLOW_INVALID_CHARACTER_REFERENCES; pub const WS_XML_WRITER_PROPERTY_MAX_NAMESPACES = WS_XML_WRITER_PROPERTY_ID.MAX_NAMESPACES; pub const WS_XML_WRITER_PROPERTY_BYTES_WRITTEN = WS_XML_WRITER_PROPERTY_ID.BYTES_WRITTEN; pub const WS_XML_WRITER_PROPERTY_BYTES_TO_CLOSE = WS_XML_WRITER_PROPERTY_ID.BYTES_TO_CLOSE; pub const WS_XML_WRITER_PROPERTY_COMPRESS_EMPTY_ELEMENTS = WS_XML_WRITER_PROPERTY_ID.COMPRESS_EMPTY_ELEMENTS; pub const WS_XML_WRITER_PROPERTY_EMIT_UNCOMPRESSED_EMPTY_ELEMENTS = WS_XML_WRITER_PROPERTY_ID.EMIT_UNCOMPRESSED_EMPTY_ELEMENTS; pub const WS_XML_BUFFER_PROPERTY_ID = enum(i32) { _ }; pub const WS_XML_TEXT_TYPE = enum(i32) { UTF8 = 1, UTF16 = 2, BASE64 = 3, BOOL = 4, INT32 = 5, INT64 = 6, UINT64 = 7, FLOAT = 8, DOUBLE = 9, DECIMAL = 10, GUID = 11, UNIQUE_ID = 12, DATETIME = 13, TIMESPAN = 14, QNAME = 15, LIST = 16, }; pub const WS_XML_TEXT_TYPE_UTF8 = WS_XML_TEXT_TYPE.UTF8; pub const WS_XML_TEXT_TYPE_UTF16 = WS_XML_TEXT_TYPE.UTF16; pub const WS_XML_TEXT_TYPE_BASE64 = WS_XML_TEXT_TYPE.BASE64; pub const WS_XML_TEXT_TYPE_BOOL = WS_XML_TEXT_TYPE.BOOL; pub const WS_XML_TEXT_TYPE_INT32 = WS_XML_TEXT_TYPE.INT32; pub const WS_XML_TEXT_TYPE_INT64 = WS_XML_TEXT_TYPE.INT64; pub const WS_XML_TEXT_TYPE_UINT64 = WS_XML_TEXT_TYPE.UINT64; pub const WS_XML_TEXT_TYPE_FLOAT = WS_XML_TEXT_TYPE.FLOAT; pub const WS_XML_TEXT_TYPE_DOUBLE = WS_XML_TEXT_TYPE.DOUBLE; pub const WS_XML_TEXT_TYPE_DECIMAL = WS_XML_TEXT_TYPE.DECIMAL; pub const WS_XML_TEXT_TYPE_GUID = WS_XML_TEXT_TYPE.GUID; pub const WS_XML_TEXT_TYPE_UNIQUE_ID = WS_XML_TEXT_TYPE.UNIQUE_ID; pub const WS_XML_TEXT_TYPE_DATETIME = WS_XML_TEXT_TYPE.DATETIME; pub const WS_XML_TEXT_TYPE_TIMESPAN = WS_XML_TEXT_TYPE.TIMESPAN; pub const WS_XML_TEXT_TYPE_QNAME = WS_XML_TEXT_TYPE.QNAME; pub const WS_XML_TEXT_TYPE_LIST = WS_XML_TEXT_TYPE.LIST; pub const WS_XML_NODE_TYPE = enum(i32) { ELEMENT = 1, TEXT = 2, END_ELEMENT = 3, COMMENT = 4, CDATA = 6, END_CDATA = 7, EOF = 8, BOF = 9, }; pub const WS_XML_NODE_TYPE_ELEMENT = WS_XML_NODE_TYPE.ELEMENT; pub const WS_XML_NODE_TYPE_TEXT = WS_XML_NODE_TYPE.TEXT; pub const WS_XML_NODE_TYPE_END_ELEMENT = WS_XML_NODE_TYPE.END_ELEMENT; pub const WS_XML_NODE_TYPE_COMMENT = WS_XML_NODE_TYPE.COMMENT; pub const WS_XML_NODE_TYPE_CDATA = WS_XML_NODE_TYPE.CDATA; pub const WS_XML_NODE_TYPE_END_CDATA = WS_XML_NODE_TYPE.END_CDATA; pub const WS_XML_NODE_TYPE_EOF = WS_XML_NODE_TYPE.EOF; pub const WS_XML_NODE_TYPE_BOF = WS_XML_NODE_TYPE.BOF; pub const WS_MOVE_TO = enum(i32) { ROOT_ELEMENT = 0, NEXT_ELEMENT = 1, PREVIOUS_ELEMENT = 2, CHILD_ELEMENT = 3, END_ELEMENT = 4, PARENT_ELEMENT = 5, NEXT_NODE = 6, PREVIOUS_NODE = 7, FIRST_NODE = 8, BOF = 9, EOF = 10, CHILD_NODE = 11, }; pub const WS_MOVE_TO_ROOT_ELEMENT = WS_MOVE_TO.ROOT_ELEMENT; pub const WS_MOVE_TO_NEXT_ELEMENT = WS_MOVE_TO.NEXT_ELEMENT; pub const WS_MOVE_TO_PREVIOUS_ELEMENT = WS_MOVE_TO.PREVIOUS_ELEMENT; pub const WS_MOVE_TO_CHILD_ELEMENT = WS_MOVE_TO.CHILD_ELEMENT; pub const WS_MOVE_TO_END_ELEMENT = WS_MOVE_TO.END_ELEMENT; pub const WS_MOVE_TO_PARENT_ELEMENT = WS_MOVE_TO.PARENT_ELEMENT; pub const WS_MOVE_TO_NEXT_NODE = WS_MOVE_TO.NEXT_NODE; pub const WS_MOVE_TO_PREVIOUS_NODE = WS_MOVE_TO.PREVIOUS_NODE; pub const WS_MOVE_TO_FIRST_NODE = WS_MOVE_TO.FIRST_NODE; pub const WS_MOVE_TO_BOF = WS_MOVE_TO.BOF; pub const WS_MOVE_TO_EOF = WS_MOVE_TO.EOF; pub const WS_MOVE_TO_CHILD_NODE = WS_MOVE_TO.CHILD_NODE; pub const WS_VALUE_TYPE = enum(i32) { BOOL_VALUE_TYPE = 0, INT8_VALUE_TYPE = 1, INT16_VALUE_TYPE = 2, INT32_VALUE_TYPE = 3, INT64_VALUE_TYPE = 4, UINT8_VALUE_TYPE = 5, UINT16_VALUE_TYPE = 6, UINT32_VALUE_TYPE = 7, UINT64_VALUE_TYPE = 8, FLOAT_VALUE_TYPE = 9, DOUBLE_VALUE_TYPE = 10, DECIMAL_VALUE_TYPE = 11, DATETIME_VALUE_TYPE = 12, TIMESPAN_VALUE_TYPE = 13, GUID_VALUE_TYPE = 14, DURATION_VALUE_TYPE = 15, }; pub const WS_BOOL_VALUE_TYPE = WS_VALUE_TYPE.BOOL_VALUE_TYPE; pub const WS_INT8_VALUE_TYPE = WS_VALUE_TYPE.INT8_VALUE_TYPE; pub const WS_INT16_VALUE_TYPE = WS_VALUE_TYPE.INT16_VALUE_TYPE; pub const WS_INT32_VALUE_TYPE = WS_VALUE_TYPE.INT32_VALUE_TYPE; pub const WS_INT64_VALUE_TYPE = WS_VALUE_TYPE.INT64_VALUE_TYPE; pub const WS_UINT8_VALUE_TYPE = WS_VALUE_TYPE.UINT8_VALUE_TYPE; pub const WS_UINT16_VALUE_TYPE = WS_VALUE_TYPE.UINT16_VALUE_TYPE; pub const WS_UINT32_VALUE_TYPE = WS_VALUE_TYPE.UINT32_VALUE_TYPE; pub const WS_UINT64_VALUE_TYPE = WS_VALUE_TYPE.UINT64_VALUE_TYPE; pub const WS_FLOAT_VALUE_TYPE = WS_VALUE_TYPE.FLOAT_VALUE_TYPE; pub const WS_DOUBLE_VALUE_TYPE = WS_VALUE_TYPE.DOUBLE_VALUE_TYPE; pub const WS_DECIMAL_VALUE_TYPE = WS_VALUE_TYPE.DECIMAL_VALUE_TYPE; pub const WS_DATETIME_VALUE_TYPE = WS_VALUE_TYPE.DATETIME_VALUE_TYPE; pub const WS_TIMESPAN_VALUE_TYPE = WS_VALUE_TYPE.TIMESPAN_VALUE_TYPE; pub const WS_GUID_VALUE_TYPE = WS_VALUE_TYPE.GUID_VALUE_TYPE; pub const WS_DURATION_VALUE_TYPE = WS_VALUE_TYPE.DURATION_VALUE_TYPE; pub const WS_XML_READER_INPUT_TYPE = enum(i32) { BUFFER = 1, STREAM = 2, }; pub const WS_XML_READER_INPUT_TYPE_BUFFER = WS_XML_READER_INPUT_TYPE.BUFFER; pub const WS_XML_READER_INPUT_TYPE_STREAM = WS_XML_READER_INPUT_TYPE.STREAM; pub const WS_XML_READER_ENCODING_TYPE = enum(i32) { TEXT = 1, BINARY = 2, MTOM = 3, RAW = 4, }; pub const WS_XML_READER_ENCODING_TYPE_TEXT = WS_XML_READER_ENCODING_TYPE.TEXT; pub const WS_XML_READER_ENCODING_TYPE_BINARY = WS_XML_READER_ENCODING_TYPE.BINARY; pub const WS_XML_READER_ENCODING_TYPE_MTOM = WS_XML_READER_ENCODING_TYPE.MTOM; pub const WS_XML_READER_ENCODING_TYPE_RAW = WS_XML_READER_ENCODING_TYPE.RAW; pub const WS_CHARSET = enum(i32) { AUTO = 0, UTF8 = 1, UTF16LE = 2, UTF16BE = 3, }; pub const WS_CHARSET_AUTO = WS_CHARSET.AUTO; pub const WS_CHARSET_UTF8 = WS_CHARSET.UTF8; pub const WS_CHARSET_UTF16LE = WS_CHARSET.UTF16LE; pub const WS_CHARSET_UTF16BE = WS_CHARSET.UTF16BE; pub const WS_XML_WRITER_ENCODING_TYPE = enum(i32) { TEXT = 1, BINARY = 2, MTOM = 3, RAW = 4, }; pub const WS_XML_WRITER_ENCODING_TYPE_TEXT = WS_XML_WRITER_ENCODING_TYPE.TEXT; pub const WS_XML_WRITER_ENCODING_TYPE_BINARY = WS_XML_WRITER_ENCODING_TYPE.BINARY; pub const WS_XML_WRITER_ENCODING_TYPE_MTOM = WS_XML_WRITER_ENCODING_TYPE.MTOM; pub const WS_XML_WRITER_ENCODING_TYPE_RAW = WS_XML_WRITER_ENCODING_TYPE.RAW; pub const WS_XML_WRITER_OUTPUT_TYPE = enum(i32) { BUFFER = 1, STREAM = 2, }; pub const WS_XML_WRITER_OUTPUT_TYPE_BUFFER = WS_XML_WRITER_OUTPUT_TYPE.BUFFER; pub const WS_XML_WRITER_OUTPUT_TYPE_STREAM = WS_XML_WRITER_OUTPUT_TYPE.STREAM; pub const WS_CALLBACK_MODEL = enum(i32) { SHORT_CALLBACK = 0, LONG_CALLBACK = 1, }; pub const WS_SHORT_CALLBACK = WS_CALLBACK_MODEL.SHORT_CALLBACK; pub const WS_LONG_CALLBACK = WS_CALLBACK_MODEL.LONG_CALLBACK; pub const WS_ENCODING = enum(i32) { XML_BINARY_1 = 0, XML_BINARY_SESSION_1 = 1, XML_MTOM_UTF8 = 2, XML_MTOM_UTF16BE = 3, XML_MTOM_UTF16LE = 4, XML_UTF8 = 5, XML_UTF16BE = 6, XML_UTF16LE = 7, RAW = 8, }; pub const WS_ENCODING_XML_BINARY_1 = WS_ENCODING.XML_BINARY_1; pub const WS_ENCODING_XML_BINARY_SESSION_1 = WS_ENCODING.XML_BINARY_SESSION_1; pub const WS_ENCODING_XML_MTOM_UTF8 = WS_ENCODING.XML_MTOM_UTF8; pub const WS_ENCODING_XML_MTOM_UTF16BE = WS_ENCODING.XML_MTOM_UTF16BE; pub const WS_ENCODING_XML_MTOM_UTF16LE = WS_ENCODING.XML_MTOM_UTF16LE; pub const WS_ENCODING_XML_UTF8 = WS_ENCODING.XML_UTF8; pub const WS_ENCODING_XML_UTF16BE = WS_ENCODING.XML_UTF16BE; pub const WS_ENCODING_XML_UTF16LE = WS_ENCODING.XML_UTF16LE; pub const WS_ENCODING_RAW = WS_ENCODING.RAW; pub const WS_CHANNEL_STATE = enum(i32) { CREATED = 0, OPENING = 1, ACCEPTING = 2, OPEN = 3, FAULTED = 4, CLOSING = 5, CLOSED = 6, }; pub const WS_CHANNEL_STATE_CREATED = WS_CHANNEL_STATE.CREATED; pub const WS_CHANNEL_STATE_OPENING = WS_CHANNEL_STATE.OPENING; pub const WS_CHANNEL_STATE_ACCEPTING = WS_CHANNEL_STATE.ACCEPTING; pub const WS_CHANNEL_STATE_OPEN = WS_CHANNEL_STATE.OPEN; pub const WS_CHANNEL_STATE_FAULTED = WS_CHANNEL_STATE.FAULTED; pub const WS_CHANNEL_STATE_CLOSING = WS_CHANNEL_STATE.CLOSING; pub const WS_CHANNEL_STATE_CLOSED = WS_CHANNEL_STATE.CLOSED; pub const WS_RECEIVE_OPTION = enum(i32) { REQUIRED_MESSAGE = 1, OPTIONAL_MESSAGE = 2, }; pub const WS_RECEIVE_REQUIRED_MESSAGE = WS_RECEIVE_OPTION.REQUIRED_MESSAGE; pub const WS_RECEIVE_OPTIONAL_MESSAGE = WS_RECEIVE_OPTION.OPTIONAL_MESSAGE; pub const WS_CHANNEL_BINDING = enum(i32) { HTTP_CHANNEL_BINDING = 0, TCP_CHANNEL_BINDING = 1, UDP_CHANNEL_BINDING = 2, CUSTOM_CHANNEL_BINDING = 3, NAMEDPIPE_CHANNEL_BINDING = 4, }; pub const WS_HTTP_CHANNEL_BINDING = WS_CHANNEL_BINDING.HTTP_CHANNEL_BINDING; pub const WS_TCP_CHANNEL_BINDING = WS_CHANNEL_BINDING.TCP_CHANNEL_BINDING; pub const WS_UDP_CHANNEL_BINDING = WS_CHANNEL_BINDING.UDP_CHANNEL_BINDING; pub const WS_CUSTOM_CHANNEL_BINDING = WS_CHANNEL_BINDING.CUSTOM_CHANNEL_BINDING; pub const WS_NAMEDPIPE_CHANNEL_BINDING = WS_CHANNEL_BINDING.NAMEDPIPE_CHANNEL_BINDING; pub const WS_CHANNEL_TYPE = enum(i32) { INPUT = 1, OUTPUT = 2, SESSION = 4, INPUT_SESSION = 5, OUTPUT_SESSION = 6, DUPLEX = 3, DUPLEX_SESSION = 7, REQUEST = 8, REPLY = 16, }; pub const WS_CHANNEL_TYPE_INPUT = WS_CHANNEL_TYPE.INPUT; pub const WS_CHANNEL_TYPE_OUTPUT = WS_CHANNEL_TYPE.OUTPUT; pub const WS_CHANNEL_TYPE_SESSION = WS_CHANNEL_TYPE.SESSION; pub const WS_CHANNEL_TYPE_INPUT_SESSION = WS_CHANNEL_TYPE.INPUT_SESSION; pub const WS_CHANNEL_TYPE_OUTPUT_SESSION = WS_CHANNEL_TYPE.OUTPUT_SESSION; pub const WS_CHANNEL_TYPE_DUPLEX = WS_CHANNEL_TYPE.DUPLEX; pub const WS_CHANNEL_TYPE_DUPLEX_SESSION = WS_CHANNEL_TYPE.DUPLEX_SESSION; pub const WS_CHANNEL_TYPE_REQUEST = WS_CHANNEL_TYPE.REQUEST; pub const WS_CHANNEL_TYPE_REPLY = WS_CHANNEL_TYPE.REPLY; pub const WS_TRANSFER_MODE = enum(i32) { STREAMED_INPUT_TRANSFER_MODE = 1, STREAMED_OUTPUT_TRANSFER_MODE = 2, BUFFERED_TRANSFER_MODE = 0, STREAMED_TRANSFER_MODE = 3, }; pub const WS_STREAMED_INPUT_TRANSFER_MODE = WS_TRANSFER_MODE.STREAMED_INPUT_TRANSFER_MODE; pub const WS_STREAMED_OUTPUT_TRANSFER_MODE = WS_TRANSFER_MODE.STREAMED_OUTPUT_TRANSFER_MODE; pub const WS_BUFFERED_TRANSFER_MODE = WS_TRANSFER_MODE.BUFFERED_TRANSFER_MODE; pub const WS_STREAMED_TRANSFER_MODE = WS_TRANSFER_MODE.STREAMED_TRANSFER_MODE; pub const WS_HTTP_PROXY_SETTING_MODE = enum(i32) { AUTO = 1, NONE = 2, CUSTOM = 3, }; pub const WS_HTTP_PROXY_SETTING_MODE_AUTO = WS_HTTP_PROXY_SETTING_MODE.AUTO; pub const WS_HTTP_PROXY_SETTING_MODE_NONE = WS_HTTP_PROXY_SETTING_MODE.NONE; pub const WS_HTTP_PROXY_SETTING_MODE_CUSTOM = WS_HTTP_PROXY_SETTING_MODE.CUSTOM; pub const WS_CHANNEL_PROPERTY_ID = enum(i32) { MAX_BUFFERED_MESSAGE_SIZE = 0, MAX_STREAMED_MESSAGE_SIZE = 1, MAX_STREAMED_START_SIZE = 2, MAX_STREAMED_FLUSH_SIZE = 3, ENCODING = 4, ENVELOPE_VERSION = 5, ADDRESSING_VERSION = 6, MAX_SESSION_DICTIONARY_SIZE = 7, STATE = 8, ASYNC_CALLBACK_MODEL = 9, IP_VERSION = 10, RESOLVE_TIMEOUT = 11, CONNECT_TIMEOUT = 12, SEND_TIMEOUT = 13, RECEIVE_RESPONSE_TIMEOUT = 14, RECEIVE_TIMEOUT = 15, CLOSE_TIMEOUT = 16, ENABLE_TIMEOUTS = 17, TRANSFER_MODE = 18, MULTICAST_INTERFACE = 19, MULTICAST_HOPS = 20, REMOTE_ADDRESS = 21, REMOTE_IP_ADDRESS = 22, HTTP_CONNECTION_ID = 23, CUSTOM_CHANNEL_CALLBACKS = 24, CUSTOM_CHANNEL_PARAMETERS = 25, CUSTOM_CHANNEL_INSTANCE = 26, TRANSPORT_URL = 27, NO_DELAY = 28, SEND_KEEP_ALIVES = 29, KEEP_ALIVE_TIME = 30, KEEP_ALIVE_INTERVAL = 31, MAX_HTTP_SERVER_CONNECTIONS = 32, IS_SESSION_SHUT_DOWN = 33, CHANNEL_TYPE = 34, TRIM_BUFFERED_MESSAGE_SIZE = 35, ENCODER = 36, DECODER = 37, PROTECTION_LEVEL = 38, COOKIE_MODE = 39, HTTP_PROXY_SETTING_MODE = 40, CUSTOM_HTTP_PROXY = 41, HTTP_MESSAGE_MAPPING = 42, ENABLE_HTTP_REDIRECT = 43, HTTP_REDIRECT_CALLBACK_CONTEXT = 44, FAULTS_AS_ERRORS = 45, ALLOW_UNSECURED_FAULTS = 46, HTTP_SERVER_SPN = 47, HTTP_PROXY_SPN = 48, MAX_HTTP_REQUEST_HEADERS_BUFFER_SIZE = 49, }; pub const WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE = WS_CHANNEL_PROPERTY_ID.MAX_BUFFERED_MESSAGE_SIZE; pub const WS_CHANNEL_PROPERTY_MAX_STREAMED_MESSAGE_SIZE = WS_CHANNEL_PROPERTY_ID.MAX_STREAMED_MESSAGE_SIZE; pub const WS_CHANNEL_PROPERTY_MAX_STREAMED_START_SIZE = WS_CHANNEL_PROPERTY_ID.MAX_STREAMED_START_SIZE; pub const WS_CHANNEL_PROPERTY_MAX_STREAMED_FLUSH_SIZE = WS_CHANNEL_PROPERTY_ID.MAX_STREAMED_FLUSH_SIZE; pub const WS_CHANNEL_PROPERTY_ENCODING = WS_CHANNEL_PROPERTY_ID.ENCODING; pub const WS_CHANNEL_PROPERTY_ENVELOPE_VERSION = WS_CHANNEL_PROPERTY_ID.ENVELOPE_VERSION; pub const WS_CHANNEL_PROPERTY_ADDRESSING_VERSION = WS_CHANNEL_PROPERTY_ID.ADDRESSING_VERSION; pub const WS_CHANNEL_PROPERTY_MAX_SESSION_DICTIONARY_SIZE = WS_CHANNEL_PROPERTY_ID.MAX_SESSION_DICTIONARY_SIZE; pub const WS_CHANNEL_PROPERTY_STATE = WS_CHANNEL_PROPERTY_ID.STATE; pub const WS_CHANNEL_PROPERTY_ASYNC_CALLBACK_MODEL = WS_CHANNEL_PROPERTY_ID.ASYNC_CALLBACK_MODEL; pub const WS_CHANNEL_PROPERTY_IP_VERSION = WS_CHANNEL_PROPERTY_ID.IP_VERSION; pub const WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT = WS_CHANNEL_PROPERTY_ID.RESOLVE_TIMEOUT; pub const WS_CHANNEL_PROPERTY_CONNECT_TIMEOUT = WS_CHANNEL_PROPERTY_ID.CONNECT_TIMEOUT; pub const WS_CHANNEL_PROPERTY_SEND_TIMEOUT = WS_CHANNEL_PROPERTY_ID.SEND_TIMEOUT; pub const WS_CHANNEL_PROPERTY_RECEIVE_RESPONSE_TIMEOUT = WS_CHANNEL_PROPERTY_ID.RECEIVE_RESPONSE_TIMEOUT; pub const WS_CHANNEL_PROPERTY_RECEIVE_TIMEOUT = WS_CHANNEL_PROPERTY_ID.RECEIVE_TIMEOUT; pub const WS_CHANNEL_PROPERTY_CLOSE_TIMEOUT = WS_CHANNEL_PROPERTY_ID.CLOSE_TIMEOUT; pub const WS_CHANNEL_PROPERTY_ENABLE_TIMEOUTS = WS_CHANNEL_PROPERTY_ID.ENABLE_TIMEOUTS; pub const WS_CHANNEL_PROPERTY_TRANSFER_MODE = WS_CHANNEL_PROPERTY_ID.TRANSFER_MODE; pub const WS_CHANNEL_PROPERTY_MULTICAST_INTERFACE = WS_CHANNEL_PROPERTY_ID.MULTICAST_INTERFACE; pub const WS_CHANNEL_PROPERTY_MULTICAST_HOPS = WS_CHANNEL_PROPERTY_ID.MULTICAST_HOPS; pub const WS_CHANNEL_PROPERTY_REMOTE_ADDRESS = WS_CHANNEL_PROPERTY_ID.REMOTE_ADDRESS; pub const WS_CHANNEL_PROPERTY_REMOTE_IP_ADDRESS = WS_CHANNEL_PROPERTY_ID.REMOTE_IP_ADDRESS; pub const WS_CHANNEL_PROPERTY_HTTP_CONNECTION_ID = WS_CHANNEL_PROPERTY_ID.HTTP_CONNECTION_ID; pub const WS_CHANNEL_PROPERTY_CUSTOM_CHANNEL_CALLBACKS = WS_CHANNEL_PROPERTY_ID.CUSTOM_CHANNEL_CALLBACKS; pub const WS_CHANNEL_PROPERTY_CUSTOM_CHANNEL_PARAMETERS = WS_CHANNEL_PROPERTY_ID.CUSTOM_CHANNEL_PARAMETERS; pub const WS_CHANNEL_PROPERTY_CUSTOM_CHANNEL_INSTANCE = WS_CHANNEL_PROPERTY_ID.CUSTOM_CHANNEL_INSTANCE; pub const WS_CHANNEL_PROPERTY_TRANSPORT_URL = WS_CHANNEL_PROPERTY_ID.TRANSPORT_URL; pub const WS_CHANNEL_PROPERTY_NO_DELAY = WS_CHANNEL_PROPERTY_ID.NO_DELAY; pub const WS_CHANNEL_PROPERTY_SEND_KEEP_ALIVES = WS_CHANNEL_PROPERTY_ID.SEND_KEEP_ALIVES; pub const WS_CHANNEL_PROPERTY_KEEP_ALIVE_TIME = WS_CHANNEL_PROPERTY_ID.KEEP_ALIVE_TIME; pub const WS_CHANNEL_PROPERTY_KEEP_ALIVE_INTERVAL = WS_CHANNEL_PROPERTY_ID.KEEP_ALIVE_INTERVAL; pub const WS_CHANNEL_PROPERTY_MAX_HTTP_SERVER_CONNECTIONS = WS_CHANNEL_PROPERTY_ID.MAX_HTTP_SERVER_CONNECTIONS; pub const WS_CHANNEL_PROPERTY_IS_SESSION_SHUT_DOWN = WS_CHANNEL_PROPERTY_ID.IS_SESSION_SHUT_DOWN; pub const WS_CHANNEL_PROPERTY_CHANNEL_TYPE = WS_CHANNEL_PROPERTY_ID.CHANNEL_TYPE; pub const WS_CHANNEL_PROPERTY_TRIM_BUFFERED_MESSAGE_SIZE = WS_CHANNEL_PROPERTY_ID.TRIM_BUFFERED_MESSAGE_SIZE; pub const WS_CHANNEL_PROPERTY_ENCODER = WS_CHANNEL_PROPERTY_ID.ENCODER; pub const WS_CHANNEL_PROPERTY_DECODER = WS_CHANNEL_PROPERTY_ID.DECODER; pub const WS_CHANNEL_PROPERTY_PROTECTION_LEVEL = WS_CHANNEL_PROPERTY_ID.PROTECTION_LEVEL; pub const WS_CHANNEL_PROPERTY_COOKIE_MODE = WS_CHANNEL_PROPERTY_ID.COOKIE_MODE; pub const WS_CHANNEL_PROPERTY_HTTP_PROXY_SETTING_MODE = WS_CHANNEL_PROPERTY_ID.HTTP_PROXY_SETTING_MODE; pub const WS_CHANNEL_PROPERTY_CUSTOM_HTTP_PROXY = WS_CHANNEL_PROPERTY_ID.CUSTOM_HTTP_PROXY; pub const WS_CHANNEL_PROPERTY_HTTP_MESSAGE_MAPPING = WS_CHANNEL_PROPERTY_ID.HTTP_MESSAGE_MAPPING; pub const WS_CHANNEL_PROPERTY_ENABLE_HTTP_REDIRECT = WS_CHANNEL_PROPERTY_ID.ENABLE_HTTP_REDIRECT; pub const WS_CHANNEL_PROPERTY_HTTP_REDIRECT_CALLBACK_CONTEXT = WS_CHANNEL_PROPERTY_ID.HTTP_REDIRECT_CALLBACK_CONTEXT; pub const WS_CHANNEL_PROPERTY_FAULTS_AS_ERRORS = WS_CHANNEL_PROPERTY_ID.FAULTS_AS_ERRORS; pub const WS_CHANNEL_PROPERTY_ALLOW_UNSECURED_FAULTS = WS_CHANNEL_PROPERTY_ID.ALLOW_UNSECURED_FAULTS; pub const WS_CHANNEL_PROPERTY_HTTP_SERVER_SPN = WS_CHANNEL_PROPERTY_ID.HTTP_SERVER_SPN; pub const WS_CHANNEL_PROPERTY_HTTP_PROXY_SPN = WS_CHANNEL_PROPERTY_ID.HTTP_PROXY_SPN; pub const WS_CHANNEL_PROPERTY_MAX_HTTP_REQUEST_HEADERS_BUFFER_SIZE = WS_CHANNEL_PROPERTY_ID.MAX_HTTP_REQUEST_HEADERS_BUFFER_SIZE; pub const WS_COOKIE_MODE = enum(i32) { MANUAL_COOKIE_MODE = 1, AUTO_COOKIE_MODE = 2, }; pub const WS_MANUAL_COOKIE_MODE = WS_COOKIE_MODE.MANUAL_COOKIE_MODE; pub const WS_AUTO_COOKIE_MODE = WS_COOKIE_MODE.AUTO_COOKIE_MODE; pub const WS_OPERATION_CONTEXT_PROPERTY_ID = enum(i32) { CHANNEL = 0, CONTRACT_DESCRIPTION = 1, HOST_USER_STATE = 2, CHANNEL_USER_STATE = 3, INPUT_MESSAGE = 4, OUTPUT_MESSAGE = 5, HEAP = 6, LISTENER = 7, ENDPOINT_ADDRESS = 8, }; pub const WS_OPERATION_CONTEXT_PROPERTY_CHANNEL = WS_OPERATION_CONTEXT_PROPERTY_ID.CHANNEL; pub const WS_OPERATION_CONTEXT_PROPERTY_CONTRACT_DESCRIPTION = WS_OPERATION_CONTEXT_PROPERTY_ID.CONTRACT_DESCRIPTION; pub const WS_OPERATION_CONTEXT_PROPERTY_HOST_USER_STATE = WS_OPERATION_CONTEXT_PROPERTY_ID.HOST_USER_STATE; pub const WS_OPERATION_CONTEXT_PROPERTY_CHANNEL_USER_STATE = WS_OPERATION_CONTEXT_PROPERTY_ID.CHANNEL_USER_STATE; pub const WS_OPERATION_CONTEXT_PROPERTY_INPUT_MESSAGE = WS_OPERATION_CONTEXT_PROPERTY_ID.INPUT_MESSAGE; pub const WS_OPERATION_CONTEXT_PROPERTY_OUTPUT_MESSAGE = WS_OPERATION_CONTEXT_PROPERTY_ID.OUTPUT_MESSAGE; pub const WS_OPERATION_CONTEXT_PROPERTY_HEAP = WS_OPERATION_CONTEXT_PROPERTY_ID.HEAP; pub const WS_OPERATION_CONTEXT_PROPERTY_LISTENER = WS_OPERATION_CONTEXT_PROPERTY_ID.LISTENER; pub const WS_OPERATION_CONTEXT_PROPERTY_ENDPOINT_ADDRESS = WS_OPERATION_CONTEXT_PROPERTY_ID.ENDPOINT_ADDRESS; pub const WS_ENDPOINT_IDENTITY_TYPE = enum(i32) { DNS_ENDPOINT_IDENTITY_TYPE = 1, UPN_ENDPOINT_IDENTITY_TYPE = 2, SPN_ENDPOINT_IDENTITY_TYPE = 3, RSA_ENDPOINT_IDENTITY_TYPE = 4, CERT_ENDPOINT_IDENTITY_TYPE = 5, UNKNOWN_ENDPOINT_IDENTITY_TYPE = 6, }; pub const WS_DNS_ENDPOINT_IDENTITY_TYPE = WS_ENDPOINT_IDENTITY_TYPE.DNS_ENDPOINT_IDENTITY_TYPE; pub const WS_UPN_ENDPOINT_IDENTITY_TYPE = WS_ENDPOINT_IDENTITY_TYPE.UPN_ENDPOINT_IDENTITY_TYPE; pub const WS_SPN_ENDPOINT_IDENTITY_TYPE = WS_ENDPOINT_IDENTITY_TYPE.SPN_ENDPOINT_IDENTITY_TYPE; pub const WS_RSA_ENDPOINT_IDENTITY_TYPE = WS_ENDPOINT_IDENTITY_TYPE.RSA_ENDPOINT_IDENTITY_TYPE; pub const WS_CERT_ENDPOINT_IDENTITY_TYPE = WS_ENDPOINT_IDENTITY_TYPE.CERT_ENDPOINT_IDENTITY_TYPE; pub const WS_UNKNOWN_ENDPOINT_IDENTITY_TYPE = WS_ENDPOINT_IDENTITY_TYPE.UNKNOWN_ENDPOINT_IDENTITY_TYPE; pub const WS_ENDPOINT_ADDRESS_EXTENSION_TYPE = enum(i32) { S = 1, }; pub const WS_ENDPOINT_ADDRESS_EXTENSION_METADATA_ADDRESS = WS_ENDPOINT_ADDRESS_EXTENSION_TYPE.S; pub const WS_ERROR_PROPERTY_ID = enum(i32) { STRING_COUNT = 0, ORIGINAL_ERROR_CODE = 1, LANGID = 2, }; pub const WS_ERROR_PROPERTY_STRING_COUNT = WS_ERROR_PROPERTY_ID.STRING_COUNT; pub const WS_ERROR_PROPERTY_ORIGINAL_ERROR_CODE = WS_ERROR_PROPERTY_ID.ORIGINAL_ERROR_CODE; pub const WS_ERROR_PROPERTY_LANGID = WS_ERROR_PROPERTY_ID.LANGID; pub const WS_EXCEPTION_CODE = enum(i32) { USAGE_FAILURE = -1069744128, INTERNAL_FAILURE = -1069744127, }; pub const WS_EXCEPTION_CODE_USAGE_FAILURE = WS_EXCEPTION_CODE.USAGE_FAILURE; pub const WS_EXCEPTION_CODE_INTERNAL_FAILURE = WS_EXCEPTION_CODE.INTERNAL_FAILURE; pub const WS_FAULT_ERROR_PROPERTY_ID = enum(i32) { FAULT = 0, ACTION = 1, HEADER = 2, }; pub const WS_FAULT_ERROR_PROPERTY_FAULT = WS_FAULT_ERROR_PROPERTY_ID.FAULT; pub const WS_FAULT_ERROR_PROPERTY_ACTION = WS_FAULT_ERROR_PROPERTY_ID.ACTION; pub const WS_FAULT_ERROR_PROPERTY_HEADER = WS_FAULT_ERROR_PROPERTY_ID.HEADER; pub const WS_FAULT_DISCLOSURE = enum(i32) { MINIMAL_FAULT_DISCLOSURE = 0, FULL_FAULT_DISCLOSURE = 1, }; pub const WS_MINIMAL_FAULT_DISCLOSURE = WS_FAULT_DISCLOSURE.MINIMAL_FAULT_DISCLOSURE; pub const WS_FULL_FAULT_DISCLOSURE = WS_FAULT_DISCLOSURE.FULL_FAULT_DISCLOSURE; pub const WS_HEAP_PROPERTY_ID = enum(i32) { MAX_SIZE = 0, TRIM_SIZE = 1, REQUESTED_SIZE = 2, ACTUAL_SIZE = 3, }; pub const WS_HEAP_PROPERTY_MAX_SIZE = WS_HEAP_PROPERTY_ID.MAX_SIZE; pub const WS_HEAP_PROPERTY_TRIM_SIZE = WS_HEAP_PROPERTY_ID.TRIM_SIZE; pub const WS_HEAP_PROPERTY_REQUESTED_SIZE = WS_HEAP_PROPERTY_ID.REQUESTED_SIZE; pub const WS_HEAP_PROPERTY_ACTUAL_SIZE = WS_HEAP_PROPERTY_ID.ACTUAL_SIZE; pub const WS_LISTENER_STATE = enum(i32) { CREATED = 0, OPENING = 1, OPEN = 2, FAULTED = 3, CLOSING = 4, CLOSED = 5, }; pub const WS_LISTENER_STATE_CREATED = WS_LISTENER_STATE.CREATED; pub const WS_LISTENER_STATE_OPENING = WS_LISTENER_STATE.OPENING; pub const WS_LISTENER_STATE_OPEN = WS_LISTENER_STATE.OPEN; pub const WS_LISTENER_STATE_FAULTED = WS_LISTENER_STATE.FAULTED; pub const WS_LISTENER_STATE_CLOSING = WS_LISTENER_STATE.CLOSING; pub const WS_LISTENER_STATE_CLOSED = WS_LISTENER_STATE.CLOSED; pub const WS_LISTENER_PROPERTY_ID = enum(i32) { LISTEN_BACKLOG = 0, IP_VERSION = 1, STATE = 2, ASYNC_CALLBACK_MODEL = 3, CHANNEL_TYPE = 4, CHANNEL_BINDING = 5, CONNECT_TIMEOUT = 6, IS_MULTICAST = 7, MULTICAST_INTERFACES = 8, MULTICAST_LOOPBACK = 9, CLOSE_TIMEOUT = 10, TO_HEADER_MATCHING_OPTIONS = 11, TRANSPORT_URL_MATCHING_OPTIONS = 12, CUSTOM_LISTENER_CALLBACKS = 13, CUSTOM_LISTENER_PARAMETERS = 14, CUSTOM_LISTENER_INSTANCE = 15, DISALLOWED_USER_AGENT = 16, }; pub const WS_LISTENER_PROPERTY_LISTEN_BACKLOG = WS_LISTENER_PROPERTY_ID.LISTEN_BACKLOG; pub const WS_LISTENER_PROPERTY_IP_VERSION = WS_LISTENER_PROPERTY_ID.IP_VERSION; pub const WS_LISTENER_PROPERTY_STATE = WS_LISTENER_PROPERTY_ID.STATE; pub const WS_LISTENER_PROPERTY_ASYNC_CALLBACK_MODEL = WS_LISTENER_PROPERTY_ID.ASYNC_CALLBACK_MODEL; pub const WS_LISTENER_PROPERTY_CHANNEL_TYPE = WS_LISTENER_PROPERTY_ID.CHANNEL_TYPE; pub const WS_LISTENER_PROPERTY_CHANNEL_BINDING = WS_LISTENER_PROPERTY_ID.CHANNEL_BINDING; pub const WS_LISTENER_PROPERTY_CONNECT_TIMEOUT = WS_LISTENER_PROPERTY_ID.CONNECT_TIMEOUT; pub const WS_LISTENER_PROPERTY_IS_MULTICAST = WS_LISTENER_PROPERTY_ID.IS_MULTICAST; pub const WS_LISTENER_PROPERTY_MULTICAST_INTERFACES = WS_LISTENER_PROPERTY_ID.MULTICAST_INTERFACES; pub const WS_LISTENER_PROPERTY_MULTICAST_LOOPBACK = WS_LISTENER_PROPERTY_ID.MULTICAST_LOOPBACK; pub const WS_LISTENER_PROPERTY_CLOSE_TIMEOUT = WS_LISTENER_PROPERTY_ID.CLOSE_TIMEOUT; pub const WS_LISTENER_PROPERTY_TO_HEADER_MATCHING_OPTIONS = WS_LISTENER_PROPERTY_ID.TO_HEADER_MATCHING_OPTIONS; pub const WS_LISTENER_PROPERTY_TRANSPORT_URL_MATCHING_OPTIONS = WS_LISTENER_PROPERTY_ID.TRANSPORT_URL_MATCHING_OPTIONS; pub const WS_LISTENER_PROPERTY_CUSTOM_LISTENER_CALLBACKS = WS_LISTENER_PROPERTY_ID.CUSTOM_LISTENER_CALLBACKS; pub const WS_LISTENER_PROPERTY_CUSTOM_LISTENER_PARAMETERS = WS_LISTENER_PROPERTY_ID.CUSTOM_LISTENER_PARAMETERS; pub const WS_LISTENER_PROPERTY_CUSTOM_LISTENER_INSTANCE = WS_LISTENER_PROPERTY_ID.CUSTOM_LISTENER_INSTANCE; pub const WS_LISTENER_PROPERTY_DISALLOWED_USER_AGENT = WS_LISTENER_PROPERTY_ID.DISALLOWED_USER_AGENT; pub const WS_IP_VERSION = enum(i32) { @"4" = 1, @"6" = 2, AUTO = 3, }; pub const WS_IP_VERSION_4 = WS_IP_VERSION.@"4"; pub const WS_IP_VERSION_6 = WS_IP_VERSION.@"6"; pub const WS_IP_VERSION_AUTO = WS_IP_VERSION.AUTO; pub const WS_MESSAGE_STATE = enum(i32) { EMPTY = 1, INITIALIZED = 2, READING = 3, WRITING = 4, DONE = 5, }; pub const WS_MESSAGE_STATE_EMPTY = WS_MESSAGE_STATE.EMPTY; pub const WS_MESSAGE_STATE_INITIALIZED = WS_MESSAGE_STATE.INITIALIZED; pub const WS_MESSAGE_STATE_READING = WS_MESSAGE_STATE.READING; pub const WS_MESSAGE_STATE_WRITING = WS_MESSAGE_STATE.WRITING; pub const WS_MESSAGE_STATE_DONE = WS_MESSAGE_STATE.DONE; pub const WS_MESSAGE_INITIALIZATION = enum(i32) { BLANK_MESSAGE = 0, DUPLICATE_MESSAGE = 1, REQUEST_MESSAGE = 2, REPLY_MESSAGE = 3, FAULT_MESSAGE = 4, }; pub const WS_BLANK_MESSAGE = WS_MESSAGE_INITIALIZATION.BLANK_MESSAGE; pub const WS_DUPLICATE_MESSAGE = WS_MESSAGE_INITIALIZATION.DUPLICATE_MESSAGE; pub const WS_REQUEST_MESSAGE = WS_MESSAGE_INITIALIZATION.REQUEST_MESSAGE; pub const WS_REPLY_MESSAGE = WS_MESSAGE_INITIALIZATION.REPLY_MESSAGE; pub const WS_FAULT_MESSAGE = WS_MESSAGE_INITIALIZATION.FAULT_MESSAGE; pub const WS_REPEATING_HEADER_OPTION = enum(i32) { REPEATING_HEADER = 1, SINGLETON_HEADER = 2, }; pub const WS_REPEATING_HEADER = WS_REPEATING_HEADER_OPTION.REPEATING_HEADER; pub const WS_SINGLETON_HEADER = WS_REPEATING_HEADER_OPTION.SINGLETON_HEADER; pub const WS_HEADER_TYPE = enum(i32) { ACTION_HEADER = 1, TO_HEADER = 2, MESSAGE_ID_HEADER = 3, RELATES_TO_HEADER = 4, FROM_HEADER = 5, REPLY_TO_HEADER = 6, FAULT_TO_HEADER = 7, }; pub const WS_ACTION_HEADER = WS_HEADER_TYPE.ACTION_HEADER; pub const WS_TO_HEADER = WS_HEADER_TYPE.TO_HEADER; pub const WS_MESSAGE_ID_HEADER = WS_HEADER_TYPE.MESSAGE_ID_HEADER; pub const WS_RELATES_TO_HEADER = WS_HEADER_TYPE.RELATES_TO_HEADER; pub const WS_FROM_HEADER = WS_HEADER_TYPE.FROM_HEADER; pub const WS_REPLY_TO_HEADER = WS_HEADER_TYPE.REPLY_TO_HEADER; pub const WS_FAULT_TO_HEADER = WS_HEADER_TYPE.FAULT_TO_HEADER; pub const WS_ADDRESSING_VERSION = enum(i32) { @"0_9" = 1, @"1_0" = 2, TRANSPORT = 3, }; pub const WS_ADDRESSING_VERSION_0_9 = WS_ADDRESSING_VERSION.@"0_9"; pub const WS_ADDRESSING_VERSION_1_0 = WS_ADDRESSING_VERSION.@"1_0"; pub const WS_ADDRESSING_VERSION_TRANSPORT = WS_ADDRESSING_VERSION.TRANSPORT; pub const WS_ENVELOPE_VERSION = enum(i32) { SOAP_1_1 = 1, SOAP_1_2 = 2, NONE = 3, }; pub const WS_ENVELOPE_VERSION_SOAP_1_1 = WS_ENVELOPE_VERSION.SOAP_1_1; pub const WS_ENVELOPE_VERSION_SOAP_1_2 = WS_ENVELOPE_VERSION.SOAP_1_2; pub const WS_ENVELOPE_VERSION_NONE = WS_ENVELOPE_VERSION.NONE; pub const WS_MESSAGE_PROPERTY_ID = enum(i32) { STATE = 0, HEAP = 1, ENVELOPE_VERSION = 2, ADDRESSING_VERSION = 3, HEADER_BUFFER = 4, HEADER_POSITION = 5, BODY_READER = 6, BODY_WRITER = 7, IS_ADDRESSED = 8, HEAP_PROPERTIES = 9, XML_READER_PROPERTIES = 10, XML_WRITER_PROPERTIES = 11, IS_FAULT = 12, MAX_PROCESSED_HEADERS = 13, USERNAME = 14, ENCODED_CERT = 15, TRANSPORT_SECURITY_WINDOWS_TOKEN = 16, HTTP_HEADER_AUTH_WINDOWS_TOKEN = 17, MESSAGE_SECURITY_WINDOWS_TOKEN = 18, SAML_ASSERTION = 19, SECURITY_CONTEXT = 20, PROTECTION_LEVEL = 21, }; pub const WS_MESSAGE_PROPERTY_STATE = WS_MESSAGE_PROPERTY_ID.STATE; pub const WS_MESSAGE_PROPERTY_HEAP = WS_MESSAGE_PROPERTY_ID.HEAP; pub const WS_MESSAGE_PROPERTY_ENVELOPE_VERSION = WS_MESSAGE_PROPERTY_ID.ENVELOPE_VERSION; pub const WS_MESSAGE_PROPERTY_ADDRESSING_VERSION = WS_MESSAGE_PROPERTY_ID.ADDRESSING_VERSION; pub const WS_MESSAGE_PROPERTY_HEADER_BUFFER = WS_MESSAGE_PROPERTY_ID.HEADER_BUFFER; pub const WS_MESSAGE_PROPERTY_HEADER_POSITION = WS_MESSAGE_PROPERTY_ID.HEADER_POSITION; pub const WS_MESSAGE_PROPERTY_BODY_READER = WS_MESSAGE_PROPERTY_ID.BODY_READER; pub const WS_MESSAGE_PROPERTY_BODY_WRITER = WS_MESSAGE_PROPERTY_ID.BODY_WRITER; pub const WS_MESSAGE_PROPERTY_IS_ADDRESSED = WS_MESSAGE_PROPERTY_ID.IS_ADDRESSED; pub const WS_MESSAGE_PROPERTY_HEAP_PROPERTIES = WS_MESSAGE_PROPERTY_ID.HEAP_PROPERTIES; pub const WS_MESSAGE_PROPERTY_XML_READER_PROPERTIES = WS_MESSAGE_PROPERTY_ID.XML_READER_PROPERTIES; pub const WS_MESSAGE_PROPERTY_XML_WRITER_PROPERTIES = WS_MESSAGE_PROPERTY_ID.XML_WRITER_PROPERTIES; pub const WS_MESSAGE_PROPERTY_IS_FAULT = WS_MESSAGE_PROPERTY_ID.IS_FAULT; pub const WS_MESSAGE_PROPERTY_MAX_PROCESSED_HEADERS = WS_MESSAGE_PROPERTY_ID.MAX_PROCESSED_HEADERS; pub const WS_MESSAGE_PROPERTY_USERNAME = WS_MESSAGE_PROPERTY_ID.USERNAME; pub const WS_MESSAGE_PROPERTY_ENCODED_CERT = WS_MESSAGE_PROPERTY_ID.ENCODED_CERT; pub const WS_MESSAGE_PROPERTY_TRANSPORT_SECURITY_WINDOWS_TOKEN = WS_MESSAGE_PROPERTY_ID.TRANSPORT_SECURITY_WINDOWS_TOKEN; pub const WS_MESSAGE_PROPERTY_HTTP_HEADER_AUTH_WINDOWS_TOKEN = WS_MESSAGE_PROPERTY_ID.HTTP_HEADER_AUTH_WINDOWS_TOKEN; pub const WS_MESSAGE_PROPERTY_MESSAGE_SECURITY_WINDOWS_TOKEN = WS_MESSAGE_PROPERTY_ID.MESSAGE_SECURITY_WINDOWS_TOKEN; pub const WS_MESSAGE_PROPERTY_SAML_ASSERTION = WS_MESSAGE_PROPERTY_ID.SAML_ASSERTION; pub const WS_MESSAGE_PROPERTY_SECURITY_CONTEXT = WS_MESSAGE_PROPERTY_ID.SECURITY_CONTEXT; pub const WS_MESSAGE_PROPERTY_PROTECTION_LEVEL = WS_MESSAGE_PROPERTY_ID.PROTECTION_LEVEL; pub const WS_SECURITY_BINDING_TYPE = enum(i32) { SSL_TRANSPORT_SECURITY_BINDING_TYPE = 1, TCP_SSPI_TRANSPORT_SECURITY_BINDING_TYPE = 2, HTTP_HEADER_AUTH_SECURITY_BINDING_TYPE = 3, USERNAME_MESSAGE_SECURITY_BINDING_TYPE = 4, KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_TYPE = 5, XML_TOKEN_MESSAGE_SECURITY_BINDING_TYPE = 6, SAML_MESSAGE_SECURITY_BINDING_TYPE = 7, SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_TYPE = 8, NAMEDPIPE_SSPI_TRANSPORT_SECURITY_BINDING_TYPE = 9, }; pub const WS_SSL_TRANSPORT_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.SSL_TRANSPORT_SECURITY_BINDING_TYPE; pub const WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.TCP_SSPI_TRANSPORT_SECURITY_BINDING_TYPE; pub const WS_HTTP_HEADER_AUTH_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.HTTP_HEADER_AUTH_SECURITY_BINDING_TYPE; pub const WS_USERNAME_MESSAGE_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.USERNAME_MESSAGE_SECURITY_BINDING_TYPE; pub const WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_TYPE; pub const WS_XML_TOKEN_MESSAGE_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.XML_TOKEN_MESSAGE_SECURITY_BINDING_TYPE; pub const WS_SAML_MESSAGE_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.SAML_MESSAGE_SECURITY_BINDING_TYPE; pub const WS_SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_TYPE; pub const WS_NAMEDPIPE_SSPI_TRANSPORT_SECURITY_BINDING_TYPE = WS_SECURITY_BINDING_TYPE.NAMEDPIPE_SSPI_TRANSPORT_SECURITY_BINDING_TYPE; pub const WS_HTTP_HEADER_AUTH_TARGET = enum(i32) { SERVICE = 1, PROXY = 2, }; pub const WS_HTTP_HEADER_AUTH_TARGET_SERVICE = WS_HTTP_HEADER_AUTH_TARGET.SERVICE; pub const WS_HTTP_HEADER_AUTH_TARGET_PROXY = WS_HTTP_HEADER_AUTH_TARGET.PROXY; pub const WS_WINDOWS_INTEGRATED_AUTH_PACKAGE = enum(i32) { KERBEROS = 1, NTLM = 2, SPNEGO = 3, }; pub const WS_WINDOWS_INTEGRATED_AUTH_PACKAGE_KERBEROS = WS_WINDOWS_INTEGRATED_AUTH_PACKAGE.KERBEROS; pub const WS_WINDOWS_INTEGRATED_AUTH_PACKAGE_NTLM = WS_WINDOWS_INTEGRATED_AUTH_PACKAGE.NTLM; pub const WS_WINDOWS_INTEGRATED_AUTH_PACKAGE_SPNEGO = WS_WINDOWS_INTEGRATED_AUTH_PACKAGE.SPNEGO; pub const WS_SECURITY_HEADER_VERSION = enum(i32) { @"0" = 1, @"1" = 2, }; pub const WS_SECURITY_HEADER_VERSION_1_0 = WS_SECURITY_HEADER_VERSION.@"0"; pub const WS_SECURITY_HEADER_VERSION_1_1 = WS_SECURITY_HEADER_VERSION.@"1"; pub const WS_TRUST_VERSION = enum(i32) { FEBRUARY_2005 = 1, @"1_3" = 2, }; pub const WS_TRUST_VERSION_FEBRUARY_2005 = WS_TRUST_VERSION.FEBRUARY_2005; pub const WS_TRUST_VERSION_1_3 = WS_TRUST_VERSION.@"1_3"; pub const WS_REQUEST_SECURITY_TOKEN_ACTION = enum(i32) { ISSUE = 1, NEW_CONTEXT = 2, RENEW_CONTEXT = 3, }; pub const WS_REQUEST_SECURITY_TOKEN_ACTION_ISSUE = WS_REQUEST_SECURITY_TOKEN_ACTION.ISSUE; pub const WS_REQUEST_SECURITY_TOKEN_ACTION_NEW_CONTEXT = WS_REQUEST_SECURITY_TOKEN_ACTION.NEW_CONTEXT; pub const WS_REQUEST_SECURITY_TOKEN_ACTION_RENEW_CONTEXT = WS_REQUEST_SECURITY_TOKEN_ACTION.RENEW_CONTEXT; pub const WS_SECURE_CONVERSATION_VERSION = enum(i32) { FEBRUARY_2005 = 1, @"1_3" = 2, }; pub const WS_SECURE_CONVERSATION_VERSION_FEBRUARY_2005 = WS_SECURE_CONVERSATION_VERSION.FEBRUARY_2005; pub const WS_SECURE_CONVERSATION_VERSION_1_3 = WS_SECURE_CONVERSATION_VERSION.@"1_3"; pub const WS_SECURE_PROTOCOL = enum(i32) { SSL2 = 1, SSL3 = 2, TLS1_0 = 4, TLS1_1 = 8, TLS1_2 = 16, }; pub const WS_SECURE_PROTOCOL_SSL2 = WS_SECURE_PROTOCOL.SSL2; pub const WS_SECURE_PROTOCOL_SSL3 = WS_SECURE_PROTOCOL.SSL3; pub const WS_SECURE_PROTOCOL_TLS1_0 = WS_SECURE_PROTOCOL.TLS1_0; pub const WS_SECURE_PROTOCOL_TLS1_1 = WS_SECURE_PROTOCOL.TLS1_1; pub const WS_SECURE_PROTOCOL_TLS1_2 = WS_SECURE_PROTOCOL.TLS1_2; pub const WS_SECURITY_TIMESTAMP_USAGE = enum(i32) { ALWAYS = 1, NEVER = 2, REQUESTS_ONLY = 3, }; pub const WS_SECURITY_TIMESTAMP_USAGE_ALWAYS = WS_SECURITY_TIMESTAMP_USAGE.ALWAYS; pub const WS_SECURITY_TIMESTAMP_USAGE_NEVER = WS_SECURITY_TIMESTAMP_USAGE.NEVER; pub const WS_SECURITY_TIMESTAMP_USAGE_REQUESTS_ONLY = WS_SECURITY_TIMESTAMP_USAGE.REQUESTS_ONLY; pub const WS_SECURITY_HEADER_LAYOUT = enum(i32) { STRICT = 1, LAX = 2, LAX_WITH_TIMESTAMP_FIRST = 3, LAX_WITH_TIMESTAMP_LAST = 4, }; pub const WS_SECURITY_HEADER_LAYOUT_STRICT = WS_SECURITY_HEADER_LAYOUT.STRICT; pub const WS_SECURITY_HEADER_LAYOUT_LAX = WS_SECURITY_HEADER_LAYOUT.LAX; pub const WS_SECURITY_HEADER_LAYOUT_LAX_WITH_TIMESTAMP_FIRST = WS_SECURITY_HEADER_LAYOUT.LAX_WITH_TIMESTAMP_FIRST; pub const WS_SECURITY_HEADER_LAYOUT_LAX_WITH_TIMESTAMP_LAST = WS_SECURITY_HEADER_LAYOUT.LAX_WITH_TIMESTAMP_LAST; pub const WS_SECURITY_ALGORITHM_PROPERTY_ID = enum(i32) { _ }; pub const WS_SECURITY_ALGORITHM_ID = enum(i32) { DEFAULT = 0, CANONICALIZATION_EXCLUSIVE = 1, CANONICALIZATION_EXCLUSIVE_WITH_COMMENTS = 2, DIGEST_SHA1 = 3, DIGEST_SHA_256 = 4, DIGEST_SHA_384 = 5, DIGEST_SHA_512 = 6, SYMMETRIC_SIGNATURE_HMAC_SHA1 = 7, SYMMETRIC_SIGNATURE_HMAC_SHA_256 = 8, SYMMETRIC_SIGNATURE_HMAC_SHA_384 = 9, SYMMETRIC_SIGNATURE_HMAC_SHA_512 = 10, ASYMMETRIC_SIGNATURE_RSA_SHA1 = 11, ASYMMETRIC_SIGNATURE_DSA_SHA1 = 12, ASYMMETRIC_SIGNATURE_RSA_SHA_256 = 13, ASYMMETRIC_SIGNATURE_RSA_SHA_384 = 14, ASYMMETRIC_SIGNATURE_RSA_SHA_512 = 15, ASYMMETRIC_KEYWRAP_RSA_1_5 = 16, ASYMMETRIC_KEYWRAP_RSA_OAEP = 17, KEY_DERIVATION_P_SHA1 = 18, }; pub const WS_SECURITY_ALGORITHM_DEFAULT = WS_SECURITY_ALGORITHM_ID.DEFAULT; pub const WS_SECURITY_ALGORITHM_CANONICALIZATION_EXCLUSIVE = WS_SECURITY_ALGORITHM_ID.CANONICALIZATION_EXCLUSIVE; pub const WS_SECURITY_ALGORITHM_CANONICALIZATION_EXCLUSIVE_WITH_COMMENTS = WS_SECURITY_ALGORITHM_ID.CANONICALIZATION_EXCLUSIVE_WITH_COMMENTS; pub const WS_SECURITY_ALGORITHM_DIGEST_SHA1 = WS_SECURITY_ALGORITHM_ID.DIGEST_SHA1; pub const WS_SECURITY_ALGORITHM_DIGEST_SHA_256 = WS_SECURITY_ALGORITHM_ID.DIGEST_SHA_256; pub const WS_SECURITY_ALGORITHM_DIGEST_SHA_384 = WS_SECURITY_ALGORITHM_ID.DIGEST_SHA_384; pub const WS_SECURITY_ALGORITHM_DIGEST_SHA_512 = WS_SECURITY_ALGORITHM_ID.DIGEST_SHA_512; pub const WS_SECURITY_ALGORITHM_SYMMETRIC_SIGNATURE_HMAC_SHA1 = WS_SECURITY_ALGORITHM_ID.SYMMETRIC_SIGNATURE_HMAC_SHA1; pub const WS_SECURITY_ALGORITHM_SYMMETRIC_SIGNATURE_HMAC_SHA_256 = WS_SECURITY_ALGORITHM_ID.SYMMETRIC_SIGNATURE_HMAC_SHA_256; pub const WS_SECURITY_ALGORITHM_SYMMETRIC_SIGNATURE_HMAC_SHA_384 = WS_SECURITY_ALGORITHM_ID.SYMMETRIC_SIGNATURE_HMAC_SHA_384; pub const WS_SECURITY_ALGORITHM_SYMMETRIC_SIGNATURE_HMAC_SHA_512 = WS_SECURITY_ALGORITHM_ID.SYMMETRIC_SIGNATURE_HMAC_SHA_512; pub const WS_SECURITY_ALGORITHM_ASYMMETRIC_SIGNATURE_RSA_SHA1 = WS_SECURITY_ALGORITHM_ID.ASYMMETRIC_SIGNATURE_RSA_SHA1; pub const WS_SECURITY_ALGORITHM_ASYMMETRIC_SIGNATURE_DSA_SHA1 = WS_SECURITY_ALGORITHM_ID.ASYMMETRIC_SIGNATURE_DSA_SHA1; pub const WS_SECURITY_ALGORITHM_ASYMMETRIC_SIGNATURE_RSA_SHA_256 = WS_SECURITY_ALGORITHM_ID.ASYMMETRIC_SIGNATURE_RSA_SHA_256; pub const WS_SECURITY_ALGORITHM_ASYMMETRIC_SIGNATURE_RSA_SHA_384 = WS_SECURITY_ALGORITHM_ID.ASYMMETRIC_SIGNATURE_RSA_SHA_384; pub const WS_SECURITY_ALGORITHM_ASYMMETRIC_SIGNATURE_RSA_SHA_512 = WS_SECURITY_ALGORITHM_ID.ASYMMETRIC_SIGNATURE_RSA_SHA_512; pub const WS_SECURITY_ALGORITHM_ASYMMETRIC_KEYWRAP_RSA_1_5 = WS_SECURITY_ALGORITHM_ID.ASYMMETRIC_KEYWRAP_RSA_1_5; pub const WS_SECURITY_ALGORITHM_ASYMMETRIC_KEYWRAP_RSA_OAEP = WS_SECURITY_ALGORITHM_ID.ASYMMETRIC_KEYWRAP_RSA_OAEP; pub const WS_SECURITY_ALGORITHM_KEY_DERIVATION_P_SHA1 = WS_SECURITY_ALGORITHM_ID.KEY_DERIVATION_P_SHA1; pub const WS_PROTECTION_LEVEL = enum(i32) { NONE = 1, SIGN = 2, SIGN_AND_ENCRYPT = 3, }; pub const WS_PROTECTION_LEVEL_NONE = WS_PROTECTION_LEVEL.NONE; pub const WS_PROTECTION_LEVEL_SIGN = WS_PROTECTION_LEVEL.SIGN; pub const WS_PROTECTION_LEVEL_SIGN_AND_ENCRYPT = WS_PROTECTION_LEVEL.SIGN_AND_ENCRYPT; pub const WS_SECURITY_PROPERTY_ID = enum(i32) { TRANSPORT_PROTECTION_LEVEL = 1, ALGORITHM_SUITE = 2, ALGORITHM_SUITE_NAME = 3, MAX_ALLOWED_LATENCY = 4, TIMESTAMP_VALIDITY_DURATION = 5, MAX_ALLOWED_CLOCK_SKEW = 6, TIMESTAMP_USAGE = 7, SECURITY_HEADER_LAYOUT = 8, SECURITY_HEADER_VERSION = 9, EXTENDED_PROTECTION_POLICY = 10, EXTENDED_PROTECTION_SCENARIO = 11, SERVICE_IDENTITIES = 12, }; pub const WS_SECURITY_PROPERTY_TRANSPORT_PROTECTION_LEVEL = WS_SECURITY_PROPERTY_ID.TRANSPORT_PROTECTION_LEVEL; pub const WS_SECURITY_PROPERTY_ALGORITHM_SUITE = WS_SECURITY_PROPERTY_ID.ALGORITHM_SUITE; pub const WS_SECURITY_PROPERTY_ALGORITHM_SUITE_NAME = WS_SECURITY_PROPERTY_ID.ALGORITHM_SUITE_NAME; pub const WS_SECURITY_PROPERTY_MAX_ALLOWED_LATENCY = WS_SECURITY_PROPERTY_ID.MAX_ALLOWED_LATENCY; pub const WS_SECURITY_PROPERTY_TIMESTAMP_VALIDITY_DURATION = WS_SECURITY_PROPERTY_ID.TIMESTAMP_VALIDITY_DURATION; pub const WS_SECURITY_PROPERTY_MAX_ALLOWED_CLOCK_SKEW = WS_SECURITY_PROPERTY_ID.MAX_ALLOWED_CLOCK_SKEW; pub const WS_SECURITY_PROPERTY_TIMESTAMP_USAGE = WS_SECURITY_PROPERTY_ID.TIMESTAMP_USAGE; pub const WS_SECURITY_PROPERTY_SECURITY_HEADER_LAYOUT = WS_SECURITY_PROPERTY_ID.SECURITY_HEADER_LAYOUT; pub const WS_SECURITY_PROPERTY_SECURITY_HEADER_VERSION = WS_SECURITY_PROPERTY_ID.SECURITY_HEADER_VERSION; pub const WS_SECURITY_PROPERTY_EXTENDED_PROTECTION_POLICY = WS_SECURITY_PROPERTY_ID.EXTENDED_PROTECTION_POLICY; pub const WS_SECURITY_PROPERTY_EXTENDED_PROTECTION_SCENARIO = WS_SECURITY_PROPERTY_ID.EXTENDED_PROTECTION_SCENARIO; pub const WS_SECURITY_PROPERTY_SERVICE_IDENTITIES = WS_SECURITY_PROPERTY_ID.SERVICE_IDENTITIES; pub const WS_SECURITY_KEY_TYPE = enum(i32) { NONE = 1, SYMMETRIC = 2, ASYMMETRIC = 3, }; pub const WS_SECURITY_KEY_TYPE_NONE = WS_SECURITY_KEY_TYPE.NONE; pub const WS_SECURITY_KEY_TYPE_SYMMETRIC = WS_SECURITY_KEY_TYPE.SYMMETRIC; pub const WS_SECURITY_KEY_TYPE_ASYMMETRIC = WS_SECURITY_KEY_TYPE.ASYMMETRIC; pub const WS_SECURITY_ALGORITHM_SUITE_NAME = enum(i32) { @"256" = 1, @"192" = 2, @"128" = 3, @"256_RSA15" = 4, @"192_RSA15" = 5, @"128_RSA15" = 6, @"256_SHA256" = 7, @"192_SHA256" = 8, @"128_SHA256" = 9, @"256_SHA256_RSA15" = 10, @"192_SHA256_RSA15" = 11, @"128_SHA256_RSA15" = 12, }; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC256 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"256"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC192 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"192"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC128 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"128"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC256_RSA15 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"256_RSA15"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC192_RSA15 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"192_RSA15"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC128_RSA15 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"128_RSA15"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC256_SHA256 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"256_SHA256"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC192_SHA256 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"192_SHA256"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC128_SHA256 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"128_SHA256"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC256_SHA256_RSA15 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"256_SHA256_RSA15"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC192_SHA256_RSA15 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"192_SHA256_RSA15"; pub const WS_SECURITY_ALGORITHM_SUITE_NAME_BASIC128_SHA256_RSA15 = WS_SECURITY_ALGORITHM_SUITE_NAME.@"128_SHA256_RSA15"; pub const WS_SECURITY_TOKEN_REFERENCE_MODE = enum(i32) { LOCAL_ID = 1, XML_BUFFER = 2, CERT_THUMBPRINT = 3, SECURITY_CONTEXT_ID = 4, SAML_ASSERTION_ID = 5, }; pub const WS_SECURITY_TOKEN_REFERENCE_MODE_LOCAL_ID = WS_SECURITY_TOKEN_REFERENCE_MODE.LOCAL_ID; pub const WS_SECURITY_TOKEN_REFERENCE_MODE_XML_BUFFER = WS_SECURITY_TOKEN_REFERENCE_MODE.XML_BUFFER; pub const WS_SECURITY_TOKEN_REFERENCE_MODE_CERT_THUMBPRINT = WS_SECURITY_TOKEN_REFERENCE_MODE.CERT_THUMBPRINT; pub const WS_SECURITY_TOKEN_REFERENCE_MODE_SECURITY_CONTEXT_ID = WS_SECURITY_TOKEN_REFERENCE_MODE.SECURITY_CONTEXT_ID; pub const WS_SECURITY_TOKEN_REFERENCE_MODE_SAML_ASSERTION_ID = WS_SECURITY_TOKEN_REFERENCE_MODE.SAML_ASSERTION_ID; pub const WS_SECURITY_KEY_ENTROPY_MODE = enum(i32) { CLIENT_ONLY = 1, SERVER_ONLY = 2, COMBINED = 3, }; pub const WS_SECURITY_KEY_ENTROPY_MODE_CLIENT_ONLY = WS_SECURITY_KEY_ENTROPY_MODE.CLIENT_ONLY; pub const WS_SECURITY_KEY_ENTROPY_MODE_SERVER_ONLY = WS_SECURITY_KEY_ENTROPY_MODE.SERVER_ONLY; pub const WS_SECURITY_KEY_ENTROPY_MODE_COMBINED = WS_SECURITY_KEY_ENTROPY_MODE.COMBINED; pub const WS_EXTENDED_PROTECTION_POLICY = enum(i32) { NEVER = 1, WHEN_SUPPORTED = 2, ALWAYS = 3, }; pub const WS_EXTENDED_PROTECTION_POLICY_NEVER = WS_EXTENDED_PROTECTION_POLICY.NEVER; pub const WS_EXTENDED_PROTECTION_POLICY_WHEN_SUPPORTED = WS_EXTENDED_PROTECTION_POLICY.WHEN_SUPPORTED; pub const WS_EXTENDED_PROTECTION_POLICY_ALWAYS = WS_EXTENDED_PROTECTION_POLICY.ALWAYS; pub const WS_EXTENDED_PROTECTION_SCENARIO = enum(i32) { BOUND_SERVER = 1, TERMINATED_SSL = 2, }; pub const WS_EXTENDED_PROTECTION_SCENARIO_BOUND_SERVER = WS_EXTENDED_PROTECTION_SCENARIO.BOUND_SERVER; pub const WS_EXTENDED_PROTECTION_SCENARIO_TERMINATED_SSL = WS_EXTENDED_PROTECTION_SCENARIO.TERMINATED_SSL; pub const WS_SECURITY_BINDING_PROPERTY_ID = enum(i32) { REQUIRE_SSL_CLIENT_CERT = 1, WINDOWS_INTEGRATED_AUTH_PACKAGE = 2, REQUIRE_SERVER_AUTH = 3, ALLOW_ANONYMOUS_CLIENTS = 4, ALLOWED_IMPERSONATION_LEVEL = 5, HTTP_HEADER_AUTH_SCHEME = 6, HTTP_HEADER_AUTH_TARGET = 7, HTTP_HEADER_AUTH_BASIC_REALM = 8, HTTP_HEADER_AUTH_DIGEST_REALM = 9, HTTP_HEADER_AUTH_DIGEST_DOMAIN = 10, SECURITY_CONTEXT_KEY_SIZE = 11, SECURITY_CONTEXT_KEY_ENTROPY_MODE = 12, MESSAGE_PROPERTIES = 13, SECURITY_CONTEXT_MAX_PENDING_CONTEXTS = 14, SECURITY_CONTEXT_MAX_ACTIVE_CONTEXTS = 15, SECURE_CONVERSATION_VERSION = 16, SECURITY_CONTEXT_SUPPORT_RENEW = 17, SECURITY_CONTEXT_RENEWAL_INTERVAL = 18, SECURITY_CONTEXT_ROLLOVER_INTERVAL = 19, CERT_FAILURES_TO_IGNORE = 20, DISABLE_CERT_REVOCATION_CHECK = 21, DISALLOWED_SECURE_PROTOCOLS = 22, CERTIFICATE_VALIDATION_CALLBACK_CONTEXT = 23, }; pub const WS_SECURITY_BINDING_PROPERTY_REQUIRE_SSL_CLIENT_CERT = WS_SECURITY_BINDING_PROPERTY_ID.REQUIRE_SSL_CLIENT_CERT; pub const WS_SECURITY_BINDING_PROPERTY_WINDOWS_INTEGRATED_AUTH_PACKAGE = WS_SECURITY_BINDING_PROPERTY_ID.WINDOWS_INTEGRATED_AUTH_PACKAGE; pub const WS_SECURITY_BINDING_PROPERTY_REQUIRE_SERVER_AUTH = WS_SECURITY_BINDING_PROPERTY_ID.REQUIRE_SERVER_AUTH; pub const WS_SECURITY_BINDING_PROPERTY_ALLOW_ANONYMOUS_CLIENTS = WS_SECURITY_BINDING_PROPERTY_ID.ALLOW_ANONYMOUS_CLIENTS; pub const WS_SECURITY_BINDING_PROPERTY_ALLOWED_IMPERSONATION_LEVEL = WS_SECURITY_BINDING_PROPERTY_ID.ALLOWED_IMPERSONATION_LEVEL; pub const WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_SCHEME = WS_SECURITY_BINDING_PROPERTY_ID.HTTP_HEADER_AUTH_SCHEME; pub const WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_TARGET = WS_SECURITY_BINDING_PROPERTY_ID.HTTP_HEADER_AUTH_TARGET; pub const WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_BASIC_REALM = WS_SECURITY_BINDING_PROPERTY_ID.HTTP_HEADER_AUTH_BASIC_REALM; pub const WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_DIGEST_REALM = WS_SECURITY_BINDING_PROPERTY_ID.HTTP_HEADER_AUTH_DIGEST_REALM; pub const WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_DIGEST_DOMAIN = WS_SECURITY_BINDING_PROPERTY_ID.HTTP_HEADER_AUTH_DIGEST_DOMAIN; pub const WS_SECURITY_BINDING_PROPERTY_SECURITY_CONTEXT_KEY_SIZE = WS_SECURITY_BINDING_PROPERTY_ID.SECURITY_CONTEXT_KEY_SIZE; pub const WS_SECURITY_BINDING_PROPERTY_SECURITY_CONTEXT_KEY_ENTROPY_MODE = WS_SECURITY_BINDING_PROPERTY_ID.SECURITY_CONTEXT_KEY_ENTROPY_MODE; pub const WS_SECURITY_BINDING_PROPERTY_MESSAGE_PROPERTIES = WS_SECURITY_BINDING_PROPERTY_ID.MESSAGE_PROPERTIES; pub const WS_SECURITY_BINDING_PROPERTY_SECURITY_CONTEXT_MAX_PENDING_CONTEXTS = WS_SECURITY_BINDING_PROPERTY_ID.SECURITY_CONTEXT_MAX_PENDING_CONTEXTS; pub const WS_SECURITY_BINDING_PROPERTY_SECURITY_CONTEXT_MAX_ACTIVE_CONTEXTS = WS_SECURITY_BINDING_PROPERTY_ID.SECURITY_CONTEXT_MAX_ACTIVE_CONTEXTS; pub const WS_SECURITY_BINDING_PROPERTY_SECURE_CONVERSATION_VERSION = WS_SECURITY_BINDING_PROPERTY_ID.SECURE_CONVERSATION_VERSION; pub const WS_SECURITY_BINDING_PROPERTY_SECURITY_CONTEXT_SUPPORT_RENEW = WS_SECURITY_BINDING_PROPERTY_ID.SECURITY_CONTEXT_SUPPORT_RENEW; pub const WS_SECURITY_BINDING_PROPERTY_SECURITY_CONTEXT_RENEWAL_INTERVAL = WS_SECURITY_BINDING_PROPERTY_ID.SECURITY_CONTEXT_RENEWAL_INTERVAL; pub const WS_SECURITY_BINDING_PROPERTY_SECURITY_CONTEXT_ROLLOVER_INTERVAL = WS_SECURITY_BINDING_PROPERTY_ID.SECURITY_CONTEXT_ROLLOVER_INTERVAL; pub const WS_SECURITY_BINDING_PROPERTY_CERT_FAILURES_TO_IGNORE = WS_SECURITY_BINDING_PROPERTY_ID.CERT_FAILURES_TO_IGNORE; pub const WS_SECURITY_BINDING_PROPERTY_DISABLE_CERT_REVOCATION_CHECK = WS_SECURITY_BINDING_PROPERTY_ID.DISABLE_CERT_REVOCATION_CHECK; pub const WS_SECURITY_BINDING_PROPERTY_DISALLOWED_SECURE_PROTOCOLS = WS_SECURITY_BINDING_PROPERTY_ID.DISALLOWED_SECURE_PROTOCOLS; pub const WS_SECURITY_BINDING_PROPERTY_CERTIFICATE_VALIDATION_CALLBACK_CONTEXT = WS_SECURITY_BINDING_PROPERTY_ID.CERTIFICATE_VALIDATION_CALLBACK_CONTEXT; pub const WS_CERT_CREDENTIAL_TYPE = enum(i32) { SUBJECT_NAME_CERT_CREDENTIAL_TYPE = 1, THUMBPRINT_CERT_CREDENTIAL_TYPE = 2, CUSTOM_CERT_CREDENTIAL_TYPE = 3, }; pub const WS_SUBJECT_NAME_CERT_CREDENTIAL_TYPE = WS_CERT_CREDENTIAL_TYPE.SUBJECT_NAME_CERT_CREDENTIAL_TYPE; pub const WS_THUMBPRINT_CERT_CREDENTIAL_TYPE = WS_CERT_CREDENTIAL_TYPE.THUMBPRINT_CERT_CREDENTIAL_TYPE; pub const WS_CUSTOM_CERT_CREDENTIAL_TYPE = WS_CERT_CREDENTIAL_TYPE.CUSTOM_CERT_CREDENTIAL_TYPE; pub const WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE = enum(i32) { STRING_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE = 1, DEFAULT_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE = 2, OPAQUE_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE = 3, }; pub const WS_STRING_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE = WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE.STRING_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE; pub const WS_DEFAULT_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE = WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE.DEFAULT_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE; pub const WS_OPAQUE_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE = WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE.OPAQUE_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE; pub const WS_USERNAME_CREDENTIAL_TYPE = enum(i32) { E = 1, }; pub const WS_STRING_USERNAME_CREDENTIAL_TYPE = WS_USERNAME_CREDENTIAL_TYPE.E; pub const WS_SECURITY_TOKEN_PROPERTY_ID = enum(i32) { KEY_TYPE = 1, VALID_FROM_TIME = 2, VALID_TILL_TIME = 3, SERIALIZED_XML = 4, ATTACHED_REFERENCE_XML = 5, UNATTACHED_REFERENCE_XML = 6, SYMMETRIC_KEY = 7, }; pub const WS_SECURITY_TOKEN_PROPERTY_KEY_TYPE = WS_SECURITY_TOKEN_PROPERTY_ID.KEY_TYPE; pub const WS_SECURITY_TOKEN_PROPERTY_VALID_FROM_TIME = WS_SECURITY_TOKEN_PROPERTY_ID.VALID_FROM_TIME; pub const WS_SECURITY_TOKEN_PROPERTY_VALID_TILL_TIME = WS_SECURITY_TOKEN_PROPERTY_ID.VALID_TILL_TIME; pub const WS_SECURITY_TOKEN_PROPERTY_SERIALIZED_XML = WS_SECURITY_TOKEN_PROPERTY_ID.SERIALIZED_XML; pub const WS_SECURITY_TOKEN_PROPERTY_ATTACHED_REFERENCE_XML = WS_SECURITY_TOKEN_PROPERTY_ID.ATTACHED_REFERENCE_XML; pub const WS_SECURITY_TOKEN_PROPERTY_UNATTACHED_REFERENCE_XML = WS_SECURITY_TOKEN_PROPERTY_ID.UNATTACHED_REFERENCE_XML; pub const WS_SECURITY_TOKEN_PROPERTY_SYMMETRIC_KEY = WS_SECURITY_TOKEN_PROPERTY_ID.SYMMETRIC_KEY; pub const WS_SECURITY_KEY_HANDLE_TYPE = enum(i32) { RAW_SYMMETRIC_SECURITY_KEY_HANDLE_TYPE = 1, NCRYPT_ASYMMETRIC_SECURITY_KEY_HANDLE_TYPE = 2, CAPI_ASYMMETRIC_SECURITY_KEY_HANDLE_TYPE = 3, }; pub const WS_RAW_SYMMETRIC_SECURITY_KEY_HANDLE_TYPE = WS_SECURITY_KEY_HANDLE_TYPE.RAW_SYMMETRIC_SECURITY_KEY_HANDLE_TYPE; pub const WS_NCRYPT_ASYMMETRIC_SECURITY_KEY_HANDLE_TYPE = WS_SECURITY_KEY_HANDLE_TYPE.NCRYPT_ASYMMETRIC_SECURITY_KEY_HANDLE_TYPE; pub const WS_CAPI_ASYMMETRIC_SECURITY_KEY_HANDLE_TYPE = WS_SECURITY_KEY_HANDLE_TYPE.CAPI_ASYMMETRIC_SECURITY_KEY_HANDLE_TYPE; pub const WS_MESSAGE_SECURITY_USAGE = enum(i32) { E = 1, }; pub const WS_SUPPORTING_MESSAGE_SECURITY_USAGE = WS_MESSAGE_SECURITY_USAGE.E; pub const WS_SECURITY_CONTEXT_PROPERTY_ID = enum(i32) { IDENTIFIER = 1, USERNAME = 2, MESSAGE_SECURITY_WINDOWS_TOKEN = 3, SAML_ASSERTION = 4, }; pub const WS_SECURITY_CONTEXT_PROPERTY_IDENTIFIER = WS_SECURITY_CONTEXT_PROPERTY_ID.IDENTIFIER; pub const WS_SECURITY_CONTEXT_PROPERTY_USERNAME = WS_SECURITY_CONTEXT_PROPERTY_ID.USERNAME; pub const WS_SECURITY_CONTEXT_PROPERTY_MESSAGE_SECURITY_WINDOWS_TOKEN = WS_SECURITY_CONTEXT_PROPERTY_ID.MESSAGE_SECURITY_WINDOWS_TOKEN; pub const WS_SECURITY_CONTEXT_PROPERTY_SAML_ASSERTION = WS_SECURITY_CONTEXT_PROPERTY_ID.SAML_ASSERTION; pub const WS_XML_SECURITY_TOKEN_PROPERTY_ID = enum(i32) { ATTACHED_REFERENCE = 1, UNATTACHED_REFERENCE = 2, VALID_FROM_TIME = 3, VALID_TILL_TIME = 4, }; pub const WS_XML_SECURITY_TOKEN_PROPERTY_ATTACHED_REFERENCE = WS_XML_SECURITY_TOKEN_PROPERTY_ID.ATTACHED_REFERENCE; pub const WS_XML_SECURITY_TOKEN_PROPERTY_UNATTACHED_REFERENCE = WS_XML_SECURITY_TOKEN_PROPERTY_ID.UNATTACHED_REFERENCE; pub const WS_XML_SECURITY_TOKEN_PROPERTY_VALID_FROM_TIME = WS_XML_SECURITY_TOKEN_PROPERTY_ID.VALID_FROM_TIME; pub const WS_XML_SECURITY_TOKEN_PROPERTY_VALID_TILL_TIME = WS_XML_SECURITY_TOKEN_PROPERTY_ID.VALID_TILL_TIME; pub const WS_SAML_AUTHENTICATOR_TYPE = enum(i32) { E = 1, }; pub const WS_CERT_SIGNED_SAML_AUTHENTICATOR_TYPE = WS_SAML_AUTHENTICATOR_TYPE.E; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID = enum(i32) { APPLIES_TO = 1, TRUST_VERSION = 2, SECURE_CONVERSATION_VERSION = 3, ISSUED_TOKEN_TYPE = 4, REQUEST_ACTION = 5, EXISTING_TOKEN = 6, ISSUED_TOKEN_KEY_TYPE = 7, ISSUED_TOKEN_KEY_SIZE = 8, ISSUED_TOKEN_KEY_ENTROPY = 9, LOCAL_REQUEST_PARAMETERS = 10, SERVICE_REQUEST_PARAMETERS = 11, MESSAGE_PROPERTIES = 12, BEARER_KEY_TYPE_VERSION = 13, }; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_APPLIES_TO = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.APPLIES_TO; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_TRUST_VERSION = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.TRUST_VERSION; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_SECURE_CONVERSATION_VERSION = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.SECURE_CONVERSATION_VERSION; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_ISSUED_TOKEN_TYPE = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.ISSUED_TOKEN_TYPE; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_REQUEST_ACTION = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.REQUEST_ACTION; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_EXISTING_TOKEN = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.EXISTING_TOKEN; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_ISSUED_TOKEN_KEY_TYPE = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.ISSUED_TOKEN_KEY_TYPE; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_ISSUED_TOKEN_KEY_SIZE = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.ISSUED_TOKEN_KEY_SIZE; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_ISSUED_TOKEN_KEY_ENTROPY = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.ISSUED_TOKEN_KEY_ENTROPY; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_LOCAL_REQUEST_PARAMETERS = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.LOCAL_REQUEST_PARAMETERS; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_SERVICE_REQUEST_PARAMETERS = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.SERVICE_REQUEST_PARAMETERS; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_MESSAGE_PROPERTIES = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.MESSAGE_PROPERTIES; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_BEARER_KEY_TYPE_VERSION = WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID.BEARER_KEY_TYPE_VERSION; pub const WS_SECURITY_BEARER_KEY_TYPE_VERSION = enum(i32) { ORIGINAL_SPECIFICATION = 1, ORIGINAL_SCHEMA = 2, ERRATA_01 = 3, }; pub const WS_SECURITY_BEARER_KEY_TYPE_VERSION_1_3_ORIGINAL_SPECIFICATION = WS_SECURITY_BEARER_KEY_TYPE_VERSION.ORIGINAL_SPECIFICATION; pub const WS_SECURITY_BEARER_KEY_TYPE_VERSION_1_3_ORIGINAL_SCHEMA = WS_SECURITY_BEARER_KEY_TYPE_VERSION.ORIGINAL_SCHEMA; pub const WS_SECURITY_BEARER_KEY_TYPE_VERSION_1_3_ERRATA_01 = WS_SECURITY_BEARER_KEY_TYPE_VERSION.ERRATA_01; pub const WS_TYPE = enum(i32) { BOOL_TYPE = 0, INT8_TYPE = 1, INT16_TYPE = 2, INT32_TYPE = 3, INT64_TYPE = 4, UINT8_TYPE = 5, UINT16_TYPE = 6, UINT32_TYPE = 7, UINT64_TYPE = 8, FLOAT_TYPE = 9, DOUBLE_TYPE = 10, DECIMAL_TYPE = 11, DATETIME_TYPE = 12, TIMESPAN_TYPE = 13, GUID_TYPE = 14, UNIQUE_ID_TYPE = 15, STRING_TYPE = 16, WSZ_TYPE = 17, BYTES_TYPE = 18, XML_STRING_TYPE = 19, XML_QNAME_TYPE = 20, XML_BUFFER_TYPE = 21, CHAR_ARRAY_TYPE = 22, UTF8_ARRAY_TYPE = 23, BYTE_ARRAY_TYPE = 24, DESCRIPTION_TYPE = 25, STRUCT_TYPE = 26, CUSTOM_TYPE = 27, ENDPOINT_ADDRESS_TYPE = 28, FAULT_TYPE = 29, VOID_TYPE = 30, ENUM_TYPE = 31, DURATION_TYPE = 32, UNION_TYPE = 33, ANY_ATTRIBUTES_TYPE = 34, }; pub const WS_BOOL_TYPE = WS_TYPE.BOOL_TYPE; pub const WS_INT8_TYPE = WS_TYPE.INT8_TYPE; pub const WS_INT16_TYPE = WS_TYPE.INT16_TYPE; pub const WS_INT32_TYPE = WS_TYPE.INT32_TYPE; pub const WS_INT64_TYPE = WS_TYPE.INT64_TYPE; pub const WS_UINT8_TYPE = WS_TYPE.UINT8_TYPE; pub const WS_UINT16_TYPE = WS_TYPE.UINT16_TYPE; pub const WS_UINT32_TYPE = WS_TYPE.UINT32_TYPE; pub const WS_UINT64_TYPE = WS_TYPE.UINT64_TYPE; pub const WS_FLOAT_TYPE = WS_TYPE.FLOAT_TYPE; pub const WS_DOUBLE_TYPE = WS_TYPE.DOUBLE_TYPE; pub const WS_DECIMAL_TYPE = WS_TYPE.DECIMAL_TYPE; pub const WS_DATETIME_TYPE = WS_TYPE.DATETIME_TYPE; pub const WS_TIMESPAN_TYPE = WS_TYPE.TIMESPAN_TYPE; pub const WS_GUID_TYPE = WS_TYPE.GUID_TYPE; pub const WS_UNIQUE_ID_TYPE = WS_TYPE.UNIQUE_ID_TYPE; pub const WS_STRING_TYPE = WS_TYPE.STRING_TYPE; pub const WS_WSZ_TYPE = WS_TYPE.WSZ_TYPE; pub const WS_BYTES_TYPE = WS_TYPE.BYTES_TYPE; pub const WS_XML_STRING_TYPE = WS_TYPE.XML_STRING_TYPE; pub const WS_XML_QNAME_TYPE = WS_TYPE.XML_QNAME_TYPE; pub const WS_XML_BUFFER_TYPE = WS_TYPE.XML_BUFFER_TYPE; pub const WS_CHAR_ARRAY_TYPE = WS_TYPE.CHAR_ARRAY_TYPE; pub const WS_UTF8_ARRAY_TYPE = WS_TYPE.UTF8_ARRAY_TYPE; pub const WS_BYTE_ARRAY_TYPE = WS_TYPE.BYTE_ARRAY_TYPE; pub const WS_DESCRIPTION_TYPE = WS_TYPE.DESCRIPTION_TYPE; pub const WS_STRUCT_TYPE = WS_TYPE.STRUCT_TYPE; pub const WS_CUSTOM_TYPE = WS_TYPE.CUSTOM_TYPE; pub const WS_ENDPOINT_ADDRESS_TYPE = WS_TYPE.ENDPOINT_ADDRESS_TYPE; pub const WS_FAULT_TYPE = WS_TYPE.FAULT_TYPE; pub const WS_VOID_TYPE = WS_TYPE.VOID_TYPE; pub const WS_ENUM_TYPE = WS_TYPE.ENUM_TYPE; pub const WS_DURATION_TYPE = WS_TYPE.DURATION_TYPE; pub const WS_UNION_TYPE = WS_TYPE.UNION_TYPE; pub const WS_ANY_ATTRIBUTES_TYPE = WS_TYPE.ANY_ATTRIBUTES_TYPE; pub const WS_FIELD_MAPPING = enum(i32) { TYPE_ATTRIBUTE_FIELD_MAPPING = 0, ATTRIBUTE_FIELD_MAPPING = 1, ELEMENT_FIELD_MAPPING = 2, REPEATING_ELEMENT_FIELD_MAPPING = 3, TEXT_FIELD_MAPPING = 4, NO_FIELD_MAPPING = 5, XML_ATTRIBUTE_FIELD_MAPPING = 6, ELEMENT_CHOICE_FIELD_MAPPING = 7, REPEATING_ELEMENT_CHOICE_FIELD_MAPPING = 8, ANY_ELEMENT_FIELD_MAPPING = 9, REPEATING_ANY_ELEMENT_FIELD_MAPPING = 10, ANY_CONTENT_FIELD_MAPPING = 11, ANY_ATTRIBUTES_FIELD_MAPPING = 12, }; pub const WS_TYPE_ATTRIBUTE_FIELD_MAPPING = WS_FIELD_MAPPING.TYPE_ATTRIBUTE_FIELD_MAPPING; pub const WS_ATTRIBUTE_FIELD_MAPPING = WS_FIELD_MAPPING.ATTRIBUTE_FIELD_MAPPING; pub const WS_ELEMENT_FIELD_MAPPING = WS_FIELD_MAPPING.ELEMENT_FIELD_MAPPING; pub const WS_REPEATING_ELEMENT_FIELD_MAPPING = WS_FIELD_MAPPING.REPEATING_ELEMENT_FIELD_MAPPING; pub const WS_TEXT_FIELD_MAPPING = WS_FIELD_MAPPING.TEXT_FIELD_MAPPING; pub const WS_NO_FIELD_MAPPING = WS_FIELD_MAPPING.NO_FIELD_MAPPING; pub const WS_XML_ATTRIBUTE_FIELD_MAPPING = WS_FIELD_MAPPING.XML_ATTRIBUTE_FIELD_MAPPING; pub const WS_ELEMENT_CHOICE_FIELD_MAPPING = WS_FIELD_MAPPING.ELEMENT_CHOICE_FIELD_MAPPING; pub const WS_REPEATING_ELEMENT_CHOICE_FIELD_MAPPING = WS_FIELD_MAPPING.REPEATING_ELEMENT_CHOICE_FIELD_MAPPING; pub const WS_ANY_ELEMENT_FIELD_MAPPING = WS_FIELD_MAPPING.ANY_ELEMENT_FIELD_MAPPING; pub const WS_REPEATING_ANY_ELEMENT_FIELD_MAPPING = WS_FIELD_MAPPING.REPEATING_ANY_ELEMENT_FIELD_MAPPING; pub const WS_ANY_CONTENT_FIELD_MAPPING = WS_FIELD_MAPPING.ANY_CONTENT_FIELD_MAPPING; pub const WS_ANY_ATTRIBUTES_FIELD_MAPPING = WS_FIELD_MAPPING.ANY_ATTRIBUTES_FIELD_MAPPING; pub const WS_TYPE_MAPPING = enum(i32) { ELEMENT_TYPE_MAPPING = 1, ATTRIBUTE_TYPE_MAPPING = 2, ELEMENT_CONTENT_TYPE_MAPPING = 3, ANY_ELEMENT_TYPE_MAPPING = 4, }; pub const WS_ELEMENT_TYPE_MAPPING = WS_TYPE_MAPPING.ELEMENT_TYPE_MAPPING; pub const WS_ATTRIBUTE_TYPE_MAPPING = WS_TYPE_MAPPING.ATTRIBUTE_TYPE_MAPPING; pub const WS_ELEMENT_CONTENT_TYPE_MAPPING = WS_TYPE_MAPPING.ELEMENT_CONTENT_TYPE_MAPPING; pub const WS_ANY_ELEMENT_TYPE_MAPPING = WS_TYPE_MAPPING.ANY_ELEMENT_TYPE_MAPPING; pub const WS_READ_OPTION = enum(i32) { REQUIRED_VALUE = 1, REQUIRED_POINTER = 2, OPTIONAL_POINTER = 3, NILLABLE_POINTER = 4, NILLABLE_VALUE = 5, }; pub const WS_READ_REQUIRED_VALUE = WS_READ_OPTION.REQUIRED_VALUE; pub const WS_READ_REQUIRED_POINTER = WS_READ_OPTION.REQUIRED_POINTER; pub const WS_READ_OPTIONAL_POINTER = WS_READ_OPTION.OPTIONAL_POINTER; pub const WS_READ_NILLABLE_POINTER = WS_READ_OPTION.NILLABLE_POINTER; pub const WS_READ_NILLABLE_VALUE = WS_READ_OPTION.NILLABLE_VALUE; pub const WS_WRITE_OPTION = enum(i32) { REQUIRED_VALUE = 1, REQUIRED_POINTER = 2, NILLABLE_VALUE = 3, NILLABLE_POINTER = 4, }; pub const WS_WRITE_REQUIRED_VALUE = WS_WRITE_OPTION.REQUIRED_VALUE; pub const WS_WRITE_REQUIRED_POINTER = WS_WRITE_OPTION.REQUIRED_POINTER; pub const WS_WRITE_NILLABLE_VALUE = WS_WRITE_OPTION.NILLABLE_VALUE; pub const WS_WRITE_NILLABLE_POINTER = WS_WRITE_OPTION.NILLABLE_POINTER; pub const WS_SERVICE_CANCEL_REASON = enum(i32) { HOST_ABORT = 0, CHANNEL_FAULTED = 1, }; pub const WS_SERVICE_HOST_ABORT = WS_SERVICE_CANCEL_REASON.HOST_ABORT; pub const WS_SERVICE_CHANNEL_FAULTED = WS_SERVICE_CANCEL_REASON.CHANNEL_FAULTED; pub const WS_OPERATION_STYLE = enum(i32) { NON_RPC_LITERAL_OPERATION = 0, RPC_LITERAL_OPERATION = 1, }; pub const WS_NON_RPC_LITERAL_OPERATION = WS_OPERATION_STYLE.NON_RPC_LITERAL_OPERATION; pub const WS_RPC_LITERAL_OPERATION = WS_OPERATION_STYLE.RPC_LITERAL_OPERATION; pub const WS_PARAMETER_TYPE = enum(i32) { NORMAL = 0, ARRAY = 1, ARRAY_COUNT = 2, MESSAGES = 3, }; pub const WS_PARAMETER_TYPE_NORMAL = WS_PARAMETER_TYPE.NORMAL; pub const WS_PARAMETER_TYPE_ARRAY = WS_PARAMETER_TYPE.ARRAY; pub const WS_PARAMETER_TYPE_ARRAY_COUNT = WS_PARAMETER_TYPE.ARRAY_COUNT; pub const WS_PARAMETER_TYPE_MESSAGES = WS_PARAMETER_TYPE.MESSAGES; pub const WS_SERVICE_ENDPOINT_PROPERTY_ID = enum(i32) { ACCEPT_CHANNEL_CALLBACK = 0, CLOSE_CHANNEL_CALLBACK = 1, MAX_ACCEPTING_CHANNELS = 2, MAX_CONCURRENCY = 3, BODY_HEAP_MAX_SIZE = 4, BODY_HEAP_TRIM_SIZE = 5, MESSAGE_PROPERTIES = 6, MAX_CALL_POOL_SIZE = 7, MAX_CHANNEL_POOL_SIZE = 8, LISTENER_PROPERTIES = 9, CHECK_MUST_UNDERSTAND = 10, METADATA_EXCHANGE_TYPE = 11, METADATA = 12, METADATA_EXCHANGE_URL_SUFFIX = 13, MAX_CHANNELS = 14, }; pub const WS_SERVICE_ENDPOINT_PROPERTY_ACCEPT_CHANNEL_CALLBACK = WS_SERVICE_ENDPOINT_PROPERTY_ID.ACCEPT_CHANNEL_CALLBACK; pub const WS_SERVICE_ENDPOINT_PROPERTY_CLOSE_CHANNEL_CALLBACK = WS_SERVICE_ENDPOINT_PROPERTY_ID.CLOSE_CHANNEL_CALLBACK; pub const WS_SERVICE_ENDPOINT_PROPERTY_MAX_ACCEPTING_CHANNELS = WS_SERVICE_ENDPOINT_PROPERTY_ID.MAX_ACCEPTING_CHANNELS; pub const WS_SERVICE_ENDPOINT_PROPERTY_MAX_CONCURRENCY = WS_SERVICE_ENDPOINT_PROPERTY_ID.MAX_CONCURRENCY; pub const WS_SERVICE_ENDPOINT_PROPERTY_BODY_HEAP_MAX_SIZE = WS_SERVICE_ENDPOINT_PROPERTY_ID.BODY_HEAP_MAX_SIZE; pub const WS_SERVICE_ENDPOINT_PROPERTY_BODY_HEAP_TRIM_SIZE = WS_SERVICE_ENDPOINT_PROPERTY_ID.BODY_HEAP_TRIM_SIZE; pub const WS_SERVICE_ENDPOINT_PROPERTY_MESSAGE_PROPERTIES = WS_SERVICE_ENDPOINT_PROPERTY_ID.MESSAGE_PROPERTIES; pub const WS_SERVICE_ENDPOINT_PROPERTY_MAX_CALL_POOL_SIZE = WS_SERVICE_ENDPOINT_PROPERTY_ID.MAX_CALL_POOL_SIZE; pub const WS_SERVICE_ENDPOINT_PROPERTY_MAX_CHANNEL_POOL_SIZE = WS_SERVICE_ENDPOINT_PROPERTY_ID.MAX_CHANNEL_POOL_SIZE; pub const WS_SERVICE_ENDPOINT_PROPERTY_LISTENER_PROPERTIES = WS_SERVICE_ENDPOINT_PROPERTY_ID.LISTENER_PROPERTIES; pub const WS_SERVICE_ENDPOINT_PROPERTY_CHECK_MUST_UNDERSTAND = WS_SERVICE_ENDPOINT_PROPERTY_ID.CHECK_MUST_UNDERSTAND; pub const WS_SERVICE_ENDPOINT_PROPERTY_METADATA_EXCHANGE_TYPE = WS_SERVICE_ENDPOINT_PROPERTY_ID.METADATA_EXCHANGE_TYPE; pub const WS_SERVICE_ENDPOINT_PROPERTY_METADATA = WS_SERVICE_ENDPOINT_PROPERTY_ID.METADATA; pub const WS_SERVICE_ENDPOINT_PROPERTY_METADATA_EXCHANGE_URL_SUFFIX = WS_SERVICE_ENDPOINT_PROPERTY_ID.METADATA_EXCHANGE_URL_SUFFIX; pub const WS_SERVICE_ENDPOINT_PROPERTY_MAX_CHANNELS = WS_SERVICE_ENDPOINT_PROPERTY_ID.MAX_CHANNELS; pub const WS_METADATA_EXCHANGE_TYPE = enum(i32) { NONE = 0, MEX = 1, HTTP_GET = 2, }; pub const WS_METADATA_EXCHANGE_TYPE_NONE = WS_METADATA_EXCHANGE_TYPE.NONE; pub const WS_METADATA_EXCHANGE_TYPE_MEX = WS_METADATA_EXCHANGE_TYPE.MEX; pub const WS_METADATA_EXCHANGE_TYPE_HTTP_GET = WS_METADATA_EXCHANGE_TYPE.HTTP_GET; pub const WS_SERVICE_PROPERTY_ID = enum(i32) { HOST_USER_STATE = 0, FAULT_DISCLOSURE = 1, FAULT_LANGID = 2, HOST_STATE = 3, METADATA = 4, CLOSE_TIMEOUT = 5, }; pub const WS_SERVICE_PROPERTY_HOST_USER_STATE = WS_SERVICE_PROPERTY_ID.HOST_USER_STATE; pub const WS_SERVICE_PROPERTY_FAULT_DISCLOSURE = WS_SERVICE_PROPERTY_ID.FAULT_DISCLOSURE; pub const WS_SERVICE_PROPERTY_FAULT_LANGID = WS_SERVICE_PROPERTY_ID.FAULT_LANGID; pub const WS_SERVICE_PROPERTY_HOST_STATE = WS_SERVICE_PROPERTY_ID.HOST_STATE; pub const WS_SERVICE_PROPERTY_METADATA = WS_SERVICE_PROPERTY_ID.METADATA; pub const WS_SERVICE_PROPERTY_CLOSE_TIMEOUT = WS_SERVICE_PROPERTY_ID.CLOSE_TIMEOUT; pub const WS_SERVICE_HOST_STATE = enum(i32) { CREATED = 0, OPENING = 1, OPEN = 2, CLOSING = 3, CLOSED = 4, FAULTED = 5, }; pub const WS_SERVICE_HOST_STATE_CREATED = WS_SERVICE_HOST_STATE.CREATED; pub const WS_SERVICE_HOST_STATE_OPENING = WS_SERVICE_HOST_STATE.OPENING; pub const WS_SERVICE_HOST_STATE_OPEN = WS_SERVICE_HOST_STATE.OPEN; pub const WS_SERVICE_HOST_STATE_CLOSING = WS_SERVICE_HOST_STATE.CLOSING; pub const WS_SERVICE_HOST_STATE_CLOSED = WS_SERVICE_HOST_STATE.CLOSED; pub const WS_SERVICE_HOST_STATE_FAULTED = WS_SERVICE_HOST_STATE.FAULTED; pub const WS_SERVICE_PROXY_STATE = enum(i32) { CREATED = 0, OPENING = 1, OPEN = 2, CLOSING = 3, CLOSED = 4, FAULTED = 5, }; pub const WS_SERVICE_PROXY_STATE_CREATED = WS_SERVICE_PROXY_STATE.CREATED; pub const WS_SERVICE_PROXY_STATE_OPENING = WS_SERVICE_PROXY_STATE.OPENING; pub const WS_SERVICE_PROXY_STATE_OPEN = WS_SERVICE_PROXY_STATE.OPEN; pub const WS_SERVICE_PROXY_STATE_CLOSING = WS_SERVICE_PROXY_STATE.CLOSING; pub const WS_SERVICE_PROXY_STATE_CLOSED = WS_SERVICE_PROXY_STATE.CLOSED; pub const WS_SERVICE_PROXY_STATE_FAULTED = WS_SERVICE_PROXY_STATE.FAULTED; pub const WS_PROXY_PROPERTY_ID = enum(i32) { PROPERTY_CALL_TIMEOUT = 0, PROPERTY_MESSAGE_PROPERTIES = 1, PROPERTY_MAX_CALL_POOL_SIZE = 2, PROPERTY_STATE = 3, PROPERTY_MAX_PENDING_CALLS = 4, PROPERTY_MAX_CLOSE_TIMEOUT = 5, FAULT_LANG_ID = 6, }; pub const WS_PROXY_PROPERTY_CALL_TIMEOUT = WS_PROXY_PROPERTY_ID.PROPERTY_CALL_TIMEOUT; pub const WS_PROXY_PROPERTY_MESSAGE_PROPERTIES = WS_PROXY_PROPERTY_ID.PROPERTY_MESSAGE_PROPERTIES; pub const WS_PROXY_PROPERTY_MAX_CALL_POOL_SIZE = WS_PROXY_PROPERTY_ID.PROPERTY_MAX_CALL_POOL_SIZE; pub const WS_PROXY_PROPERTY_STATE = WS_PROXY_PROPERTY_ID.PROPERTY_STATE; pub const WS_PROXY_PROPERTY_MAX_PENDING_CALLS = WS_PROXY_PROPERTY_ID.PROPERTY_MAX_PENDING_CALLS; pub const WS_PROXY_PROPERTY_MAX_CLOSE_TIMEOUT = WS_PROXY_PROPERTY_ID.PROPERTY_MAX_CLOSE_TIMEOUT; pub const WS_PROXY_FAULT_LANG_ID = WS_PROXY_PROPERTY_ID.FAULT_LANG_ID; pub const WS_CALL_PROPERTY_ID = enum(i32) { CHECK_MUST_UNDERSTAND = 0, SEND_MESSAGE_CONTEXT = 1, RECEIVE_MESSAGE_CONTEXT = 2, CALL_ID = 3, }; pub const WS_CALL_PROPERTY_CHECK_MUST_UNDERSTAND = WS_CALL_PROPERTY_ID.CHECK_MUST_UNDERSTAND; pub const WS_CALL_PROPERTY_SEND_MESSAGE_CONTEXT = WS_CALL_PROPERTY_ID.SEND_MESSAGE_CONTEXT; pub const WS_CALL_PROPERTY_RECEIVE_MESSAGE_CONTEXT = WS_CALL_PROPERTY_ID.RECEIVE_MESSAGE_CONTEXT; pub const WS_CALL_PROPERTY_CALL_ID = WS_CALL_PROPERTY_ID.CALL_ID; pub const WS_TRACE_API = enum(i32) { NONE = -1, START_READER_CANONICALIZATION = 0, END_READER_CANONICALIZATION = 1, START_WRITER_CANONICALIZATION = 2, END_WRITER_CANONICALIZATION = 3, CREATE_XML_BUFFER = 4, REMOVE_NODE = 5, CREATE_READER = 6, SET_INPUT = 7, SET_INPUT_TO_BUFFER = 8, FREE_XML_READER = 9, GET_READER_PROPERTY = 10, GET_READER_NODE = 11, FILL_READER = 12, READ_START_ELEMENT = 13, READ_TO_START_ELEMENT = 14, READ_START_ATTRIBUTE = 15, READ_END_ATTRIBUTE = 16, READ_NODE = 17, SKIP_NODE = 18, READ_END_ELEMENT = 19, FIND_ATTRIBUTE = 20, READ_ELEMENT_VALUE = 21, READ_CHARS = 22, READ_CHARS_UTF8 = 23, READ_BYTES = 24, READ_ARRAY = 25, GET_READER_POSITION = 26, SET_READER_POSITION = 27, MOVE_READER = 28, CREATE_WRITER = 29, FREE_XML_WRITER = 30, SET_OUTPUT = 31, SET_OUTPUT_TO_BUFFER = 32, GET_WRITER_PROPERTY = 33, FLUSH_WRITER = 34, WRITE_START_ELEMENT = 35, WRITE_END_START_ELEMENT = 36, WRITE_XMLNS_ATTRIBUTE = 37, WRITE_START_ATTRIBUTE = 38, WRITE_END_ATTRIBUTE = 39, WRITE_VALUE = 40, WRITE_XML_BUFFER = 41, READ_XML_BUFFER = 42, WRITE_XML_BUFFER_TO_BYTES = 43, READ_XML_BUFFER_FROM_BYTES = 44, WRITE_ARRAY = 45, WRITE_QUALIFIED_NAME = 46, WRITE_CHARS = 47, WRITE_CHARS_UTF8 = 48, WRITE_BYTES = 49, PUSH_BYTES = 50, PULL_BYTES = 51, WRITE_END_ELEMENT = 52, WRITE_TEXT = 53, WRITE_START_CDATA = 54, WRITE_END_CDATA = 55, WRITE_NODE = 56, PREFIX_FROM_NAMESPACE = 57, GET_WRITER_POSITION = 58, SET_WRITER_POSITION = 59, MOVE_WRITER = 60, TRIM_XML_WHITESPACE = 61, VERIFY_XML_NCNAME = 62, XML_STRING_EQUALS = 63, NAMESPACE_FROM_PREFIX = 64, READ_QUALIFIED_NAME = 65, GET_XML_ATTRIBUTE = 66, COPY_NODE = 67, ASYNC_EXECUTE = 68, CREATE_CHANNEL = 69, OPEN_CHANNEL = 70, SEND_MESSAGE = 71, RECEIVE_MESSAGE = 72, REQUEST_REPLY = 73, SEND_REPLY_MESSAGE = 74, SEND_FAULT_MESSAGE_FOR_ERROR = 75, GET_CHANNEL_PROPERTY = 76, SET_CHANNEL_PROPERTY = 77, WRITE_MESSAGE_START = 78, WRITE_MESSAGE_END = 79, READ_MESSAGE_START = 80, READ_MESSAGE_END = 81, CLOSE_CHANNEL = 82, ABORT_CHANNEL = 83, FREE_CHANNEL = 84, RESET_CHANNEL = 85, ABANDON_MESSAGE = 86, SHUTDOWN_SESSION_CHANNEL = 87, GET_CONTEXT_PROPERTY = 88, GET_DICTIONARY = 89, READ_ENDPOINT_ADDRESS_EXTENSION = 90, CREATE_ERROR = 91, ADD_ERROR_STRING = 92, GET_ERROR_STRING = 93, COPY_ERROR = 94, GET_ERROR_PROPERTY = 95, SET_ERROR_PROPERTY = 96, RESET_ERROR = 97, FREE_ERROR = 98, GET_FAULT_ERROR_PROPERTY = 99, SET_FAULT_ERROR_PROPERTY = 100, CREATE_FAULT_FROM_ERROR = 101, SET_FAULT_ERROR_DETAIL = 102, GET_FAULT_ERROR_DETAIL = 103, CREATE_HEAP = 104, ALLOC = 105, GET_HEAP_PROPERTY = 106, RESET_HEAP = 107, FREE_HEAP = 108, CREATE_LISTENER = 109, OPEN_LISTENER = 110, ACCEPT_CHANNEL = 111, CLOSE_LISTENER = 112, ABORT_LISTENER = 113, RESET_LISTENER = 114, FREE_LISTENER = 115, GET_LISTENER_PROPERTY = 116, SET_LISTENER_PROPERTY = 117, CREATE_CHANNEL_FOR_LISTENER = 118, CREATE_MESSAGE = 119, CREATE_MESSAGE_FOR_CHANNEL = 120, INITIALIZE_MESSAGE = 121, RESET_MESSAGE = 122, FREE_MESSAGE = 123, GET_HEADER_ATTRIBUTES = 124, GET_HEADER = 125, GET_CUSTOM_HEADER = 126, REMOVE_HEADER = 127, SET_HEADER = 128, REMOVE_CUSTOM_HEADER = 129, ADD_CUSTOM_HEADER = 130, ADD_MAPPED_HEADER = 131, REMOVE_MAPPED_HEADER = 132, GET_MAPPED_HEADER = 133, WRITE_BODY = 134, READ_BODY = 135, WRITE_ENVELOPE_START = 136, WRITE_ENVELOPE_END = 137, READ_ENVELOPE_START = 138, READ_ENVELOPE_END = 139, GET_MESSAGE_PROPERTY = 140, SET_MESSAGE_PROPERTY = 141, ADDRESS_MESSAGE = 142, CHECK_MUST_UNDERSTAND_HEADERS = 143, MARK_HEADER_AS_UNDERSTOOD = 144, FILL_BODY = 145, FLUSH_BODY = 146, REQUEST_SECURITY_TOKEN = 147, GET_SECURITY_TOKEN_PROPERTY = 148, CREATE_XML_SECURITY_TOKEN = 149, FREE_SECURITY_TOKEN = 150, REVOKE_SECURITY_CONTEXT = 151, GET_SECURITY_CONTEXT_PROPERTY = 152, READ_ELEMENT_TYPE = 153, READ_ATTRIBUTE_TYPE = 154, READ_TYPE = 155, WRITE_ELEMENT_TYPE = 156, WRITE_ATTRIBUTE_TYPE = 157, WRITE_TYPE = 158, SERVICE_REGISTER_FOR_CANCEL = 159, GET_SERVICE_HOST_PROPERTY = 160, CREATE_SERVICE_HOST = 161, OPEN_SERVICE_HOST = 162, CLOSE_SERVICE_HOST = 163, ABORT_SERVICE_HOST = 164, FREE_SERVICE_HOST = 165, RESET_SERVICE_HOST = 166, GET_SERVICE_PROXY_PROPERTY = 167, CREATE_SERVICE_PROXY = 168, OPEN_SERVICE_PROXY = 169, CLOSE_SERVICE_PROXY = 170, ABORT_SERVICE_PROXY = 171, FREE_SERVICE_PROXY = 172, RESET_SERVICE_PROXY = 173, ABORT_CALL = 174, CALL = 175, DECODE_URL = 176, ENCODE_URL = 177, COMBINE_URL = 178, DATETIME_TO_FILETIME = 179, FILETIME_TO_DATETIME = 180, DUMP_MEMORY = 181, SET_AUTOFAIL = 182, CREATE_METADATA = 183, READ_METADATA = 184, FREE_METADATA = 185, RESET_METADATA = 186, GET_METADATA_PROPERTY = 187, GET_MISSING_METADATA_DOCUMENT_ADDRESS = 188, GET_METADATA_ENDPOINTS = 189, MATCH_POLICY_ALTERNATIVE = 190, GET_POLICY_PROPERTY = 191, GET_POLICY_ALTERNATIVE_COUNT = 192, WS_CREATE_SERVICE_PROXY_FROM_TEMPLATE = 193, WS_CREATE_SERVICE_HOST_FROM_TEMPLATE = 194, }; pub const WS_TRACE_API_NONE = WS_TRACE_API.NONE; pub const WS_TRACE_API_START_READER_CANONICALIZATION = WS_TRACE_API.START_READER_CANONICALIZATION; pub const WS_TRACE_API_END_READER_CANONICALIZATION = WS_TRACE_API.END_READER_CANONICALIZATION; pub const WS_TRACE_API_START_WRITER_CANONICALIZATION = WS_TRACE_API.START_WRITER_CANONICALIZATION; pub const WS_TRACE_API_END_WRITER_CANONICALIZATION = WS_TRACE_API.END_WRITER_CANONICALIZATION; pub const WS_TRACE_API_CREATE_XML_BUFFER = WS_TRACE_API.CREATE_XML_BUFFER; pub const WS_TRACE_API_REMOVE_NODE = WS_TRACE_API.REMOVE_NODE; pub const WS_TRACE_API_CREATE_READER = WS_TRACE_API.CREATE_READER; pub const WS_TRACE_API_SET_INPUT = WS_TRACE_API.SET_INPUT; pub const WS_TRACE_API_SET_INPUT_TO_BUFFER = WS_TRACE_API.SET_INPUT_TO_BUFFER; pub const WS_TRACE_API_FREE_XML_READER = WS_TRACE_API.FREE_XML_READER; pub const WS_TRACE_API_GET_READER_PROPERTY = WS_TRACE_API.GET_READER_PROPERTY; pub const WS_TRACE_API_GET_READER_NODE = WS_TRACE_API.GET_READER_NODE; pub const WS_TRACE_API_FILL_READER = WS_TRACE_API.FILL_READER; pub const WS_TRACE_API_READ_START_ELEMENT = WS_TRACE_API.READ_START_ELEMENT; pub const WS_TRACE_API_READ_TO_START_ELEMENT = WS_TRACE_API.READ_TO_START_ELEMENT; pub const WS_TRACE_API_READ_START_ATTRIBUTE = WS_TRACE_API.READ_START_ATTRIBUTE; pub const WS_TRACE_API_READ_END_ATTRIBUTE = WS_TRACE_API.READ_END_ATTRIBUTE; pub const WS_TRACE_API_READ_NODE = WS_TRACE_API.READ_NODE; pub const WS_TRACE_API_SKIP_NODE = WS_TRACE_API.SKIP_NODE; pub const WS_TRACE_API_READ_END_ELEMENT = WS_TRACE_API.READ_END_ELEMENT; pub const WS_TRACE_API_FIND_ATTRIBUTE = WS_TRACE_API.FIND_ATTRIBUTE; pub const WS_TRACE_API_READ_ELEMENT_VALUE = WS_TRACE_API.READ_ELEMENT_VALUE; pub const WS_TRACE_API_READ_CHARS = WS_TRACE_API.READ_CHARS; pub const WS_TRACE_API_READ_CHARS_UTF8 = WS_TRACE_API.READ_CHARS_UTF8; pub const WS_TRACE_API_READ_BYTES = WS_TRACE_API.READ_BYTES; pub const WS_TRACE_API_READ_ARRAY = WS_TRACE_API.READ_ARRAY; pub const WS_TRACE_API_GET_READER_POSITION = WS_TRACE_API.GET_READER_POSITION; pub const WS_TRACE_API_SET_READER_POSITION = WS_TRACE_API.SET_READER_POSITION; pub const WS_TRACE_API_MOVE_READER = WS_TRACE_API.MOVE_READER; pub const WS_TRACE_API_CREATE_WRITER = WS_TRACE_API.CREATE_WRITER; pub const WS_TRACE_API_FREE_XML_WRITER = WS_TRACE_API.FREE_XML_WRITER; pub const WS_TRACE_API_SET_OUTPUT = WS_TRACE_API.SET_OUTPUT; pub const WS_TRACE_API_SET_OUTPUT_TO_BUFFER = WS_TRACE_API.SET_OUTPUT_TO_BUFFER; pub const WS_TRACE_API_GET_WRITER_PROPERTY = WS_TRACE_API.GET_WRITER_PROPERTY; pub const WS_TRACE_API_FLUSH_WRITER = WS_TRACE_API.FLUSH_WRITER; pub const WS_TRACE_API_WRITE_START_ELEMENT = WS_TRACE_API.WRITE_START_ELEMENT; pub const WS_TRACE_API_WRITE_END_START_ELEMENT = WS_TRACE_API.WRITE_END_START_ELEMENT; pub const WS_TRACE_API_WRITE_XMLNS_ATTRIBUTE = WS_TRACE_API.WRITE_XMLNS_ATTRIBUTE; pub const WS_TRACE_API_WRITE_START_ATTRIBUTE = WS_TRACE_API.WRITE_START_ATTRIBUTE; pub const WS_TRACE_API_WRITE_END_ATTRIBUTE = WS_TRACE_API.WRITE_END_ATTRIBUTE; pub const WS_TRACE_API_WRITE_VALUE = WS_TRACE_API.WRITE_VALUE; pub const WS_TRACE_API_WRITE_XML_BUFFER = WS_TRACE_API.WRITE_XML_BUFFER; pub const WS_TRACE_API_READ_XML_BUFFER = WS_TRACE_API.READ_XML_BUFFER; pub const WS_TRACE_API_WRITE_XML_BUFFER_TO_BYTES = WS_TRACE_API.WRITE_XML_BUFFER_TO_BYTES; pub const WS_TRACE_API_READ_XML_BUFFER_FROM_BYTES = WS_TRACE_API.READ_XML_BUFFER_FROM_BYTES; pub const WS_TRACE_API_WRITE_ARRAY = WS_TRACE_API.WRITE_ARRAY; pub const WS_TRACE_API_WRITE_QUALIFIED_NAME = WS_TRACE_API.WRITE_QUALIFIED_NAME; pub const WS_TRACE_API_WRITE_CHARS = WS_TRACE_API.WRITE_CHARS; pub const WS_TRACE_API_WRITE_CHARS_UTF8 = WS_TRACE_API.WRITE_CHARS_UTF8; pub const WS_TRACE_API_WRITE_BYTES = WS_TRACE_API.WRITE_BYTES; pub const WS_TRACE_API_PUSH_BYTES = WS_TRACE_API.PUSH_BYTES; pub const WS_TRACE_API_PULL_BYTES = WS_TRACE_API.PULL_BYTES; pub const WS_TRACE_API_WRITE_END_ELEMENT = WS_TRACE_API.WRITE_END_ELEMENT; pub const WS_TRACE_API_WRITE_TEXT = WS_TRACE_API.WRITE_TEXT; pub const WS_TRACE_API_WRITE_START_CDATA = WS_TRACE_API.WRITE_START_CDATA; pub const WS_TRACE_API_WRITE_END_CDATA = WS_TRACE_API.WRITE_END_CDATA; pub const WS_TRACE_API_WRITE_NODE = WS_TRACE_API.WRITE_NODE; pub const WS_TRACE_API_PREFIX_FROM_NAMESPACE = WS_TRACE_API.PREFIX_FROM_NAMESPACE; pub const WS_TRACE_API_GET_WRITER_POSITION = WS_TRACE_API.GET_WRITER_POSITION; pub const WS_TRACE_API_SET_WRITER_POSITION = WS_TRACE_API.SET_WRITER_POSITION; pub const WS_TRACE_API_MOVE_WRITER = WS_TRACE_API.MOVE_WRITER; pub const WS_TRACE_API_TRIM_XML_WHITESPACE = WS_TRACE_API.TRIM_XML_WHITESPACE; pub const WS_TRACE_API_VERIFY_XML_NCNAME = WS_TRACE_API.VERIFY_XML_NCNAME; pub const WS_TRACE_API_XML_STRING_EQUALS = WS_TRACE_API.XML_STRING_EQUALS; pub const WS_TRACE_API_NAMESPACE_FROM_PREFIX = WS_TRACE_API.NAMESPACE_FROM_PREFIX; pub const WS_TRACE_API_READ_QUALIFIED_NAME = WS_TRACE_API.READ_QUALIFIED_NAME; pub const WS_TRACE_API_GET_XML_ATTRIBUTE = WS_TRACE_API.GET_XML_ATTRIBUTE; pub const WS_TRACE_API_COPY_NODE = WS_TRACE_API.COPY_NODE; pub const WS_TRACE_API_ASYNC_EXECUTE = WS_TRACE_API.ASYNC_EXECUTE; pub const WS_TRACE_API_CREATE_CHANNEL = WS_TRACE_API.CREATE_CHANNEL; pub const WS_TRACE_API_OPEN_CHANNEL = WS_TRACE_API.OPEN_CHANNEL; pub const WS_TRACE_API_SEND_MESSAGE = WS_TRACE_API.SEND_MESSAGE; pub const WS_TRACE_API_RECEIVE_MESSAGE = WS_TRACE_API.RECEIVE_MESSAGE; pub const WS_TRACE_API_REQUEST_REPLY = WS_TRACE_API.REQUEST_REPLY; pub const WS_TRACE_API_SEND_REPLY_MESSAGE = WS_TRACE_API.SEND_REPLY_MESSAGE; pub const WS_TRACE_API_SEND_FAULT_MESSAGE_FOR_ERROR = WS_TRACE_API.SEND_FAULT_MESSAGE_FOR_ERROR; pub const WS_TRACE_API_GET_CHANNEL_PROPERTY = WS_TRACE_API.GET_CHANNEL_PROPERTY; pub const WS_TRACE_API_SET_CHANNEL_PROPERTY = WS_TRACE_API.SET_CHANNEL_PROPERTY; pub const WS_TRACE_API_WRITE_MESSAGE_START = WS_TRACE_API.WRITE_MESSAGE_START; pub const WS_TRACE_API_WRITE_MESSAGE_END = WS_TRACE_API.WRITE_MESSAGE_END; pub const WS_TRACE_API_READ_MESSAGE_START = WS_TRACE_API.READ_MESSAGE_START; pub const WS_TRACE_API_READ_MESSAGE_END = WS_TRACE_API.READ_MESSAGE_END; pub const WS_TRACE_API_CLOSE_CHANNEL = WS_TRACE_API.CLOSE_CHANNEL; pub const WS_TRACE_API_ABORT_CHANNEL = WS_TRACE_API.ABORT_CHANNEL; pub const WS_TRACE_API_FREE_CHANNEL = WS_TRACE_API.FREE_CHANNEL; pub const WS_TRACE_API_RESET_CHANNEL = WS_TRACE_API.RESET_CHANNEL; pub const WS_TRACE_API_ABANDON_MESSAGE = WS_TRACE_API.ABANDON_MESSAGE; pub const WS_TRACE_API_SHUTDOWN_SESSION_CHANNEL = WS_TRACE_API.SHUTDOWN_SESSION_CHANNEL; pub const WS_TRACE_API_GET_CONTEXT_PROPERTY = WS_TRACE_API.GET_CONTEXT_PROPERTY; pub const WS_TRACE_API_GET_DICTIONARY = WS_TRACE_API.GET_DICTIONARY; pub const WS_TRACE_API_READ_ENDPOINT_ADDRESS_EXTENSION = WS_TRACE_API.READ_ENDPOINT_ADDRESS_EXTENSION; pub const WS_TRACE_API_CREATE_ERROR = WS_TRACE_API.CREATE_ERROR; pub const WS_TRACE_API_ADD_ERROR_STRING = WS_TRACE_API.ADD_ERROR_STRING; pub const WS_TRACE_API_GET_ERROR_STRING = WS_TRACE_API.GET_ERROR_STRING; pub const WS_TRACE_API_COPY_ERROR = WS_TRACE_API.COPY_ERROR; pub const WS_TRACE_API_GET_ERROR_PROPERTY = WS_TRACE_API.GET_ERROR_PROPERTY; pub const WS_TRACE_API_SET_ERROR_PROPERTY = WS_TRACE_API.SET_ERROR_PROPERTY; pub const WS_TRACE_API_RESET_ERROR = WS_TRACE_API.RESET_ERROR; pub const WS_TRACE_API_FREE_ERROR = WS_TRACE_API.FREE_ERROR; pub const WS_TRACE_API_GET_FAULT_ERROR_PROPERTY = WS_TRACE_API.GET_FAULT_ERROR_PROPERTY; pub const WS_TRACE_API_SET_FAULT_ERROR_PROPERTY = WS_TRACE_API.SET_FAULT_ERROR_PROPERTY; pub const WS_TRACE_API_CREATE_FAULT_FROM_ERROR = WS_TRACE_API.CREATE_FAULT_FROM_ERROR; pub const WS_TRACE_API_SET_FAULT_ERROR_DETAIL = WS_TRACE_API.SET_FAULT_ERROR_DETAIL; pub const WS_TRACE_API_GET_FAULT_ERROR_DETAIL = WS_TRACE_API.GET_FAULT_ERROR_DETAIL; pub const WS_TRACE_API_CREATE_HEAP = WS_TRACE_API.CREATE_HEAP; pub const WS_TRACE_API_ALLOC = WS_TRACE_API.ALLOC; pub const WS_TRACE_API_GET_HEAP_PROPERTY = WS_TRACE_API.GET_HEAP_PROPERTY; pub const WS_TRACE_API_RESET_HEAP = WS_TRACE_API.RESET_HEAP; pub const WS_TRACE_API_FREE_HEAP = WS_TRACE_API.FREE_HEAP; pub const WS_TRACE_API_CREATE_LISTENER = WS_TRACE_API.CREATE_LISTENER; pub const WS_TRACE_API_OPEN_LISTENER = WS_TRACE_API.OPEN_LISTENER; pub const WS_TRACE_API_ACCEPT_CHANNEL = WS_TRACE_API.ACCEPT_CHANNEL; pub const WS_TRACE_API_CLOSE_LISTENER = WS_TRACE_API.CLOSE_LISTENER; pub const WS_TRACE_API_ABORT_LISTENER = WS_TRACE_API.ABORT_LISTENER; pub const WS_TRACE_API_RESET_LISTENER = WS_TRACE_API.RESET_LISTENER; pub const WS_TRACE_API_FREE_LISTENER = WS_TRACE_API.FREE_LISTENER; pub const WS_TRACE_API_GET_LISTENER_PROPERTY = WS_TRACE_API.GET_LISTENER_PROPERTY; pub const WS_TRACE_API_SET_LISTENER_PROPERTY = WS_TRACE_API.SET_LISTENER_PROPERTY; pub const WS_TRACE_API_CREATE_CHANNEL_FOR_LISTENER = WS_TRACE_API.CREATE_CHANNEL_FOR_LISTENER; pub const WS_TRACE_API_CREATE_MESSAGE = WS_TRACE_API.CREATE_MESSAGE; pub const WS_TRACE_API_CREATE_MESSAGE_FOR_CHANNEL = WS_TRACE_API.CREATE_MESSAGE_FOR_CHANNEL; pub const WS_TRACE_API_INITIALIZE_MESSAGE = WS_TRACE_API.INITIALIZE_MESSAGE; pub const WS_TRACE_API_RESET_MESSAGE = WS_TRACE_API.RESET_MESSAGE; pub const WS_TRACE_API_FREE_MESSAGE = WS_TRACE_API.FREE_MESSAGE; pub const WS_TRACE_API_GET_HEADER_ATTRIBUTES = WS_TRACE_API.GET_HEADER_ATTRIBUTES; pub const WS_TRACE_API_GET_HEADER = WS_TRACE_API.GET_HEADER; pub const WS_TRACE_API_GET_CUSTOM_HEADER = WS_TRACE_API.GET_CUSTOM_HEADER; pub const WS_TRACE_API_REMOVE_HEADER = WS_TRACE_API.REMOVE_HEADER; pub const WS_TRACE_API_SET_HEADER = WS_TRACE_API.SET_HEADER; pub const WS_TRACE_API_REMOVE_CUSTOM_HEADER = WS_TRACE_API.REMOVE_CUSTOM_HEADER; pub const WS_TRACE_API_ADD_CUSTOM_HEADER = WS_TRACE_API.ADD_CUSTOM_HEADER; pub const WS_TRACE_API_ADD_MAPPED_HEADER = WS_TRACE_API.ADD_MAPPED_HEADER; pub const WS_TRACE_API_REMOVE_MAPPED_HEADER = WS_TRACE_API.REMOVE_MAPPED_HEADER; pub const WS_TRACE_API_GET_MAPPED_HEADER = WS_TRACE_API.GET_MAPPED_HEADER; pub const WS_TRACE_API_WRITE_BODY = WS_TRACE_API.WRITE_BODY; pub const WS_TRACE_API_READ_BODY = WS_TRACE_API.READ_BODY; pub const WS_TRACE_API_WRITE_ENVELOPE_START = WS_TRACE_API.WRITE_ENVELOPE_START; pub const WS_TRACE_API_WRITE_ENVELOPE_END = WS_TRACE_API.WRITE_ENVELOPE_END; pub const WS_TRACE_API_READ_ENVELOPE_START = WS_TRACE_API.READ_ENVELOPE_START; pub const WS_TRACE_API_READ_ENVELOPE_END = WS_TRACE_API.READ_ENVELOPE_END; pub const WS_TRACE_API_GET_MESSAGE_PROPERTY = WS_TRACE_API.GET_MESSAGE_PROPERTY; pub const WS_TRACE_API_SET_MESSAGE_PROPERTY = WS_TRACE_API.SET_MESSAGE_PROPERTY; pub const WS_TRACE_API_ADDRESS_MESSAGE = WS_TRACE_API.ADDRESS_MESSAGE; pub const WS_TRACE_API_CHECK_MUST_UNDERSTAND_HEADERS = WS_TRACE_API.CHECK_MUST_UNDERSTAND_HEADERS; pub const WS_TRACE_API_MARK_HEADER_AS_UNDERSTOOD = WS_TRACE_API.MARK_HEADER_AS_UNDERSTOOD; pub const WS_TRACE_API_FILL_BODY = WS_TRACE_API.FILL_BODY; pub const WS_TRACE_API_FLUSH_BODY = WS_TRACE_API.FLUSH_BODY; pub const WS_TRACE_API_REQUEST_SECURITY_TOKEN = WS_TRACE_API.REQUEST_SECURITY_TOKEN; pub const WS_TRACE_API_GET_SECURITY_TOKEN_PROPERTY = WS_TRACE_API.GET_SECURITY_TOKEN_PROPERTY; pub const WS_TRACE_API_CREATE_XML_SECURITY_TOKEN = WS_TRACE_API.CREATE_XML_SECURITY_TOKEN; pub const WS_TRACE_API_FREE_SECURITY_TOKEN = WS_TRACE_API.FREE_SECURITY_TOKEN; pub const WS_TRACE_API_REVOKE_SECURITY_CONTEXT = WS_TRACE_API.REVOKE_SECURITY_CONTEXT; pub const WS_TRACE_API_GET_SECURITY_CONTEXT_PROPERTY = WS_TRACE_API.GET_SECURITY_CONTEXT_PROPERTY; pub const WS_TRACE_API_READ_ELEMENT_TYPE = WS_TRACE_API.READ_ELEMENT_TYPE; pub const WS_TRACE_API_READ_ATTRIBUTE_TYPE = WS_TRACE_API.READ_ATTRIBUTE_TYPE; pub const WS_TRACE_API_READ_TYPE = WS_TRACE_API.READ_TYPE; pub const WS_TRACE_API_WRITE_ELEMENT_TYPE = WS_TRACE_API.WRITE_ELEMENT_TYPE; pub const WS_TRACE_API_WRITE_ATTRIBUTE_TYPE = WS_TRACE_API.WRITE_ATTRIBUTE_TYPE; pub const WS_TRACE_API_WRITE_TYPE = WS_TRACE_API.WRITE_TYPE; pub const WS_TRACE_API_SERVICE_REGISTER_FOR_CANCEL = WS_TRACE_API.SERVICE_REGISTER_FOR_CANCEL; pub const WS_TRACE_API_GET_SERVICE_HOST_PROPERTY = WS_TRACE_API.GET_SERVICE_HOST_PROPERTY; pub const WS_TRACE_API_CREATE_SERVICE_HOST = WS_TRACE_API.CREATE_SERVICE_HOST; pub const WS_TRACE_API_OPEN_SERVICE_HOST = WS_TRACE_API.OPEN_SERVICE_HOST; pub const WS_TRACE_API_CLOSE_SERVICE_HOST = WS_TRACE_API.CLOSE_SERVICE_HOST; pub const WS_TRACE_API_ABORT_SERVICE_HOST = WS_TRACE_API.ABORT_SERVICE_HOST; pub const WS_TRACE_API_FREE_SERVICE_HOST = WS_TRACE_API.FREE_SERVICE_HOST; pub const WS_TRACE_API_RESET_SERVICE_HOST = WS_TRACE_API.RESET_SERVICE_HOST; pub const WS_TRACE_API_GET_SERVICE_PROXY_PROPERTY = WS_TRACE_API.GET_SERVICE_PROXY_PROPERTY; pub const WS_TRACE_API_CREATE_SERVICE_PROXY = WS_TRACE_API.CREATE_SERVICE_PROXY; pub const WS_TRACE_API_OPEN_SERVICE_PROXY = WS_TRACE_API.OPEN_SERVICE_PROXY; pub const WS_TRACE_API_CLOSE_SERVICE_PROXY = WS_TRACE_API.CLOSE_SERVICE_PROXY; pub const WS_TRACE_API_ABORT_SERVICE_PROXY = WS_TRACE_API.ABORT_SERVICE_PROXY; pub const WS_TRACE_API_FREE_SERVICE_PROXY = WS_TRACE_API.FREE_SERVICE_PROXY; pub const WS_TRACE_API_RESET_SERVICE_PROXY = WS_TRACE_API.RESET_SERVICE_PROXY; pub const WS_TRACE_API_ABORT_CALL = WS_TRACE_API.ABORT_CALL; pub const WS_TRACE_API_CALL = WS_TRACE_API.CALL; pub const WS_TRACE_API_DECODE_URL = WS_TRACE_API.DECODE_URL; pub const WS_TRACE_API_ENCODE_URL = WS_TRACE_API.ENCODE_URL; pub const WS_TRACE_API_COMBINE_URL = WS_TRACE_API.COMBINE_URL; pub const WS_TRACE_API_DATETIME_TO_FILETIME = WS_TRACE_API.DATETIME_TO_FILETIME; pub const WS_TRACE_API_FILETIME_TO_DATETIME = WS_TRACE_API.FILETIME_TO_DATETIME; pub const WS_TRACE_API_DUMP_MEMORY = WS_TRACE_API.DUMP_MEMORY; pub const WS_TRACE_API_SET_AUTOFAIL = WS_TRACE_API.SET_AUTOFAIL; pub const WS_TRACE_API_CREATE_METADATA = WS_TRACE_API.CREATE_METADATA; pub const WS_TRACE_API_READ_METADATA = WS_TRACE_API.READ_METADATA; pub const WS_TRACE_API_FREE_METADATA = WS_TRACE_API.FREE_METADATA; pub const WS_TRACE_API_RESET_METADATA = WS_TRACE_API.RESET_METADATA; pub const WS_TRACE_API_GET_METADATA_PROPERTY = WS_TRACE_API.GET_METADATA_PROPERTY; pub const WS_TRACE_API_GET_MISSING_METADATA_DOCUMENT_ADDRESS = WS_TRACE_API.GET_MISSING_METADATA_DOCUMENT_ADDRESS; pub const WS_TRACE_API_GET_METADATA_ENDPOINTS = WS_TRACE_API.GET_METADATA_ENDPOINTS; pub const WS_TRACE_API_MATCH_POLICY_ALTERNATIVE = WS_TRACE_API.MATCH_POLICY_ALTERNATIVE; pub const WS_TRACE_API_GET_POLICY_PROPERTY = WS_TRACE_API.GET_POLICY_PROPERTY; pub const WS_TRACE_API_GET_POLICY_ALTERNATIVE_COUNT = WS_TRACE_API.GET_POLICY_ALTERNATIVE_COUNT; pub const WS_TRACE_API_WS_CREATE_SERVICE_PROXY_FROM_TEMPLATE = WS_TRACE_API.WS_CREATE_SERVICE_PROXY_FROM_TEMPLATE; pub const WS_TRACE_API_WS_CREATE_SERVICE_HOST_FROM_TEMPLATE = WS_TRACE_API.WS_CREATE_SERVICE_HOST_FROM_TEMPLATE; pub const WS_URL_SCHEME_TYPE = enum(i32) { HTTP_SCHEME_TYPE = 0, HTTPS_SCHEME_TYPE = 1, NETTCP_SCHEME_TYPE = 2, SOAPUDP_SCHEME_TYPE = 3, NETPIPE_SCHEME_TYPE = 4, }; pub const WS_URL_HTTP_SCHEME_TYPE = WS_URL_SCHEME_TYPE.HTTP_SCHEME_TYPE; pub const WS_URL_HTTPS_SCHEME_TYPE = WS_URL_SCHEME_TYPE.HTTPS_SCHEME_TYPE; pub const WS_URL_NETTCP_SCHEME_TYPE = WS_URL_SCHEME_TYPE.NETTCP_SCHEME_TYPE; pub const WS_URL_SOAPUDP_SCHEME_TYPE = WS_URL_SCHEME_TYPE.SOAPUDP_SCHEME_TYPE; pub const WS_URL_NETPIPE_SCHEME_TYPE = WS_URL_SCHEME_TYPE.NETPIPE_SCHEME_TYPE; pub const WS_DATETIME_FORMAT = enum(i32) { UTC = 0, LOCAL = 1, NONE = 2, }; pub const WS_DATETIME_FORMAT_UTC = WS_DATETIME_FORMAT.UTC; pub const WS_DATETIME_FORMAT_LOCAL = WS_DATETIME_FORMAT.LOCAL; pub const WS_DATETIME_FORMAT_NONE = WS_DATETIME_FORMAT.NONE; pub const WS_METADATA_STATE = enum(i32) { CREATED = 1, RESOLVED = 2, FAULTED = 3, }; pub const WS_METADATA_STATE_CREATED = WS_METADATA_STATE.CREATED; pub const WS_METADATA_STATE_RESOLVED = WS_METADATA_STATE.RESOLVED; pub const WS_METADATA_STATE_FAULTED = WS_METADATA_STATE.FAULTED; pub const WS_METADATA_PROPERTY_ID = enum(i32) { STATE = 1, HEAP_PROPERTIES = 2, POLICY_PROPERTIES = 3, HEAP_REQUESTED_SIZE = 4, MAX_DOCUMENTS = 5, HOST_NAMES = 6, VERIFY_HOST_NAMES = 7, }; pub const WS_METADATA_PROPERTY_STATE = WS_METADATA_PROPERTY_ID.STATE; pub const WS_METADATA_PROPERTY_HEAP_PROPERTIES = WS_METADATA_PROPERTY_ID.HEAP_PROPERTIES; pub const WS_METADATA_PROPERTY_POLICY_PROPERTIES = WS_METADATA_PROPERTY_ID.POLICY_PROPERTIES; pub const WS_METADATA_PROPERTY_HEAP_REQUESTED_SIZE = WS_METADATA_PROPERTY_ID.HEAP_REQUESTED_SIZE; pub const WS_METADATA_PROPERTY_MAX_DOCUMENTS = WS_METADATA_PROPERTY_ID.MAX_DOCUMENTS; pub const WS_METADATA_PROPERTY_HOST_NAMES = WS_METADATA_PROPERTY_ID.HOST_NAMES; pub const WS_METADATA_PROPERTY_VERIFY_HOST_NAMES = WS_METADATA_PROPERTY_ID.VERIFY_HOST_NAMES; pub const WS_POLICY_STATE = enum(i32) { CREATED = 1, FAULTED = 2, }; pub const WS_POLICY_STATE_CREATED = WS_POLICY_STATE.CREATED; pub const WS_POLICY_STATE_FAULTED = WS_POLICY_STATE.FAULTED; pub const WS_POLICY_PROPERTY_ID = enum(i32) { STATE = 1, MAX_ALTERNATIVES = 2, MAX_DEPTH = 3, MAX_EXTENSIONS = 4, }; pub const WS_POLICY_PROPERTY_STATE = WS_POLICY_PROPERTY_ID.STATE; pub const WS_POLICY_PROPERTY_MAX_ALTERNATIVES = WS_POLICY_PROPERTY_ID.MAX_ALTERNATIVES; pub const WS_POLICY_PROPERTY_MAX_DEPTH = WS_POLICY_PROPERTY_ID.MAX_DEPTH; pub const WS_POLICY_PROPERTY_MAX_EXTENSIONS = WS_POLICY_PROPERTY_ID.MAX_EXTENSIONS; pub const WS_SECURITY_BINDING_CONSTRAINT_TYPE = enum(i32) { SSL_TRANSPORT_SECURITY_BINDING_CONSTRAINT_TYPE = 1, TCP_SSPI_TRANSPORT_SECURITY_BINDING_CONSTRAINT_TYPE = 2, HTTP_HEADER_AUTH_SECURITY_BINDING_CONSTRAINT_TYPE = 3, USERNAME_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = 4, KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = 5, ISSUED_TOKEN_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = 6, CERT_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = 7, SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = 8, }; pub const WS_SSL_TRANSPORT_SECURITY_BINDING_CONSTRAINT_TYPE = WS_SECURITY_BINDING_CONSTRAINT_TYPE.SSL_TRANSPORT_SECURITY_BINDING_CONSTRAINT_TYPE; pub const WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_CONSTRAINT_TYPE = WS_SECURITY_BINDING_CONSTRAINT_TYPE.TCP_SSPI_TRANSPORT_SECURITY_BINDING_CONSTRAINT_TYPE; pub const WS_HTTP_HEADER_AUTH_SECURITY_BINDING_CONSTRAINT_TYPE = WS_SECURITY_BINDING_CONSTRAINT_TYPE.HTTP_HEADER_AUTH_SECURITY_BINDING_CONSTRAINT_TYPE; pub const WS_USERNAME_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = WS_SECURITY_BINDING_CONSTRAINT_TYPE.USERNAME_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE; pub const WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = WS_SECURITY_BINDING_CONSTRAINT_TYPE.KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE; pub const WS_ISSUED_TOKEN_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = WS_SECURITY_BINDING_CONSTRAINT_TYPE.ISSUED_TOKEN_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE; pub const WS_CERT_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = WS_SECURITY_BINDING_CONSTRAINT_TYPE.CERT_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE; pub const WS_SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE = WS_SECURITY_BINDING_CONSTRAINT_TYPE.SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_CONSTRAINT_TYPE; pub const WS_POLICY_EXTENSION_TYPE = enum(i32) { E = 1, }; pub const WS_ENDPOINT_POLICY_EXTENSION_TYPE = WS_POLICY_EXTENSION_TYPE.E; pub const WS_BINDING_TEMPLATE_TYPE = enum(i32) { HTTP_BINDING_TEMPLATE_TYPE = 0, HTTP_SSL_BINDING_TEMPLATE_TYPE = 1, HTTP_HEADER_AUTH_BINDING_TEMPLATE_TYPE = 2, HTTP_SSL_HEADER_AUTH_BINDING_TEMPLATE_TYPE = 3, HTTP_SSL_USERNAME_BINDING_TEMPLATE_TYPE = 4, HTTP_SSL_KERBEROS_APREQ_BINDING_TEMPLATE_TYPE = 5, TCP_BINDING_TEMPLATE_TYPE = 6, TCP_SSPI_BINDING_TEMPLATE_TYPE = 7, TCP_SSPI_USERNAME_BINDING_TEMPLATE_TYPE = 8, TCP_SSPI_KERBEROS_APREQ_BINDING_TEMPLATE_TYPE = 9, HTTP_SSL_USERNAME_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE = 10, HTTP_SSL_KERBEROS_APREQ_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE = 11, TCP_SSPI_USERNAME_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE = 12, TCP_SSPI_KERBEROS_APREQ_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE = 13, }; pub const WS_HTTP_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.HTTP_BINDING_TEMPLATE_TYPE; pub const WS_HTTP_SSL_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.HTTP_SSL_BINDING_TEMPLATE_TYPE; pub const WS_HTTP_HEADER_AUTH_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.HTTP_HEADER_AUTH_BINDING_TEMPLATE_TYPE; pub const WS_HTTP_SSL_HEADER_AUTH_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.HTTP_SSL_HEADER_AUTH_BINDING_TEMPLATE_TYPE; pub const WS_HTTP_SSL_USERNAME_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.HTTP_SSL_USERNAME_BINDING_TEMPLATE_TYPE; pub const WS_HTTP_SSL_KERBEROS_APREQ_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.HTTP_SSL_KERBEROS_APREQ_BINDING_TEMPLATE_TYPE; pub const WS_TCP_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.TCP_BINDING_TEMPLATE_TYPE; pub const WS_TCP_SSPI_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.TCP_SSPI_BINDING_TEMPLATE_TYPE; pub const WS_TCP_SSPI_USERNAME_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.TCP_SSPI_USERNAME_BINDING_TEMPLATE_TYPE; pub const WS_TCP_SSPI_KERBEROS_APREQ_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.TCP_SSPI_KERBEROS_APREQ_BINDING_TEMPLATE_TYPE; pub const WS_HTTP_SSL_USERNAME_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.HTTP_SSL_USERNAME_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE; pub const WS_HTTP_SSL_KERBEROS_APREQ_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.HTTP_SSL_KERBEROS_APREQ_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE; pub const WS_TCP_SSPI_USERNAME_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.TCP_SSPI_USERNAME_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE; pub const WS_TCP_SSPI_KERBEROS_APREQ_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE = WS_BINDING_TEMPLATE_TYPE.TCP_SSPI_KERBEROS_APREQ_SECURITY_CONTEXT_BINDING_TEMPLATE_TYPE; pub const WS_READ_CALLBACK = fn( callbackState: ?*anyopaque, // TODO: what to do with BytesParamIndex 2? bytes: ?*anyopaque, maxSize: u32, actualSize: ?*u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_WRITE_CALLBACK = fn( callbackState: ?*anyopaque, buffers: [*]const WS_BYTES, count: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_PUSH_BYTES_CALLBACK = fn( callbackState: ?*anyopaque, writeCallback: ?WS_WRITE_CALLBACK, writeCallbackState: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_PULL_BYTES_CALLBACK = fn( callbackState: ?*anyopaque, // TODO: what to do with BytesParamIndex 2? bytes: ?*anyopaque, maxSize: u32, actualSize: ?*u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_DYNAMIC_STRING_CALLBACK = fn( callbackState: ?*anyopaque, string: ?*const WS_XML_STRING, found: ?*BOOL, id: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ASYNC_CALLBACK = fn( errorCode: HRESULT, callbackModel: WS_CALLBACK_MODEL, callbackState: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const WS_ASYNC_FUNCTION = fn( hr: HRESULT, callbackModel: WS_CALLBACK_MODEL, callbackState: ?*anyopaque, next: ?*WS_ASYNC_OPERATION, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_CREATE_CHANNEL_CALLBACK = fn( channelType: WS_CHANNEL_TYPE, // TODO: what to do with BytesParamIndex 2? channelParameters: ?*const anyopaque, channelParametersSize: u32, channelInstance: ?*?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_FREE_CHANNEL_CALLBACK = fn( channelInstance: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const WS_RESET_CHANNEL_CALLBACK = fn( channelInstance: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ABORT_CHANNEL_CALLBACK = fn( channelInstance: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_OPEN_CHANNEL_CALLBACK = fn( channelInstance: ?*anyopaque, endpointAddress: ?*const WS_ENDPOINT_ADDRESS, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_CLOSE_CHANNEL_CALLBACK = fn( channelInstance: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_SET_CHANNEL_PROPERTY_CALLBACK = fn( channelInstance: ?*anyopaque, id: WS_CHANNEL_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_GET_CHANNEL_PROPERTY_CALLBACK = fn( channelInstance: ?*anyopaque, id: WS_CHANNEL_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_READ_MESSAGE_START_CALLBACK = fn( channelInstance: ?*anyopaque, message: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_READ_MESSAGE_END_CALLBACK = fn( channelInstance: ?*anyopaque, message: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_WRITE_MESSAGE_START_CALLBACK = fn( channelInstance: ?*anyopaque, message: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_WRITE_MESSAGE_END_CALLBACK = fn( channelInstance: ?*anyopaque, message: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ABANDON_MESSAGE_CALLBACK = fn( channelInstance: ?*anyopaque, message: ?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_SHUTDOWN_SESSION_CHANNEL_CALLBACK = fn( channelInstance: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_CREATE_ENCODER_CALLBACK = fn( createContext: ?*anyopaque, writeCallback: ?WS_WRITE_CALLBACK, writeContext: ?*anyopaque, encoderContext: ?*?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ENCODER_GET_CONTENT_TYPE_CALLBACK = fn( encoderContext: ?*anyopaque, contentType: ?*const WS_STRING, newContentType: ?*WS_STRING, contentEncoding: ?*WS_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ENCODER_START_CALLBACK = fn( encoderContext: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ENCODER_ENCODE_CALLBACK = fn( encoderContext: ?*anyopaque, buffers: [*]const WS_BYTES, count: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ENCODER_END_CALLBACK = fn( encoderContext: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_FREE_ENCODER_CALLBACK = fn( encoderContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const WS_CREATE_DECODER_CALLBACK = fn( createContext: ?*anyopaque, readCallback: ?WS_READ_CALLBACK, readContext: ?*anyopaque, decoderContext: ?*?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_DECODER_GET_CONTENT_TYPE_CALLBACK = fn( decoderContext: ?*anyopaque, contentType: ?*const WS_STRING, contentEncoding: ?*const WS_STRING, newContentType: ?*WS_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_DECODER_START_CALLBACK = fn( encoderContext: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_DECODER_DECODE_CALLBACK = fn( encoderContext: ?*anyopaque, // TODO: what to do with BytesParamIndex 2? buffer: ?*anyopaque, maxLength: u32, length: ?*u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_DECODER_END_CALLBACK = fn( encoderContext: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_FREE_DECODER_CALLBACK = fn( decoderContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const WS_HTTP_REDIRECT_CALLBACK = fn( state: ?*anyopaque, originalUrl: ?*const WS_STRING, newUrl: ?*const WS_STRING, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_CREATE_LISTENER_CALLBACK = fn( channelType: WS_CHANNEL_TYPE, // TODO: what to do with BytesParamIndex 2? listenerParameters: ?*const anyopaque, listenerParametersSize: u32, listenerInstance: ?*?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_FREE_LISTENER_CALLBACK = fn( listenerInstance: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const WS_RESET_LISTENER_CALLBACK = fn( listenerInstance: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_OPEN_LISTENER_CALLBACK = fn( listenerInstance: ?*anyopaque, url: ?*const WS_STRING, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_CLOSE_LISTENER_CALLBACK = fn( listenerInstance: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_GET_LISTENER_PROPERTY_CALLBACK = fn( listenerInstance: ?*anyopaque, id: WS_LISTENER_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_SET_LISTENER_PROPERTY_CALLBACK = fn( listenerInstance: ?*anyopaque, id: WS_LISTENER_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ACCEPT_CHANNEL_CALLBACK = fn( listenerInstance: ?*anyopaque, channelInstance: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_ABORT_LISTENER_CALLBACK = fn( listenerInstance: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_CREATE_CHANNEL_FOR_LISTENER_CALLBACK = fn( listenerInstance: ?*anyopaque, // TODO: what to do with BytesParamIndex 2? channelParameters: ?*const anyopaque, channelParametersSize: u32, channelInstance: ?*?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_MESSAGE_DONE_CALLBACK = fn( doneCallbackState: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const WS_CERTIFICATE_VALIDATION_CALLBACK = fn( certContext: ?*const CERT_CONTEXT, state: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_GET_CERT_CALLBACK = fn( getCertCallbackState: ?*anyopaque, targetAddress: ?*const WS_ENDPOINT_ADDRESS, viaUri: ?*const WS_STRING, cert: ?*const ?*CERT_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_CERT_ISSUER_LIST_NOTIFICATION_CALLBACK = fn( certIssuerListNotificationCallbackState: ?*anyopaque, issuerList: ?*const SecPkgContext_IssuerListInfoEx, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_VALIDATE_PASSWORD_CALLBACK = fn( passwordValidatorCallbackState: ?*anyopaque, username: ?*const WS_STRING, password: ?*const WS_STRING, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_VALIDATE_SAML_CALLBACK = fn( samlValidatorCallbackState: ?*anyopaque, samlAssertion: ?*WS_XML_BUFFER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_DURATION_COMPARISON_CALLBACK = fn( duration1: ?*const WS_DURATION, duration2: ?*const WS_DURATION, result: ?*i32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_READ_TYPE_CALLBACK = fn( reader: ?*WS_XML_READER, typeMapping: WS_TYPE_MAPPING, descriptionData: ?*const anyopaque, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 5? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_WRITE_TYPE_CALLBACK = fn( writer: ?*WS_XML_WRITER, typeMapping: WS_TYPE_MAPPING, descriptionData: ?*const anyopaque, // TODO: what to do with BytesParamIndex 4? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_IS_DEFAULT_VALUE_CALLBACK = fn( descriptionData: ?*const anyopaque, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, // TODO: what to do with BytesParamIndex 3? defaultValue: ?*const anyopaque, valueSize: u32, isDefault: ?*BOOL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_SERVICE_MESSAGE_RECEIVE_CALLBACK = fn( context: ?*const WS_OPERATION_CONTEXT, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_OPERATION_CANCEL_CALLBACK = fn( reason: WS_SERVICE_CANCEL_REASON, state: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const WS_OPERATION_FREE_STATE_CALLBACK = fn( state: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const WS_SERVICE_STUB_CALLBACK = fn( context: ?*const WS_OPERATION_CONTEXT, frame: ?*anyopaque, callback: ?*const anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_SERVICE_ACCEPT_CHANNEL_CALLBACK = fn( context: ?*const WS_OPERATION_CONTEXT, channelState: ?*?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_SERVICE_CLOSE_CHANNEL_CALLBACK = fn( context: ?*const WS_OPERATION_CONTEXT, asyncContext: ?*const WS_ASYNC_CONTEXT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_SERVICE_SECURITY_CALLBACK = fn( context: ?*const WS_OPERATION_CONTEXT, authorized: ?*BOOL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_PROXY_MESSAGE_CALLBACK = fn( message: ?*WS_MESSAGE, heap: ?*WS_HEAP, state: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const WS_XML_DICTIONARY = extern struct { guid: Guid, strings: ?*WS_XML_STRING, stringCount: u32, isConst: BOOL, }; pub const WS_XML_STRING = extern struct { length: u32, bytes: ?*u8, dictionary: ?*WS_XML_DICTIONARY, id: u32, }; pub const WS_XML_QNAME = extern struct { localName: WS_XML_STRING, ns: WS_XML_STRING, }; pub const WS_XML_NODE_POSITION = extern struct { buffer: ?*WS_XML_BUFFER, node: ?*anyopaque, }; pub const WS_XML_READER_PROPERTY = extern struct { id: WS_XML_READER_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_XML_CANONICALIZATION_INCLUSIVE_PREFIXES = extern struct { prefixCount: u32, prefixes: ?*WS_XML_STRING, }; pub const WS_XML_CANONICALIZATION_PROPERTY = extern struct { id: WS_XML_CANONICALIZATION_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_XML_WRITER_PROPERTY = extern struct { id: WS_XML_WRITER_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_XML_BUFFER_PROPERTY = extern struct { id: WS_XML_BUFFER_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_XML_TEXT = extern struct { textType: WS_XML_TEXT_TYPE, }; pub const WS_XML_UTF8_TEXT = extern struct { text: WS_XML_TEXT, value: WS_XML_STRING, }; pub const WS_XML_UTF16_TEXT = extern struct { text: WS_XML_TEXT, bytes: ?*u8, byteCount: u32, }; pub const WS_XML_BASE64_TEXT = extern struct { text: WS_XML_TEXT, bytes: ?*u8, length: u32, }; pub const WS_XML_BOOL_TEXT = extern struct { text: WS_XML_TEXT, value: BOOL, }; pub const WS_XML_INT32_TEXT = extern struct { text: WS_XML_TEXT, value: i32, }; pub const WS_XML_INT64_TEXT = extern struct { text: WS_XML_TEXT, value: i64, }; pub const WS_XML_UINT64_TEXT = extern struct { text: WS_XML_TEXT, value: u64, }; pub const WS_XML_FLOAT_TEXT = extern struct { text: WS_XML_TEXT, value: f32, }; pub const WS_XML_DOUBLE_TEXT = extern struct { text: WS_XML_TEXT, value: f64, }; pub const WS_XML_DECIMAL_TEXT = extern struct { text: WS_XML_TEXT, value: DECIMAL, }; pub const WS_XML_GUID_TEXT = extern struct { text: WS_XML_TEXT, value: Guid, }; pub const WS_XML_UNIQUE_ID_TEXT = extern struct { text: WS_XML_TEXT, value: Guid, }; pub const WS_DATETIME = extern struct { ticks: u64, format: WS_DATETIME_FORMAT, }; pub const WS_XML_DATETIME_TEXT = extern struct { text: WS_XML_TEXT, value: WS_DATETIME, }; pub const WS_TIMESPAN = extern struct { ticks: i64, }; pub const WS_XML_TIMESPAN_TEXT = extern struct { text: WS_XML_TEXT, value: WS_TIMESPAN, }; pub const WS_XML_QNAME_TEXT = extern struct { text: WS_XML_TEXT, prefix: ?*WS_XML_STRING, localName: ?*WS_XML_STRING, ns: ?*WS_XML_STRING, }; pub const WS_XML_LIST_TEXT = extern struct { text: WS_XML_TEXT, itemCount: u32, items: ?*?*WS_XML_TEXT, }; pub const WS_XML_NODE = extern struct { nodeType: WS_XML_NODE_TYPE, }; pub const WS_XML_ATTRIBUTE = extern struct { singleQuote: u8, isXmlNs: u8, prefix: ?*WS_XML_STRING, localName: ?*WS_XML_STRING, ns: ?*WS_XML_STRING, value: ?*WS_XML_TEXT, }; pub const WS_XML_ELEMENT_NODE = extern struct { node: WS_XML_NODE, prefix: ?*WS_XML_STRING, localName: ?*WS_XML_STRING, ns: ?*WS_XML_STRING, attributeCount: u32, attributes: ?*?*WS_XML_ATTRIBUTE, isEmpty: BOOL, }; pub const WS_XML_TEXT_NODE = extern struct { node: WS_XML_NODE, text: ?*WS_XML_TEXT, }; pub const WS_XML_COMMENT_NODE = extern struct { node: WS_XML_NODE, value: WS_XML_STRING, }; pub const WS_XML_READER_INPUT = extern struct { inputType: WS_XML_READER_INPUT_TYPE, }; pub const WS_XML_READER_BUFFER_INPUT = extern struct { input: WS_XML_READER_INPUT, encodedData: ?*anyopaque, encodedDataSize: u32, }; pub const WS_XML_READER_STREAM_INPUT = extern struct { input: WS_XML_READER_INPUT, readCallback: ?WS_READ_CALLBACK, readCallbackState: ?*anyopaque, }; pub const WS_XML_READER_ENCODING = extern struct { encodingType: WS_XML_READER_ENCODING_TYPE, }; pub const WS_XML_READER_TEXT_ENCODING = extern struct { encoding: WS_XML_READER_ENCODING, charSet: WS_CHARSET, }; pub const WS_XML_READER_BINARY_ENCODING = extern struct { encoding: WS_XML_READER_ENCODING, staticDictionary: ?*WS_XML_DICTIONARY, dynamicDictionary: ?*WS_XML_DICTIONARY, }; pub const WS_STRING = extern struct { length: u32, chars: ?PWSTR, }; pub const WS_XML_READER_MTOM_ENCODING = extern struct { encoding: WS_XML_READER_ENCODING, textEncoding: ?*WS_XML_READER_ENCODING, readMimeHeader: BOOL, startInfo: WS_STRING, boundary: WS_STRING, startUri: WS_STRING, }; pub const WS_XML_READER_RAW_ENCODING = extern struct { encoding: WS_XML_READER_ENCODING, }; pub const WS_XML_WRITER_ENCODING = extern struct { encodingType: WS_XML_WRITER_ENCODING_TYPE, }; pub const WS_XML_WRITER_TEXT_ENCODING = extern struct { encoding: WS_XML_WRITER_ENCODING, charSet: WS_CHARSET, }; pub const WS_XML_WRITER_BINARY_ENCODING = extern struct { encoding: WS_XML_WRITER_ENCODING, staticDictionary: ?*WS_XML_DICTIONARY, dynamicStringCallback: ?WS_DYNAMIC_STRING_CALLBACK, dynamicStringCallbackState: ?*anyopaque, }; pub const WS_XML_WRITER_MTOM_ENCODING = extern struct { encoding: WS_XML_WRITER_ENCODING, textEncoding: ?*WS_XML_WRITER_ENCODING, writeMimeHeader: BOOL, boundary: WS_STRING, startInfo: WS_STRING, startUri: WS_STRING, maxInlineByteCount: u32, }; pub const WS_XML_WRITER_RAW_ENCODING = extern struct { encoding: WS_XML_WRITER_ENCODING, }; pub const WS_XML_WRITER_OUTPUT = extern struct { outputType: WS_XML_WRITER_OUTPUT_TYPE, }; pub const WS_XML_WRITER_BUFFER_OUTPUT = extern struct { output: WS_XML_WRITER_OUTPUT, }; pub const WS_XML_WRITER_STREAM_OUTPUT = extern struct { output: WS_XML_WRITER_OUTPUT, writeCallback: ?WS_WRITE_CALLBACK, writeCallbackState: ?*anyopaque, }; pub const WS_XML_WRITER_PROPERTIES = extern struct { properties: ?*WS_XML_WRITER_PROPERTY, propertyCount: u32, }; pub const WS_XML_READER_PROPERTIES = extern struct { properties: ?*WS_XML_READER_PROPERTY, propertyCount: u32, }; pub const WS_ASYNC_CONTEXT = extern struct { callback: ?WS_ASYNC_CALLBACK, callbackState: ?*anyopaque, }; pub const WS_ASYNC_STATE = extern struct { internal0: ?*anyopaque, internal1: ?*anyopaque, internal2: ?*anyopaque, internal3: ?*anyopaque, internal4: ?*anyopaque, }; pub const WS_ASYNC_OPERATION = extern struct { function: ?WS_ASYNC_FUNCTION, }; pub const WS_CHANNEL_PROPERTY = extern struct { id: WS_CHANNEL_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_CUSTOM_HTTP_PROXY = extern struct { servers: WS_STRING, bypass: WS_STRING, }; pub const WS_CHANNEL_PROPERTIES = extern struct { properties: ?*WS_CHANNEL_PROPERTY, propertyCount: u32, }; pub const WS_CUSTOM_CHANNEL_CALLBACKS = extern struct { createChannelCallback: ?WS_CREATE_CHANNEL_CALLBACK, freeChannelCallback: ?WS_FREE_CHANNEL_CALLBACK, resetChannelCallback: ?WS_RESET_CHANNEL_CALLBACK, openChannelCallback: ?WS_OPEN_CHANNEL_CALLBACK, closeChannelCallback: ?WS_CLOSE_CHANNEL_CALLBACK, abortChannelCallback: ?WS_ABORT_CHANNEL_CALLBACK, getChannelPropertyCallback: ?WS_GET_CHANNEL_PROPERTY_CALLBACK, setChannelPropertyCallback: ?WS_SET_CHANNEL_PROPERTY_CALLBACK, writeMessageStartCallback: ?WS_WRITE_MESSAGE_START_CALLBACK, writeMessageEndCallback: ?WS_WRITE_MESSAGE_END_CALLBACK, readMessageStartCallback: ?WS_READ_MESSAGE_START_CALLBACK, readMessageEndCallback: ?WS_READ_MESSAGE_END_CALLBACK, abandonMessageCallback: ?WS_ABANDON_MESSAGE_CALLBACK, shutdownSessionChannelCallback: ?WS_SHUTDOWN_SESSION_CHANNEL_CALLBACK, }; pub const WS_HTTP_HEADER_MAPPING = extern struct { headerName: WS_XML_STRING, headerMappingOptions: u32, }; pub const WS_HTTP_MESSAGE_MAPPING = extern struct { requestMappingOptions: u32, responseMappingOptions: u32, requestHeaderMappings: ?*?*WS_HTTP_HEADER_MAPPING, requestHeaderMappingCount: u32, responseHeaderMappings: ?*?*WS_HTTP_HEADER_MAPPING, responseHeaderMappingCount: u32, }; pub const WS_ELEMENT_DESCRIPTION = extern struct { elementLocalName: ?*WS_XML_STRING, elementNs: ?*WS_XML_STRING, type: WS_TYPE, typeDescription: ?*anyopaque, }; pub const WS_MESSAGE_DESCRIPTION = extern struct { action: ?*WS_XML_STRING, bodyElementDescription: ?*WS_ELEMENT_DESCRIPTION, }; pub const WS_CHANNEL_ENCODER = extern struct { createContext: ?*anyopaque, createEncoderCallback: ?WS_CREATE_ENCODER_CALLBACK, encoderGetContentTypeCallback: ?WS_ENCODER_GET_CONTENT_TYPE_CALLBACK, encoderStartCallback: ?WS_ENCODER_START_CALLBACK, encoderEncodeCallback: ?WS_ENCODER_ENCODE_CALLBACK, encoderEndCallback: ?WS_ENCODER_END_CALLBACK, freeEncoderCallback: ?WS_FREE_ENCODER_CALLBACK, }; pub const WS_CHANNEL_DECODER = extern struct { createContext: ?*anyopaque, createDecoderCallback: ?WS_CREATE_DECODER_CALLBACK, decoderGetContentTypeCallback: ?WS_DECODER_GET_CONTENT_TYPE_CALLBACK, decoderStartCallback: ?WS_DECODER_START_CALLBACK, decoderDecodeCallback: ?WS_DECODER_DECODE_CALLBACK, decoderEndCallback: ?WS_DECODER_END_CALLBACK, freeDecoderCallback: ?WS_FREE_DECODER_CALLBACK, }; pub const WS_HTTP_REDIRECT_CALLBACK_CONTEXT = extern struct { callback: ?WS_HTTP_REDIRECT_CALLBACK, state: ?*anyopaque, }; pub const WS_ENDPOINT_IDENTITY = extern struct { identityType: WS_ENDPOINT_IDENTITY_TYPE, }; pub const WS_ENDPOINT_ADDRESS = extern struct { url: WS_STRING, headers: ?*WS_XML_BUFFER, extensions: ?*WS_XML_BUFFER, identity: ?*WS_ENDPOINT_IDENTITY, }; pub const WS_DNS_ENDPOINT_IDENTITY = extern struct { identity: WS_ENDPOINT_IDENTITY, dns: WS_STRING, }; pub const WS_UPN_ENDPOINT_IDENTITY = extern struct { identity: WS_ENDPOINT_IDENTITY, upn: WS_STRING, }; pub const WS_SPN_ENDPOINT_IDENTITY = extern struct { identity: WS_ENDPOINT_IDENTITY, spn: WS_STRING, }; pub const WS_BYTES = extern struct { length: u32, bytes: ?*u8, }; pub const WS_RSA_ENDPOINT_IDENTITY = extern struct { identity: WS_ENDPOINT_IDENTITY, modulus: WS_BYTES, exponent: WS_BYTES, }; pub const WS_CERT_ENDPOINT_IDENTITY = extern struct { identity: WS_ENDPOINT_IDENTITY, rawCertificateData: WS_BYTES, }; pub const WS_UNKNOWN_ENDPOINT_IDENTITY = extern struct { identity: WS_ENDPOINT_IDENTITY, element: ?*WS_XML_BUFFER, }; pub const WS_ERROR_PROPERTY = extern struct { id: WS_ERROR_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_FAULT_REASON = extern struct { text: WS_STRING, lang: WS_STRING, }; pub const WS_FAULT_CODE = extern struct { value: WS_XML_QNAME, subCode: ?*WS_FAULT_CODE, }; pub const WS_FAULT = extern struct { code: ?*WS_FAULT_CODE, reasons: ?*WS_FAULT_REASON, reasonCount: u32, actor: WS_STRING, node: WS_STRING, detail: ?*WS_XML_BUFFER, }; pub const WS_FAULT_DETAIL_DESCRIPTION = extern struct { action: ?*WS_XML_STRING, detailElementDescription: ?*WS_ELEMENT_DESCRIPTION, }; pub const WS_HEAP_PROPERTY = extern struct { id: WS_HEAP_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_HEAP_PROPERTIES = extern struct { properties: ?*WS_HEAP_PROPERTY, propertyCount: u32, }; pub const WS_LISTENER_PROPERTY = extern struct { id: WS_LISTENER_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_DISALLOWED_USER_AGENT_SUBSTRINGS = extern struct { subStringCount: u32, subStrings: ?*?*WS_STRING, }; pub const WS_LISTENER_PROPERTIES = extern struct { properties: ?*WS_LISTENER_PROPERTY, propertyCount: u32, }; pub const WS_HOST_NAMES = extern struct { hostNames: ?*WS_STRING, hostNameCount: u32, }; pub const WS_CUSTOM_LISTENER_CALLBACKS = extern struct { createListenerCallback: ?WS_CREATE_LISTENER_CALLBACK, freeListenerCallback: ?WS_FREE_LISTENER_CALLBACK, resetListenerCallback: ?WS_RESET_LISTENER_CALLBACK, openListenerCallback: ?WS_OPEN_LISTENER_CALLBACK, closeListenerCallback: ?WS_CLOSE_LISTENER_CALLBACK, abortListenerCallback: ?WS_ABORT_LISTENER_CALLBACK, getListenerPropertyCallback: ?WS_GET_LISTENER_PROPERTY_CALLBACK, setListenerPropertyCallback: ?WS_SET_LISTENER_PROPERTY_CALLBACK, createChannelForListenerCallback: ?WS_CREATE_CHANNEL_FOR_LISTENER_CALLBACK, acceptChannelCallback: ?WS_ACCEPT_CHANNEL_CALLBACK, }; pub const WS_MESSAGE_PROPERTY = extern struct { id: WS_MESSAGE_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_MESSAGE_PROPERTIES = extern struct { properties: ?*WS_MESSAGE_PROPERTY, propertyCount: u32, }; pub const WS_SECURITY_ALGORITHM_PROPERTY = extern struct { id: WS_SECURITY_ALGORITHM_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_SECURITY_ALGORITHM_SUITE = extern struct { canonicalizationAlgorithm: WS_SECURITY_ALGORITHM_ID, digestAlgorithm: WS_SECURITY_ALGORITHM_ID, symmetricSignatureAlgorithm: WS_SECURITY_ALGORITHM_ID, asymmetricSignatureAlgorithm: WS_SECURITY_ALGORITHM_ID, encryptionAlgorithm: WS_SECURITY_ALGORITHM_ID, keyDerivationAlgorithm: WS_SECURITY_ALGORITHM_ID, symmetricKeyWrapAlgorithm: WS_SECURITY_ALGORITHM_ID, asymmetricKeyWrapAlgorithm: WS_SECURITY_ALGORITHM_ID, minSymmetricKeyLength: u32, maxSymmetricKeyLength: u32, minAsymmetricKeyLength: u32, maxAsymmetricKeyLength: u32, properties: ?*WS_SECURITY_ALGORITHM_PROPERTY, propertyCount: u32, }; pub const WS_SECURITY_PROPERTY = extern struct { id: WS_SECURITY_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_SECURITY_PROPERTIES = extern struct { properties: ?*WS_SECURITY_PROPERTY, propertyCount: u32, }; pub const WS_SECURITY_BINDING_PROPERTY = extern struct { id: WS_SECURITY_BINDING_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_SECURITY_BINDING_PROPERTIES = extern struct { properties: ?*WS_SECURITY_BINDING_PROPERTY, propertyCount: u32, }; pub const WS_SERVICE_SECURITY_IDENTITIES = extern struct { serviceIdentities: ?*WS_STRING, serviceIdentityCount: u32, }; pub const WS_CERTIFICATE_VALIDATION_CALLBACK_CONTEXT = extern struct { callback: ?WS_CERTIFICATE_VALIDATION_CALLBACK, state: ?*anyopaque, }; pub const WS_CERT_CREDENTIAL = extern struct { credentialType: WS_CERT_CREDENTIAL_TYPE, }; pub const WS_SUBJECT_NAME_CERT_CREDENTIAL = extern struct { credential: WS_CERT_CREDENTIAL, storeLocation: u32, storeName: WS_STRING, subjectName: WS_STRING, }; pub const WS_THUMBPRINT_CERT_CREDENTIAL = extern struct { credential: WS_CERT_CREDENTIAL, storeLocation: u32, storeName: WS_STRING, thumbprint: WS_STRING, }; pub const WS_CUSTOM_CERT_CREDENTIAL = extern struct { credential: WS_CERT_CREDENTIAL, getCertCallback: ?WS_GET_CERT_CALLBACK, getCertCallbackState: ?*anyopaque, certIssuerListNotificationCallback: ?WS_CERT_ISSUER_LIST_NOTIFICATION_CALLBACK, certIssuerListNotificationCallbackState: ?*anyopaque, }; pub const WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL = extern struct { credentialType: WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE, }; pub const WS_STRING_WINDOWS_INTEGRATED_AUTH_CREDENTIAL = extern struct { credential: WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, username: WS_STRING, password: <PASSWORD>, domain: WS_STRING, }; pub const WS_DEFAULT_WINDOWS_INTEGRATED_AUTH_CREDENTIAL = extern struct { credential: WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, }; pub const WS_OPAQUE_WINDOWS_INTEGRATED_AUTH_CREDENTIAL = extern struct { credential: WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, opaqueAuthIdentity: ?*anyopaque, }; pub const WS_USERNAME_CREDENTIAL = extern struct { credentialType: WS_USERNAME_CREDENTIAL_TYPE, }; pub const WS_STRING_USERNAME_CREDENTIAL = extern struct { credential: WS_USERNAME_CREDENTIAL, username: WS_STRING, password: <PASSWORD>, }; pub const WS_SECURITY_KEY_HANDLE = extern struct { keyHandleType: WS_SECURITY_KEY_HANDLE_TYPE, }; pub const WS_RAW_SYMMETRIC_SECURITY_KEY_HANDLE = extern struct { keyHandle: WS_SECURITY_KEY_HANDLE, rawKeyBytes: WS_BYTES, }; pub const WS_NCRYPT_ASYMMETRIC_SECURITY_KEY_HANDLE = extern struct { keyHandle: WS_SECURITY_KEY_HANDLE, asymmetricKey: usize, }; pub const WS_CAPI_ASYMMETRIC_SECURITY_KEY_HANDLE = extern struct { keyHandle: WS_SECURITY_KEY_HANDLE, provider: usize, keySpec: u32, }; pub const WS_SECURITY_BINDING = extern struct { bindingType: WS_SECURITY_BINDING_TYPE, properties: ?*WS_SECURITY_BINDING_PROPERTY, propertyCount: u32, }; pub const WS_SSL_TRANSPORT_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, localCertCredential: ?*WS_CERT_CREDENTIAL, }; pub const WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, clientCredential: ?*WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, }; pub const WS_NAMEDPIPE_SSPI_TRANSPORT_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, clientCredential: ?*WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, }; pub const WS_HTTP_HEADER_AUTH_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, clientCredential: ?*WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, }; pub const WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, bindingUsage: WS_MESSAGE_SECURITY_USAGE, clientCredential: ?*WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, }; pub const WS_USERNAME_MESSAGE_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, bindingUsage: WS_MESSAGE_SECURITY_USAGE, clientCredential: ?*WS_USERNAME_CREDENTIAL, passwordValidator: ?WS_VALIDATE_PASSWORD_CALLBACK, passwordValidatorCallbackState: ?*anyopaque, }; pub const WS_SECURITY_DESCRIPTION = extern struct { securityBindings: ?*?*WS_SECURITY_BINDING, securityBindingCount: u32, properties: ?*WS_SECURITY_PROPERTY, propertyCount: u32, }; pub const WS_SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, bindingUsage: WS_MESSAGE_SECURITY_USAGE, bootstrapSecurityDescription: ?*WS_SECURITY_DESCRIPTION, }; pub const WS_SECURITY_CONTEXT_PROPERTY = extern struct { id: WS_SECURITY_CONTEXT_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_XML_SECURITY_TOKEN_PROPERTY = extern struct { id: WS_XML_SECURITY_TOKEN_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_XML_TOKEN_MESSAGE_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, bindingUsage: WS_MESSAGE_SECURITY_USAGE, xmlToken: ?*WS_SECURITY_TOKEN, }; pub const WS_SAML_AUTHENTICATOR = extern struct { authenticatorType: WS_SAML_AUTHENTICATOR_TYPE, }; pub const WS_CERT_SIGNED_SAML_AUTHENTICATOR = extern struct { authenticator: WS_SAML_AUTHENTICATOR, trustedIssuerCerts: ?*const ?*CERT_CONTEXT, trustedIssuerCertCount: u32, decryptionCert: ?*const CERT_CONTEXT, samlValidator: ?WS_VALIDATE_SAML_CALLBACK, samlValidatorCallbackState: ?*anyopaque, }; pub const WS_SAML_MESSAGE_SECURITY_BINDING = extern struct { binding: WS_SECURITY_BINDING, bindingUsage: WS_MESSAGE_SECURITY_USAGE, authenticator: ?*WS_SAML_AUTHENTICATOR, }; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY = extern struct { id: WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_ANY_ATTRIBUTE = extern struct { localName: WS_XML_STRING, ns: WS_XML_STRING, value: ?*WS_XML_TEXT, }; pub const WS_ANY_ATTRIBUTES = extern struct { attributes: ?*WS_ANY_ATTRIBUTE, attributeCount: u32, }; pub const WS_BOOL_DESCRIPTION = extern struct { value: BOOL, }; pub const WS_GUID_DESCRIPTION = extern struct { value: Guid, }; pub const WS_DATETIME_DESCRIPTION = extern struct { minValue: WS_DATETIME, maxValue: WS_DATETIME, }; pub const WS_DURATION = extern struct { negative: BOOL, years: u32, months: u32, days: u32, hours: u32, minutes: u32, seconds: u32, milliseconds: u32, ticks: u32, }; pub const WS_DURATION_DESCRIPTION = extern struct { minValue: WS_DURATION, maxValue: WS_DURATION, comparer: ?WS_DURATION_COMPARISON_CALLBACK, }; pub const WS_TIMESPAN_DESCRIPTION = extern struct { minValue: WS_TIMESPAN, maxValue: WS_TIMESPAN, }; pub const WS_UNIQUE_ID_DESCRIPTION = extern struct { minCharCount: u32, maxCharCount: u32, }; pub const WS_STRING_DESCRIPTION = extern struct { minCharCount: u32, maxCharCount: u32, }; pub const WS_XML_STRING_DESCRIPTION = extern struct { minByteCount: u32, maxByteCount: u32, }; pub const WS_XML_QNAME_DESCRIPTION = extern struct { minLocalNameByteCount: u32, maxLocalNameByteCount: u32, minNsByteCount: u32, maxNsByteCount: u32, }; pub const WS_CHAR_ARRAY_DESCRIPTION = extern struct { minCharCount: u32, maxCharCount: u32, }; pub const WS_BYTE_ARRAY_DESCRIPTION = extern struct { minByteCount: u32, maxByteCount: u32, }; pub const WS_UTF8_ARRAY_DESCRIPTION = extern struct { minByteCount: u32, maxByteCount: u32, }; pub const WS_WSZ_DESCRIPTION = extern struct { minCharCount: u32, maxCharCount: u32, }; pub const WS_INT8_DESCRIPTION = extern struct { minValue: CHAR, maxValue: CHAR, }; pub const WS_UINT8_DESCRIPTION = extern struct { minValue: u8, maxValue: u8, }; pub const WS_INT16_DESCRIPTION = extern struct { minValue: i16, maxValue: i16, }; pub const WS_UINT16_DESCRIPTION = extern struct { minValue: u16, maxValue: u16, }; pub const WS_INT32_DESCRIPTION = extern struct { minValue: i32, maxValue: i32, }; pub const WS_UINT32_DESCRIPTION = extern struct { minValue: u32, maxValue: u32, }; pub const WS_INT64_DESCRIPTION = extern struct { minValue: i64, maxValue: i64, }; pub const WS_UINT64_DESCRIPTION = extern struct { minValue: u64, maxValue: u64, }; pub const WS_FLOAT_DESCRIPTION = extern struct { minValue: f32, maxValue: f32, }; pub const WS_DOUBLE_DESCRIPTION = extern struct { minValue: f64, maxValue: f64, }; pub const WS_DECIMAL_DESCRIPTION = extern struct { minValue: DECIMAL, maxValue: DECIMAL, }; pub const WS_BYTES_DESCRIPTION = extern struct { minByteCount: u32, maxByteCount: u32, }; pub const WS_ENUM_VALUE = extern struct { value: i32, name: ?*WS_XML_STRING, }; pub const WS_ENUM_DESCRIPTION = extern struct { values: ?*WS_ENUM_VALUE, valueCount: u32, maxByteCount: u32, nameIndices: ?*u32, }; pub const WS_ITEM_RANGE = extern struct { minItemCount: u32, maxItemCount: u32, }; pub const WS_DEFAULT_VALUE = extern struct { value: ?*anyopaque, valueSize: u32, }; pub const WS_FIELD_DESCRIPTION = extern struct { mapping: WS_FIELD_MAPPING, localName: ?*WS_XML_STRING, ns: ?*WS_XML_STRING, type: WS_TYPE, typeDescription: ?*anyopaque, offset: u32, options: u32, defaultValue: ?*WS_DEFAULT_VALUE, countOffset: u32, itemLocalName: ?*WS_XML_STRING, itemNs: ?*WS_XML_STRING, itemRange: ?*WS_ITEM_RANGE, }; pub const WS_UNION_FIELD_DESCRIPTION = extern struct { value: i32, field: WS_FIELD_DESCRIPTION, }; pub const WS_STRUCT_DESCRIPTION = extern struct { size: u32, alignment: u32, fields: ?*?*WS_FIELD_DESCRIPTION, fieldCount: u32, typeLocalName: ?*WS_XML_STRING, typeNs: ?*WS_XML_STRING, parentType: ?*WS_STRUCT_DESCRIPTION, subTypes: ?*?*WS_STRUCT_DESCRIPTION, subTypeCount: u32, structOptions: u32, }; pub const WS_UNION_DESCRIPTION = extern struct { size: u32, alignment: u32, fields: ?*?*WS_UNION_FIELD_DESCRIPTION, fieldCount: u32, enumOffset: u32, noneEnumValue: i32, valueIndices: ?*u32, }; pub const WS_ENDPOINT_ADDRESS_DESCRIPTION = extern struct { addressingVersion: WS_ADDRESSING_VERSION, }; pub const WS_FAULT_DESCRIPTION = extern struct { envelopeVersion: WS_ENVELOPE_VERSION, }; pub const WS_VOID_DESCRIPTION = extern struct { size: u32, }; pub const WS_CUSTOM_TYPE_DESCRIPTION = extern struct { size: u32, alignment: u32, readCallback: ?WS_READ_TYPE_CALLBACK, writeCallback: ?WS_WRITE_TYPE_CALLBACK, descriptionData: ?*anyopaque, isDefaultValueCallback: ?WS_IS_DEFAULT_VALUE_CALLBACK, }; pub const WS_ATTRIBUTE_DESCRIPTION = extern struct { attributeLocalName: ?*WS_XML_STRING, attributeNs: ?*WS_XML_STRING, type: WS_TYPE, typeDescription: ?*anyopaque, }; pub const WS_PARAMETER_DESCRIPTION = extern struct { parameterType: WS_PARAMETER_TYPE, inputMessageIndex: u16, outputMessageIndex: u16, }; pub const WS_OPERATION_DESCRIPTION = extern struct { versionInfo: u32, inputMessageDescription: ?*WS_MESSAGE_DESCRIPTION, outputMessageDescription: ?*WS_MESSAGE_DESCRIPTION, inputMessageOptions: u32, outputMessageOptions: u32, parameterCount: u16, parameterDescription: ?*WS_PARAMETER_DESCRIPTION, stubCallback: ?WS_SERVICE_STUB_CALLBACK, style: WS_OPERATION_STYLE, }; pub const WS_CONTRACT_DESCRIPTION = extern struct { operationCount: u32, operations: ?*?*WS_OPERATION_DESCRIPTION, }; pub const WS_SERVICE_CONTRACT = extern struct { contractDescription: ?*const WS_CONTRACT_DESCRIPTION, defaultMessageHandlerCallback: ?WS_SERVICE_MESSAGE_RECEIVE_CALLBACK, methodTable: ?*const anyopaque, }; pub const WS_SERVICE_PROPERTY = extern struct { id: WS_SERVICE_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_SERVICE_ENDPOINT_PROPERTY = extern struct { id: WS_SERVICE_ENDPOINT_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_SERVICE_PROPERTY_ACCEPT_CALLBACK = extern struct { callback: ?WS_SERVICE_ACCEPT_CHANNEL_CALLBACK, }; pub const WS_SERVICE_METADATA_DOCUMENT = extern struct { content: ?*WS_XML_STRING, name: ?*WS_STRING, }; pub const WS_SERVICE_METADATA = extern struct { documentCount: u32, documents: ?*?*WS_SERVICE_METADATA_DOCUMENT, serviceName: ?*WS_XML_STRING, serviceNs: ?*WS_XML_STRING, }; pub const WS_SERVICE_PROPERTY_CLOSE_CALLBACK = extern struct { callback: ?WS_SERVICE_CLOSE_CHANNEL_CALLBACK, }; pub const WS_SERVICE_ENDPOINT_METADATA = extern struct { portName: ?*WS_XML_STRING, bindingName: ?*WS_XML_STRING, bindingNs: ?*WS_XML_STRING, }; pub const WS_SERVICE_ENDPOINT = extern struct { address: WS_ENDPOINT_ADDRESS, channelBinding: WS_CHANNEL_BINDING, channelType: WS_CHANNEL_TYPE, securityDescription: ?*const WS_SECURITY_DESCRIPTION, contract: ?*const WS_SERVICE_CONTRACT, authorizationCallback: ?WS_SERVICE_SECURITY_CALLBACK, properties: ?*const WS_SERVICE_ENDPOINT_PROPERTY, propertyCount: u32, channelProperties: WS_CHANNEL_PROPERTIES, }; pub const WS_PROXY_PROPERTY = extern struct { id: WS_PROXY_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_PROXY_MESSAGE_CALLBACK_CONTEXT = extern struct { callback: ?WS_PROXY_MESSAGE_CALLBACK, state: ?*anyopaque, }; pub const WS_CALL_PROPERTY = extern struct { id: WS_CALL_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_URL = extern struct { scheme: WS_URL_SCHEME_TYPE, }; pub const WS_HTTP_URL = extern struct { url: WS_URL, host: WS_STRING, port: u16, portAsString: WS_STRING, path: WS_STRING, query: WS_STRING, fragment: WS_STRING, }; pub const WS_HTTPS_URL = extern struct { url: WS_URL, host: WS_STRING, port: u16, portAsString: WS_STRING, path: WS_STRING, query: WS_STRING, fragment: WS_STRING, }; pub const WS_NETTCP_URL = extern struct { url: WS_URL, host: WS_STRING, port: u16, portAsString: WS_STRING, path: WS_STRING, query: WS_STRING, fragment: WS_STRING, }; pub const WS_SOAPUDP_URL = extern struct { url: WS_URL, host: WS_STRING, port: u16, portAsString: WS_STRING, path: WS_STRING, query: WS_STRING, fragment: WS_STRING, }; pub const WS_NETPIPE_URL = extern struct { url: WS_URL, host: WS_STRING, port: u16, portAsString: WS_STRING, path: WS_STRING, query: WS_STRING, fragment: WS_STRING, }; pub const WS_UNIQUE_ID = extern struct { uri: WS_STRING, guid: Guid, }; pub const WS_BUFFERS = extern struct { bufferCount: u32, buffers: ?*WS_BYTES, }; pub const WS_METADATA_ENDPOINT = extern struct { endpointAddress: WS_ENDPOINT_ADDRESS, endpointPolicy: ?*WS_POLICY, portName: ?*WS_XML_STRING, serviceName: ?*WS_XML_STRING, serviceNs: ?*WS_XML_STRING, bindingName: ?*WS_XML_STRING, bindingNs: ?*WS_XML_STRING, portTypeName: ?*WS_XML_STRING, portTypeNs: ?*WS_XML_STRING, }; pub const WS_METADATA_ENDPOINTS = extern struct { endpoints: ?*WS_METADATA_ENDPOINT, endpointCount: u32, }; pub const WS_METADATA_PROPERTY = extern struct { id: WS_METADATA_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_POLICY_PROPERTY = extern struct { id: WS_POLICY_PROPERTY_ID, value: ?*anyopaque, valueSize: u32, }; pub const WS_POLICY_PROPERTIES = extern struct { properties: ?*WS_POLICY_PROPERTY, propertyCount: u32, }; pub const WS_SECURITY_BINDING_PROPERTY_CONSTRAINT = extern struct { id: WS_SECURITY_BINDING_PROPERTY_ID, allowedValues: ?*anyopaque, allowedValuesSize: u32, out: extern struct { securityBindingProperty: WS_SECURITY_BINDING_PROPERTY, }, }; pub const WS_SECURITY_BINDING_CONSTRAINT = extern struct { type: WS_SECURITY_BINDING_CONSTRAINT_TYPE, propertyConstraints: ?*WS_SECURITY_BINDING_PROPERTY_CONSTRAINT, propertyConstraintCount: u32, }; pub const WS_SSL_TRANSPORT_SECURITY_BINDING_CONSTRAINT = extern struct { bindingConstraint: WS_SECURITY_BINDING_CONSTRAINT, out: extern struct { clientCertCredentialRequired: BOOL, }, }; pub const WS_USERNAME_MESSAGE_SECURITY_BINDING_CONSTRAINT = extern struct { bindingConstraint: WS_SECURITY_BINDING_CONSTRAINT, bindingUsage: WS_MESSAGE_SECURITY_USAGE, }; pub const WS_HTTP_HEADER_AUTH_SECURITY_BINDING_CONSTRAINT = extern struct { bindingConstraint: WS_SECURITY_BINDING_CONSTRAINT, }; pub const WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_CONSTRAINT = extern struct { bindingConstraint: WS_SECURITY_BINDING_CONSTRAINT, }; pub const WS_CERT_MESSAGE_SECURITY_BINDING_CONSTRAINT = extern struct { bindingConstraint: WS_SECURITY_BINDING_CONSTRAINT, bindingUsage: WS_MESSAGE_SECURITY_USAGE, }; pub const WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_CONSTRAINT = extern struct { bindingConstraint: WS_SECURITY_BINDING_CONSTRAINT, bindingUsage: WS_MESSAGE_SECURITY_USAGE, }; pub const WS_REQUEST_SECURITY_TOKEN_PROPERTY_CONSTRAINT = extern struct { id: WS_REQUEST_SECURITY_TOKEN_PROPERTY_ID, allowedValues: ?*anyopaque, allowedValuesSize: u32, out: extern struct { requestSecurityTokenProperty: WS_REQUEST_SECURITY_TOKEN_PROPERTY, }, }; pub const WS_ISSUED_TOKEN_MESSAGE_SECURITY_BINDING_CONSTRAINT = extern struct { bindingConstraint: WS_SECURITY_BINDING_CONSTRAINT, bindingUsage: WS_MESSAGE_SECURITY_USAGE, claimConstraints: ?*WS_XML_STRING, claimConstraintCount: u32, requestSecurityTokenPropertyConstraints: ?*WS_REQUEST_SECURITY_TOKEN_PROPERTY_CONSTRAINT, requestSecurityTokenPropertyConstraintCount: u32, out: extern struct { issuerAddress: ?*WS_ENDPOINT_ADDRESS, requestSecurityTokenTemplate: ?*WS_XML_BUFFER, }, }; pub const WS_SECURITY_PROPERTY_CONSTRAINT = extern struct { id: WS_SECURITY_PROPERTY_ID, allowedValues: ?*anyopaque, allowedValuesSize: u32, out: extern struct { securityProperty: WS_SECURITY_PROPERTY, }, }; pub const WS_SECURITY_CONSTRAINTS = extern struct { securityPropertyConstraints: ?*WS_SECURITY_PROPERTY_CONSTRAINT, securityPropertyConstraintCount: u32, securityBindingConstraints: ?*?*WS_SECURITY_BINDING_CONSTRAINT, securityBindingConstraintCount: u32, }; pub const WS_SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_CONSTRAINT = extern struct { bindingConstraint: WS_SECURITY_BINDING_CONSTRAINT, bindingUsage: WS_MESSAGE_SECURITY_USAGE, bootstrapSecurityConstraint: ?*WS_SECURITY_CONSTRAINTS, }; pub const WS_CHANNEL_PROPERTY_CONSTRAINT = extern struct { id: WS_CHANNEL_PROPERTY_ID, allowedValues: ?*anyopaque, allowedValuesSize: u32, out: extern struct { channelProperty: WS_CHANNEL_PROPERTY, }, }; pub const WS_POLICY_EXTENSION = extern struct { type: WS_POLICY_EXTENSION_TYPE, }; pub const WS_ENDPOINT_POLICY_EXTENSION = extern struct { policyExtension: WS_POLICY_EXTENSION, assertionName: ?*WS_XML_STRING, assertionNs: ?*WS_XML_STRING, out: extern struct { assertionValue: ?*WS_XML_BUFFER, }, }; pub const WS_POLICY_CONSTRAINTS = extern struct { channelBinding: WS_CHANNEL_BINDING, channelPropertyConstraints: ?*WS_CHANNEL_PROPERTY_CONSTRAINT, channelPropertyConstraintCount: u32, securityConstraints: ?*WS_SECURITY_CONSTRAINTS, policyExtensions: ?*?*WS_POLICY_EXTENSION, policyExtensionCount: u32, }; pub const WS_HTTP_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, }; pub const WS_SSL_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, }; pub const WS_HTTP_SSL_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_HTTP_HEADER_AUTH_SECURITY_BINDING_POLICY_DESCRIPTION = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, }; pub const WS_HTTP_HEADER_AUTH_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, httpHeaderAuthSecurityBinding: WS_HTTP_HEADER_AUTH_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_HTTP_SSL_HEADER_AUTH_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, httpHeaderAuthSecurityBinding: WS_HTTP_HEADER_AUTH_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_USERNAME_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, bindingUsage: WS_MESSAGE_SECURITY_USAGE, }; pub const WS_HTTP_SSL_USERNAME_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, usernameMessageSecurityBinding: WS_USERNAME_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, bindingUsage: WS_MESSAGE_SECURITY_USAGE, }; pub const WS_HTTP_SSL_KERBEROS_APREQ_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, kerberosApreqMessageSecurityBinding: WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_TCP_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, }; pub const WS_SSPI_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, }; pub const WS_TCP_SSPI_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_SSPI_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_TCP_SSPI_USERNAME_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_SSPI_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, usernameMessageSecurityBinding: WS_USERNAME_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_TCP_SSPI_KERBEROS_APREQ_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_SSPI_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, kerberosApreqMessageSecurityBinding: WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, bindingUsage: WS_MESSAGE_SECURITY_USAGE, }; pub const WS_SECURITY_CONTEXT_SECURITY_BINDING_POLICY_DESCRIPTION = extern struct { securityContextMessageSecurityBinding: WS_SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, securityProperties: WS_SECURITY_PROPERTIES, }; pub const WS_TCP_SSPI_KERBEROS_APREQ_SECURITY_CONTEXT_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_SSPI_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, kerberosApreqMessageSecurityBinding: WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, securityContextSecurityBinding: WS_SECURITY_CONTEXT_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_TCP_SSPI_USERNAME_SECURITY_CONTEXT_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_SSPI_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, usernameMessageSecurityBinding: WS_USERNAME_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, securityContextSecurityBinding: WS_SECURITY_CONTEXT_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_HTTP_SSL_USERNAME_SECURITY_CONTEXT_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, usernameMessageSecurityBinding: WS_USERNAME_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, securityContextSecurityBinding: WS_SECURITY_CONTEXT_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_HTTP_SSL_KERBEROS_APREQ_SECURITY_CONTEXT_POLICY_DESCRIPTION = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_POLICY_DESCRIPTION, kerberosApreqMessageSecurityBinding: WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_POLICY_DESCRIPTION, securityContextSecurityBinding: WS_SECURITY_CONTEXT_SECURITY_BINDING_POLICY_DESCRIPTION, }; pub const WS_HTTP_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, }; pub const WS_TCP_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, }; pub const WS_SSL_TRANSPORT_SECURITY_BINDING_TEMPLATE = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, localCertCredential: ?*WS_CERT_CREDENTIAL, }; pub const WS_HTTP_SSL_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_TEMPLATE, }; pub const WS_HTTP_HEADER_AUTH_SECURITY_BINDING_TEMPLATE = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, clientCredential: ?*WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, }; pub const WS_HTTP_HEADER_AUTH_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, httpHeaderAuthSecurityBinding: WS_HTTP_HEADER_AUTH_SECURITY_BINDING_TEMPLATE, }; pub const WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_TEMPLATE = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, clientCredential: ?*WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, }; pub const WS_TCP_SSPI_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_TEMPLATE, }; pub const WS_HTTP_SSL_HEADER_AUTH_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_TEMPLATE, httpHeaderAuthSecurityBinding: WS_HTTP_HEADER_AUTH_SECURITY_BINDING_TEMPLATE, }; pub const WS_USERNAME_MESSAGE_SECURITY_BINDING_TEMPLATE = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, clientCredential: ?*WS_USERNAME_CREDENTIAL, passwordValidator: ?WS_VALIDATE_PASSWORD_CALLBACK, passwordValidatorCallbackState: ?*anyopaque, }; pub const WS_HTTP_SSL_USERNAME_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_TEMPLATE, usernameMessageSecurityBinding: WS_USERNAME_MESSAGE_SECURITY_BINDING_TEMPLATE, }; pub const WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_TEMPLATE = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, clientCredential: ?*WS_WINDOWS_INTEGRATED_AUTH_CREDENTIAL, }; pub const WS_HTTP_SSL_KERBEROS_APREQ_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_TEMPLATE, kerberosApreqMessageSecurityBinding: WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_TEMPLATE, }; pub const WS_TCP_SSPI_USERNAME_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_TEMPLATE, usernameMessageSecurityBinding: WS_USERNAME_MESSAGE_SECURITY_BINDING_TEMPLATE, }; pub const WS_TCP_SSPI_KERBEROS_APREQ_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_TEMPLATE, kerberosApreqMessageSecurityBinding: WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_TEMPLATE, }; pub const WS_SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_TEMPLATE = extern struct { securityBindingProperties: WS_SECURITY_BINDING_PROPERTIES, }; pub const WS_SECURITY_CONTEXT_SECURITY_BINDING_TEMPLATE = extern struct { securityContextMessageSecurityBinding: WS_SECURITY_CONTEXT_MESSAGE_SECURITY_BINDING_TEMPLATE, securityProperties: WS_SECURITY_PROPERTIES, }; pub const WS_HTTP_SSL_USERNAME_SECURITY_CONTEXT_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_TEMPLATE, usernameMessageSecurityBinding: WS_USERNAME_MESSAGE_SECURITY_BINDING_TEMPLATE, securityContextSecurityBinding: WS_SECURITY_CONTEXT_SECURITY_BINDING_TEMPLATE, }; pub const WS_HTTP_SSL_KERBEROS_APREQ_SECURITY_CONTEXT_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sslTransportSecurityBinding: WS_SSL_TRANSPORT_SECURITY_BINDING_TEMPLATE, kerberosApreqMessageSecurityBinding: WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_TEMPLATE, securityContextSecurityBinding: WS_SECURITY_CONTEXT_SECURITY_BINDING_TEMPLATE, }; pub const WS_TCP_SSPI_USERNAME_SECURITY_CONTEXT_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_TEMPLATE, usernameMessageSecurityBinding: WS_USERNAME_MESSAGE_SECURITY_BINDING_TEMPLATE, securityContextSecurityBinding: WS_SECURITY_CONTEXT_SECURITY_BINDING_TEMPLATE, }; pub const WS_TCP_SSPI_KERBEROS_APREQ_SECURITY_CONTEXT_BINDING_TEMPLATE = extern struct { channelProperties: WS_CHANNEL_PROPERTIES, securityProperties: WS_SECURITY_PROPERTIES, sspiTransportSecurityBinding: WS_TCP_SSPI_TRANSPORT_SECURITY_BINDING_TEMPLATE, kerberosApreqMessageSecurityBinding: WS_KERBEROS_APREQ_MESSAGE_SECURITY_BINDING_TEMPLATE, securityContextSecurityBinding: WS_SECURITY_CONTEXT_SECURITY_BINDING_TEMPLATE, }; // TODO: this type is limited to platform 'windows8.1' const IID_IContentPrefetcherTaskTrigger_Value = Guid.initString("1b35a14a-6094-4799-a60e-e474e15d4dc9"); pub const IID_IContentPrefetcherTaskTrigger = &IID_IContentPrefetcherTaskTrigger_Value; pub const IContentPrefetcherTaskTrigger = extern struct { pub const VTable = extern struct { base: IInspectable.VTable, TriggerContentPrefetcherTask: fn( self: *const IContentPrefetcherTaskTrigger, packageFullName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, IsRegisteredForContentPrefetch: fn( self: *const IContentPrefetcherTaskTrigger, packageFullName: ?[*:0]const u16, isRegistered: ?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IInspectable.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IContentPrefetcherTaskTrigger_TriggerContentPrefetcherTask(self: *const T, packageFullName: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IContentPrefetcherTaskTrigger.VTable, self.vtable).TriggerContentPrefetcherTask(@ptrCast(*const IContentPrefetcherTaskTrigger, self), packageFullName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IContentPrefetcherTaskTrigger_IsRegisteredForContentPrefetch(self: *const T, packageFullName: ?[*:0]const u16, isRegistered: ?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const IContentPrefetcherTaskTrigger.VTable, self.vtable).IsRegisteredForContentPrefetch(@ptrCast(*const IContentPrefetcherTaskTrigger, self), packageFullName, isRegistered); } };} pub usingnamespace MethodMixin(@This()); }; pub const WEBAUTHN_RP_ENTITY_INFORMATION = extern struct { dwVersion: u32, pwszId: ?[*:0]const u16, pwszName: ?[*:0]const u16, pwszIcon: ?[*:0]const u16, }; pub const WEBAUTHN_USER_ENTITY_INFORMATION = extern struct { dwVersion: u32, cbId: u32, pbId: ?*u8, pwszName: ?[*:0]const u16, pwszIcon: ?[*:0]const u16, pwszDisplayName: ?[*:0]const u16, }; pub const WEBAUTHN_CLIENT_DATA = extern struct { dwVersion: u32, cbClientDataJSON: u32, pbClientDataJSON: ?*u8, pwszHashAlgId: ?[*:0]const u16, }; pub const WEBAUTHN_COSE_CREDENTIAL_PARAMETER = extern struct { dwVersion: u32, pwszCredentialType: ?[*:0]const u16, lAlg: i32, }; pub const WEBAUTHN_COSE_CREDENTIAL_PARAMETERS = extern struct { cCredentialParameters: u32, pCredentialParameters: ?*WEBAUTHN_COSE_CREDENTIAL_PARAMETER, }; pub const WEBAUTHN_CREDENTIAL = extern struct { dwVersion: u32, cbId: u32, pbId: ?*u8, pwszCredentialType: ?[*:0]const u16, }; pub const WEBAUTHN_CREDENTIALS = extern struct { cCredentials: u32, pCredentials: ?*WEBAUTHN_CREDENTIAL, }; pub const WEBAUTHN_CREDENTIAL_EX = extern struct { dwVersion: u32, cbId: u32, pbId: ?*u8, pwszCredentialType: ?[*:0]const u16, dwTransports: u32, }; pub const WEBAUTHN_CREDENTIAL_LIST = extern struct { cCredentials: u32, ppCredentials: ?*?*WEBAUTHN_CREDENTIAL_EX, }; pub const WEBAUTHN_CRED_PROTECT_EXTENSION_IN = extern struct { dwCredProtect: u32, bRequireCredProtect: BOOL, }; pub const WEBAUTHN_CRED_BLOB_EXTENSION = extern struct { cbCredBlob: u32, pbCredBlob: ?*u8, }; pub const WEBAUTHN_EXTENSION = extern struct { pwszExtensionIdentifier: ?[*:0]const u16, cbExtension: u32, pvExtension: ?*anyopaque, }; pub const WEBAUTHN_EXTENSIONS = extern struct { cExtensions: u32, pExtensions: ?*WEBAUTHN_EXTENSION, }; pub const WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS = extern struct { dwVersion: u32, dwTimeoutMilliseconds: u32, CredentialList: WEBAUTHN_CREDENTIALS, Extensions: WEBAUTHN_EXTENSIONS, dwAuthenticatorAttachment: u32, bRequireResidentKey: BOOL, dwUserVerificationRequirement: u32, dwAttestationConveyancePreference: u32, dwFlags: u32, pCancellationId: ?*Guid, pExcludeCredentialList: ?*WEBAUTHN_CREDENTIAL_LIST, dwEnterpriseAttestation: u32, dwLargeBlobSupport: u32, bPreferResidentKey: BOOL, }; pub const WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS = extern struct { dwVersion: u32, dwTimeoutMilliseconds: u32, CredentialList: WEBAUTHN_CREDENTIALS, Extensions: WEBAUTHN_EXTENSIONS, dwAuthenticatorAttachment: u32, dwUserVerificationRequirement: u32, dwFlags: u32, pwszU2fAppId: ?[*:0]const u16, pbU2fAppId: ?*BOOL, pCancellationId: ?*Guid, pAllowCredentialList: ?*WEBAUTHN_CREDENTIAL_LIST, dwCredLargeBlobOperation: u32, cbCredLargeBlob: u32, pbCredLargeBlob: ?*u8, }; pub const WEBAUTHN_X5C = extern struct { cbData: u32, pbData: ?*u8, }; pub const WEBAUTHN_COMMON_ATTESTATION = extern struct { dwVersion: u32, pwszAlg: ?[*:0]const u16, lAlg: i32, cbSignature: u32, pbSignature: ?*u8, cX5c: u32, pX5c: ?*WEBAUTHN_X5C, pwszVer: ?[*:0]const u16, cbCertInfo: u32, pbCertInfo: ?*u8, cbPubArea: u32, pbPubArea: ?*u8, }; pub const WEBAUTHN_CREDENTIAL_ATTESTATION = extern struct { dwVersion: u32, pwszFormatType: ?[*:0]const u16, cbAuthenticatorData: u32, pbAuthenticatorData: ?*u8, cbAttestation: u32, pbAttestation: ?*u8, dwAttestationDecodeType: u32, pvAttestationDecode: ?*anyopaque, cbAttestationObject: u32, pbAttestationObject: ?*u8, cbCredentialId: u32, pbCredentialId: ?*u8, Extensions: WEBAUTHN_EXTENSIONS, dwUsedTransport: u32, bEpAtt: BOOL, bLargeBlobSupported: BOOL, bResidentKey: BOOL, }; pub const WEBAUTHN_ASSERTION = extern struct { dwVersion: u32, cbAuthenticatorData: u32, pbAuthenticatorData: ?*u8, cbSignature: u32, pbSignature: ?*u8, Credential: WEBAUTHN_CREDENTIAL, cbUserId: u32, pbUserId: ?*u8, Extensions: WEBAUTHN_EXTENSIONS, cbCredLargeBlob: u32, pbCredLargeBlob: ?*u8, dwCredLargeBlobStatus: u32, }; //-------------------------------------------------------------------------------- // Section: Functions (203) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsStartReaderCanonicalization( reader: ?*WS_XML_READER, writeCallback: ?WS_WRITE_CALLBACK, writeCallbackState: ?*anyopaque, properties: ?[*]const WS_XML_CANONICALIZATION_PROPERTY, propertyCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsEndReaderCanonicalization( reader: ?*WS_XML_READER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsStartWriterCanonicalization( writer: ?*WS_XML_WRITER, writeCallback: ?WS_WRITE_CALLBACK, writeCallbackState: ?*anyopaque, properties: ?[*]const WS_XML_CANONICALIZATION_PROPERTY, propertyCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsEndWriterCanonicalization( writer: ?*WS_XML_WRITER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateXmlBuffer( heap: ?*WS_HEAP, properties: ?[*]const WS_XML_BUFFER_PROPERTY, propertyCount: u32, buffer: ?*?*WS_XML_BUFFER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsRemoveNode( nodePosition: ?*const WS_XML_NODE_POSITION, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateReader( properties: ?[*]const WS_XML_READER_PROPERTY, propertyCount: u32, reader: ?*?*WS_XML_READER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetInput( reader: ?*WS_XML_READER, encoding: ?*const WS_XML_READER_ENCODING, input: ?*const WS_XML_READER_INPUT, properties: ?[*]const WS_XML_READER_PROPERTY, propertyCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetInputToBuffer( reader: ?*WS_XML_READER, buffer: ?*WS_XML_BUFFER, properties: ?[*]const WS_XML_READER_PROPERTY, propertyCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeReader( reader: ?*WS_XML_READER, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetReaderProperty( reader: ?*WS_XML_READER, id: WS_XML_READER_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetReaderNode( xmlReader: ?*WS_XML_READER, node: ?*const ?*WS_XML_NODE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFillReader( reader: ?*WS_XML_READER, minSize: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadStartElement( reader: ?*WS_XML_READER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadToStartElement( reader: ?*WS_XML_READER, localName: ?*const WS_XML_STRING, ns: ?*const WS_XML_STRING, found: ?*BOOL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadStartAttribute( reader: ?*WS_XML_READER, attributeIndex: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadEndAttribute( reader: ?*WS_XML_READER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadNode( reader: ?*WS_XML_READER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSkipNode( reader: ?*WS_XML_READER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadEndElement( reader: ?*WS_XML_READER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFindAttribute( reader: ?*WS_XML_READER, localName: ?*const WS_XML_STRING, ns: ?*const WS_XML_STRING, required: BOOL, attributeIndex: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadValue( reader: ?*WS_XML_READER, valueType: WS_VALUE_TYPE, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadChars( reader: ?*WS_XML_READER, chars: [*:0]u16, maxCharCount: u32, actualCharCount: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadCharsUtf8( reader: ?*WS_XML_READER, bytes: [*:0]u8, maxByteCount: u32, actualByteCount: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadBytes( reader: ?*WS_XML_READER, // TODO: what to do with BytesParamIndex 2? bytes: ?*anyopaque, maxByteCount: u32, actualByteCount: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadArray( reader: ?*WS_XML_READER, localName: ?*const WS_XML_STRING, ns: ?*const WS_XML_STRING, valueType: WS_VALUE_TYPE, // TODO: what to do with BytesParamIndex 5? array: ?*anyopaque, arraySize: u32, itemOffset: u32, itemCount: u32, actualItemCount: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetReaderPosition( reader: ?*WS_XML_READER, nodePosition: ?*WS_XML_NODE_POSITION, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetReaderPosition( reader: ?*WS_XML_READER, nodePosition: ?*const WS_XML_NODE_POSITION, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsMoveReader( reader: ?*WS_XML_READER, moveTo: WS_MOVE_TO, found: ?*BOOL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateWriter( properties: ?[*]const WS_XML_WRITER_PROPERTY, propertyCount: u32, writer: ?*?*WS_XML_WRITER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeWriter( writer: ?*WS_XML_WRITER, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetOutput( writer: ?*WS_XML_WRITER, encoding: ?*const WS_XML_WRITER_ENCODING, output: ?*const WS_XML_WRITER_OUTPUT, properties: ?[*]const WS_XML_WRITER_PROPERTY, propertyCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetOutputToBuffer( writer: ?*WS_XML_WRITER, buffer: ?*WS_XML_BUFFER, properties: ?[*]const WS_XML_WRITER_PROPERTY, propertyCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetWriterProperty( writer: ?*WS_XML_WRITER, id: WS_XML_WRITER_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFlushWriter( writer: ?*WS_XML_WRITER, minSize: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteStartElement( writer: ?*WS_XML_WRITER, prefix: ?*const WS_XML_STRING, localName: ?*const WS_XML_STRING, ns: ?*const WS_XML_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteEndStartElement( writer: ?*WS_XML_WRITER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteXmlnsAttribute( writer: ?*WS_XML_WRITER, prefix: ?*const WS_XML_STRING, ns: ?*const WS_XML_STRING, singleQuote: BOOL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteStartAttribute( writer: ?*WS_XML_WRITER, prefix: ?*const WS_XML_STRING, localName: ?*const WS_XML_STRING, ns: ?*const WS_XML_STRING, singleQuote: BOOL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteEndAttribute( writer: ?*WS_XML_WRITER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteValue( writer: ?*WS_XML_WRITER, valueType: WS_VALUE_TYPE, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteXmlBuffer( writer: ?*WS_XML_WRITER, xmlBuffer: ?*WS_XML_BUFFER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadXmlBuffer( reader: ?*WS_XML_READER, heap: ?*WS_HEAP, xmlBuffer: ?*?*WS_XML_BUFFER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteXmlBufferToBytes( writer: ?*WS_XML_WRITER, xmlBuffer: ?*WS_XML_BUFFER, encoding: ?*const WS_XML_WRITER_ENCODING, properties: ?[*]const WS_XML_WRITER_PROPERTY, propertyCount: u32, heap: ?*WS_HEAP, bytes: ?*?*anyopaque, byteCount: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadXmlBufferFromBytes( reader: ?*WS_XML_READER, encoding: ?*const WS_XML_READER_ENCODING, properties: ?[*]const WS_XML_READER_PROPERTY, propertyCount: u32, // TODO: what to do with BytesParamIndex 5? bytes: ?*const anyopaque, byteCount: u32, heap: ?*WS_HEAP, xmlBuffer: ?*?*WS_XML_BUFFER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteArray( writer: ?*WS_XML_WRITER, localName: ?*const WS_XML_STRING, ns: ?*const WS_XML_STRING, valueType: WS_VALUE_TYPE, // TODO: what to do with BytesParamIndex 5? array: ?*const anyopaque, arraySize: u32, itemOffset: u32, itemCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteQualifiedName( writer: ?*WS_XML_WRITER, prefix: ?*const WS_XML_STRING, localName: ?*const WS_XML_STRING, ns: ?*const WS_XML_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteChars( writer: ?*WS_XML_WRITER, chars: [*:0]const u16, charCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteCharsUtf8( writer: ?*WS_XML_WRITER, bytes: [*:0]const u8, byteCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteBytes( writer: ?*WS_XML_WRITER, // TODO: what to do with BytesParamIndex 2? bytes: ?*const anyopaque, byteCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsPushBytes( writer: ?*WS_XML_WRITER, callback: ?WS_PUSH_BYTES_CALLBACK, callbackState: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsPullBytes( writer: ?*WS_XML_WRITER, callback: ?WS_PULL_BYTES_CALLBACK, callbackState: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteEndElement( writer: ?*WS_XML_WRITER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteText( writer: ?*WS_XML_WRITER, text: ?*const WS_XML_TEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteStartCData( writer: ?*WS_XML_WRITER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteEndCData( writer: ?*WS_XML_WRITER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteNode( writer: ?*WS_XML_WRITER, node: ?*const WS_XML_NODE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetPrefixFromNamespace( writer: ?*WS_XML_WRITER, ns: ?*const WS_XML_STRING, required: BOOL, prefix: ?*const ?*WS_XML_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetWriterPosition( writer: ?*WS_XML_WRITER, nodePosition: ?*WS_XML_NODE_POSITION, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetWriterPosition( writer: ?*WS_XML_WRITER, nodePosition: ?*const WS_XML_NODE_POSITION, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsMoveWriter( writer: ?*WS_XML_WRITER, moveTo: WS_MOVE_TO, found: ?*BOOL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsTrimXmlWhitespace( chars: [*:0]u16, charCount: u32, trimmedChars: ?*?*u16, trimmedCount: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsVerifyXmlNCName( ncNameChars: [*:0]const u16, ncNameCharCount: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsXmlStringEquals( string1: ?*const WS_XML_STRING, string2: ?*const WS_XML_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetNamespaceFromPrefix( reader: ?*WS_XML_READER, prefix: ?*const WS_XML_STRING, required: BOOL, ns: ?*const ?*WS_XML_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadQualifiedName( reader: ?*WS_XML_READER, heap: ?*WS_HEAP, prefix: ?*WS_XML_STRING, localName: ?*WS_XML_STRING, ns: ?*WS_XML_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetXmlAttribute( reader: ?*WS_XML_READER, localName: ?*const WS_XML_STRING, heap: ?*WS_HEAP, valueChars: ?*?*u16, valueCharCount: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCopyNode( writer: ?*WS_XML_WRITER, reader: ?*WS_XML_READER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAsyncExecute( asyncState: ?*WS_ASYNC_STATE, operation: ?WS_ASYNC_FUNCTION, callbackModel: WS_CALLBACK_MODEL, callbackState: ?*anyopaque, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateChannel( channelType: WS_CHANNEL_TYPE, channelBinding: WS_CHANNEL_BINDING, properties: ?[*]const WS_CHANNEL_PROPERTY, propertyCount: u32, securityDescription: ?*const WS_SECURITY_DESCRIPTION, channel: ?*?*WS_CHANNEL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsOpenChannel( channel: ?*WS_CHANNEL, endpointAddress: ?*const WS_ENDPOINT_ADDRESS, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSendMessage( channel: ?*WS_CHANNEL, message: ?*WS_MESSAGE, messageDescription: ?*const WS_MESSAGE_DESCRIPTION, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 5? bodyValue: ?*const anyopaque, bodyValueSize: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReceiveMessage( channel: ?*WS_CHANNEL, message: ?*WS_MESSAGE, messageDescriptions: [*]const ?*const WS_MESSAGE_DESCRIPTION, messageDescriptionCount: u32, receiveOption: WS_RECEIVE_OPTION, readBodyOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 8? value: ?*anyopaque, valueSize: u32, index: ?*u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsRequestReply( channel: ?*WS_CHANNEL, requestMessage: ?*WS_MESSAGE, requestMessageDescription: ?*const WS_MESSAGE_DESCRIPTION, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 5? requestBodyValue: ?*const anyopaque, requestBodyValueSize: u32, replyMessage: ?*WS_MESSAGE, replyMessageDescription: ?*const WS_MESSAGE_DESCRIPTION, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 11? value: ?*anyopaque, valueSize: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSendReplyMessage( channel: ?*WS_CHANNEL, replyMessage: ?*WS_MESSAGE, replyMessageDescription: ?*const WS_MESSAGE_DESCRIPTION, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 5? replyBodyValue: ?*const anyopaque, replyBodyValueSize: u32, requestMessage: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSendFaultMessageForError( channel: ?*WS_CHANNEL, replyMessage: ?*WS_MESSAGE, faultError: ?*WS_ERROR, faultErrorCode: HRESULT, faultDisclosure: WS_FAULT_DISCLOSURE, requestMessage: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetChannelProperty( channel: ?*WS_CHANNEL, id: WS_CHANNEL_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetChannelProperty( channel: ?*WS_CHANNEL, id: WS_CHANNEL_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteMessageStart( channel: ?*WS_CHANNEL, message: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteMessageEnd( channel: ?*WS_CHANNEL, message: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadMessageStart( channel: ?*WS_CHANNEL, message: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadMessageEnd( channel: ?*WS_CHANNEL, message: ?*WS_MESSAGE, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCloseChannel( channel: ?*WS_CHANNEL, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAbortChannel( channel: ?*WS_CHANNEL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeChannel( channel: ?*WS_CHANNEL, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsResetChannel( channel: ?*WS_CHANNEL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAbandonMessage( channel: ?*WS_CHANNEL, message: ?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsShutdownSessionChannel( channel: ?*WS_CHANNEL, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetOperationContextProperty( context: ?*const WS_OPERATION_CONTEXT, id: WS_OPERATION_CONTEXT_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetDictionary( encoding: WS_ENCODING, dictionary: ?*?*WS_XML_DICTIONARY, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadEndpointAddressExtension( reader: ?*WS_XML_READER, endpointAddress: ?*WS_ENDPOINT_ADDRESS, extensionType: WS_ENDPOINT_ADDRESS_EXTENSION_TYPE, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 6? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateError( properties: ?[*]const WS_ERROR_PROPERTY, propertyCount: u32, @"error": ?*?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAddErrorString( @"error": ?*WS_ERROR, string: ?*const WS_STRING, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetErrorString( @"error": ?*WS_ERROR, index: u32, string: ?*WS_STRING, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCopyError( source: ?*WS_ERROR, destination: ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetErrorProperty( @"error": ?*WS_ERROR, id: WS_ERROR_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? buffer: ?*anyopaque, bufferSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetErrorProperty( @"error": ?*WS_ERROR, id: WS_ERROR_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, valueSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsResetError( @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeError( @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetFaultErrorProperty( @"error": ?*WS_ERROR, id: WS_FAULT_ERROR_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? buffer: ?*anyopaque, bufferSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetFaultErrorProperty( @"error": ?*WS_ERROR, id: WS_FAULT_ERROR_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, valueSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateFaultFromError( @"error": ?*WS_ERROR, faultErrorCode: HRESULT, faultDisclosure: WS_FAULT_DISCLOSURE, heap: ?*WS_HEAP, fault: ?*WS_FAULT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetFaultErrorDetail( @"error": ?*WS_ERROR, faultDetailDescription: ?*const WS_FAULT_DETAIL_DESCRIPTION, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 4? value: ?*const anyopaque, valueSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetFaultErrorDetail( @"error": ?*WS_ERROR, faultDetailDescription: ?*const WS_FAULT_DETAIL_DESCRIPTION, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 5? value: ?*anyopaque, valueSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateHeap( maxSize: usize, trimSize: usize, properties: ?*const WS_HEAP_PROPERTY, propertyCount: u32, heap: ?*?*WS_HEAP, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAlloc( heap: ?*WS_HEAP, size: usize, ptr: ?*?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetHeapProperty( heap: ?*WS_HEAP, id: WS_HEAP_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsResetHeap( heap: ?*WS_HEAP, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeHeap( heap: ?*WS_HEAP, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateListener( channelType: WS_CHANNEL_TYPE, channelBinding: WS_CHANNEL_BINDING, properties: ?[*]const WS_LISTENER_PROPERTY, propertyCount: u32, securityDescription: ?*const WS_SECURITY_DESCRIPTION, listener: ?*?*WS_LISTENER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsOpenListener( listener: ?*WS_LISTENER, url: ?*const WS_STRING, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAcceptChannel( listener: ?*WS_LISTENER, channel: ?*WS_CHANNEL, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCloseListener( listener: ?*WS_LISTENER, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAbortListener( listener: ?*WS_LISTENER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsResetListener( listener: ?*WS_LISTENER, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeListener( listener: ?*WS_LISTENER, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetListenerProperty( listener: ?*WS_LISTENER, id: WS_LISTENER_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetListenerProperty( listener: ?*WS_LISTENER, id: WS_LISTENER_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateChannelForListener( listener: ?*WS_LISTENER, properties: ?[*]const WS_CHANNEL_PROPERTY, propertyCount: u32, channel: ?*?*WS_CHANNEL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateMessage( envelopeVersion: WS_ENVELOPE_VERSION, addressingVersion: WS_ADDRESSING_VERSION, properties: ?[*]const WS_MESSAGE_PROPERTY, propertyCount: u32, message: ?*?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateMessageForChannel( channel: ?*WS_CHANNEL, properties: ?[*]const WS_MESSAGE_PROPERTY, propertyCount: u32, message: ?*?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsInitializeMessage( message: ?*WS_MESSAGE, initialization: WS_MESSAGE_INITIALIZATION, sourceMessage: ?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsResetMessage( message: ?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeMessage( message: ?*WS_MESSAGE, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetHeaderAttributes( message: ?*WS_MESSAGE, reader: ?*WS_XML_READER, headerAttributes: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetHeader( message: ?*WS_MESSAGE, headerType: WS_HEADER_TYPE, valueType: WS_TYPE, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 6? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetCustomHeader( message: ?*WS_MESSAGE, customHeaderDescription: ?*const WS_ELEMENT_DESCRIPTION, repeatingOption: WS_REPEATING_HEADER_OPTION, headerIndex: u32, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 7? value: ?*anyopaque, valueSize: u32, headerAttributes: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsRemoveHeader( message: ?*WS_MESSAGE, headerType: WS_HEADER_TYPE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetHeader( message: ?*WS_MESSAGE, headerType: WS_HEADER_TYPE, valueType: WS_TYPE, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 5? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsRemoveCustomHeader( message: ?*WS_MESSAGE, headerName: ?*const WS_XML_STRING, headerNs: ?*const WS_XML_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAddCustomHeader( message: ?*WS_MESSAGE, headerDescription: ?*const WS_ELEMENT_DESCRIPTION, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 4? value: ?*const anyopaque, valueSize: u32, headerAttributes: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAddMappedHeader( message: ?*WS_MESSAGE, headerName: ?*const WS_XML_STRING, valueType: WS_TYPE, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 5? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsRemoveMappedHeader( message: ?*WS_MESSAGE, headerName: ?*const WS_XML_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetMappedHeader( message: ?*WS_MESSAGE, headerName: ?*const WS_XML_STRING, repeatingOption: WS_REPEATING_HEADER_OPTION, headerIndex: u32, valueType: WS_TYPE, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 8? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteBody( message: ?*WS_MESSAGE, bodyDescription: ?*const WS_ELEMENT_DESCRIPTION, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 4? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadBody( message: ?*WS_MESSAGE, bodyDescription: ?*const WS_ELEMENT_DESCRIPTION, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 5? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteEnvelopeStart( message: ?*WS_MESSAGE, writer: ?*WS_XML_WRITER, doneCallback: ?WS_MESSAGE_DONE_CALLBACK, doneCallbackState: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteEnvelopeEnd( message: ?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadEnvelopeStart( message: ?*WS_MESSAGE, reader: ?*WS_XML_READER, doneCallback: ?WS_MESSAGE_DONE_CALLBACK, doneCallbackState: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadEnvelopeEnd( message: ?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetMessageProperty( message: ?*WS_MESSAGE, id: WS_MESSAGE_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsSetMessageProperty( message: ?*WS_MESSAGE, id: WS_MESSAGE_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAddressMessage( message: ?*WS_MESSAGE, address: ?*const WS_ENDPOINT_ADDRESS, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCheckMustUnderstandHeaders( message: ?*WS_MESSAGE, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsMarkHeaderAsUnderstood( message: ?*WS_MESSAGE, headerPosition: ?*const WS_XML_NODE_POSITION, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFillBody( message: ?*WS_MESSAGE, minSize: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFlushBody( message: ?*WS_MESSAGE, minSize: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsRequestSecurityToken( channel: ?*WS_CHANNEL, properties: ?[*]const WS_REQUEST_SECURITY_TOKEN_PROPERTY, propertyCount: u32, token: ?*?*WS_SECURITY_TOKEN, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetSecurityTokenProperty( securityToken: ?*WS_SECURITY_TOKEN, id: WS_SECURITY_TOKEN_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, heap: ?*WS_HEAP, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateXmlSecurityToken( tokenXml: ?*WS_XML_BUFFER, tokenKey: ?*WS_SECURITY_KEY_HANDLE, properties: ?[*]const WS_XML_SECURITY_TOKEN_PROPERTY, propertyCount: u32, token: ?*?*WS_SECURITY_TOKEN, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeSecurityToken( token: ?*WS_SECURITY_TOKEN, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsRevokeSecurityContext( securityContext: ?*WS_SECURITY_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetSecurityContextProperty( securityContext: ?*WS_SECURITY_CONTEXT, id: WS_SECURITY_CONTEXT_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadElement( reader: ?*WS_XML_READER, elementDescription: ?*const WS_ELEMENT_DESCRIPTION, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 5? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadAttribute( reader: ?*WS_XML_READER, attributeDescription: ?*const WS_ATTRIBUTE_DESCRIPTION, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 5? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadType( reader: ?*WS_XML_READER, typeMapping: WS_TYPE_MAPPING, type: WS_TYPE, typeDescription: ?*const anyopaque, readOption: WS_READ_OPTION, heap: ?*WS_HEAP, // TODO: what to do with BytesParamIndex 7? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteElement( writer: ?*WS_XML_WRITER, elementDescription: ?*const WS_ELEMENT_DESCRIPTION, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 4? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteAttribute( writer: ?*WS_XML_WRITER, attributeDescription: ?*const WS_ATTRIBUTE_DESCRIPTION, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 4? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsWriteType( writer: ?*WS_XML_WRITER, typeMapping: WS_TYPE_MAPPING, type: WS_TYPE, typeDescription: ?*const anyopaque, writeOption: WS_WRITE_OPTION, // TODO: what to do with BytesParamIndex 6? value: ?*const anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsRegisterOperationForCancel( context: ?*const WS_OPERATION_CONTEXT, cancelCallback: ?WS_OPERATION_CANCEL_CALLBACK, freestateCallback: ?WS_OPERATION_FREE_STATE_CALLBACK, userState: ?*anyopaque, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetServiceHostProperty( serviceHost: ?*WS_SERVICE_HOST, id: WS_SERVICE_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateServiceHost( endpoints: ?[*]const ?*const WS_SERVICE_ENDPOINT, endpointCount: u16, serviceProperties: ?[*]const WS_SERVICE_PROPERTY, servicePropertyCount: u32, serviceHost: ?*?*WS_SERVICE_HOST, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsOpenServiceHost( serviceHost: ?*WS_SERVICE_HOST, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCloseServiceHost( serviceHost: ?*WS_SERVICE_HOST, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAbortServiceHost( serviceHost: ?*WS_SERVICE_HOST, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeServiceHost( serviceHost: ?*WS_SERVICE_HOST, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsResetServiceHost( serviceHost: ?*WS_SERVICE_HOST, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetServiceProxyProperty( serviceProxy: ?*WS_SERVICE_PROXY, id: WS_PROXY_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateServiceProxy( channelType: WS_CHANNEL_TYPE, channelBinding: WS_CHANNEL_BINDING, securityDescription: ?*const WS_SECURITY_DESCRIPTION, properties: ?[*]const WS_PROXY_PROPERTY, propertyCount: u32, channelProperties: ?[*]const WS_CHANNEL_PROPERTY, channelPropertyCount: u32, serviceProxy: ?*?*WS_SERVICE_PROXY, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsOpenServiceProxy( serviceProxy: ?*WS_SERVICE_PROXY, address: ?*const WS_ENDPOINT_ADDRESS, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCloseServiceProxy( serviceProxy: ?*WS_SERVICE_PROXY, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAbortServiceProxy( serviceProxy: ?*WS_SERVICE_PROXY, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeServiceProxy( serviceProxy: ?*WS_SERVICE_PROXY, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsResetServiceProxy( serviceProxy: ?*WS_SERVICE_PROXY, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsAbandonCall( serviceProxy: ?*WS_SERVICE_PROXY, callId: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCall( serviceProxy: ?*WS_SERVICE_PROXY, operation: ?*const WS_OPERATION_DESCRIPTION, arguments: ?*const ?*anyopaque, heap: ?*WS_HEAP, callProperties: ?[*]const WS_CALL_PROPERTY, callPropertyCount: u32, asyncContext: ?*const WS_ASYNC_CONTEXT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsDecodeUrl( url: ?*const WS_STRING, flags: u32, heap: ?*WS_HEAP, outUrl: ?*?*WS_URL, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsEncodeUrl( url: ?*const WS_URL, flags: u32, heap: ?*WS_HEAP, outUrl: ?*WS_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCombineUrl( baseUrl: ?*const WS_STRING, referenceUrl: ?*const WS_STRING, flags: u32, heap: ?*WS_HEAP, resultUrl: ?*WS_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsDateTimeToFileTime( dateTime: ?*const WS_DATETIME, fileTime: ?*FILETIME, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFileTimeToDateTime( fileTime: ?*const FILETIME, dateTime: ?*WS_DATETIME, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateMetadata( properties: ?[*]const WS_METADATA_PROPERTY, propertyCount: u32, metadata: ?*?*WS_METADATA, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsReadMetadata( metadata: ?*WS_METADATA, reader: ?*WS_XML_READER, url: ?*const WS_STRING, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsFreeMetadata( metadata: ?*WS_METADATA, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsResetMetadata( metadata: ?*WS_METADATA, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetMetadataProperty( metadata: ?*WS_METADATA, id: WS_METADATA_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetMissingMetadataDocumentAddress( metadata: ?*WS_METADATA, address: ?*?*WS_ENDPOINT_ADDRESS, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetMetadataEndpoints( metadata: ?*WS_METADATA, endpoints: ?*WS_METADATA_ENDPOINTS, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsMatchPolicyAlternative( policy: ?*WS_POLICY, alternativeIndex: u32, policyConstraints: ?*WS_POLICY_CONSTRAINTS, matchRequired: BOOL, heap: ?*WS_HEAP, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetPolicyProperty( policy: ?*WS_POLICY, id: WS_POLICY_PROPERTY_ID, // TODO: what to do with BytesParamIndex 3? value: ?*anyopaque, valueSize: u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsGetPolicyAlternativeCount( policy: ?*WS_POLICY, count: ?*u32, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateServiceProxyFromTemplate( channelType: WS_CHANNEL_TYPE, properties: ?[*]const WS_PROXY_PROPERTY, propertyCount: u32, templateType: WS_BINDING_TEMPLATE_TYPE, // TODO: what to do with BytesParamIndex 5? templateValue: ?*anyopaque, templateSize: u32, templateDescription: ?*const anyopaque, templateDescriptionSize: u32, serviceProxy: ?*?*WS_SERVICE_PROXY, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "webservices" fn WsCreateServiceEndpointFromTemplate( channelType: WS_CHANNEL_TYPE, properties: ?[*]const WS_SERVICE_ENDPOINT_PROPERTY, propertyCount: u32, addressUrl: ?*const WS_STRING, contract: ?*const WS_SERVICE_CONTRACT, authorizationCallback: ?WS_SERVICE_SECURITY_CALLBACK, heap: ?*WS_HEAP, templateType: WS_BINDING_TEMPLATE_TYPE, // TODO: what to do with BytesParamIndex 9? templateValue: ?*anyopaque, templateSize: u32, templateDescription: ?*const anyopaque, templateDescriptionSize: u32, serviceEndpoint: ?*?*WS_SERVICE_ENDPOINT, @"error": ?*WS_ERROR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "webauthn" fn WebAuthNGetApiVersionNumber( ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "webauthn" fn WebAuthNIsUserVerifyingPlatformAuthenticatorAvailable( pbIsUserVerifyingPlatformAuthenticatorAvailable: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "webauthn" fn WebAuthNAuthenticatorMakeCredential( hWnd: ?HWND, pRpInformation: ?*WEBAUTHN_RP_ENTITY_INFORMATION, pUserInformation: ?*WEBAUTHN_USER_ENTITY_INFORMATION, pPubKeyCredParams: ?*WEBAUTHN_COSE_CREDENTIAL_PARAMETERS, pWebAuthNClientData: ?*WEBAUTHN_CLIENT_DATA, pWebAuthNMakeCredentialOptions: ?*WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS, ppWebAuthNCredentialAttestation: ?*?*WEBAUTHN_CREDENTIAL_ATTESTATION, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "webauthn" fn WebAuthNAuthenticatorGetAssertion( hWnd: ?HWND, pwszRpId: ?[*:0]const u16, pWebAuthNClientData: ?*WEBAUTHN_CLIENT_DATA, pWebAuthNGetAssertionOptions: ?*WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS, ppWebAuthNAssertion: ?*?*WEBAUTHN_ASSERTION, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "webauthn" fn WebAuthNFreeCredentialAttestation( pWebAuthNCredentialAttestation: ?*WEBAUTHN_CREDENTIAL_ATTESTATION, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "webauthn" fn WebAuthNFreeAssertion( pWebAuthNAssertion: ?*WEBAUTHN_ASSERTION, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "webauthn" fn WebAuthNGetCancellationId( pCancellationId: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "webauthn" fn WebAuthNCancelCurrentOperation( pCancellationId: ?*const Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "webauthn" fn WebAuthNGetErrorName( hr: HRESULT, ) callconv(@import("std").os.windows.WINAPI) ?PWSTR; pub extern "webauthn" fn WebAuthNGetW3CExceptionDOMError( hr: HRESULT, ) 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 (11) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const BOOL = @import("../foundation.zig").BOOL; const CERT_CONTEXT = @import("../security/cryptography.zig").CERT_CONTEXT; const CHAR = @import("../foundation.zig").CHAR; const DECIMAL = @import("../foundation.zig").DECIMAL; const FILETIME = @import("../foundation.zig").FILETIME; const HRESULT = @import("../foundation.zig").HRESULT; const HWND = @import("../foundation.zig").HWND; const IInspectable = @import("../system/win_rt.zig").IInspectable; const PWSTR = @import("../foundation.zig").PWSTR; const SecPkgContext_IssuerListInfoEx = @import("../security/authentication/identity.zig").SecPkgContext_IssuerListInfoEx; test { // The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476 if (@hasDecl(@This(), "WS_READ_CALLBACK")) { _ = WS_READ_CALLBACK; } if (@hasDecl(@This(), "WS_WRITE_CALLBACK")) { _ = WS_WRITE_CALLBACK; } if (@hasDecl(@This(), "WS_PUSH_BYTES_CALLBACK")) { _ = WS_PUSH_BYTES_CALLBACK; } if (@hasDecl(@This(), "WS_PULL_BYTES_CALLBACK")) { _ = WS_PULL_BYTES_CALLBACK; } if (@hasDecl(@This(), "WS_DYNAMIC_STRING_CALLBACK")) { _ = WS_DYNAMIC_STRING_CALLBACK; } if (@hasDecl(@This(), "WS_ASYNC_CALLBACK")) { _ = WS_ASYNC_CALLBACK; } if (@hasDecl(@This(), "WS_ASYNC_FUNCTION")) { _ = WS_ASYNC_FUNCTION; } if (@hasDecl(@This(), "WS_CREATE_CHANNEL_CALLBACK")) { _ = WS_CREATE_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_FREE_CHANNEL_CALLBACK")) { _ = WS_FREE_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_RESET_CHANNEL_CALLBACK")) { _ = WS_RESET_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_ABORT_CHANNEL_CALLBACK")) { _ = WS_ABORT_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_OPEN_CHANNEL_CALLBACK")) { _ = WS_OPEN_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_CLOSE_CHANNEL_CALLBACK")) { _ = WS_CLOSE_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_SET_CHANNEL_PROPERTY_CALLBACK")) { _ = WS_SET_CHANNEL_PROPERTY_CALLBACK; } if (@hasDecl(@This(), "WS_GET_CHANNEL_PROPERTY_CALLBACK")) { _ = WS_GET_CHANNEL_PROPERTY_CALLBACK; } if (@hasDecl(@This(), "WS_READ_MESSAGE_START_CALLBACK")) { _ = WS_READ_MESSAGE_START_CALLBACK; } if (@hasDecl(@This(), "WS_READ_MESSAGE_END_CALLBACK")) { _ = WS_READ_MESSAGE_END_CALLBACK; } if (@hasDecl(@This(), "WS_WRITE_MESSAGE_START_CALLBACK")) { _ = WS_WRITE_MESSAGE_START_CALLBACK; } if (@hasDecl(@This(), "WS_WRITE_MESSAGE_END_CALLBACK")) { _ = WS_WRITE_MESSAGE_END_CALLBACK; } if (@hasDecl(@This(), "WS_ABANDON_MESSAGE_CALLBACK")) { _ = WS_ABANDON_MESSAGE_CALLBACK; } if (@hasDecl(@This(), "WS_SHUTDOWN_SESSION_CHANNEL_CALLBACK")) { _ = WS_SHUTDOWN_SESSION_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_CREATE_ENCODER_CALLBACK")) { _ = WS_CREATE_ENCODER_CALLBACK; } if (@hasDecl(@This(), "WS_ENCODER_GET_CONTENT_TYPE_CALLBACK")) { _ = WS_ENCODER_GET_CONTENT_TYPE_CALLBACK; } if (@hasDecl(@This(), "WS_ENCODER_START_CALLBACK")) { _ = WS_ENCODER_START_CALLBACK; } if (@hasDecl(@This(), "WS_ENCODER_ENCODE_CALLBACK")) { _ = WS_ENCODER_ENCODE_CALLBACK; } if (@hasDecl(@This(), "WS_ENCODER_END_CALLBACK")) { _ = WS_ENCODER_END_CALLBACK; } if (@hasDecl(@This(), "WS_FREE_ENCODER_CALLBACK")) { _ = WS_FREE_ENCODER_CALLBACK; } if (@hasDecl(@This(), "WS_CREATE_DECODER_CALLBACK")) { _ = WS_CREATE_DECODER_CALLBACK; } if (@hasDecl(@This(), "WS_DECODER_GET_CONTENT_TYPE_CALLBACK")) { _ = WS_DECODER_GET_CONTENT_TYPE_CALLBACK; } if (@hasDecl(@This(), "WS_DECODER_START_CALLBACK")) { _ = WS_DECODER_START_CALLBACK; } if (@hasDecl(@This(), "WS_DECODER_DECODE_CALLBACK")) { _ = WS_DECODER_DECODE_CALLBACK; } if (@hasDecl(@This(), "WS_DECODER_END_CALLBACK")) { _ = WS_DECODER_END_CALLBACK; } if (@hasDecl(@This(), "WS_FREE_DECODER_CALLBACK")) { _ = WS_FREE_DECODER_CALLBACK; } if (@hasDecl(@This(), "WS_HTTP_REDIRECT_CALLBACK")) { _ = WS_HTTP_REDIRECT_CALLBACK; } if (@hasDecl(@This(), "WS_CREATE_LISTENER_CALLBACK")) { _ = WS_CREATE_LISTENER_CALLBACK; } if (@hasDecl(@This(), "WS_FREE_LISTENER_CALLBACK")) { _ = WS_FREE_LISTENER_CALLBACK; } if (@hasDecl(@This(), "WS_RESET_LISTENER_CALLBACK")) { _ = WS_RESET_LISTENER_CALLBACK; } if (@hasDecl(@This(), "WS_OPEN_LISTENER_CALLBACK")) { _ = WS_OPEN_LISTENER_CALLBACK; } if (@hasDecl(@This(), "WS_CLOSE_LISTENER_CALLBACK")) { _ = WS_CLOSE_LISTENER_CALLBACK; } if (@hasDecl(@This(), "WS_GET_LISTENER_PROPERTY_CALLBACK")) { _ = WS_GET_LISTENER_PROPERTY_CALLBACK; } if (@hasDecl(@This(), "WS_SET_LISTENER_PROPERTY_CALLBACK")) { _ = WS_SET_LISTENER_PROPERTY_CALLBACK; } if (@hasDecl(@This(), "WS_ACCEPT_CHANNEL_CALLBACK")) { _ = WS_ACCEPT_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_ABORT_LISTENER_CALLBACK")) { _ = WS_ABORT_LISTENER_CALLBACK; } if (@hasDecl(@This(), "WS_CREATE_CHANNEL_FOR_LISTENER_CALLBACK")) { _ = WS_CREATE_CHANNEL_FOR_LISTENER_CALLBACK; } if (@hasDecl(@This(), "WS_MESSAGE_DONE_CALLBACK")) { _ = WS_MESSAGE_DONE_CALLBACK; } if (@hasDecl(@This(), "WS_CERTIFICATE_VALIDATION_CALLBACK")) { _ = WS_CERTIFICATE_VALIDATION_CALLBACK; } if (@hasDecl(@This(), "WS_GET_CERT_CALLBACK")) { _ = WS_GET_CERT_CALLBACK; } if (@hasDecl(@This(), "WS_CERT_ISSUER_LIST_NOTIFICATION_CALLBACK")) { _ = WS_CERT_ISSUER_LIST_NOTIFICATION_CALLBACK; } if (@hasDecl(@This(), "WS_VALIDATE_PASSWORD_CALLBACK")) { _ = WS_VALIDATE_PASSWORD_CALLBACK; } if (@hasDecl(@This(), "WS_VALIDATE_SAML_CALLBACK")) { _ = WS_VALIDATE_SAML_CALLBACK; } if (@hasDecl(@This(), "WS_DURATION_COMPARISON_CALLBACK")) { _ = WS_DURATION_COMPARISON_CALLBACK; } if (@hasDecl(@This(), "WS_READ_TYPE_CALLBACK")) { _ = WS_READ_TYPE_CALLBACK; } if (@hasDecl(@This(), "WS_WRITE_TYPE_CALLBACK")) { _ = WS_WRITE_TYPE_CALLBACK; } if (@hasDecl(@This(), "WS_IS_DEFAULT_VALUE_CALLBACK")) { _ = WS_IS_DEFAULT_VALUE_CALLBACK; } if (@hasDecl(@This(), "WS_SERVICE_MESSAGE_RECEIVE_CALLBACK")) { _ = WS_SERVICE_MESSAGE_RECEIVE_CALLBACK; } if (@hasDecl(@This(), "WS_OPERATION_CANCEL_CALLBACK")) { _ = WS_OPERATION_CANCEL_CALLBACK; } if (@hasDecl(@This(), "WS_OPERATION_FREE_STATE_CALLBACK")) { _ = WS_OPERATION_FREE_STATE_CALLBACK; } if (@hasDecl(@This(), "WS_SERVICE_STUB_CALLBACK")) { _ = WS_SERVICE_STUB_CALLBACK; } if (@hasDecl(@This(), "WS_SERVICE_ACCEPT_CHANNEL_CALLBACK")) { _ = WS_SERVICE_ACCEPT_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_SERVICE_CLOSE_CHANNEL_CALLBACK")) { _ = WS_SERVICE_CLOSE_CHANNEL_CALLBACK; } if (@hasDecl(@This(), "WS_SERVICE_SECURITY_CALLBACK")) { _ = WS_SERVICE_SECURITY_CALLBACK; } if (@hasDecl(@This(), "WS_PROXY_MESSAGE_CALLBACK")) { _ = WS_PROXY_MESSAGE_CALLBACK; } @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/networking/windows_web_services.zig
pub const PSAPI_VERSION = @as(u32, 2); //-------------------------------------------------------------------------------- // Section: Types (14) //-------------------------------------------------------------------------------- pub const ENUM_PROCESS_MODULES_EX_FLAGS = enum(u32) { ALL = 3, DEFAULT = 0, @"32BIT" = 1, @"64BIT" = 2, }; pub const LIST_MODULES_ALL = ENUM_PROCESS_MODULES_EX_FLAGS.ALL; pub const LIST_MODULES_DEFAULT = ENUM_PROCESS_MODULES_EX_FLAGS.DEFAULT; pub const LIST_MODULES_32BIT = ENUM_PROCESS_MODULES_EX_FLAGS.@"32BIT"; pub const LIST_MODULES_64BIT = ENUM_PROCESS_MODULES_EX_FLAGS.@"64BIT"; pub const MODULEINFO = extern struct { lpBaseOfDll: ?*anyopaque, SizeOfImage: u32, EntryPoint: ?*anyopaque, }; pub const PSAPI_WS_WATCH_INFORMATION = extern struct { FaultingPc: ?*anyopaque, FaultingVa: ?*anyopaque, }; pub const PSAPI_WS_WATCH_INFORMATION_EX = extern struct { BasicInfo: PSAPI_WS_WATCH_INFORMATION, FaultingThreadId: usize, Flags: usize, }; pub const PSAPI_WORKING_SET_BLOCK = extern union { Flags: usize, Anonymous: extern struct { _bitfield: usize, }, }; pub const PSAPI_WORKING_SET_INFORMATION = extern struct { NumberOfEntries: usize, WorkingSetInfo: [1]PSAPI_WORKING_SET_BLOCK, }; pub const PSAPI_WORKING_SET_EX_BLOCK = extern union { Flags: usize, Anonymous: extern union { Anonymous: extern struct { _bitfield: usize, }, Invalid: extern struct { _bitfield: usize, }, }, }; pub const PSAPI_WORKING_SET_EX_INFORMATION = extern struct { VirtualAddress: ?*anyopaque, VirtualAttributes: PSAPI_WORKING_SET_EX_BLOCK, }; pub const PROCESS_MEMORY_COUNTERS = extern struct { cb: u32, PageFaultCount: u32, PeakWorkingSetSize: usize, WorkingSetSize: usize, QuotaPeakPagedPoolUsage: usize, QuotaPagedPoolUsage: usize, QuotaPeakNonPagedPoolUsage: usize, QuotaNonPagedPoolUsage: usize, PagefileUsage: usize, PeakPagefileUsage: usize, }; pub const PROCESS_MEMORY_COUNTERS_EX = extern struct { cb: u32, PageFaultCount: u32, PeakWorkingSetSize: usize, WorkingSetSize: usize, QuotaPeakPagedPoolUsage: usize, QuotaPagedPoolUsage: usize, QuotaPeakNonPagedPoolUsage: usize, QuotaNonPagedPoolUsage: usize, PagefileUsage: usize, PeakPagefileUsage: usize, PrivateUsage: usize, }; pub const PERFORMANCE_INFORMATION = extern struct { cb: u32, CommitTotal: usize, CommitLimit: usize, CommitPeak: usize, PhysicalTotal: usize, PhysicalAvailable: usize, SystemCache: usize, KernelTotal: usize, KernelPaged: usize, KernelNonpaged: usize, PageSize: usize, HandleCount: u32, ProcessCount: u32, ThreadCount: u32, }; pub const ENUM_PAGE_FILE_INFORMATION = extern struct { cb: u32, Reserved: u32, TotalSize: usize, TotalInUse: usize, PeakUsage: usize, }; pub const PENUM_PAGE_FILE_CALLBACKW = fn( pContext: ?*anyopaque, pPageFileInfo: ?*ENUM_PAGE_FILE_INFORMATION, lpFilename: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub const PENUM_PAGE_FILE_CALLBACKA = fn( pContext: ?*anyopaque, pPageFileInfo: ?*ENUM_PAGE_FILE_INFORMATION, lpFilename: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; //-------------------------------------------------------------------------------- // Section: Functions (27) //-------------------------------------------------------------------------------- pub extern "KERNEL32" fn K32EnumProcesses( // TODO: what to do with BytesParamIndex 1? lpidProcess: ?*u32, cb: u32, lpcbNeeded: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32EnumProcessModules( hProcess: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lphModule: ?*?HINSTANCE, cb: u32, lpcbNeeded: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32EnumProcessModulesEx( hProcess: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lphModule: ?*?HINSTANCE, cb: u32, lpcbNeeded: ?*u32, dwFilterFlag: ENUM_PROCESS_MODULES_EX_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32GetModuleBaseNameA( hProcess: ?HANDLE, hModule: ?HINSTANCE, lpBaseName: [*:0]u8, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetModuleBaseNameW( hProcess: ?HANDLE, hModule: ?HINSTANCE, lpBaseName: [*:0]u16, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetModuleFileNameExA( hProcess: ?HANDLE, hModule: ?HINSTANCE, lpFilename: [*:0]u8, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetModuleFileNameExW( hProcess: ?HANDLE, hModule: ?HINSTANCE, lpFilename: [*:0]u16, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetModuleInformation( hProcess: ?HANDLE, hModule: ?HINSTANCE, lpmodinfo: ?*MODULEINFO, cb: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32EmptyWorkingSet( hProcess: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32InitializeProcessForWsWatch( hProcess: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32GetWsChanges( hProcess: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpWatchInfo: ?*PSAPI_WS_WATCH_INFORMATION, cb: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32GetWsChangesEx( hProcess: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpWatchInfoEx: ?*PSAPI_WS_WATCH_INFORMATION_EX, cb: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32GetMappedFileNameW( hProcess: ?HANDLE, lpv: ?*anyopaque, lpFilename: [*:0]u16, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetMappedFileNameA( hProcess: ?HANDLE, lpv: ?*anyopaque, lpFilename: [*:0]u8, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32EnumDeviceDrivers( // TODO: what to do with BytesParamIndex 1? lpImageBase: ?*?*anyopaque, cb: u32, lpcbNeeded: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32GetDeviceDriverBaseNameA( ImageBase: ?*anyopaque, lpFilename: [*:0]u8, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetDeviceDriverBaseNameW( ImageBase: ?*anyopaque, lpBaseName: [*:0]u16, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetDeviceDriverFileNameA( ImageBase: ?*anyopaque, lpFilename: [*:0]u8, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetDeviceDriverFileNameW( ImageBase: ?*anyopaque, lpFilename: [*:0]u16, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32QueryWorkingSet( hProcess: ?HANDLE, // TODO: what to do with BytesParamIndex 2? pv: ?*anyopaque, cb: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32QueryWorkingSetEx( hProcess: ?HANDLE, // TODO: what to do with BytesParamIndex 2? pv: ?*anyopaque, cb: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32GetProcessMemoryInfo( Process: ?HANDLE, ppsmemCounters: ?*PROCESS_MEMORY_COUNTERS, cb: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32GetPerformanceInfo( pPerformanceInformation: ?*PERFORMANCE_INFORMATION, cb: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32EnumPageFilesW( pCallBackRoutine: ?PENUM_PAGE_FILE_CALLBACKW, pContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32EnumPageFilesA( pCallBackRoutine: ?PENUM_PAGE_FILE_CALLBACKA, pContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn K32GetProcessImageFileNameA( hProcess: ?HANDLE, lpImageFileName: [*:0]u8, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn K32GetProcessImageFileNameW( hProcess: ?HANDLE, lpImageFileName: [*:0]u16, nSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (8) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { pub const PENUM_PAGE_FILE_CALLBACK = thismodule.PENUM_PAGE_FILE_CALLBACKA; pub const K32GetModuleBaseName = thismodule.K32GetModuleBaseNameA; pub const K32GetModuleFileNameEx = thismodule.K32GetModuleFileNameExA; pub const K32GetMappedFileName = thismodule.K32GetMappedFileNameA; pub const K32GetDeviceDriverBaseName = thismodule.K32GetDeviceDriverBaseNameA; pub const K32GetDeviceDriverFileName = thismodule.K32GetDeviceDriverFileNameA; pub const K32EnumPageFiles = thismodule.K32EnumPageFilesA; pub const K32GetProcessImageFileName = thismodule.K32GetProcessImageFileNameA; }, .wide => struct { pub const PENUM_PAGE_FILE_CALLBACK = thismodule.PENUM_PAGE_FILE_CALLBACKW; pub const K32GetModuleBaseName = thismodule.K32GetModuleBaseNameW; pub const K32GetModuleFileNameEx = thismodule.K32GetModuleFileNameExW; pub const K32GetMappedFileName = thismodule.K32GetMappedFileNameW; pub const K32GetDeviceDriverBaseName = thismodule.K32GetDeviceDriverBaseNameW; pub const K32GetDeviceDriverFileName = thismodule.K32GetDeviceDriverFileNameW; pub const K32EnumPageFiles = thismodule.K32EnumPageFilesW; pub const K32GetProcessImageFileName = thismodule.K32GetProcessImageFileNameW; }, .unspecified => if (@import("builtin").is_test) struct { pub const PENUM_PAGE_FILE_CALLBACK = *opaque{}; pub const K32GetModuleBaseName = *opaque{}; pub const K32GetModuleFileNameEx = *opaque{}; pub const K32GetMappedFileName = *opaque{}; pub const K32GetDeviceDriverBaseName = *opaque{}; pub const K32GetDeviceDriverFileName = *opaque{}; pub const K32EnumPageFiles = *opaque{}; pub const K32GetProcessImageFileName = *opaque{}; } else struct { pub const PENUM_PAGE_FILE_CALLBACK = @compileError("'PENUM_PAGE_FILE_CALLBACK' requires that UNICODE be set to true or false in the root module"); pub const K32GetModuleBaseName = @compileError("'K32GetModuleBaseName' requires that UNICODE be set to true or false in the root module"); pub const K32GetModuleFileNameEx = @compileError("'K32GetModuleFileNameEx' requires that UNICODE be set to true or false in the root module"); pub const K32GetMappedFileName = @compileError("'K32GetMappedFileName' requires that UNICODE be set to true or false in the root module"); pub const K32GetDeviceDriverBaseName = @compileError("'K32GetDeviceDriverBaseName' requires that UNICODE be set to true or false in the root module"); pub const K32GetDeviceDriverFileName = @compileError("'K32GetDeviceDriverFileName' requires that UNICODE be set to true or false in the root module"); pub const K32EnumPageFiles = @compileError("'K32EnumPageFiles' requires that UNICODE be set to true or false in the root module"); pub const K32GetProcessImageFileName = @compileError("'K32GetProcessImageFileName' requires that UNICODE be set to true or false in the root module"); }, }; //-------------------------------------------------------------------------------- // Section: Imports (5) //-------------------------------------------------------------------------------- const BOOL = @import("../foundation.zig").BOOL; const HANDLE = @import("../foundation.zig").HANDLE; const HINSTANCE = @import("../foundation.zig").HINSTANCE; const PSTR = @import("../foundation.zig").PSTR; const PWSTR = @import("../foundation.zig").PWSTR; test { // The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476 if (@hasDecl(@This(), "PENUM_PAGE_FILE_CALLBACKW")) { _ = PENUM_PAGE_FILE_CALLBACKW; } if (@hasDecl(@This(), "PENUM_PAGE_FILE_CALLBACKA")) { _ = PENUM_PAGE_FILE_CALLBACKA; } @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/system/process_status.zig
const std = @import("std"); const utils = @import("utils.zig"); /// stores a single object of type T for each T added pub const TypeStore = struct { map: std.AutoHashMap(u32, []u8), allocator: std.mem.Allocator, pub fn init(allocator: std.mem.Allocator) TypeStore { return TypeStore{ .map = std.AutoHashMap(u32, []u8).init(allocator), .allocator = allocator, }; } pub fn deinit(self: *TypeStore) void { var iter = self.map.valueIterator(); while (iter.next()) |val_ptr| { self.allocator.free(val_ptr.*); } self.map.deinit(); } /// adds instance, returning a pointer to the item as it lives in the store pub fn add(self: *TypeStore, instance: anytype) void { var bytes = self.allocator.alloc(u8, @sizeOf(@TypeOf(instance))) catch unreachable; std.mem.copy(u8, bytes, std.mem.asBytes(&instance)); _ = self.map.put(utils.typeId(@TypeOf(instance)), bytes) catch unreachable; } pub fn get(self: *TypeStore, comptime T: type) *T { if (self.map.get(utils.typeId(T))) |bytes| { return @ptrCast(*T, @alignCast(@alignOf(T), bytes)); } unreachable; } pub fn getConst(self: *TypeStore, comptime T: type) T { return self.get(T).*; } pub fn getOrAdd(self: *TypeStore, comptime T: type) *T { if (!self.has(T)) { var instance = std.mem.zeroes(T); self.add(instance); } return self.get(T); } pub fn remove(self: *TypeStore, comptime T: type) void { if (self.map.get(utils.typeId(T))) |bytes| { self.allocator.free(bytes); _ = self.map.remove(utils.typeId(T)); } } pub fn has(self: *TypeStore, comptime T: type) bool { return self.map.contains(utils.typeId(T)); } }; test "TypeStore" { const Vector = struct { x: f32 = 0, y: f32 = 0, z: f32 = 0 }; var store = TypeStore.init(std.testing.allocator); defer store.deinit(); var orig = Vector{ .x = 5, .y = 6, .z = 8 }; store.add(orig); try std.testing.expect(store.has(Vector)); try std.testing.expectEqual(store.get(Vector).*, orig); var v = store.get(Vector); try std.testing.expectEqual(v.*, Vector{ .x = 5, .y = 6, .z = 8 }); v.*.x = 666; var v2 = store.get(Vector); try std.testing.expectEqual(v2.*, Vector{ .x = 666, .y = 6, .z = 8 }); store.remove(Vector); try std.testing.expect(!store.has(Vector)); var v3 = store.getOrAdd(u32); try std.testing.expectEqual(v3.*, 0); v3.* = 777; _ = store.get(u32); try std.testing.expectEqual(v3.*, 777); }
src/ecs/type_store.zig
const std = @import("std"); const builtin = @import("builtin"); const LibExeObjStep = std.build.LibExeObjStep; const Builder = std.build.Builder; const CrossTarget = std.zig.CrossTarget; const Pkg = std.build.Pkg; const renderkit_build = @import("renderkit/build.zig"); const ShaderCompileStep = renderkit_build.ShaderCompileStep; var enable_imgui: ?bool = null; pub fn build(b: *Builder) !void { const target = b.standardTargetOptions(.{}); // const mode = b.standardReleaseOptions(); // use a different cache folder for macos arm builds b.cache_root = if (builtin.os.tag == .macos and builtin.arch == builtin.Arch.aarch64) "zig-arm-cache" else "zig-cache"; const examples = [_][2][]const u8{ [_][]const u8{ "mode7", "examples/mode7.zig" }, [_][]const u8{ "primitives", "examples/primitives.zig" }, [_][]const u8{ "offscreen", "examples/offscreen.zig" }, [_][]const u8{ "tri_batcher", "examples/tri_batcher.zig" }, [_][]const u8{ "batcher", "examples/batcher.zig" }, [_][]const u8{ "meshes", "examples/meshes.zig" }, [_][]const u8{ "clear", "examples/clear.zig" }, [_][]const u8{ "clear_imgui", "examples/clear_imgui.zig" }, }; const examples_step = b.step("examples", "build all examples"); b.default_step.dependOn(examples_step); for (examples) |example, i| { const name = example[0]; const source = example[1]; var exe = createExe(b, target, name, source); examples_step.dependOn(&exe.step); // first element in the list is added as "run" so "zig build run" works if (i == 0) _ = createExe(b, target, "run", source); } // shader compiler, run with `zig build compile-shaders` const res = ShaderCompileStep.init(b, "renderkit/shader_compiler/", .{ .shader = "examples/assets/shaders/shader_src.glsl", .shader_output_path = "examples/assets/shaders", .package_output_path = "examples/assets", .additional_imports = &[_][]const u8{ "const gk = @import(\"gamekit\");", "const gfx = gk.gfx;", "const math = gk.math;", "const renderkit = gk.renderkit;", }, }); const comple_shaders_step = b.step("compile-shaders", "compiles all shaders"); b.default_step.dependOn(comple_shaders_step); comple_shaders_step.dependOn(&res.step); } fn createExe(b: *Builder, target: CrossTarget, name: []const u8, source: []const u8) *std.build.LibExeObjStep { var exe = b.addExecutable(name, source); exe.setBuildMode(b.standardReleaseOptions()); exe.setOutputDir(std.fs.path.join(b.allocator, &[_][]const u8{ b.cache_root, "bin" }) catch unreachable); addGameKitToArtifact(b, exe, target, ""); const run_cmd = exe.run(); const exe_step = b.step(name, b.fmt("run {s}.zig", .{name})); exe_step.dependOn(&run_cmd.step); return exe; } /// adds gamekit, renderkit, stb and sdl packages to the LibExeObjStep pub fn addGameKitToArtifact(b: *Builder, exe: *std.build.LibExeObjStep, target: CrossTarget, comptime prefix_path: []const u8) void { if (prefix_path.len > 0 and !std.mem.endsWith(u8, prefix_path, "/")) @panic("prefix-path must end with '/' if it is not empty"); // only add the build option once! if (enable_imgui == null) enable_imgui = b.option(bool, "imgui", "enable imgui") orelse false; const exe_options = b.addOptions(); exe.addOptions("gamekit_build_options", exe_options); exe_options.addOption(bool, "enable_imgui", enable_imgui.?); // var dependencies = std.ArrayList(Pkg).init(b.allocator); // sdl const sdl_builder = @import("gamekit/deps/sdl/build.zig"); sdl_builder.linkArtifact(b, exe, target, prefix_path); const sdl_pkg = sdl_builder.getPackage(prefix_path); // stb const stb_builder = @import("gamekit/deps/stb/build.zig"); stb_builder.linkArtifact(b, exe, target, prefix_path); const stb_pkg = stb_builder.getPackage(prefix_path); // fontstash const fontstash_build = @import("gamekit/deps/fontstash/build.zig"); fontstash_build.linkArtifact(b, exe, target, prefix_path); const fontstash_pkg = fontstash_build.getPackage(prefix_path); // renderkit renderkit_build.addRenderKitToArtifact(b, exe, target, prefix_path ++ "renderkit/"); const renderkit_pkg = renderkit_build.getRenderKitPackage(prefix_path ++ "renderkit/"); // imgui const imgui_builder = @import("gamekit/deps/imgui/build.zig"); imgui_builder.linkArtifact(b, exe, target, prefix_path); const imgui_pkg = imgui_builder.getImGuiPackage(prefix_path); // gamekit const gamekit_package = Pkg{ .name = "gamekit", .path = .{ .path = prefix_path ++ "gamekit/gamekit.zig" }, .dependencies = &[_]Pkg{ renderkit_pkg, sdl_pkg, stb_pkg, fontstash_pkg, imgui_pkg }, }; exe.addPackage(gamekit_package); }
build.zig
const std = @import( "std" ); const Mutex = std.Thread.Mutex; const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; usingnamespace @import( "../core/core.zig" ); usingnamespace @import( "../core/glz.zig" ); usingnamespace @import( "../sim.zig" ); pub fn CurvePaintable( comptime N: usize, comptime P: usize ) type { return struct { const Self = @This(); axes: [2]*const Axis, rgbKinetic: [3]GLfloat, rgbPotential: [3]GLfloat, rgbPotentialA: [3]GLfloat, hMutex: Mutex, hCoords: ArrayList(GLfloat), hIndices: ArrayList(GLuint), hDirty: bool, vao: GLuint, prog: CurveProgram, dCoords: GLuint, dIndices: GLuint, dCount: GLsizei, painter: Painter, simListener: SimListener(N,P) = SimListener(N,P) { .handleFrameFn = handleFrame, }, pub fn init( name: []const u8, axes: [2]*const Axis, allocator: *Allocator ) !Self { return Self { .axes = axes, .rgbKinetic = [3]GLfloat { 0.0, 0.0, 0.0 }, .rgbPotential = [3]GLfloat { 1.0, 0.0, 0.0 }, .rgbPotentialA = [3]GLfloat { 1.0, 1.0, 1.0 }, .hMutex = Mutex {}, .hCoords = ArrayList(GLfloat).init( allocator ), .hIndices = ArrayList(GLuint).init( allocator ), .hDirty = false, .vao = 0, .prog = undefined, .dCoords = 0, .dIndices = 0, .dCount = 0, .painter = Painter { .name = name, .glInitFn = glInit, .glPaintFn = glPaint, .glDeinitFn = glDeinit, }, }; } /// Called on simulator thread fn handleFrame( simListener: *SimListener(N,P), simFrame: *const SimFrame(N,P) ) !void { const self = @fieldParentPtr( Self, "simListener", simListener ); const t = @floatCast( GLfloat, simFrame.t ); var kineticEnergy = @as( f64, 0.0 ); for ( simFrame.ms ) |m, p| { var vSquared = @as( f64, 0.0 ); for ( simFrame.vs[ p*N.. ][ 0..N ] ) |v| { vSquared += v*v; } kineticEnergy += 0.5 * m * vSquared; } // TODO: Find a less kludgy way to store and render all the potentials separately var potentialEnergyA = @as( f64, 0.0 ); var potentialEnergyB = @as( f64, 0.0 ); for ( simFrame.config.accelerators ) |accelerator, i| { const potentialEnergy = accelerator.computePotentialEnergy( simFrame.xs, simFrame.ms ); if ( i == 0 ) { potentialEnergyA += potentialEnergy; } else { potentialEnergyB += potentialEnergy; } } const potentialEnergy = potentialEnergyA + potentialEnergyB; const totalEnergy = kineticEnergy + potentialEnergy; const newCoords = [_]GLfloat { t, @as( GLfloat, 0 ), @as( GLfloat, 0 ), t, @floatCast( GLfloat, potentialEnergyA ), @as( GLfloat, 1 ), t, @floatCast( GLfloat, potentialEnergy ), @as( GLfloat, 2 ), t, @floatCast( GLfloat, totalEnergy ), @as( GLfloat, 3 ), }; { const held = self.hMutex.acquire( ); defer held.release( ); try self.hCoords.appendSlice( &newCoords ); const hCount = @intCast( GLuint, @divTrunc( self.hCoords.items.len, 3 ) ); if ( hCount >= 8 ) { const D = hCount-5; const H = hCount-1; const C = hCount-6; const G = hCount-2; const B = hCount-7; const F = hCount-3; const A = hCount-8; const E = hCount-4; const newIndices = [_]GLuint { D, C, H, H, C, G, C, B, G, G, B, F, B, A, F, F, A, E, }; try self.hIndices.appendSlice( &newIndices ); } self.hDirty = true; } } fn glInit( painter: *Painter, pc: *const PainterContext ) !void { const self = @fieldParentPtr( Self, "painter", painter ); self.prog = try CurveProgram.glCreate( ); glGenBuffers( 1, &self.dCoords ); glGenBuffers( 1, &self.dIndices ); glBindBuffer( GL_ARRAY_BUFFER, self.dCoords ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self.dIndices ); glGenVertexArrays( 1, &self.vao ); glBindVertexArray( self.vao ); if ( self.prog.inCoords >= 0 ) { const inCoords = @intCast( GLuint, self.prog.inCoords ); glEnableVertexAttribArray( inCoords ); glVertexAttribPointer( inCoords, 3, GL_FLOAT, GL_FALSE, 0, null ); } } fn glPaint( painter: *Painter, pc: *const PainterContext ) !void { const self = @fieldParentPtr( Self, "painter", painter ); glBindBuffer( GL_ARRAY_BUFFER, self.dCoords ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self.dIndices ); { const held = self.hMutex.acquire( ); defer held.release( ); if ( self.hDirty ) { glzBufferData( GL_ARRAY_BUFFER, GLfloat, self.hCoords.items, GL_STATIC_DRAW ); glzBufferData( GL_ELEMENT_ARRAY_BUFFER, GLuint, self.hIndices.items, GL_STATIC_DRAW ); self.dCount = @intCast( GLsizei, self.hIndices.items.len ); // FIXME: Overflow self.hDirty = false; } } if ( self.dCount > 0 ) { const bounds = axisBounds( 2, self.axes ); glzEnablePremultipliedAlphaBlending( ); glUseProgram( self.prog.program ); glzUniformInterval2( self.prog.XY_BOUNDS, bounds ); glUniform3fv( self.prog.RGB_Z0, 1, &self.rgbPotentialA ); glUniform3fv( self.prog.RGB_Z1, 1, &self.rgbPotential ); glUniform3fv( self.prog.RGB_Z2, 1, &self.rgbKinetic ); glBindVertexArray( self.vao ); glDrawElements( GL_TRIANGLES, self.dCount, GL_UNSIGNED_INT, null ); } } fn glDeinit( painter: *Painter ) void { const self = @fieldParentPtr( Self, "painter", painter ); glDeleteProgram( self.prog.program ); glDeleteVertexArrays( 1, &self.vao ); glDeleteBuffers( 1, &self.dCoords ); glDeleteBuffers( 1, &self.dIndices ); } pub fn deinit( self: *Self ) void { { const held = self.hMutex.acquire( ); defer held.release( ); self.hCoords.deinit( ); self.hIndices.deinit( ); } } }; } const CurveProgram = struct { program: GLuint, XY_BOUNDS: GLint, RGB_Z0: GLint, RGB_Z1: GLint, RGB_Z2: GLint, /// x_XAXIS, y_YAXIS, z inCoords: GLint, pub fn glCreate( ) !CurveProgram { const vertSource = \\#version 150 core \\ \\vec2 start2D( vec4 interval2D ) \\{ \\ return interval2D.xy; \\} \\ \\vec2 span2D( vec4 interval2D ) \\{ \\ return interval2D.zw; \\} \\ \\vec2 coordsToNdc2D( vec2 coords, vec4 bounds ) \\{ \\ vec2 frac = ( coords - start2D( bounds ) ) / span2D( bounds ); \\ return ( -1.0 + 2.0*frac ); \\} \\ \\uniform vec4 XY_BOUNDS; \\ \\// x_XAXIS, y_YAXIS, z \\in vec3 inCoords; \\ \\out float vZ; // FIXME: Try "flat" keyword \\ \\void main( void ) { \\ vec2 xy_XYAXIS = inCoords.xy; \\ gl_Position = vec4( coordsToNdc2D( xy_XYAXIS, XY_BOUNDS ), 0.0, 1.0 ); \\ vZ = inCoords.z; \\} ; const fragSource = \\#version 150 core \\precision lowp float; \\ \\uniform vec3 RGB_Z0; \\uniform vec3 RGB_Z1; \\uniform vec3 RGB_Z2; \\ \\in float vZ; \\ \\out vec4 outRgba; \\ \\void main( void ) { \\ switch ( int( vZ ) ) { \\ case 0: \\ outRgba = vec4( RGB_Z0, 1.0 ); \\ break; \\ case 1: \\ outRgba = vec4( RGB_Z1, 1.0 ); \\ break; \\ case 2: \\ outRgba = vec4( RGB_Z2, 1.0 ); \\ break; \\ default: \\ discard; \\ break; \\ } \\} ; const program = try glzCreateProgram( vertSource, fragSource ); return CurveProgram { .program = program, .XY_BOUNDS = glGetUniformLocation( program, "XY_BOUNDS" ), .RGB_Z0 = glGetUniformLocation( program, "RGB_Z0" ), .RGB_Z1 = glGetUniformLocation( program, "RGB_Z1" ), .RGB_Z2 = glGetUniformLocation( program, "RGB_Z2" ), .inCoords = glGetAttribLocation( program, "inCoords" ), }; } };
src/time/curve.zig
usingnamespace @import( "../core/core.zig" ); usingnamespace @import( "../core/glz.zig" ); pub fn StaticPaintable( comptime vCapacity: usize ) type { return struct { const Self = @This(); axes: [2]*const Axis, mode: GLenum, rgba: [4]GLfloat, vCoords: [2*vCapacity]GLfloat, vCount: GLsizei, vModified: bool, prog: StaticProgram, vbo: GLuint, vao: GLuint, painter: Painter, pub fn init( name: []const u8, axes: [2]*const Axis, mode: GLenum ) Self { return Self { .axes = axes, .mode = mode, .rgba = [4]GLfloat { 0.0, 0.0, 0.0, 1.0 }, .vCoords = [1]GLfloat { 0.0 } ** ( 2*vCapacity ), .vCount = 0, .vModified = true, .prog = undefined, .vbo = 0, .vao = 0, .painter = Painter { .name = name, .glInitFn = glInit, .glPaintFn = glPaint, .glDeinitFn = glDeinit, }, }; } fn glInit( painter: *Painter, pc: *const PainterContext ) !void { const self = @fieldParentPtr( Self, "painter", painter ); self.prog = try StaticProgram.glCreate( ); glGenBuffers( 1, &self.vbo ); glBindBuffer( GL_ARRAY_BUFFER, self.vbo ); glGenVertexArrays( 1, &self.vao ); glBindVertexArray( self.vao ); glEnableVertexAttribArray( self.prog.inCoords ); glVertexAttribPointer( self.prog.inCoords, 2, GL_FLOAT, GL_FALSE, 0, null ); } fn glPaint( painter: *Painter, pc: *const PainterContext ) !void { const self = @fieldParentPtr( Self, "painter", painter ); if ( self.vModified ) { if ( self.vCount > 0 ) { glBufferData( GL_ARRAY_BUFFER, 2*self.vCount*@sizeOf( GLfloat ), @ptrCast( *const c_void, &self.vCoords ), GL_STATIC_DRAW ); } else { // FIXME: glBufferData with null? } self.vModified = false; } if ( self.vCount > 0 ) { const bounds = axisBounds( 2, self.axes ); glzEnablePremultipliedAlphaBlending( ); glUseProgram( self.prog.program ); glzUniformInterval2( self.prog.XY_BOUNDS, bounds ); glUniform4fv( self.prog.RGBA, 1, &self.rgba ); glBindVertexArray( self.vao ); glDrawArrays( self.mode, 0, self.vCount ); } } fn glDeinit( painter: *Painter ) void { const self = @fieldParentPtr( Self, "painter", painter ); glDeleteProgram( self.prog.program ); glDeleteVertexArrays( 1, &self.vao ); glDeleteBuffers( 1, &self.vbo ); } }; } const StaticProgram = struct { program: GLuint, XY_BOUNDS: GLint, RGBA: GLint, /// x_XAXIS, y_YAXIS inCoords: GLuint, pub fn glCreate( ) !StaticProgram { const vertSource = \\#version 150 core \\ \\vec2 start2D( vec4 interval2D ) \\{ \\ return interval2D.xy; \\} \\ \\vec2 span2D( vec4 interval2D ) \\{ \\ return interval2D.zw; \\} \\ \\vec2 coordsToNdc2D( vec2 coords, vec4 bounds ) \\{ \\ vec2 frac = ( coords - start2D( bounds ) ) / span2D( bounds ); \\ return ( -1.0 + 2.0*frac ); \\} \\ \\uniform vec4 XY_BOUNDS; \\ \\// x_XAXIS, y_YAXIS \\in vec2 inCoords; \\ \\void main( void ) { \\ vec2 xy_XYAXIS = inCoords.xy; \\ gl_Position = vec4( coordsToNdc2D( xy_XYAXIS, XY_BOUNDS ), 0.0, 1.0 ); \\} ; const fragSource = \\#version 150 core \\precision lowp float; \\ \\uniform vec4 RGBA; \\ \\out vec4 outRgba; \\ \\void main( void ) { \\ float alpha = RGBA.a; \\ outRgba = vec4( alpha*RGBA.rgb, alpha ); \\} ; const program = try glzCreateProgram( vertSource, fragSource ); return StaticProgram { .program = program, .XY_BOUNDS = glGetUniformLocation( program, "XY_BOUNDS" ), .RGBA = glGetUniformLocation( program, "RGBA" ), .inCoords = @intCast( GLuint, glGetAttribLocation( program, "inCoords" ) ), }; } };
src/space/staticPaintable.zig
const std = @import("std"); const expect = std.testing.expect; const io = std.io; const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; pub fn main() anyerror!void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); var allocator = &gpa.allocator; var list = try readSeats(allocator, "input.txt"); defer allocator.free(list); std.sort.sort(u16, list, {}, comptime std.sort.asc(u16)); const largest = std.mem.max(u16, list); var last: u16 = list[0]; var gap: u16 = 0; for (list[1..]) |item| { if (item != last + 1) { gap = item - 1; break; } last = item; } const stdout = io.getStdOut().writer(); try stdout.print("Part 1: {d}\n", .{largest}); try stdout.print("Part 2: {d}\n", .{gap}); } fn readSeats(allocator: *Allocator, path: []const u8) ![]u16 { var file = try std.fs.cwd().openFile(path, .{}); defer file.close(); var list = ArrayList(u16).init(allocator); defer list.deinit(); var buf_reader = io.bufferedReader(file.reader()); var in_stream = buf_reader.reader(); var buf: [64]u8 = undefined; while (try in_stream.readUntilDelimiterOrEof(&buf, '\n')) |line| { try list.append(seatNumber(line)); } return list.toOwnedSlice(); } pub fn seatNumber(str: []const u8) u16 { const row = partition(str[0..7], 0, 127); const col = partition(str[7..], 0, 7); return (row * 8) + col; } fn partition(str: []const u8, min: u16, max: u16) u16 { if (max == min) { return min; } const offset: f16 = (@intToFloat(f16, max - min)) / 2; switch (str[0]) { 'F', 'L' => { return partition(str[1..], min, min + @floatToInt(u16, @floor(offset))); }, 'B', 'R' => { return partition(str[1..], min + @floatToInt(u16, @ceil(offset)), max); }, else => unreachable, } unreachable; } test "part1" { try expect(357 == seatNumber("FBFBBFFRLR")); try expect(567 == seatNumber("BFFFBBFRRR")); try expect(119 == seatNumber("FFFBBBFRRR")); try expect(820 == seatNumber("BBFFBBFRLL")); }
day05/src/main.zig
const std = @import("std"); const net = std.net; const okredis = @import("./src/okredis.zig"); const Client = okredis.Client; pub fn main() !void { // Connect const addr = try net.Address.parseIp4("1192.168.3.11", 6379); var connection = try net.tcpConnectToAddress(addr); var client: Client = undefined; try client.init(connection); defer client.close(); // - // == INTRODUCTION == // - // Send a command, and we're not interested in // ispecting the response, so we don't even allocate // memory for it. If Redis replies with an error message, // this function will return a Zig error. try client.send(void, .{ "SET", "key", "42" }); // Get a key, decode the response as an i64. // `GET` actually returns a string response, but the // parser is nice enough to try and parse it for us. // Works with both integers and floats. const reply = try client.send(i64, .{ "GET", "key" }); std.debug.print("key = {}\n", .{reply}); // Try to get the value, but this time using an optional type, // this allows decoding Redis Nil replies. try client.send(void, .{ "DEL", "nokey" }); var maybe = try client.send(?i64, .{ "GET", "nokey" }); if (maybe) |val| { std.debug.print("Found nokey with value = {}\n", .{val}); // Won't be printed. } else { std.debug.print("Yep, nokey is not present.\n", .{}); } // To decode strings without allocating, use a FixBuf type. // FixBuf is just an array + length, so it allows decoding // strings up to its length. If the buffer is not big enough, // an error is returned. const FixBuf = okredis.types.FixBuf; try client.send(void, .{ "SET", "stringkey", "Hello World!" }); var stringkey = try client.send(FixBuf(30), .{ "GET", "stringkey" }); std.debug.print("stringkey = {s}\n", .{stringkey.toSlice()}); // Send a bad command, this time we are interested in the error response. // OrErr also has a .Nil case, so you don't need to make your return type // optional in this case. In general, wrapping all response types with // OrErr() is a good idea. const OrErr = okredis.types.OrErr; switch (try client.send(OrErr(i64), .{ "INCR", "stringkey" })) { .Ok, .Nil => unreachable, .Err => |err| std.debug.print("error code = {s}\n", .{err.getCode()}), } const MyHash = struct { banana: FixBuf(11), price: f32, }; // Create a hash with the same fields as our struct try client.send(void, .{ "HSET", "myhash", "banana", "yes please", "price", "9.99" }); // Parse it directly into the struct switch (try client.send(OrErr(MyHash), .{ "HGETALL", "myhash" })) { .Nil, .Err => unreachable, .Ok => |val| { std.debug.print("myhash = \n\t{}\n", .{val}); }, } // Create a big string key try client.send(void, .{ "SET", "divine", \\When half way through the journey of our life \\I found that I was in a gloomy wood, \\because the path which led aright was lost. \\And ah, how hard it is to say just what \\this wild and rough and stubborn woodland was, \\the very thought of which renews my fear! }); // When you are fine with allocating memory, // you can use the .sendAlloc interface. const allocator = std.heap.page_allocator; // But then it's up to you to free all that was allocated. var inferno = try client.sendAlloc([]u8, allocator, .{ "GET", "divine" }); defer allocator.free(inferno); std.debug.print("\ndivine comedy - inferno 1: \n{s}\n\n", .{inferno}); // When using sendAlloc, you can use OrFullErr to parse not just the error code // but also the full error message. The error message is allocated with `allocator` // so it will need to be freed. (the next example will free it) const OrFullErr = okredis.types.OrFullErr; var incrErr = try client.sendAlloc(OrFullErr(i64), allocator, .{ "INCR", "divine" }); switch (incrErr) { .Ok, .Nil => unreachable, .Err => |err| std.debug.print("error code = {s} message = '{s}'\n", .{ err.getCode(), err.message }), } // To help deallocating resources allocated by `sendAlloc`, you can use `freeReply`. // `freeReply` knows how to deallocate values created by `sendAlloc`. const freeReply = okredis.freeReply; // For example, instead of freeing directly incrErr.Err.message, you can do this: defer freeReply(incrErr, allocator); // In general, sendAlloc will only allocate where the type you specify is a // pointer. This call doesn't require to free anything. _ = try client.sendAlloc(f64, allocator, .{ "HGET", "myhash", "price" }); // This does require a free var allocatedNum = try client.sendAlloc(*f64, allocator, .{ "HGET", "myhash", "price" }); defer freeReply(allocatedNum, allocator); // alternatively: defer allocator.destroy(allocatedNum); std.debug.print("allocated num = {} ptr = {}\n", .{ allocatedNum.*, allocatedNum }); // Now we can decode the reply in a struct that doesn't need a FixBuf const MyDynHash = struct { banana: []u8, price: f32, }; const dynHash = try client.sendAlloc(OrErr(MyDynHash), allocator, .{ "HGETALL", "myhash" }); defer freeReply(dynHash, allocator); switch (dynHash) { .Nil, .Err => unreachable, .Ok => |val| { std.debug.print("mydynhash = \n\t{any}\n", .{val}); }, } // - // == DYNAMIC REPLIES == // - // While most programs will use simple Redis commands, and will know // the shape of the reply, one might also be in a situation where the // reply is unknown or dynamic. To help with that, supredis includes // `DynamicReply`, which can decode any possible Redis reply. const DynamicReply = okredis.types.DynamicReply; var dynReply = try client.sendAlloc(DynamicReply, allocator, .{ "HGETALL", "myhash" }); defer freeReply(dynReply, allocator); // DynamicReply is a union that represents all possible replies. std.debug.print("\nmyhash decoded as DynamicReply:\n", .{}); switch (dynReply.data) { .Nil, .Bool, .Number, .Double, .Bignum, .String, .List, .Set => {}, .Map => |kvs| { for (kvs) |kv| { std.debug.print("\t[{s}] => '{s}'\n", .{ kv[0].data.String.string, kv[1].data.String }); } }, } // Pipelining is a way of sending a batch of commands to Redis // in a more performant way than sending them one by one. // It's especially useful when using blocking I/O but, it can also // give small boosts when doing evented I/O. const r1 = try client.pipe(struct { c1: void, c2: u64, c3: OrErr(FixBuf(10)), }, .{ .{ "SET", "counter", 0 }, .{ "INCR", "counter" }, .{ "ECHO", "banana" }, }); std.debug.print("\n\n[INCR => {}]\n", .{r1.c2}); std.debug.print("[ECHO => {s}]\n", .{r1.c3}); // You can also allocate when doing pipelining. const r2 = try client.pipeAlloc(struct { c1: void, value: []u8, }, allocator, .{ .{ "SET", "banana", "yes please" }, .{ "GET", "banana" }, }); defer freeReply(r2, allocator); std.debug.print("\n[banana] => '{s}'\n", .{r2.value}); // Transactions are a way of providing isolation and all-or-nothing semantics to // a group of Redis commands. The relative methods (`trans` and `transAlloc`) are // included mostly for convenience as they implicitly apply pipelining to the // commands passed, but the same result could be achieved by making explicit use // of MULTI/EXEC and `pipe`/`pipeAlloc`. switch (try client.trans(OrErr(struct { c1: OrErr(FixBuf(10)), c2: u64, c3: OrErr(void), }), .{ .{ "SET", "banana", "no, thanks" }, .{ "INCR", "counter" }, .{ "INCR", "banana" }, })) { .Err => |e| @panic(e.getCode()), .Nil => @panic("got nil"), .Ok => |tx_reply| { std.debug.print("\n[SET = {s}] [INCR = {}] [INCR (error) = {s}]\n", .{ tx_reply.c1.Ok.toSlice(), tx_reply.c2, tx_reply.c3.Err.getCode(), }); }, } }
example.zig
const std = @import("std"); const assert = std.debug.assert; const Camera = @import("Camera.zig"); const Material = @import("Material.zig"); const Mesh = @import("Mesh.zig"); const Renderer = @import("Renderer.zig"); const zp = @import("../../zplay.zig"); const drawcall = zp.graphics.common.drawcall; const ShaderProgram = zp.graphics.common.ShaderProgram; const VertexArray = zp.graphics.common.VertexArray; const alg = zp.deps.alg; const Mat4 = alg.Mat4; const Vec2 = alg.Vec2; const Vec3 = alg.Vec3; const Self = @This(); pub const ATTRIB_LOCATION_POS = 0; pub const ATTRIB_LOCATION_NORMAL = 1; const vs = \\#version 330 core \\layout (location = 0) in vec3 a_pos; \\layout (location = 1) in vec3 a_normal; \\ \\out vec3 v_pos; \\out vec3 v_normal; \\ \\uniform mat4 u_model; \\uniform mat4 u_normal; \\uniform mat4 u_view; \\uniform mat4 u_project; \\ \\void main() \\{ \\ gl_Position = u_project * u_view * u_model * vec4(a_pos, 1.0); \\ v_pos = vec3(u_model * vec4(a_pos, 1.0)); \\ v_normal = mat3(u_normal) * a_normal; \\} ; const reflect_fs = \\#version 330 core \\out vec4 frag_color; \\ \\in vec3 v_pos; \\in vec3 v_normal; \\ \\uniform vec3 u_view_pos; \\uniform samplerCube u_texture; \\ \\void main() \\{ \\ vec3 view_dir = normalize(v_pos - u_view_pos); \\ vec3 reflect_dir = reflect(view_dir, v_normal); \\ frag_color = vec4(texture(u_texture, reflect_dir).rgb, 1.0); \\} ; const refract_fs = \\#version 330 core \\out vec4 frag_color; \\ \\in vec3 v_pos; \\in vec3 v_normal; \\ \\uniform vec3 u_view_pos; \\uniform samplerCube u_texture; \\uniform float u_ratio; \\ \\void main() \\{ \\ vec3 view_dir = normalize(v_pos - u_view_pos); \\ vec3 refract_dir = refract(view_dir, v_normal, u_ratio); \\ frag_color = vec4(texture(u_texture, refract_dir).rgb, 1.0); \\} ; // environment mapping type const Type = enum { reflect, refract, }; /// lighting program program: ShaderProgram = undefined, /// type of mapping type: Type, /// create a Phong lighting renderer pub fn init(t: Type) Self { return .{ .program = ShaderProgram.init( vs, switch (t) { .reflect => reflect_fs, .refract => refract_fs, }, ), .type = t, }; } /// free resources pub fn deinit(self: *Self) void { self.program.deinit(); } /// get renderer pub fn renderer(self: *Self) Renderer { return Renderer.init(self, begin, end, render, renderMesh); } /// begin rendering fn begin(self: *Self) void { self.program.use(); } /// end rendering fn end(self: *Self) void { self.program.disuse(); } /// use material data fn applyMaterial(self: *Self, material: Material) void { switch (self.type) { .reflect => { assert(material.data == .single_cubemap); self.program.setUniformByName( "u_texture", material.data.single_cubemap.tex.getTextureUnit(), ); }, .refract => { assert(material.data == .refract_mapping); self.program.setUniformByName( "u_texture", material.data.refract_mapping.cubemap.tex.getTextureUnit(), ); self.program.setUniformByName( "u_ratio", 1.0 / material.data.refract_mapping.ratio, ); }, } } /// render geometries fn render( self: *Self, vertex_array: VertexArray, use_elements: bool, primitive: drawcall.PrimitiveType, offset: u32, count: u32, model: Mat4, projection: Mat4, camera: ?Camera, material: ?Material, instance_count: ?u32, ) !void { if (!self.program.isUsing()) { return error.RendererNotActive; } // set uniforms self.program.setUniformByName("u_model", model); self.program.setUniformByName("u_normal", model.inv().transpose()); self.program.setUniformByName("u_project", projection); self.program.setUniformByName("u_view", camera.?.getViewMatrix()); self.program.setUniformByName("u_view_pos", camera.?.position); self.applyMaterial(material.?); // issue draw call vertex_array.use(); defer vertex_array.disuse(); if (use_elements) { drawcall.drawElements(primitive, offset, count, u32, instance_count); } else { drawcall.drawBuffer(primitive, offset, count, instance_count); } } fn renderMesh( self: *Self, mesh: Mesh, model: Mat4, projection: Mat4, camera: ?Camera, material: ?Material, instance_count: ?u32, ) !void { if (!self.program.isUsing()) { return error.RendererNotActive; } mesh.vertex_array.use(); defer mesh.vertex_array.disuse(); // attribute settings mesh.vertex_array.setAttribute(Mesh.vbo_positions, ATTRIB_LOCATION_POS, 3, f32, false, 0, 0); assert(mesh.normals != null); mesh.vertex_array.setAttribute(Mesh.vbo_normals, ATTRIB_LOCATION_NORMAL, 3, f32, false, 0, 0); // set uniforms self.program.setUniformByName("u_model", model); self.program.setUniformByName("u_normal", model.inv().transpose()); self.program.setUniformByName("u_project", projection); self.program.setUniformByName("u_view", camera.?.getViewMatrix()); self.program.setUniformByName("u_view_pos", camera.?.position); self.applyMaterial(material.?); // issue draw call if (mesh.indices) |ids| { drawcall.drawElements(mesh.primitive_type, 0, @intCast(u32, ids.items.len), u32, instance_count); } else { drawcall.drawBuffer(mesh.primitive_type, 0, @intCast(u32, mesh.positions.items.len), instance_count); } }
src/graphics/3d/EnvMappingRenderer.zig
const std = @import("std"); const heap = std.heap; const io = std.io; const mem = std.mem; const c = @cImport({ @cInclude("curl/curl.h"); }); pub const Response = struct { allocator: mem.Allocator, response_code: usize, data: []const u8, pub fn deinit(self: *Response) void { self.allocator.free(self.data); } }; pub fn do(allocator: mem.Allocator, method: []const u8, url: [:0]const u8, body_opt: ?[]const u8) !Response { _ = method; if (c.curl_global_init(c.CURL_GLOBAL_ALL) != c.CURLE_OK) { return error.CURLGlobalInitFailed; } defer c.curl_global_cleanup(); const handle = c.curl_easy_init() orelse return error.CURLHandleInitFailed; defer c.curl_easy_cleanup(handle); var response = std.ArrayList(u8).init(allocator); // setup curl options _ = c.curl_easy_setopt(handle, c.CURLOPT_URL, url.ptr); // set write function callbacks _ = c.curl_easy_setopt(handle, c.CURLOPT_WRITEFUNCTION, writeToArrayListCallback); _ = c.curl_easy_setopt(handle, c.CURLOPT_WRITEDATA, &response); // set read function callbacks var headers: [*c]c.curl_slist = null; defer c.curl_slist_free_all(headers); if (body_opt) |data| { headers = c.curl_slist_append(headers, "Content-Type: application/json"); _ = c.curl_easy_setopt(handle, c.CURLOPT_HTTPHEADER, headers); _ = c.curl_easy_setopt(handle, c.CURLOPT_POSTFIELDSIZE, data.len); _ = c.curl_easy_setopt(handle, c.CURLOPT_COPYPOSTFIELDS, data.ptr); } // perform if (c.curl_easy_perform(handle) != c.CURLE_OK) { return error.FailedToPerformRequest; } // get information var res = Response{ .allocator = allocator, .response_code = 0, .data = response.toOwnedSlice(), }; _ = c.curl_easy_getinfo(handle, c.CURLINFO_RESPONSE_CODE, &res.response_code); return res; } fn writeToArrayListCallback(data: *anyopaque, size: c_uint, nmemb: c_uint, user_data: *anyopaque) callconv(.C) c_uint { var buffer = @intToPtr(*std.ArrayList(u8), @ptrToInt(user_data)); var typed_data = @intToPtr([*]u8, @ptrToInt(data)); buffer.appendSlice(typed_data[0 .. nmemb * size]) catch return 0; return nmemb * size; }
src/curl.zig
const assert = @import("std").debug.assert; const buf_size = 8; const KeyState = struct { pressed_time: u64 = 0, key_code: u8 = 0, released: bool = false, }; const KeyBuffer = @This(); // time in microseconds that pressed keys will at least remain pressed sticky_duration: u64, // current time in microsecs, bumped by update() cur_time: u64 = 0, // currently pressed keys keys: [buf_size]KeyState = [_]KeyState{.{}} ** buf_size, // call once per frame with frame duration (any time unit) pub fn update(self: *KeyBuffer, frame_duration: u32) void { // check for sticky keys that should be released for (self.keys) |*key| { if (key.released) { // properly handle time wraparound if ((self.cur_time < key.pressed_time) or (self.cur_time > (key.pressed_time + self.sticky_duration))) { // reset "expired" keys key.* = .{}; } } } self.cur_time +%= frame_duration; } // notify keyboard matrix about a pressed key pub fn keyDown(self: *KeyBuffer, key_code: u8) void { assert(0 != key_code); // first check if key is already in key buffer, if yes, just update the pressed-time for (self.keys) |*key| { if (key.key_code == key_code) { key.pressed_time = self.cur_time; key.released = false; return; } } // otherwise find the first free slot in the buffer for (self.keys) |*key| { if (0 == key.key_code) { key.key_code = key_code; key.pressed_time = self.cur_time; key.released = false; return; } } } // notify keyboard matrix about a released key pub fn keyUp(self: *KeyBuffer, key_code: u8) void { assert(0 != key_code); for (self.keys) |*key| { if (key.key_code == key_code) { key.released = true; return; } } } // get the most recently pressed key in the key buffer, zero means none pub fn mostRecentKey(self: *KeyBuffer) u8 { var t: u64 = 0; var key_code: u8 = 0; for (self.keys) |*key| { if ((0 != key.key_code) and (key.pressed_time > t)) { t = key.pressed_time; key_code = key.key_code; } } return key_code; }
src/emu/KeyBuffer.zig
const std = @import("std"); const testing = std.testing; const mem = std.mem; const ParserPath = @import("parser_path.zig").ParserPath; const ParserPosKey = @import("parser.zig").ParserPosKey; const deinitOptional = @import("parser.zig").deinitOptional; /// A ResultStream iterator. pub fn Iterator(comptime T: type) type { return struct { stream: *ResultStream(T), index: usize = 0, subscriber: ParserPosKey, path: ParserPath, cyclic_closed: bool = false, cyclic_error: ?T, const Self = @This(); /// Gets the next value, or null if the end of values has been reached. /// /// If the next value is not yet available, the frame is suspended and will be resumed once /// a new value is added. pub fn next(self: *Self) callconv(.Async) ?T { if (self.stream.past_values.items.len == 0 or self.index >= self.stream.past_values.items.len) { if (self.stream.closed or self.cyclic_closed or self.cyclic_error == null) { return null; // no more results } if (self.path.contains(self.subscriber)) { // The parser waiting on these results (self.subscriber) is itself a part of // a larger path of parsers which depend on this result in order to produce a // result. This indicates a cyclic grammar which parses the empty language, // e.g. in the most simple form: // // Expr = Expr; // Grammar = Expr; // // In practice it may be a more complex form; but regardless this means that // the subscriber should recieve no results. self.cyclic_closed = true; return self.cyclic_error.?; } // set ourselves up to be resumed later: self.stream.listeners.append(@frame()) catch unreachable; suspend {} // wait for more results, or stream close if (self.stream.closed) { return null; // no more results } } // return the next result const v = self.stream.past_values.items[self.index]; self.index += 1; return v; } }; } /// A stream of results from a parser. /// /// Listeners can be added at any time, and will recieve all past values upon /// subscription. /// /// New values can be added at any time. pub fn ResultStream(comptime T: type) type { return struct { past_values: std.ArrayList(T), listeners: std.ArrayList(anyframe), closed: bool, source: ParserPosKey, allocator: *mem.Allocator, const Self = @This(); pub fn init(allocator: *mem.Allocator, source: ParserPosKey) !Self { return Self{ .past_values = std.ArrayList(T).init(allocator), .listeners = std.ArrayList(anyframe).init(allocator), .closed = false, .source = source, .allocator = allocator, }; } /// adds a value to the stream, resuming the frames of any pending listeners. /// /// Added values are owned by the result stream, subscribers borrow them and they are valid /// until the result stream is deinitialized - at which point `deinit(allocator)` is called /// on all values. /// /// Returns only once all pending listeners' frames have been resumed. pub fn add(self: *Self, value: T) !void { try self.past_values.append(value); for (self.listeners.items) |listener| { resume listener; } self.listeners.shrinkRetainingCapacity(0); } /// closes the stream, signaling the end and waiting for all pending listeners' frames to /// be resumed. pub fn close(self: *Self) void { self.closed = true; for (self.listeners.items) |listener| { resume listener; } self.listeners.shrinkRetainingCapacity(0); } /// deinitializes the stream, all future calls to add, subscribe, and usage of iterators is /// forbidden. /// /// All values in this result stream are deinitialized via a call to `v.deinit(allocator)`. /// /// `close` must be called before deinit. pub fn deinit(self: *const Self) void { for (self.past_values.items) |v| deinitOptional(v, self.allocator); self.past_values.deinit(); self.listeners.deinit(); } /// subscribes to all past and future values of the stream, producing an async iterator. /// /// Uses of the returned iterator are valid for as long as the result stream is not /// deinitialized. pub fn subscribe(self: *Self, subscriber: ParserPosKey, path: ParserPath, cyclic_error: T) Iterator(T) { const iter = Iterator(T){ .stream = self, .subscriber = subscriber, .path = path, .cyclic_error = cyclic_error, }; return iter; } }; } test "result_stream" { nosuspend { const value = struct { value: i32, pub fn deinit(self: *const @This(), allocator: *mem.Allocator) void {} }; const subscriber = ParserPosKey{ .node_name = 0, .src_ptr = 0, .offset = 0, }; const source = subscriber; const path = ParserPath.init(); var stream = try ResultStream(value).init(testing.allocator, source); defer stream.deinit(); // Subscribe and begin to query a value (next() will suspend) before any values have been added // to the stream. var sub1 = stream.subscribe(subscriber, path, .{ .value = -1 }); var sub1first = async sub1.next(); // Add a value to the stream, our first subscription will get it. try stream.add(.{ .value = 1 }); try testing.expectEqual(@as(i32, 1), (await sub1first).?.value); // Query the next value (next() will suspend again), then add a value and close the stream for // good. var sub1second = async sub1.next(); try stream.add(.{ .value = 2 }); stream.close(); // Confirm we get the remaining values, and the null terminator forever after that. try testing.expectEqual(@as(i32, 2), (await sub1second).?.value); try testing.expectEqual(@as(?value, null), sub1.next()); try testing.expectEqual(@as(?value, null), sub1.next()); // Now that the stream is closed, add a new subscription and confirm we get all prior values. var sub2 = stream.subscribe(subscriber, path, .{ .value = -1 }); try testing.expectEqual(@as(i32, 1), sub2.next().?.value); try testing.expectEqual(@as(i32, 2), sub2.next().?.value); try testing.expectEqual(@as(?value, null), sub2.next()); } }
src/combn/engine/result_stream.zig
const std = @import("std"); const io = std.io; const File = std.fs.File; const Reader = File.Reader; const Allocator = std.mem.Allocator; const expect = std.testing.expect; const math = std.math; const alloc = std.heap.c_allocator; const Record = struct { const Self = @This(); min: usize, max: usize, char: u8, text: []const u8, pub fn validCount(self: Self) bool { const char = self.char; var n: usize = 0; for (self.text) |c| { if (c == char) n += 1; } return n >= self.min and n <= self.max; } pub fn validPositional(self: Self) bool { var n: usize = 0; const r = self.min - 1; const s = self.max - 1; const text = self.text; const char = self.char; return text.len > math.max(r, s) and text[r] != text[s] and (text[r] == char or text[s] == char); } }; const RecordError = error{ MissingMin, MissingMax, MissingChar, BadCharLen, MissingText, }; fn parseRecord(line: []const u8) !Record { var rec: Record = undefined; var iter = std.mem.tokenize(line, "-: "); if (iter.next()) |minStr| { rec.min = try std.fmt.parseInt(usize, minStr, 10); } else { return RecordError.MissingMin; } if (iter.next()) |maxStr| { rec.max = try std.fmt.parseInt(usize, maxStr, 10); } else { return RecordError.MissingMax; } if (iter.next()) |char| { if (char.len != 1) { return RecordError.BadCharLen; } rec.char = char[0]; } else { return RecordError.MissingChar; } if (iter.next()) |text| { rec.text = text; } else { return RecordError.MissingText; } return rec; } pub fn main() anyerror!void { var buf: [4000]u8 = undefined; const bufp = buf[0..]; var stream = io.bufferedReader(io.getStdIn().reader()); var rd = stream.reader(); // var records = std.ArrayList(Record).init(alloc); // defer numbers.deinit(); var validCount: usize = 0; var validPositional: usize = 0; while (try rd.readUntilDelimiterOrEof(bufp, '\n')) |line| { const rec = try parseRecord(line); if (rec.validCount()) { validCount += 1; } if (rec.validPositional()) { validPositional += 1; } } std.log.notice("Valid by Count = {} Position = {}", .{ validCount, validPositional }); }
day2/src/main.zig
// SPDX-License-Identifier: MIT // This file is part of the Termelot project under the MIT license. const std = @import("std"); const termelot_import = @import("../termelot.zig"); const Termelot = termelot_import.Termelot; const Config = termelot_import.Config; const SupportedFeatures = termelot_import.SupportedFeatures; const Position = termelot_import.Position; const Size = termelot_import.Size; const Rune = termelot_import.Rune; const Style = termelot_import.style.Style; pub const Backend = struct { // Add desired backend fields here; the `Backend` struct's fields // will *never* be accessed, so add/remove as needed. const Self = @This(); /// Initialize backend pub fn init( termelot: *Termelot, allocator: *std.mem.Allocator, config: Config, ) !Backend { @compileError("Unimplemented"); } /// Deinitialize backend pub fn deinit(self: *Self) void { @compileError("Unimplemented"); } /// Retrieve supported features for this backend. pub fn getSupportedFeatures(self: *Self) !SupportedFeatures { @compileError("Unimplemented"); } /// Retrieve raw mode status. pub fn getRawMode(self: *Self) !bool { @compileError("Unimplemented"); } /// Enter/exit raw mode. pub fn setRawMode(self: *Self, enabled: bool) !void { @compileError("Unimplemented"); } /// Retrieve alternate screen status. pub fn getAlternateScreen(self: *Self) !bool { @compileError("Unimplemented"); } /// Enter/exit alternate screen. pub fn setAlternateScreen(self: *Self, enabled: bool) !void { @compileError("Unimplemented"); } /// Start event/signal handling loop, non-blocking immediate return. pub fn start(self: *Self) !void { // This function should call necessary functions for screen size // update, key event callbacks, and mouse event callbacks. @compileError("Unimplemented"); } /// Stop event/signal handling loop. pub fn stop(self: *Self) void { @compileError("Unimplemented"); } /// Set terminal title. pub fn setTitle(self: *Self, runes: []const Rune) !void { @compileError("Unimplemented"); } /// Get screen size. pub fn getScreenSize(self: *Self) !Size { // This function will only be called once on // startup, and then the size should be set // through the event handling loop. @compileError("Unimplemented"); } /// Get cursor position. pub fn getCursorPosition(self: *Self) !Position { @compileError("Unimplemented"); } /// Set cursor position. pub fn setCursorPosition(self: *Self, position: Position) !void { @compileError("Unimplemented"); } /// Get cursor visibility. pub fn getCursorVisibility(self: *Self) !bool { @compileError("Unimplemented"); } /// Set cursor visibility. pub fn setCursorVisibility(self: *Self, visible: bool) !void { @compileError("Unimplemented"); } /// Write styled output to screen at position. Assumed that no newline /// or carriage return runes are provided. pub fn write( self: *Self, position: Position, runes: []Rune, styles: []Style, ) !void { @compileError("Unimplemented"); } };
src/backend/unimplemented.zig
pub const NTDDI_WIN2K = @as(u32, 83886080); pub const NTDDI_WINXP = @as(u32, 83951616); pub const NTDDI_WINXPSP2 = @as(u32, 83952128); pub const NTDDI_WS03SP1 = @as(u32, 84017408); pub const NTDDI_VISTA = @as(u32, 100663296); pub const NTDDI_VISTASP1 = @as(u32, 100663552); pub const NTDDI_WIN7 = @as(u32, 100728832); pub const NTDDI_WIN8 = @as(u32, 100794368); pub const NTDDI_WINBLUE = @as(u32, 100859904); pub const NTDDI_WINTHRESHOLD = @as(u32, 167772160); pub const SYSTEM_CPU_SET_INFORMATION_PARKED = @as(u32, 1); pub const SYSTEM_CPU_SET_INFORMATION_ALLOCATED = @as(u32, 2); pub const SYSTEM_CPU_SET_INFORMATION_ALLOCATED_TO_TARGET_PROCESS = @as(u32, 4); pub const SYSTEM_CPU_SET_INFORMATION_REALTIME = @as(u32, 8); pub const _WIN32_WINNT_NT4 = @as(u32, 1024); pub const _WIN32_WINNT_WIN2K = @as(u32, 1280); pub const _WIN32_WINNT_WINXP = @as(u32, 1281); pub const _WIN32_WINNT_WS03 = @as(u32, 1282); pub const _WIN32_WINNT_WIN6 = @as(u32, 1536); pub const _WIN32_WINNT_VISTA = @as(u32, 1536); pub const _WIN32_WINNT_WS08 = @as(u32, 1536); pub const _WIN32_WINNT_LONGHORN = @as(u32, 1536); pub const _WIN32_WINNT_WIN7 = @as(u32, 1537); pub const _WIN32_WINNT_WIN8 = @as(u32, 1538); pub const _WIN32_WINNT_WINBLUE = @as(u32, 1539); pub const _WIN32_WINNT_WINTHRESHOLD = @as(u32, 2560); pub const _WIN32_WINNT_WIN10 = @as(u32, 2560); pub const _WIN32_IE_IE20 = @as(u32, 512); pub const _WIN32_IE_IE30 = @as(u32, 768); pub const _WIN32_IE_IE302 = @as(u32, 770); pub const _WIN32_IE_IE40 = @as(u32, 1024); pub const _WIN32_IE_IE401 = @as(u32, 1025); pub const _WIN32_IE_IE50 = @as(u32, 1280); pub const _WIN32_IE_IE501 = @as(u32, 1281); pub const _WIN32_IE_IE55 = @as(u32, 1360); pub const _WIN32_IE_IE60 = @as(u32, 1536); pub const _WIN32_IE_IE60SP1 = @as(u32, 1537); pub const _WIN32_IE_IE60SP2 = @as(u32, 1539); pub const _WIN32_IE_IE70 = @as(u32, 1792); pub const _WIN32_IE_IE80 = @as(u32, 2048); pub const _WIN32_IE_IE90 = @as(u32, 2304); pub const _WIN32_IE_IE100 = @as(u32, 2560); pub const _WIN32_IE_IE110 = @as(u32, 2560); pub const _WIN32_IE_NT4 = @as(u32, 512); pub const _WIN32_IE_NT4SP1 = @as(u32, 512); pub const _WIN32_IE_NT4SP2 = @as(u32, 512); pub const _WIN32_IE_NT4SP3 = @as(u32, 770); pub const _WIN32_IE_NT4SP4 = @as(u32, 1025); pub const _WIN32_IE_NT4SP5 = @as(u32, 1025); pub const _WIN32_IE_NT4SP6 = @as(u32, 1280); pub const _WIN32_IE_WIN98 = @as(u32, 1025); pub const _WIN32_IE_WIN98SE = @as(u32, 1280); pub const _WIN32_IE_WINME = @as(u32, 1360); pub const _WIN32_IE_WIN2K = @as(u32, 1281); pub const _WIN32_IE_WIN2KSP1 = @as(u32, 1281); pub const _WIN32_IE_WIN2KSP2 = @as(u32, 1281); pub const _WIN32_IE_WIN2KSP3 = @as(u32, 1281); pub const _WIN32_IE_WIN2KSP4 = @as(u32, 1281); pub const _WIN32_IE_XP = @as(u32, 1536); pub const _WIN32_IE_XPSP1 = @as(u32, 1537); pub const _WIN32_IE_XPSP2 = @as(u32, 1539); pub const _WIN32_IE_WS03 = @as(u32, 1538); pub const _WIN32_IE_WS03SP1 = @as(u32, 1539); pub const _WIN32_IE_WIN6 = @as(u32, 1792); pub const _WIN32_IE_LONGHORN = @as(u32, 1792); pub const _WIN32_IE_WIN7 = @as(u32, 2048); pub const _WIN32_IE_WIN8 = @as(u32, 2560); pub const _WIN32_IE_WINBLUE = @as(u32, 2560); pub const _WIN32_IE_WINTHRESHOLD = @as(u32, 2560); pub const _WIN32_IE_WIN10 = @as(u32, 2560); pub const NTDDI_WIN4 = @as(u32, 67108864); pub const NTDDI_WIN2KSP1 = @as(u32, 83886336); pub const NTDDI_WIN2KSP2 = @as(u32, 83886592); pub const NTDDI_WIN2KSP3 = @as(u32, 83886848); pub const NTDDI_WIN2KSP4 = @as(u32, 83887104); pub const NTDDI_WINXPSP1 = @as(u32, 83951872); pub const NTDDI_WINXPSP3 = @as(u32, 83952384); pub const NTDDI_WINXPSP4 = @as(u32, 83952640); pub const NTDDI_WS03 = @as(u32, 84017152); pub const NTDDI_WS03SP2 = @as(u32, 84017664); pub const NTDDI_WS03SP3 = @as(u32, 84017920); pub const NTDDI_WS03SP4 = @as(u32, 84018176); pub const NTDDI_WIN6 = @as(u32, 100663296); pub const NTDDI_WIN6SP1 = @as(u32, 100663552); pub const NTDDI_WIN6SP2 = @as(u32, 100663808); pub const NTDDI_WIN6SP3 = @as(u32, 100664064); pub const NTDDI_WIN6SP4 = @as(u32, 100664320); pub const NTDDI_VISTASP2 = @as(u32, 100663808); pub const NTDDI_VISTASP3 = @as(u32, 100664064); pub const NTDDI_VISTASP4 = @as(u32, 100664320); pub const NTDDI_LONGHORN = @as(u32, 100663296); pub const NTDDI_WS08 = @as(u32, 100663552); pub const NTDDI_WS08SP2 = @as(u32, 100663808); pub const NTDDI_WS08SP3 = @as(u32, 100664064); pub const NTDDI_WS08SP4 = @as(u32, 100664320); pub const NTDDI_WIN10 = @as(u32, 167772160); pub const NTDDI_WIN10_TH2 = @as(u32, 167772161); pub const NTDDI_WIN10_RS1 = @as(u32, 167772162); pub const NTDDI_WIN10_RS2 = @as(u32, 167772163); pub const NTDDI_WIN10_RS3 = @as(u32, 167772164); pub const NTDDI_WIN10_RS4 = @as(u32, 167772165); pub const NTDDI_WIN10_RS5 = @as(u32, 167772166); pub const NTDDI_WIN10_19H1 = @as(u32, 167772167); pub const NTDDI_WIN10_VB = @as(u32, 167772168); pub const NTDDI_WIN10_MN = @as(u32, 167772169); pub const NTDDI_WIN10_FE = @as(u32, 167772170); pub const NTDDI_WIN10_CO = @as(u32, 167772171); pub const WDK_NTDDI_VERSION = @as(u32, 167772171); pub const OSVERSION_MASK = @as(u32, 4294901760); pub const SPVERSION_MASK = @as(u32, 65280); pub const SUBVERSION_MASK = @as(u32, 255); pub const NTDDI_VERSION = @as(u32, 167772171); pub const SCEX2_ALT_NETBIOS_NAME = @as(u32, 1); //-------------------------------------------------------------------------------- // Section: Types (37) //-------------------------------------------------------------------------------- pub const VER_FLAGS = enum(u32) { MINORVERSION = 1, MAJORVERSION = 2, BUILDNUMBER = 4, PLATFORMID = 8, SERVICEPACKMINOR = 16, SERVICEPACKMAJOR = 32, SUITENAME = 64, PRODUCT_TYPE = 128, _, pub fn initFlags(o: struct { MINORVERSION: u1 = 0, MAJORVERSION: u1 = 0, BUILDNUMBER: u1 = 0, PLATFORMID: u1 = 0, SERVICEPACKMINOR: u1 = 0, SERVICEPACKMAJOR: u1 = 0, SUITENAME: u1 = 0, PRODUCT_TYPE: u1 = 0, }) VER_FLAGS { return @intToEnum(VER_FLAGS, (if (o.MINORVERSION == 1) @enumToInt(VER_FLAGS.MINORVERSION) else 0) | (if (o.MAJORVERSION == 1) @enumToInt(VER_FLAGS.MAJORVERSION) else 0) | (if (o.BUILDNUMBER == 1) @enumToInt(VER_FLAGS.BUILDNUMBER) else 0) | (if (o.PLATFORMID == 1) @enumToInt(VER_FLAGS.PLATFORMID) else 0) | (if (o.SERVICEPACKMINOR == 1) @enumToInt(VER_FLAGS.SERVICEPACKMINOR) else 0) | (if (o.SERVICEPACKMAJOR == 1) @enumToInt(VER_FLAGS.SERVICEPACKMAJOR) else 0) | (if (o.SUITENAME == 1) @enumToInt(VER_FLAGS.SUITENAME) else 0) | (if (o.PRODUCT_TYPE == 1) @enumToInt(VER_FLAGS.PRODUCT_TYPE) else 0) ); } }; pub const VER_MINORVERSION = VER_FLAGS.MINORVERSION; pub const VER_MAJORVERSION = VER_FLAGS.MAJORVERSION; pub const VER_BUILDNUMBER = VER_FLAGS.BUILDNUMBER; pub const VER_PLATFORMID = VER_FLAGS.PLATFORMID; pub const VER_SERVICEPACKMINOR = VER_FLAGS.SERVICEPACKMINOR; pub const VER_SERVICEPACKMAJOR = VER_FLAGS.SERVICEPACKMAJOR; pub const VER_SUITENAME = VER_FLAGS.SUITENAME; pub const VER_PRODUCT_TYPE = VER_FLAGS.PRODUCT_TYPE; pub const FIRMWARE_TABLE_PROVIDER = enum(u32) { ACPI = 1094930505, FIRM = 1179210317, RSMB = 1381190978, }; pub const ACPI = FIRMWARE_TABLE_PROVIDER.ACPI; pub const FIRM = FIRMWARE_TABLE_PROVIDER.FIRM; pub const RSMB = FIRMWARE_TABLE_PROVIDER.RSMB; pub const USER_CET_ENVIRONMENT = enum(u32) { WIN32_PROCESS = 0, SGX2_ENCLAVE = 2, VBS_ENCLAVE = 16, VBS_BASIC_ENCLAVE = 17, }; pub const USER_CET_ENVIRONMENT_WIN32_PROCESS = USER_CET_ENVIRONMENT.WIN32_PROCESS; pub const USER_CET_ENVIRONMENT_SGX2_ENCLAVE = USER_CET_ENVIRONMENT.SGX2_ENCLAVE; pub const USER_CET_ENVIRONMENT_VBS_ENCLAVE = USER_CET_ENVIRONMENT.VBS_ENCLAVE; pub const USER_CET_ENVIRONMENT_VBS_BASIC_ENCLAVE = USER_CET_ENVIRONMENT.VBS_BASIC_ENCLAVE; pub const OS_PRODUCT_TYPE = enum(u32) { BUSINESS = 6, BUSINESS_N = 16, CLUSTER_SERVER = 18, CLUSTER_SERVER_V = 64, CORE = 101, CORE_COUNTRYSPECIFIC = 99, CORE_N = 98, CORE_SINGLELANGUAGE = 100, DATACENTER_EVALUATION_SERVER = 80, DATACENTER_A_SERVER_CORE = 145, STANDARD_A_SERVER_CORE = 146, DATACENTER_SERVER = 8, DATACENTER_SERVER_CORE = 12, DATACENTER_SERVER_CORE_V = 39, DATACENTER_SERVER_V = 37, EDUCATION = 121, EDUCATION_N = 122, ENTERPRISE = 4, ENTERPRISE_E = 70, ENTERPRISE_EVALUATION = 72, ENTERPRISE_N = 27, ENTERPRISE_N_EVALUATION = 84, ENTERPRISE_S = 125, ENTERPRISE_S_EVALUATION = 129, ENTERPRISE_S_N = 126, ENTERPRISE_S_N_EVALUATION = 130, ENTERPRISE_SERVER = 10, ENTERPRISE_SERVER_CORE = 14, ENTERPRISE_SERVER_CORE_V = 41, ENTERPRISE_SERVER_IA64 = 15, ENTERPRISE_SERVER_V = 38, ESSENTIALBUSINESS_SERVER_ADDL = 60, ESSENTIALBUSINESS_SERVER_ADDLSVC = 62, ESSENTIALBUSINESS_SERVER_MGMT = 59, ESSENTIALBUSINESS_SERVER_MGMTSVC = 61, HOME_BASIC = 2, HOME_BASIC_E = 67, HOME_BASIC_N = 5, HOME_PREMIUM = 3, HOME_PREMIUM_E = 68, HOME_PREMIUM_N = 26, HOME_PREMIUM_SERVER = 34, HOME_SERVER = 19, HYPERV = 42, IOTUAP = 123, IOTUAPCOMMERCIAL = 131, MEDIUMBUSINESS_SERVER_MANAGEMENT = 30, MEDIUMBUSINESS_SERVER_MESSAGING = 32, MEDIUMBUSINESS_SERVER_SECURITY = 31, MOBILE_CORE = 104, MOBILE_ENTERPRISE = 133, MULTIPOINT_PREMIUM_SERVER = 77, MULTIPOINT_STANDARD_SERVER = 76, PRO_WORKSTATION = 161, PRO_WORKSTATION_N = 162, PROFESSIONAL = 48, PROFESSIONAL_E = 69, PROFESSIONAL_N = 49, PROFESSIONAL_WMC = 103, SB_SOLUTION_SERVER = 50, SB_SOLUTION_SERVER_EM = 54, SERVER_FOR_SB_SOLUTIONS = 51, SERVER_FOR_SB_SOLUTIONS_EM = 55, SERVER_FOR_SMALLBUSINESS = 24, SERVER_FOR_SMALLBUSINESS_V = 35, SERVER_FOUNDATION = 33, SMALLBUSINESS_SERVER = 9, SMALLBUSINESS_SERVER_PREMIUM = 25, SMALLBUSINESS_SERVER_PREMIUM_CORE = 63, SOLUTION_EMBEDDEDSERVER = 56, STANDARD_EVALUATION_SERVER = 79, STANDARD_SERVER = 7, STANDARD_SERVER_CORE_ = 13, STANDARD_SERVER_CORE_V = 40, STANDARD_SERVER_V = 36, STANDARD_SERVER_SOLUTIONS = 52, STANDARD_SERVER_SOLUTIONS_CORE = 53, STARTER = 11, STARTER_E = 66, STARTER_N = 47, STORAGE_ENTERPRISE_SERVER = 23, STORAGE_ENTERPRISE_SERVER_CORE = 46, STORAGE_EXPRESS_SERVER = 20, STORAGE_EXPRESS_SERVER_CORE = 43, STORAGE_STANDARD_EVALUATION_SERVER = 96, STORAGE_STANDARD_SERVER = 21, STORAGE_STANDARD_SERVER_CORE = 44, STORAGE_WORKGROUP_EVALUATION_SERVER = 95, STORAGE_WORKGROUP_SERVER = 22, STORAGE_WORKGROUP_SERVER_CORE = 45, ULTIMATE = 1, ULTIMATE_E = 71, ULTIMATE_N = 28, UNDEFINED = 0, WEB_SERVER = 17, WEB_SERVER_CORE = 29, }; pub const PRODUCT_BUSINESS = OS_PRODUCT_TYPE.BUSINESS; pub const PRODUCT_BUSINESS_N = OS_PRODUCT_TYPE.BUSINESS_N; pub const PRODUCT_CLUSTER_SERVER = OS_PRODUCT_TYPE.CLUSTER_SERVER; pub const PRODUCT_CLUSTER_SERVER_V = OS_PRODUCT_TYPE.CLUSTER_SERVER_V; pub const PRODUCT_CORE = OS_PRODUCT_TYPE.CORE; pub const PRODUCT_CORE_COUNTRYSPECIFIC = OS_PRODUCT_TYPE.CORE_COUNTRYSPECIFIC; pub const PRODUCT_CORE_N = OS_PRODUCT_TYPE.CORE_N; pub const PRODUCT_CORE_SINGLELANGUAGE = OS_PRODUCT_TYPE.CORE_SINGLELANGUAGE; pub const PRODUCT_DATACENTER_EVALUATION_SERVER = OS_PRODUCT_TYPE.DATACENTER_EVALUATION_SERVER; pub const PRODUCT_DATACENTER_A_SERVER_CORE = OS_PRODUCT_TYPE.DATACENTER_A_SERVER_CORE; pub const PRODUCT_STANDARD_A_SERVER_CORE = OS_PRODUCT_TYPE.STANDARD_A_SERVER_CORE; pub const PRODUCT_DATACENTER_SERVER = OS_PRODUCT_TYPE.DATACENTER_SERVER; pub const PRODUCT_DATACENTER_SERVER_CORE = OS_PRODUCT_TYPE.DATACENTER_SERVER_CORE; pub const PRODUCT_DATACENTER_SERVER_CORE_V = OS_PRODUCT_TYPE.DATACENTER_SERVER_CORE_V; pub const PRODUCT_DATACENTER_SERVER_V = OS_PRODUCT_TYPE.DATACENTER_SERVER_V; pub const PRODUCT_EDUCATION = OS_PRODUCT_TYPE.EDUCATION; pub const PRODUCT_EDUCATION_N = OS_PRODUCT_TYPE.EDUCATION_N; pub const PRODUCT_ENTERPRISE = OS_PRODUCT_TYPE.ENTERPRISE; pub const PRODUCT_ENTERPRISE_E = OS_PRODUCT_TYPE.ENTERPRISE_E; pub const PRODUCT_ENTERPRISE_EVALUATION = OS_PRODUCT_TYPE.ENTERPRISE_EVALUATION; pub const PRODUCT_ENTERPRISE_N = OS_PRODUCT_TYPE.ENTERPRISE_N; pub const PRODUCT_ENTERPRISE_N_EVALUATION = OS_PRODUCT_TYPE.ENTERPRISE_N_EVALUATION; pub const PRODUCT_ENTERPRISE_S = OS_PRODUCT_TYPE.ENTERPRISE_S; pub const PRODUCT_ENTERPRISE_S_EVALUATION = OS_PRODUCT_TYPE.ENTERPRISE_S_EVALUATION; pub const PRODUCT_ENTERPRISE_S_N = OS_PRODUCT_TYPE.ENTERPRISE_S_N; pub const PRODUCT_ENTERPRISE_S_N_EVALUATION = OS_PRODUCT_TYPE.ENTERPRISE_S_N_EVALUATION; pub const PRODUCT_ENTERPRISE_SERVER = OS_PRODUCT_TYPE.ENTERPRISE_SERVER; pub const PRODUCT_ENTERPRISE_SERVER_CORE = OS_PRODUCT_TYPE.ENTERPRISE_SERVER_CORE; pub const PRODUCT_ENTERPRISE_SERVER_CORE_V = OS_PRODUCT_TYPE.ENTERPRISE_SERVER_CORE_V; pub const PRODUCT_ENTERPRISE_SERVER_IA64 = OS_PRODUCT_TYPE.ENTERPRISE_SERVER_IA64; pub const PRODUCT_ENTERPRISE_SERVER_V = OS_PRODUCT_TYPE.ENTERPRISE_SERVER_V; pub const PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL = OS_PRODUCT_TYPE.ESSENTIALBUSINESS_SERVER_ADDL; pub const PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC = OS_PRODUCT_TYPE.ESSENTIALBUSINESS_SERVER_ADDLSVC; pub const PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT = OS_PRODUCT_TYPE.ESSENTIALBUSINESS_SERVER_MGMT; pub const PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC = OS_PRODUCT_TYPE.ESSENTIALBUSINESS_SERVER_MGMTSVC; pub const PRODUCT_HOME_BASIC = OS_PRODUCT_TYPE.HOME_BASIC; pub const PRODUCT_HOME_BASIC_E = OS_PRODUCT_TYPE.HOME_BASIC_E; pub const PRODUCT_HOME_BASIC_N = OS_PRODUCT_TYPE.HOME_BASIC_N; pub const PRODUCT_HOME_PREMIUM = OS_PRODUCT_TYPE.HOME_PREMIUM; pub const PRODUCT_HOME_PREMIUM_E = OS_PRODUCT_TYPE.HOME_PREMIUM_E; pub const PRODUCT_HOME_PREMIUM_N = OS_PRODUCT_TYPE.HOME_PREMIUM_N; pub const PRODUCT_HOME_PREMIUM_SERVER = OS_PRODUCT_TYPE.HOME_PREMIUM_SERVER; pub const PRODUCT_HOME_SERVER = OS_PRODUCT_TYPE.HOME_SERVER; pub const PRODUCT_HYPERV = OS_PRODUCT_TYPE.HYPERV; pub const PRODUCT_IOTUAP = OS_PRODUCT_TYPE.IOTUAP; pub const PRODUCT_IOTUAPCOMMERCIAL = OS_PRODUCT_TYPE.IOTUAPCOMMERCIAL; pub const PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT = OS_PRODUCT_TYPE.MEDIUMBUSINESS_SERVER_MANAGEMENT; pub const PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING = OS_PRODUCT_TYPE.MEDIUMBUSINESS_SERVER_MESSAGING; pub const PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY = OS_PRODUCT_TYPE.MEDIUMBUSINESS_SERVER_SECURITY; pub const PRODUCT_MOBILE_CORE = OS_PRODUCT_TYPE.MOBILE_CORE; pub const PRODUCT_MOBILE_ENTERPRISE = OS_PRODUCT_TYPE.MOBILE_ENTERPRISE; pub const PRODUCT_MULTIPOINT_PREMIUM_SERVER = OS_PRODUCT_TYPE.MULTIPOINT_PREMIUM_SERVER; pub const PRODUCT_MULTIPOINT_STANDARD_SERVER = OS_PRODUCT_TYPE.MULTIPOINT_STANDARD_SERVER; pub const PRODUCT_PRO_WORKSTATION = OS_PRODUCT_TYPE.PRO_WORKSTATION; pub const PRODUCT_PRO_WORKSTATION_N = OS_PRODUCT_TYPE.PRO_WORKSTATION_N; pub const PRODUCT_PROFESSIONAL = OS_PRODUCT_TYPE.PROFESSIONAL; pub const PRODUCT_PROFESSIONAL_E = OS_PRODUCT_TYPE.PROFESSIONAL_E; pub const PRODUCT_PROFESSIONAL_N = OS_PRODUCT_TYPE.PROFESSIONAL_N; pub const PRODUCT_PROFESSIONAL_WMC = OS_PRODUCT_TYPE.PROFESSIONAL_WMC; pub const PRODUCT_SB_SOLUTION_SERVER = OS_PRODUCT_TYPE.SB_SOLUTION_SERVER; pub const PRODUCT_SB_SOLUTION_SERVER_EM = OS_PRODUCT_TYPE.SB_SOLUTION_SERVER_EM; pub const PRODUCT_SERVER_FOR_SB_SOLUTIONS = OS_PRODUCT_TYPE.SERVER_FOR_SB_SOLUTIONS; pub const PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM = OS_PRODUCT_TYPE.SERVER_FOR_SB_SOLUTIONS_EM; pub const PRODUCT_SERVER_FOR_SMALLBUSINESS = OS_PRODUCT_TYPE.SERVER_FOR_SMALLBUSINESS; pub const PRODUCT_SERVER_FOR_SMALLBUSINESS_V = OS_PRODUCT_TYPE.SERVER_FOR_SMALLBUSINESS_V; pub const PRODUCT_SERVER_FOUNDATION = OS_PRODUCT_TYPE.SERVER_FOUNDATION; pub const PRODUCT_SMALLBUSINESS_SERVER = OS_PRODUCT_TYPE.SMALLBUSINESS_SERVER; pub const PRODUCT_SMALLBUSINESS_SERVER_PREMIUM = OS_PRODUCT_TYPE.SMALLBUSINESS_SERVER_PREMIUM; pub const PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE = OS_PRODUCT_TYPE.SMALLBUSINESS_SERVER_PREMIUM_CORE; pub const PRODUCT_SOLUTION_EMBEDDEDSERVER = OS_PRODUCT_TYPE.SOLUTION_EMBEDDEDSERVER; pub const PRODUCT_STANDARD_EVALUATION_SERVER = OS_PRODUCT_TYPE.STANDARD_EVALUATION_SERVER; pub const PRODUCT_STANDARD_SERVER = OS_PRODUCT_TYPE.STANDARD_SERVER; pub const PRODUCT_STANDARD_SERVER_CORE_ = OS_PRODUCT_TYPE.STANDARD_SERVER_CORE_; pub const PRODUCT_STANDARD_SERVER_CORE_V = OS_PRODUCT_TYPE.STANDARD_SERVER_CORE_V; pub const PRODUCT_STANDARD_SERVER_V = OS_PRODUCT_TYPE.STANDARD_SERVER_V; pub const PRODUCT_STANDARD_SERVER_SOLUTIONS = OS_PRODUCT_TYPE.STANDARD_SERVER_SOLUTIONS; pub const PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE = OS_PRODUCT_TYPE.STANDARD_SERVER_SOLUTIONS_CORE; pub const PRODUCT_STARTER = OS_PRODUCT_TYPE.STARTER; pub const PRODUCT_STARTER_E = OS_PRODUCT_TYPE.STARTER_E; pub const PRODUCT_STARTER_N = OS_PRODUCT_TYPE.STARTER_N; pub const PRODUCT_STORAGE_ENTERPRISE_SERVER = OS_PRODUCT_TYPE.STORAGE_ENTERPRISE_SERVER; pub const PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE = OS_PRODUCT_TYPE.STORAGE_ENTERPRISE_SERVER_CORE; pub const PRODUCT_STORAGE_EXPRESS_SERVER = OS_PRODUCT_TYPE.STORAGE_EXPRESS_SERVER; pub const PRODUCT_STORAGE_EXPRESS_SERVER_CORE = OS_PRODUCT_TYPE.STORAGE_EXPRESS_SERVER_CORE; pub const PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER = OS_PRODUCT_TYPE.STORAGE_STANDARD_EVALUATION_SERVER; pub const PRODUCT_STORAGE_STANDARD_SERVER = OS_PRODUCT_TYPE.STORAGE_STANDARD_SERVER; pub const PRODUCT_STORAGE_STANDARD_SERVER_CORE = OS_PRODUCT_TYPE.STORAGE_STANDARD_SERVER_CORE; pub const PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER = OS_PRODUCT_TYPE.STORAGE_WORKGROUP_EVALUATION_SERVER; pub const PRODUCT_STORAGE_WORKGROUP_SERVER = OS_PRODUCT_TYPE.STORAGE_WORKGROUP_SERVER; pub const PRODUCT_STORAGE_WORKGROUP_SERVER_CORE = OS_PRODUCT_TYPE.STORAGE_WORKGROUP_SERVER_CORE; pub const PRODUCT_ULTIMATE = OS_PRODUCT_TYPE.ULTIMATE; pub const PRODUCT_ULTIMATE_E = OS_PRODUCT_TYPE.ULTIMATE_E; pub const PRODUCT_ULTIMATE_N = OS_PRODUCT_TYPE.ULTIMATE_N; pub const PRODUCT_UNDEFINED = OS_PRODUCT_TYPE.UNDEFINED; pub const PRODUCT_WEB_SERVER = OS_PRODUCT_TYPE.WEB_SERVER; pub const PRODUCT_WEB_SERVER_CORE = OS_PRODUCT_TYPE.WEB_SERVER_CORE; pub const DEVICEFAMILYINFOENUM = enum(u32) { UAP = 0, WINDOWS_8X = 1, WINDOWS_PHONE_8X = 2, DESKTOP = 3, MOBILE = 4, XBOX = 5, TEAM = 6, IOT = 7, IOT_HEADLESS = 8, SERVER = 9, HOLOGRAPHIC = 10, XBOXSRA = 11, XBOXERA = 12, SERVER_NANO = 13, @"8828080" = 14, @"7067329" = 15, WINDOWS_CORE = 16, WINDOWS_CORE_HEADLESS = 17, // MAX = 17, this enum value conflicts with WINDOWS_CORE_HEADLESS }; pub const DEVICEFAMILYINFOENUM_UAP = DEVICEFAMILYINFOENUM.UAP; pub const DEVICEFAMILYINFOENUM_WINDOWS_8X = DEVICEFAMILYINFOENUM.WINDOWS_8X; pub const DEVICEFAMILYINFOENUM_WINDOWS_PHONE_8X = DEVICEFAMILYINFOENUM.WINDOWS_PHONE_8X; pub const DEVICEFAMILYINFOENUM_DESKTOP = DEVICEFAMILYINFOENUM.DESKTOP; pub const DEVICEFAMILYINFOENUM_MOBILE = DEVICEFAMILYINFOENUM.MOBILE; pub const DEVICEFAMILYINFOENUM_XBOX = DEVICEFAMILYINFOENUM.XBOX; pub const DEVICEFAMILYINFOENUM_TEAM = DEVICEFAMILYINFOENUM.TEAM; pub const DEVICEFAMILYINFOENUM_IOT = DEVICEFAMILYINFOENUM.IOT; pub const DEVICEFAMILYINFOENUM_IOT_HEADLESS = DEVICEFAMILYINFOENUM.IOT_HEADLESS; pub const DEVICEFAMILYINFOENUM_SERVER = DEVICEFAMILYINFOENUM.SERVER; pub const DEVICEFAMILYINFOENUM_HOLOGRAPHIC = DEVICEFAMILYINFOENUM.HOLOGRAPHIC; pub const DEVICEFAMILYINFOENUM_XBOXSRA = DEVICEFAMILYINFOENUM.XBOXSRA; pub const DEVICEFAMILYINFOENUM_XBOXERA = DEVICEFAMILYINFOENUM.XBOXERA; pub const DEVICEFAMILYINFOENUM_SERVER_NANO = DEVICEFAMILYINFOENUM.SERVER_NANO; pub const DEVICEFAMILYINFOENUM_8828080 = DEVICEFAMILYINFOENUM.@"8828080"; pub const DEVICEFAMILYINFOENUM_7067329 = DEVICEFAMILYINFOENUM.@"7067329"; pub const DEVICEFAMILYINFOENUM_WINDOWS_CORE = DEVICEFAMILYINFOENUM.WINDOWS_CORE; pub const DEVICEFAMILYINFOENUM_WINDOWS_CORE_HEADLESS = DEVICEFAMILYINFOENUM.WINDOWS_CORE_HEADLESS; pub const DEVICEFAMILYINFOENUM_MAX = DEVICEFAMILYINFOENUM.WINDOWS_CORE_HEADLESS; pub const DEVICEFAMILYDEVICEFORM = enum(u32) { UNKNOWN = 0, PHONE = 1, TABLET = 2, DESKTOP = 3, NOTEBOOK = 4, CONVERTIBLE = 5, DETACHABLE = 6, ALLINONE = 7, STICKPC = 8, PUCK = 9, LARGESCREEN = 10, HMD = 11, INDUSTRY_HANDHELD = 12, INDUSTRY_TABLET = 13, BANKING = 14, BUILDING_AUTOMATION = 15, DIGITAL_SIGNAGE = 16, GAMING = 17, HOME_AUTOMATION = 18, INDUSTRIAL_AUTOMATION = 19, KIOSK = 20, MAKER_BOARD = 21, MEDICAL = 22, NETWORKING = 23, POINT_OF_SERVICE = 24, PRINTING = 25, THIN_CLIENT = 26, TOY = 27, VENDING = 28, INDUSTRY_OTHER = 29, XBOX_ONE = 30, XBOX_ONE_S = 31, XBOX_ONE_X = 32, XBOX_ONE_X_DEVKIT = 33, XBOX_SERIES_X = 34, XBOX_SERIES_X_DEVKIT = 35, XBOX_RESERVED_00 = 36, XBOX_RESERVED_01 = 37, XBOX_RESERVED_02 = 38, XBOX_RESERVED_03 = 39, XBOX_RESERVED_04 = 40, XBOX_RESERVED_05 = 41, XBOX_RESERVED_06 = 42, XBOX_RESERVED_07 = 43, XBOX_RESERVED_08 = 44, XBOX_RESERVED_09 = 45, // MAX = 45, this enum value conflicts with XBOX_RESERVED_09 }; pub const DEVICEFAMILYDEVICEFORM_UNKNOWN = DEVICEFAMILYDEVICEFORM.UNKNOWN; pub const DEVICEFAMILYDEVICEFORM_PHONE = DEVICEFAMILYDEVICEFORM.PHONE; pub const DEVICEFAMILYDEVICEFORM_TABLET = DEVICEFAMILYDEVICEFORM.TABLET; pub const DEVICEFAMILYDEVICEFORM_DESKTOP = DEVICEFAMILYDEVICEFORM.DESKTOP; pub const DEVICEFAMILYDEVICEFORM_NOTEBOOK = DEVICEFAMILYDEVICEFORM.NOTEBOOK; pub const DEVICEFAMILYDEVICEFORM_CONVERTIBLE = DEVICEFAMILYDEVICEFORM.CONVERTIBLE; pub const DEVICEFAMILYDEVICEFORM_DETACHABLE = DEVICEFAMILYDEVICEFORM.DETACHABLE; pub const DEVICEFAMILYDEVICEFORM_ALLINONE = DEVICEFAMILYDEVICEFORM.ALLINONE; pub const DEVICEFAMILYDEVICEFORM_STICKPC = DEVICEFAMILYDEVICEFORM.STICKPC; pub const DEVICEFAMILYDEVICEFORM_PUCK = DEVICEFAMILYDEVICEFORM.PUCK; pub const DEVICEFAMILYDEVICEFORM_LARGESCREEN = DEVICEFAMILYDEVICEFORM.LARGESCREEN; pub const DEVICEFAMILYDEVICEFORM_HMD = DEVICEFAMILYDEVICEFORM.HMD; pub const DEVICEFAMILYDEVICEFORM_INDUSTRY_HANDHELD = DEVICEFAMILYDEVICEFORM.INDUSTRY_HANDHELD; pub const DEVICEFAMILYDEVICEFORM_INDUSTRY_TABLET = DEVICEFAMILYDEVICEFORM.INDUSTRY_TABLET; pub const DEVICEFAMILYDEVICEFORM_BANKING = DEVICEFAMILYDEVICEFORM.BANKING; pub const DEVICEFAMILYDEVICEFORM_BUILDING_AUTOMATION = DEVICEFAMILYDEVICEFORM.BUILDING_AUTOMATION; pub const DEVICEFAMILYDEVICEFORM_DIGITAL_SIGNAGE = DEVICEFAMILYDEVICEFORM.DIGITAL_SIGNAGE; pub const DEVICEFAMILYDEVICEFORM_GAMING = DEVICEFAMILYDEVICEFORM.GAMING; pub const DEVICEFAMILYDEVICEFORM_HOME_AUTOMATION = DEVICEFAMILYDEVICEFORM.HOME_AUTOMATION; pub const DEVICEFAMILYDEVICEFORM_INDUSTRIAL_AUTOMATION = DEVICEFAMILYDEVICEFORM.INDUSTRIAL_AUTOMATION; pub const DEVICEFAMILYDEVICEFORM_KIOSK = DEVICEFAMILYDEVICEFORM.KIOSK; pub const DEVICEFAMILYDEVICEFORM_MAKER_BOARD = DEVICEFAMILYDEVICEFORM.MAKER_BOARD; pub const DEVICEFAMILYDEVICEFORM_MEDICAL = DEVICEFAMILYDEVICEFORM.MEDICAL; pub const DEVICEFAMILYDEVICEFORM_NETWORKING = DEVICEFAMILYDEVICEFORM.NETWORKING; pub const DEVICEFAMILYDEVICEFORM_POINT_OF_SERVICE = DEVICEFAMILYDEVICEFORM.POINT_OF_SERVICE; pub const DEVICEFAMILYDEVICEFORM_PRINTING = DEVICEFAMILYDEVICEFORM.PRINTING; pub const DEVICEFAMILYDEVICEFORM_THIN_CLIENT = DEVICEFAMILYDEVICEFORM.THIN_CLIENT; pub const DEVICEFAMILYDEVICEFORM_TOY = DEVICEFAMILYDEVICEFORM.TOY; pub const DEVICEFAMILYDEVICEFORM_VENDING = DEVICEFAMILYDEVICEFORM.VENDING; pub const DEVICEFAMILYDEVICEFORM_INDUSTRY_OTHER = DEVICEFAMILYDEVICEFORM.INDUSTRY_OTHER; pub const DEVICEFAMILYDEVICEFORM_XBOX_ONE = DEVICEFAMILYDEVICEFORM.XBOX_ONE; pub const DEVICEFAMILYDEVICEFORM_XBOX_ONE_S = DEVICEFAMILYDEVICEFORM.XBOX_ONE_S; pub const DEVICEFAMILYDEVICEFORM_XBOX_ONE_X = DEVICEFAMILYDEVICEFORM.XBOX_ONE_X; pub const DEVICEFAMILYDEVICEFORM_XBOX_ONE_X_DEVKIT = DEVICEFAMILYDEVICEFORM.XBOX_ONE_X_DEVKIT; pub const DEVICEFAMILYDEVICEFORM_XBOX_SERIES_X = DEVICEFAMILYDEVICEFORM.XBOX_SERIES_X; pub const DEVICEFAMILYDEVICEFORM_XBOX_SERIES_X_DEVKIT = DEVICEFAMILYDEVICEFORM.XBOX_SERIES_X_DEVKIT; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_00 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_00; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_01 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_01; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_02 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_02; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_03 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_03; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_04 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_04; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_05 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_05; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_06 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_06; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_07 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_07; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_08 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_08; pub const DEVICEFAMILYDEVICEFORM_XBOX_RESERVED_09 = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_09; pub const DEVICEFAMILYDEVICEFORM_MAX = DEVICEFAMILYDEVICEFORM.XBOX_RESERVED_09; pub const FIRMWARE_TABLE_ID = u32; pub const GROUP_AFFINITY = extern struct { Mask: usize, Group: u16, Reserved: [3]u16, }; pub const SYSTEM_INFO = extern struct { Anonymous: extern union { dwOemId: u32, Anonymous: extern struct { wProcessorArchitecture: PROCESSOR_ARCHITECTURE, wReserved: u16, }, }, dwPageSize: u32, lpMinimumApplicationAddress: ?*anyopaque, lpMaximumApplicationAddress: ?*anyopaque, dwActiveProcessorMask: usize, dwNumberOfProcessors: u32, dwProcessorType: u32, dwAllocationGranularity: u32, wProcessorLevel: u16, wProcessorRevision: u16, }; pub const MEMORYSTATUSEX = extern struct { dwLength: u32, dwMemoryLoad: u32, ullTotalPhys: u64, ullAvailPhys: u64, ullTotalPageFile: u64, ullAvailPageFile: u64, ullTotalVirtual: u64, ullAvailVirtual: u64, ullAvailExtendedVirtual: u64, }; pub const COMPUTER_NAME_FORMAT = enum(i32) { NetBIOS = 0, DnsHostname = 1, DnsDomain = 2, DnsFullyQualified = 3, PhysicalNetBIOS = 4, PhysicalDnsHostname = 5, PhysicalDnsDomain = 6, PhysicalDnsFullyQualified = 7, Max = 8, }; pub const ComputerNameNetBIOS = COMPUTER_NAME_FORMAT.NetBIOS; pub const ComputerNameDnsHostname = COMPUTER_NAME_FORMAT.DnsHostname; pub const ComputerNameDnsDomain = COMPUTER_NAME_FORMAT.DnsDomain; pub const ComputerNameDnsFullyQualified = COMPUTER_NAME_FORMAT.DnsFullyQualified; pub const ComputerNamePhysicalNetBIOS = COMPUTER_NAME_FORMAT.PhysicalNetBIOS; pub const ComputerNamePhysicalDnsHostname = COMPUTER_NAME_FORMAT.PhysicalDnsHostname; pub const ComputerNamePhysicalDnsDomain = COMPUTER_NAME_FORMAT.PhysicalDnsDomain; pub const ComputerNamePhysicalDnsFullyQualified = COMPUTER_NAME_FORMAT.PhysicalDnsFullyQualified; pub const ComputerNameMax = COMPUTER_NAME_FORMAT.Max; pub const FIRMWARE_TYPE = enum(i32) { Unknown = 0, Bios = 1, Uefi = 2, Max = 3, }; pub const FirmwareTypeUnknown = FIRMWARE_TYPE.Unknown; pub const FirmwareTypeBios = FIRMWARE_TYPE.Bios; pub const FirmwareTypeUefi = FIRMWARE_TYPE.Uefi; pub const FirmwareTypeMax = FIRMWARE_TYPE.Max; pub const LOGICAL_PROCESSOR_RELATIONSHIP = enum(i32) { ProcessorCore = 0, NumaNode = 1, Cache = 2, ProcessorPackage = 3, Group = 4, ProcessorDie = 5, NumaNodeEx = 6, ProcessorModule = 7, All = 65535, }; pub const RelationProcessorCore = LOGICAL_PROCESSOR_RELATIONSHIP.ProcessorCore; pub const RelationNumaNode = LOGICAL_PROCESSOR_RELATIONSHIP.NumaNode; pub const RelationCache = LOGICAL_PROCESSOR_RELATIONSHIP.Cache; pub const RelationProcessorPackage = LOGICAL_PROCESSOR_RELATIONSHIP.ProcessorPackage; pub const RelationGroup = LOGICAL_PROCESSOR_RELATIONSHIP.Group; pub const RelationProcessorDie = LOGICAL_PROCESSOR_RELATIONSHIP.ProcessorDie; pub const RelationNumaNodeEx = LOGICAL_PROCESSOR_RELATIONSHIP.NumaNodeEx; pub const RelationProcessorModule = LOGICAL_PROCESSOR_RELATIONSHIP.ProcessorModule; pub const RelationAll = LOGICAL_PROCESSOR_RELATIONSHIP.All; pub const PROCESSOR_CACHE_TYPE = enum(i32) { Unified = 0, Instruction = 1, Data = 2, Trace = 3, }; pub const CacheUnified = PROCESSOR_CACHE_TYPE.Unified; pub const CacheInstruction = PROCESSOR_CACHE_TYPE.Instruction; pub const CacheData = PROCESSOR_CACHE_TYPE.Data; pub const CacheTrace = PROCESSOR_CACHE_TYPE.Trace; pub const CACHE_DESCRIPTOR = extern struct { Level: u8, Associativity: u8, LineSize: u16, Size: u32, Type: PROCESSOR_CACHE_TYPE, }; pub const SYSTEM_LOGICAL_PROCESSOR_INFORMATION = extern struct { ProcessorMask: usize, Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, Anonymous: extern union { ProcessorCore: extern struct { Flags: u8, }, NumaNode: extern struct { NodeNumber: u32, }, Cache: CACHE_DESCRIPTOR, Reserved: [2]u64, }, }; pub const PROCESSOR_RELATIONSHIP = extern struct { Flags: u8, EfficiencyClass: u8, Reserved: [20]u8, GroupCount: u16, GroupMask: [1]GROUP_AFFINITY, }; pub const NUMA_NODE_RELATIONSHIP = extern struct { NodeNumber: u32, Reserved: [18]u8, GroupCount: u16, Anonymous: extern union { GroupMask: GROUP_AFFINITY, GroupMasks: [1]GROUP_AFFINITY, }, }; pub const CACHE_RELATIONSHIP = extern struct { Level: u8, Associativity: u8, LineSize: u16, CacheSize: u32, Type: PROCESSOR_CACHE_TYPE, Reserved: [18]u8, GroupCount: u16, Anonymous: extern union { GroupMask: GROUP_AFFINITY, GroupMasks: [1]GROUP_AFFINITY, }, }; pub const PROCESSOR_GROUP_INFO = extern struct { MaximumProcessorCount: u8, ActiveProcessorCount: u8, Reserved: [38]u8, ActiveProcessorMask: usize, }; pub const GROUP_RELATIONSHIP = extern struct { MaximumGroupCount: u16, ActiveGroupCount: u16, Reserved: [20]u8, GroupInfo: [1]PROCESSOR_GROUP_INFO, }; pub const SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX = extern struct { Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, Size: u32, Anonymous: extern union { Processor: PROCESSOR_RELATIONSHIP, NumaNode: NUMA_NODE_RELATIONSHIP, Cache: CACHE_RELATIONSHIP, Group: GROUP_RELATIONSHIP, }, }; pub const CPU_SET_INFORMATION_TYPE = enum(i32) { n = 0, }; pub const CpuSetInformation = CPU_SET_INFORMATION_TYPE.n; pub const SYSTEM_CPU_SET_INFORMATION = extern struct { Size: u32, Type: CPU_SET_INFORMATION_TYPE, Anonymous: extern union { CpuSet: extern struct { Id: u32, Group: u16, LogicalProcessorIndex: u8, CoreIndex: u8, LastLevelCacheIndex: u8, NumaNodeIndex: u8, EfficiencyClass: u8, Anonymous1: extern union { AllFlags: u8, Anonymous: extern struct { _bitfield: u8, }, }, Anonymous2: extern union { Reserved: u32, SchedulingClass: u8, }, AllocationTag: u64, }, }, }; pub const SYSTEM_POOL_ZEROING_INFORMATION = extern struct { PoolZeroingSupportPresent: BOOLEAN, }; pub const SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION = extern struct { CycleTime: u64, }; pub const SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION = extern struct { _bitfield: u32, }; pub const OSVERSIONINFOA = extern struct { dwOSVersionInfoSize: u32, dwMajorVersion: u32, dwMinorVersion: u32, dwBuildNumber: u32, dwPlatformId: u32, szCSDVersion: [128]CHAR, }; pub const OSVERSIONINFOW = extern struct { dwOSVersionInfoSize: u32, dwMajorVersion: u32, dwMinorVersion: u32, dwBuildNumber: u32, dwPlatformId: u32, szCSDVersion: [128]u16, }; pub const OSVERSIONINFOEXA = extern struct { dwOSVersionInfoSize: u32, dwMajorVersion: u32, dwMinorVersion: u32, dwBuildNumber: u32, dwPlatformId: u32, szCSDVersion: [128]CHAR, wServicePackMajor: u16, wServicePackMinor: u16, wSuiteMask: u16, wProductType: u8, wReserved: u8, }; pub const OSVERSIONINFOEXW = extern struct { dwOSVersionInfoSize: u32, dwMajorVersion: u32, dwMinorVersion: u32, dwBuildNumber: u32, dwPlatformId: u32, szCSDVersion: [128]u16, wServicePackMajor: u16, wServicePackMinor: u16, wSuiteMask: u16, wProductType: u8, wReserved: u8, }; pub const OS_DEPLOYEMENT_STATE_VALUES = enum(i32) { STANDARD = 1, COMPACT = 2, }; pub const OS_DEPLOYMENT_STANDARD = OS_DEPLOYEMENT_STATE_VALUES.STANDARD; pub const OS_DEPLOYMENT_COMPACT = OS_DEPLOYEMENT_STATE_VALUES.COMPACT; pub const RTL_SYSTEM_GLOBAL_DATA_ID = enum(i32) { Unknown = 0, RngSeedVersion = 1, InterruptTime = 2, TimeZoneBias = 3, ImageNumberLow = 4, ImageNumberHigh = 5, TimeZoneId = 6, NtMajorVersion = 7, NtMinorVersion = 8, SystemExpirationDate = 9, KdDebuggerEnabled = 10, CyclesPerYield = 11, SafeBootMode = 12, LastSystemRITEventTickCount = 13, }; pub const GlobalDataIdUnknown = RTL_SYSTEM_GLOBAL_DATA_ID.Unknown; pub const GlobalDataIdRngSeedVersion = RTL_SYSTEM_GLOBAL_DATA_ID.RngSeedVersion; pub const GlobalDataIdInterruptTime = RTL_SYSTEM_GLOBAL_DATA_ID.InterruptTime; pub const GlobalDataIdTimeZoneBias = RTL_SYSTEM_GLOBAL_DATA_ID.TimeZoneBias; pub const GlobalDataIdImageNumberLow = RTL_SYSTEM_GLOBAL_DATA_ID.ImageNumberLow; pub const GlobalDataIdImageNumberHigh = RTL_SYSTEM_GLOBAL_DATA_ID.ImageNumberHigh; pub const GlobalDataIdTimeZoneId = RTL_SYSTEM_GLOBAL_DATA_ID.TimeZoneId; pub const GlobalDataIdNtMajorVersion = RTL_SYSTEM_GLOBAL_DATA_ID.NtMajorVersion; pub const GlobalDataIdNtMinorVersion = RTL_SYSTEM_GLOBAL_DATA_ID.NtMinorVersion; pub const GlobalDataIdSystemExpirationDate = RTL_SYSTEM_GLOBAL_DATA_ID.SystemExpirationDate; pub const GlobalDataIdKdDebuggerEnabled = RTL_SYSTEM_GLOBAL_DATA_ID.KdDebuggerEnabled; pub const GlobalDataIdCyclesPerYield = RTL_SYSTEM_GLOBAL_DATA_ID.CyclesPerYield; pub const GlobalDataIdSafeBootMode = RTL_SYSTEM_GLOBAL_DATA_ID.SafeBootMode; pub const GlobalDataIdLastSystemRITEventTickCount = RTL_SYSTEM_GLOBAL_DATA_ID.LastSystemRITEventTickCount; pub const MEMORYSTATUS = extern struct { dwLength: u32, dwMemoryLoad: u32, dwTotalPhys: usize, dwAvailPhys: usize, dwTotalPageFile: usize, dwAvailPageFile: usize, dwTotalVirtual: usize, dwAvailVirtual: usize, }; pub const DEP_SYSTEM_POLICY_TYPE = enum(i32) { PolicyAlwaysOff = 0, PolicyAlwaysOn = 1, PolicyOptIn = 2, PolicyOptOut = 3, TotalPolicyCount = 4, }; pub const DEPPolicyAlwaysOff = DEP_SYSTEM_POLICY_TYPE.PolicyAlwaysOff; pub const DEPPolicyAlwaysOn = DEP_SYSTEM_POLICY_TYPE.PolicyAlwaysOn; pub const DEPPolicyOptIn = DEP_SYSTEM_POLICY_TYPE.PolicyOptIn; pub const DEPPolicyOptOut = DEP_SYSTEM_POLICY_TYPE.PolicyOptOut; pub const DEPTotalPolicyCount = DEP_SYSTEM_POLICY_TYPE.TotalPolicyCount; pub const PGET_SYSTEM_WOW64_DIRECTORY_A = fn( lpBuffer: ?[*:0]u8, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub const PGET_SYSTEM_WOW64_DIRECTORY_W = fn( lpBuffer: ?[*:0]u16, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; //-------------------------------------------------------------------------------- // Section: Functions (62) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GlobalMemoryStatusEx( lpBuffer: ?*MEMORYSTATUSEX, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetSystemInfo( lpSystemInfo: ?*SYSTEM_INFO, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetSystemTime( lpSystemTime: ?*SYSTEMTIME, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetSystemTimeAsFileTime( lpSystemTimeAsFileTime: ?*FILETIME, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetLocalTime( lpSystemTime: ?*SYSTEMTIME, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "KERNEL32" fn IsUserCetAvailableInEnvironment( UserCetEnvironment: USER_CET_ENVIRONMENT, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn GetSystemLeapSecondInformation( Enabled: ?*BOOL, Flags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetVersion( ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn SetLocalTime( lpSystemTime: ?*const SYSTEMTIME, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetTickCount( ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetTickCount64( ) callconv(@import("std").os.windows.WINAPI) u64; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetSystemTimeAdjustment( lpTimeAdjustment: ?*u32, lpTimeIncrement: ?*u32, lpTimeAdjustmentDisabled: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows10.0.10240' pub extern "api-ms-win-core-sysinfo-l1-2-4" fn GetSystemTimeAdjustmentPrecise( lpTimeAdjustment: ?*u64, lpTimeIncrement: ?*u64, lpTimeAdjustmentDisabled: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetSystemDirectoryA( lpBuffer: ?[*:0]u8, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetSystemDirectoryW( lpBuffer: ?[*:0]u16, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetWindowsDirectoryA( lpBuffer: ?[*:0]u8, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetWindowsDirectoryW( lpBuffer: ?[*:0]u16, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetSystemWindowsDirectoryA( lpBuffer: ?[*:0]u8, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetSystemWindowsDirectoryW( lpBuffer: ?[*:0]u16, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetComputerNameExA( NameType: COMPUTER_NAME_FORMAT, lpBuffer: ?[*:0]u8, nSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetComputerNameExW( NameType: COMPUTER_NAME_FORMAT, lpBuffer: ?[*:0]u16, nSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn SetComputerNameExW( NameType: COMPUTER_NAME_FORMAT, lpBuffer: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn SetSystemTime( lpSystemTime: ?*const SYSTEMTIME, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetVersionExA( lpVersionInformation: ?*OSVERSIONINFOA, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn GetVersionExW( lpVersionInformation: ?*OSVERSIONINFOW, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetLogicalProcessorInformation( // TODO: what to do with BytesParamIndex 1? Buffer: ?*SYSTEM_LOGICAL_PROCESSOR_INFORMATION, ReturnedLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.1' pub extern "KERNEL32" fn GetLogicalProcessorInformationEx( RelationshipType: LOGICAL_PROCESSOR_RELATIONSHIP, // TODO: what to do with BytesParamIndex 2? Buffer: ?*SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, ReturnedLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetNativeSystemInfo( lpSystemInfo: ?*SYSTEM_INFO, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows8.0' pub extern "KERNEL32" fn GetSystemTimePreciseAsFileTime( lpSystemTimeAsFileTime: ?*FILETIME, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetProductInfo( dwOSMajorVersion: u32, dwOSMinorVersion: u32, dwSpMajorVersion: u32, dwSpMinorVersion: u32, pdwReturnedProductType: ?*OS_PRODUCT_TYPE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn VerSetConditionMask( ConditionMask: u64, TypeMask: VER_FLAGS, Condition: u8, ) callconv(@import("std").os.windows.WINAPI) u64; pub extern "api-ms-win-core-sysinfo-l1-2-0" fn GetOsSafeBootMode( Flags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn EnumSystemFirmwareTables( FirmwareTableProviderSignature: FIRMWARE_TABLE_PROVIDER, // TODO: what to do with BytesParamIndex 2? pFirmwareTableEnumBuffer: ?*FIRMWARE_TABLE_ID, BufferSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetSystemFirmwareTable( FirmwareTableProviderSignature: FIRMWARE_TABLE_PROVIDER, FirmwareTableID: FIRMWARE_TABLE_ID, // TODO: what to do with BytesParamIndex 3? pFirmwareTableBuffer: ?*anyopaque, BufferSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn DnsHostnameToComputerNameExW( Hostname: ?[*:0]const u16, ComputerName: ?[*:0]u16, nSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetPhysicallyInstalledSystemMemory( TotalMemoryInKilobytes: ?*u64, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn SetComputerNameEx2W( NameType: COMPUTER_NAME_FORMAT, Flags: u32, lpBuffer: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn SetSystemTimeAdjustment( dwTimeAdjustment: u32, bTimeAdjustmentDisabled: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows10.0.10240' pub extern "api-ms-win-core-sysinfo-l1-2-4" fn SetSystemTimeAdjustmentPrecise( dwTimeAdjustment: u64, bTimeAdjustmentDisabled: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.1' pub extern "KERNEL32" fn GetProcessorSystemCycleTime( Group: u16, // TODO: what to do with BytesParamIndex 2? Buffer: ?*SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION, ReturnedLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-sysinfo-l1-2-3" fn GetOsManufacturingMode( pbEnabled: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows10.0.10240' pub extern "api-ms-win-core-sysinfo-l1-2-3" fn GetIntegratedDisplaySize( sizeInInches: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn SetComputerNameA( lpComputerName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn SetComputerNameW( lpComputerName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn SetComputerNameExA( NameType: COMPUTER_NAME_FORMAT, lpBuffer: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn GetSystemCpuSetInformation( // TODO: what to do with BytesParamIndex 1? Information: ?*SYSTEM_CPU_SET_INFORMATION, BufferLength: u32, ReturnedLength: ?*u32, Process: ?HANDLE, Flags: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetSystemWow64DirectoryA( lpBuffer: ?[*:0]u8, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetSystemWow64DirectoryW( lpBuffer: ?[*:0]u16, uSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows10.0.10586' pub extern "api-ms-win-core-wow64-l1-1-1" fn GetSystemWow64Directory2A( lpBuffer: ?[*:0]u8, uSize: u32, ImageFileMachineType: u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows10.0.10586' pub extern "api-ms-win-core-wow64-l1-1-1" fn GetSystemWow64Directory2W( lpBuffer: ?[*:0]u16, uSize: u32, ImageFileMachineType: u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows10.0.16299' pub extern "KERNEL32" fn IsWow64GuestMachineSupported( WowGuestMachine: u16, MachineIsSupported: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "ntdll" fn RtlGetProductInfo( OSMajorVersion: u32, OSMinorVersion: u32, SpMajorVersion: u32, SpMinorVersion: u32, ReturnedProductType: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; pub extern "ntdll" fn RtlOsDeploymentState( Flags: u32, ) callconv(@import("std").os.windows.WINAPI) OS_DEPLOYEMENT_STATE_VALUES; pub extern "ntdllk" fn RtlGetSystemGlobalData( DataId: RTL_SYSTEM_GLOBAL_DATA_ID, Buffer: ?*anyopaque, Size: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "ntdll" fn RtlGetDeviceFamilyInfoEnum( pullUAPInfo: ?*u64, pulDeviceFamily: ?*DEVICEFAMILYINFOENUM, pulDeviceForm: ?*DEVICEFAMILYDEVICEFORM, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "ntdll" fn RtlConvertDeviceFamilyInfoToString( pulDeviceFamilyBufferSize: ?*u32, pulDeviceFormBufferSize: ?*u32, // TODO: what to do with BytesParamIndex 0? DeviceFamily: ?PWSTR, // TODO: what to do with BytesParamIndex 1? DeviceForm: ?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "ntdll" fn RtlSwitchedVVI( VersionInfo: ?*OSVERSIONINFOEXW, TypeMask: u32, ConditionMask: u64, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GlobalMemoryStatus( lpBuffer: ?*MEMORYSTATUS, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetSystemDEPPolicy( ) callconv(@import("std").os.windows.WINAPI) DEP_SYSTEM_POLICY_TYPE; // TODO: this type is limited to platform 'windows8.0' pub extern "KERNEL32" fn GetFirmwareType( FirmwareType: ?*FIRMWARE_TYPE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn VerifyVersionInfoA( lpVersionInformation: ?*OSVERSIONINFOEXA, dwTypeMask: VER_FLAGS, dwlConditionMask: u64, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn VerifyVersionInfoW( lpVersionInformation: ?*OSVERSIONINFOEXW, dwTypeMask: VER_FLAGS, dwlConditionMask: u64, ) callconv(@import("std").os.windows.WINAPI) BOOL; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (13) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { pub const OSVERSIONINFO = thismodule.OSVERSIONINFOA; pub const OSVERSIONINFOEX = thismodule.OSVERSIONINFOEXA; pub const PGET_SYSTEM_WOW64_DIRECTORY_ = thismodule.PGET_SYSTEM_WOW64_DIRECTORY_A; pub const GetSystemDirectory = thismodule.GetSystemDirectoryA; pub const GetWindowsDirectory = thismodule.GetWindowsDirectoryA; pub const GetSystemWindowsDirectory = thismodule.GetSystemWindowsDirectoryA; pub const GetComputerNameEx = thismodule.GetComputerNameExA; pub const SetComputerNameEx = thismodule.SetComputerNameExA; pub const GetVersionEx = thismodule.GetVersionExA; pub const SetComputerName = thismodule.SetComputerNameA; pub const GetSystemWow64Directory = thismodule.GetSystemWow64DirectoryA; pub const GetSystemWow64Directory2 = thismodule.GetSystemWow64Directory2A; pub const VerifyVersionInfo = thismodule.VerifyVersionInfoA; }, .wide => struct { pub const OSVERSIONINFO = thismodule.OSVERSIONINFOW; pub const OSVERSIONINFOEX = thismodule.OSVERSIONINFOEXW; pub const PGET_SYSTEM_WOW64_DIRECTORY_ = thismodule.PGET_SYSTEM_WOW64_DIRECTORY_W; pub const GetSystemDirectory = thismodule.GetSystemDirectoryW; pub const GetWindowsDirectory = thismodule.GetWindowsDirectoryW; pub const GetSystemWindowsDirectory = thismodule.GetSystemWindowsDirectoryW; pub const GetComputerNameEx = thismodule.GetComputerNameExW; pub const SetComputerNameEx = thismodule.SetComputerNameExW; pub const GetVersionEx = thismodule.GetVersionExW; pub const SetComputerName = thismodule.SetComputerNameW; pub const GetSystemWow64Directory = thismodule.GetSystemWow64DirectoryW; pub const GetSystemWow64Directory2 = thismodule.GetSystemWow64Directory2W; pub const VerifyVersionInfo = thismodule.VerifyVersionInfoW; }, .unspecified => if (@import("builtin").is_test) struct { pub const OSVERSIONINFO = *opaque{}; pub const OSVERSIONINFOEX = *opaque{}; pub const PGET_SYSTEM_WOW64_DIRECTORY_ = *opaque{}; pub const GetSystemDirectory = *opaque{}; pub const GetWindowsDirectory = *opaque{}; pub const GetSystemWindowsDirectory = *opaque{}; pub const GetComputerNameEx = *opaque{}; pub const SetComputerNameEx = *opaque{}; pub const GetVersionEx = *opaque{}; pub const SetComputerName = *opaque{}; pub const GetSystemWow64Directory = *opaque{}; pub const GetSystemWow64Directory2 = *opaque{}; pub const VerifyVersionInfo = *opaque{}; } else struct { pub const OSVERSIONINFO = @compileError("'OSVERSIONINFO' requires that UNICODE be set to true or false in the root module"); pub const OSVERSIONINFOEX = @compileError("'OSVERSIONINFOEX' requires that UNICODE be set to true or false in the root module"); pub const PGET_SYSTEM_WOW64_DIRECTORY_ = @compileError("'PGET_SYSTEM_WOW64_DIRECTORY_' requires that UNICODE be set to true or false in the root module"); pub const GetSystemDirectory = @compileError("'GetSystemDirectory' requires that UNICODE be set to true or false in the root module"); pub const GetWindowsDirectory = @compileError("'GetWindowsDirectory' requires that UNICODE be set to true or false in the root module"); pub const GetSystemWindowsDirectory = @compileError("'GetSystemWindowsDirectory' requires that UNICODE be set to true or false in the root module"); pub const GetComputerNameEx = @compileError("'GetComputerNameEx' requires that UNICODE be set to true or false in the root module"); pub const SetComputerNameEx = @compileError("'SetComputerNameEx' requires that UNICODE be set to true or false in the root module"); pub const GetVersionEx = @compileError("'GetVersionEx' requires that UNICODE be set to true or false in the root module"); pub const SetComputerName = @compileError("'SetComputerName' requires that UNICODE be set to true or false in the root module"); pub const GetSystemWow64Directory = @compileError("'GetSystemWow64Directory' requires that UNICODE be set to true or false in the root module"); pub const GetSystemWow64Directory2 = @compileError("'GetSystemWow64Directory2' requires that UNICODE be set to true or false in the root module"); pub const VerifyVersionInfo = @compileError("'VerifyVersionInfo' requires that UNICODE be set to true or false in the root module"); }, }; //-------------------------------------------------------------------------------- // Section: Imports (10) //-------------------------------------------------------------------------------- const BOOL = @import("../foundation.zig").BOOL; const BOOLEAN = @import("../foundation.zig").BOOLEAN; const CHAR = @import("../foundation.zig").CHAR; const FILETIME = @import("../foundation.zig").FILETIME; const HANDLE = @import("../foundation.zig").HANDLE; const HRESULT = @import("../foundation.zig").HRESULT; const PROCESSOR_ARCHITECTURE = @import("../system/diagnostics/debug.zig").PROCESSOR_ARCHITECTURE; const PSTR = @import("../foundation.zig").PSTR; const PWSTR = @import("../foundation.zig").PWSTR; const SYSTEMTIME = @import("../foundation.zig").SYSTEMTIME; test { // The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476 if (@hasDecl(@This(), "PGET_SYSTEM_WOW64_DIRECTORY_A")) { _ = PGET_SYSTEM_WOW64_DIRECTORY_A; } if (@hasDecl(@This(), "PGET_SYSTEM_WOW64_DIRECTORY_W")) { _ = PGET_SYSTEM_WOW64_DIRECTORY_W; } @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/system/system_information.zig
const builtin = @import("builtin"); const std = @import("std"); const fmt = std.fmt; const testing = std.testing; const InStream = std.io.InStream; const Allocator = std.mem.Allocator; const BigNumParser = @import("./parser/t_bignum.zig").BigNumParser; const VoidParser = @import("./parser/void.zig").VoidParser; const NumberParser = @import("./parser/t_number.zig").NumberParser; const BoolParser = @import("./parser/t_bool.zig").BoolParser; const BlobStringParser = @import("./parser/t_string_blob.zig").BlobStringParser; const SimpleStringParser = @import("./parser/t_string_simple.zig").SimpleStringParser; const DoubleParser = @import("./parser/t_double.zig").DoubleParser; const ListParser = @import("./parser/t_list.zig").ListParser; const SetParser = @import("./parser/t_set.zig").SetParser; const MapParser = @import("./parser/t_map.zig").MapParser; const traits = @import("./traits.zig"); pub const RESP3Parser = struct { const rootParser = @This(); pub fn parse(comptime T: type, msg: anytype) !T { const tag = try msg.readByte(); return parseImpl(T, tag, .{}, msg); } pub fn parseFromTag(comptime T: type, tag: u8, msg: anytype) !T { return parseImpl(T, tag, .{}, msg); } pub fn parseAlloc(comptime T: type, allocator: *Allocator, msg: anytype) !T { const tag = try msg.readByte(); return try parseImpl(T, tag, .{ .ptr = allocator }, msg); } pub fn parseAllocFromTag(comptime T: type, tag: u8, allocator: *Allocator, msg: anytype) !T { return parseImpl(T, tag, .{ .ptr = allocator }, msg); } // TODO: should the errorset really be anyerror? Should it be explicit? // const errorset = error{ // GotErrorReply, // GotNilReply, // LengthMismatch, // UnsupportedConversion, // SystemResources, // InvalidCharacter, // Overflow, // InputOutput, // IsDir, // OperationAborted, // BrokenPipe, // ConnectionResetByPeer, // WouldBlock, // Unexpected, // EndOfStream, // OutOfMemory, // GraveProtocolError, // SorryBadImplementation, // InvalidCharForDigit, // DigitTooLargeForBase, // InvalidBase, // StreamTooLong, // DecodeError, // DecodingError, // DivisionByZero, // UnexpectedRemainder, // }; // fn computeErrorSet(comptime T: type) type { // if (comptime traits.isParserType(T)) { // @compileLog("TYPE", @typeName(T), T.Redis.Parser.Errors); // return errorset || T.Redis.Parser.Errors; // } // return errorset; // } pub fn parseImpl(comptime T: type, tag: u8, allocator: anytype, msg: anytype) anyerror!T { // First we get out of the way the basic case where // the return type is void and we just discard one full answer. if (T == void) return VoidParser.discardOne(tag, msg); // Here we need to deal with optionals and pointers. // - Optionals imply the possibility of decoding a nil reply. // - Single-item pointers require us to allocate the type and recur. // - Slices are the only type of pointer that we want to delegate to sub-parsers. switch (@typeInfo(T)) { .Optional => |opt| { var nextTag = tag; if (tag == '|') { // If the type is an optional, we discard any potential attribute. try VoidParser.discardOne('%', msg); nextTag = try msg.readByte(); } // If we found nil, return immediately. if (nextTag == '_') { try msg.skipBytes(2, .{}); return null; } // Otherwise recur with the underlying type. return try parseImpl(opt.child, nextTag, allocator, msg); }, .Pointer => |ptr| { if (!@hasField(@TypeOf(allocator), "ptr")) { @compileError("`parse` can't perform allocations so it can't handle pointers, use `parseAlloc` instead."); } switch (ptr.size) { .One => { // Single-item pointer, allocate it and recur. var res: *ptr.child = try allocator.ptr.create(ptr.child); errdefer allocator.ptr.destroy(res); res.* = try parseImpl(ptr.child, tag, allocator, msg); return res; }, .Many, .C => { @panic("!"); // @compileError("Pointers to unknown size or C-type are not supported."); }, .Slice => { // Slices are ok. We continue. }, } }, else => { // Main case: no optionals, no single-item/unknown-size pointers. // We continue. }, } var nextTag = tag; if (tag == '|') { // If the type declares to be able to decode attributes, we delegate immediately. if (comptime traits.handlesAttributes(T)) { var x: T = if (@hasField(@TypeOf(allocator), "ptr")) try T.Redis.Parser.parseAlloc(tag, rootParser, allocator.ptr, msg) else try T.Redis.Parser.parse(tag, rootParser, msg); return x; } // If we reached here, the type doesn't handle attributes so we must discard them. // Here we lie to the void parser and claim we want to discard one Map element. // We lie because attributes are not counted when consuming a reply with the // void parser. If we were to be truthful about the element type, the void // parser would also discard the actual reply. try VoidParser.discardOne('%', msg); nextTag = try msg.readByte(); } // If the type implement its own decoding procedure, we delegate the job to it. if (comptime traits.isParserType(T)) { var x: T = if (@hasField(@TypeOf(allocator), "ptr")) try T.Redis.Parser.parseAlloc(tag, rootParser, allocator.ptr, msg) else try T.Redis.Parser.parse(nextTag, rootParser, msg); return x; } switch (nextTag) { else => std.debug.panic("Found `{c}` in the main parser's switch." ++ " Probably a bug in a type that implements `Redis.Parser`.", .{nextTag}), '_' => { try msg.skipBytes(2, .{}); return error.GotNilReply; }, '-' => { try VoidParser.discardOne('+', msg); return error.GotErrorReply; }, '!' => { try VoidParser.discardOne('$', msg); return error.GotErrorReply; }, ':' => return try ifSupported(NumberParser, T, allocator, msg), ',' => return try ifSupported(DoubleParser, T, allocator, msg), '#' => return try ifSupported(BoolParser, T, allocator, msg), '$', '=' => return try ifSupported(BlobStringParser, T, allocator, msg), '+' => return try ifSupported(SimpleStringParser, T, allocator, msg), '*' => return try ifSupported(ListParser, T, allocator, msg), '~' => return try ifSupported(SetParser, T, allocator, msg), '%' => return try ifSupported(MapParser, T, allocator, msg), '(' => return try ifSupported(BigNumParser, T, allocator, msg), } } fn ifSupported(comptime parser: type, comptime T: type, allocator: anytype, msg: anytype) !T { if (@hasField(@TypeOf(allocator), "ptr")) { return if (comptime parser.isSupportedAlloc(T)) parser.parseAlloc(T, rootParser, allocator.ptr, msg) else error.UnsupportedConversion; } else { return if (comptime parser.isSupported(T)) parser.parse(T, rootParser, msg) else error.UnsupportedConversion; } } // Frees values created by `sendAlloc`. // If the top value is a pointer, it frees that too. // TODO: free stdlib types! pub fn freeReply(val: anytype, allocator: *Allocator) void { const T = @TypeOf(val); switch (@typeInfo(T)) { else => return, .Optional => if (val) |v| freeReply(v, allocator), .Array => |arr| { switch (@typeInfo(arr.child)) { else => {}, .Enum, .Union, .Struct, .Pointer, .Optional, => { for (val) |elem| { freeReply(elem, allocator); } }, } // allocator.free(val); }, .Pointer => |ptr| switch (ptr.size) { .Many => @compileError("sendAlloc is incapable of generating [*] pointers. " ++ "You are passing the wrong value!"), .C => allocator.free(val), .Slice => { switch (@typeInfo(ptr.child)) { else => {}, .Enum, .Union, .Struct, .Pointer, .Optional, => { for (val) |elem| { freeReply(elem, allocator); } }, } allocator.free(val); }, .One => { switch (@typeInfo(ptr.child)) { else => {}, .Enum, .Union, .Struct, .Pointer, .Optional, => { freeReply(val.*, allocator); }, } allocator.destroy(val); }, }, .Union => |unn| if (comptime traits.isParserType(T)) { T.Redis.Parser.destroy(val, rootParser, allocator); } else { @compileError("sendAlloc cannot return Unions or Enums that don't implement " ++ "custom parsing logic. You are passing the wrong value!"); }, .Struct => |stc| { if (comptime traits.isParserType(T)) { T.Redis.Parser.destroy(val, rootParser, allocator); } else { inline for (stc.fields) |f| { switch (@typeInfo(f.field_type)) { else => {}, .Enum, .Union, .Struct, .Pointer, .Optional, => { freeReply(@field(val, f.name), allocator); }, } } } }, } } }; test "parser" { _ = @import("./parser/t_bignum.zig"); _ = @import("./parser/t_number.zig"); _ = @import("./parser/t_bool.zig"); _ = @import("./parser/t_string_blob.zig"); _ = @import("./parser/t_string_simple.zig"); _ = @import("./parser/t_double.zig"); _ = @import("./parser/t_list.zig"); _ = @import("./parser/t_set.zig"); _ = @import("./parser/t_map.zig"); _ = @import("./parser/void.zig"); } test "evil indirection" { const WithAttribs = @import("./types/attributes.zig").WithAttribs; const allocator = std.heap.page_allocator; { const yes = try RESP3Parser.parseAlloc(?**?*f32, allocator, MakeEvilFloat().inStream()); defer RESP3Parser.freeReply(yes, allocator); if (yes) |v| { testing.expectEqual(@as(f32, 123.45), v.*.*.?.*); } else { unreachable; } } { const no = try RESP3Parser.parseAlloc(?***f32, allocator, MakeEvilNil().inStream()); if (no) |v| unreachable; } { // const OrErr = @import("./types/error.zig").OrErr; // const yes = try RESP3Parser.parseAlloc(***WithAttribs(?***f32), allocator, &MakeEvilFloat().stream); // defer RESP3Parser.freeReply(yes, allocator); // std.debug.warn("{?}\n", yes.*.*.*.attribs); // if (yes.*.*.data) |v| { // // testing.expectEqual(f32(123.45), v.*.*.*); // } else { // unreachable; // } } } //zig fmt: off fn MakeEvilFloat() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream( ("|2\r\n" ++ "+Ciao\r\n" ++ "+World\r\n" ++ "+Peach\r\n" ++ ",9.99\r\n" ++ ",123.45\r\n") [0..]); } fn MakeEvilNil() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream( ("|2\r\n" ++ "+Ciao\r\n" ++ "+World\r\n" ++ "+Peach\r\n" ++ ",9.99\r\n" ++ "_\r\n") [0..]); } //zig fmt: on test "float" { // No alloc { var input = std.io.fixedBufferStream(",120.23\r\n"[0..]); const p1 = RESP3Parser.parse(f32, input.inStream()) catch unreachable; testing.expect(p1 == 120.23); } //Alloc const allocator = std.heap.page_allocator; { { const f = try RESP3Parser.parseAlloc(*f32, allocator, Make1Float().inStream()); defer allocator.destroy(f); testing.expect(f.* == 120.23); } { const f = try RESP3Parser.parseAlloc([]f32, allocator, Make2Float().inStream()); defer allocator.free(f); testing.expectEqualSlices(f32, &[_]f32{ 1.1, 2.2 }, f); } } } fn Make1Float() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream(",120.23\r\n"[0..]); } fn Make2Float() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream("*2\r\n,1.1\r\n,2.2\r\n"[0..]); } test "optional" { const maybeInt: ?i64 = null; const maybeBool: ?bool = null; const maybeArr: ?[4]bool = null; testing.expectEqual(maybeInt, try RESP3Parser.parse(?i64, MakeNull().inStream())); testing.expectEqual(maybeBool, try RESP3Parser.parse(?bool, MakeNull().inStream())); testing.expectEqual(maybeArr, try RESP3Parser.parse(?[4]bool, MakeNull().inStream())); } fn MakeNull() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream("_\r\n"[0..]); } test "array" { testing.expectError(error.LengthMismatch, RESP3Parser.parse([5]i64, MakeArray().inStream())); // testing.expectError(error.LengthMismatch, RESP3Parser.parse([0]i64, MakeArray().inStream())); testing.expectError(error.UnsupportedConversion, RESP3Parser.parse([2]i64, MakeArray().inStream())); testing.expectEqual([2]f32{ 1.2, 3.4 }, try RESP3Parser.parse([2]f32, MakeArray().inStream())); } fn MakeArray() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream("*2\r\n,1.2\r\n,3.4\r\n"[0..]); } test "string" { testing.expectError(error.LengthMismatch, RESP3Parser.parse([5]u8, MakeString().inStream())); testing.expectError(error.LengthMismatch, RESP3Parser.parse([2]u16, MakeString().inStream())); testing.expectEqualSlices(u8, "Hello World!", &try RESP3Parser.parse([12]u8, MakeSimpleString().inStream())); testing.expectError(error.LengthMismatch, RESP3Parser.parse([11]u8, MakeSimpleString().inStream())); testing.expectError(error.LengthMismatch, RESP3Parser.parse([13]u8, MakeSimpleString().inStream())); const allocator = std.heap.page_allocator; testing.expectEqualSlices(u8, "Banana", try RESP3Parser.parseAlloc([]u8, allocator, MakeString().inStream())); testing.expectEqualSlices(u8, "Hello World!", try RESP3Parser.parseAlloc([]u8, allocator, MakeSimpleString().inStream())); } fn MakeString() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream("$6\r\nBanana\r\n"[0..]); } fn MakeSimpleString() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream("+Hello World!\r\n"[0..]); } test "map2struct" { const FixBuf = @import("./types/fixbuf.zig").FixBuf; const MyStruct = struct { first: f32, second: bool, third: FixBuf(11), }; const res = try RESP3Parser.parse(MyStruct, MakeMap().inStream()); testing.expect(res.first == 12.34); testing.expect(res.second == true); testing.expectEqualSlices(u8, "Hello World", res.third.toSlice()); } test "hashmap" { const allocator = std.heap.page_allocator; const FloatDict = std.StringHashMap(f64); const res = try RESP3Parser.parseAlloc(FloatDict, allocator, MakeFloatMap().inStream()); testing.expect(12.34 == res.get("aaa").?); testing.expect(56.78 == res.get("bbb").?); testing.expect(99.99 == res.get("ccc").?); } fn MakeFloatMap() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream("%3\r\n$3\r\naaa\r\n,12.34\r\n$3\r\nbbb\r\n,56.78\r\n$3\r\nccc\r\n,99.99\r\n"[0..]); } fn MakeMap() std.io.FixedBufferStream([]const u8) { return std.io.fixedBufferStream("%3\r\n$5\r\nfirst\r\n,12.34\r\n$6\r\nsecond\r\n#t\r\n$5\r\nthird\r\n$11\r\nHello World\r\n"[0..]); } test "consume right amount" { const FixBuf = @import("./types/fixbuf.zig").FixBuf; { var msg_err = std.io.fixedBufferStream("-ERR banana\r\n"[0..]); testing.expectError(error.GotErrorReply, RESP3Parser.parse(void, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); msg_err.pos = 0; testing.expectError(error.GotErrorReply, RESP3Parser.parse(i64, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); msg_err.pos = 0; testing.expectError(error.GotErrorReply, RESP3Parser.parse(FixBuf(100), msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); } { var msg_err = std.io.fixedBufferStream("!10\r\nERR banana\r\n"[0..]); testing.expectError(error.GotErrorReply, RESP3Parser.parse(void, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); msg_err.pos = 0; testing.expectError(error.GotErrorReply, RESP3Parser.parse(u64, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); msg_err.pos = 0; testing.expectError(error.GotErrorReply, RESP3Parser.parse([10]u8, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); } { var msg_err = std.io.fixedBufferStream("*2\r\n:123\r\n!10\r\nERR banana\r\n"[0..]); testing.expectError(error.GotErrorReply, RESP3Parser.parse([2]u64, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); const MyStruct = struct { a: u8, b: u8, }; msg_err.pos = 0; testing.expectError(error.GotErrorReply, RESP3Parser.parse(MyStruct, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); } { var msg_err = std.io.fixedBufferStream("*2\r\n:123\r\n!10\r\nERR banana\r\n"[0..]); testing.expectError(error.GotErrorReply, RESP3Parser.parse([2]u64, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); const MyStruct = struct { a: u8, b: u8, }; msg_err.pos = 0; testing.expectError(error.GotErrorReply, RESP3Parser.parse(MyStruct, msg_err.inStream())); testing.expectError(error.EndOfStream, (msg_err.inStream()).readByte()); } }
src/parser.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const AutoHashMap = std.AutoHashMap; const StringHashMap = std.StringHashMap; // Useful stdlib functions const tokenize = std.mem.tokenize; const split = std.mem.split; const trim = std.mem.trim; 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; const util = @import("util.zig"); const gpa = util.gpa; const Movement = struct { jump: u32, mult: u64, }; var movements = [7]Movement{ .{ .jump = 3, .mult = 1 }, .{ .jump = 4, .mult = 3 }, .{ .jump = 5, .mult = 6 }, .{ .jump = 6, .mult = 7 }, .{ .jump = 7, .mult = 6 }, .{ .jump = 8, .mult = 3 }, .{ .jump = 9, .mult = 1 }, }; fn score(pos: u32) u64 { var p: u64 = pos % 10; if (p == 0) return 10; return p; } pub fn main() !void { // paths indices: // 0: Score of first player // 1: Score of second player // 2: Position of first player // 3: Position of second player // 4: Next player to move (0 = first, 1 = second) var paths = std.mem.zeroes([31][31][10][10][2]u64); // Initial conditions: Both players have 0 score, and there's one universe where each player // is at a certain location, and the first player is next to move. // paths[0][0][4][8][0] = 1; // sample paths[0][0][0][3][0] = 1; // input { var base_score: u32 = 0; while (base_score <= 40) : (base_score += 1) { var new_universes: u64 = 0; var p1_score: u32 = 0; while (p1_score <= base_score) : (p1_score += 1) { var p2_score = base_score - p1_score; if (p1_score > 20 or p2_score > 20) continue; var idx: u32 = 0; while (idx < 10) : (idx += 1) { var jdx: u32 = 0; while (jdx < 10) : (jdx += 1) { for (movements) |m| { // P1 to move. var new_p1 = (idx + m.jump) % 10; var new_s1 = p1_score + score(new_p1); var x = paths[p1_score][p2_score][idx][jdx][0] * m.mult; paths[new_s1][p2_score][new_p1][jdx][1] += x; new_universes += x; // P2 to move. var new_p2 = (jdx + m.jump) % 10; var new_s2 = p2_score + score(new_p2); x = paths[p1_score][p2_score][idx][jdx][1] * m.mult; paths[p1_score][new_s2][idx][new_p2][0] += x; new_universes += x; } } } } print("base scpre: {d: >2} universes: {}\n", .{ base_score, new_universes }); } } var p1_wins: u64 = 0; var p2_wins: u64 = 0; { var win_score: u32 = 21; while (win_score <= 30) : (win_score += 1) { var lose_score: u32 = 0; while (lose_score <= 20) : (lose_score += 1) { var idx: u32 = 0; while (idx < 10) : (idx += 1) { var jdx: u32 = 0; while (jdx < 10) : (jdx += 1) { p1_wins += paths[win_score][lose_score][idx][jdx][0]; p1_wins += paths[win_score][lose_score][idx][jdx][1]; p2_wins += paths[lose_score][win_score][idx][jdx][0]; p2_wins += paths[lose_score][win_score][idx][jdx][1]; } } } } } print("P1 wins: {}\n", .{p1_wins}); print("P2 wins: {}\n", .{p2_wins}); print("Total: {}\n", .{p1_wins + p2_wins}); }
src/day21.zig
const IOCTL = @import("ioctl.zig"); // Modes for the prctl(2) form `prctl(PR_SET_SECCOMP, mode)` pub const MODE = struct { /// Seccomp not in use. pub const DISABLED = 0; /// Uses a hard-coded filter. pub const STRICT = 1; /// Uses a user-supplied filter. pub const FILTER = 2; }; // Operations for the seccomp(2) form `seccomp(operation, flags, args)` pub const SET_MODE_STRICT = 0; pub const SET_MODE_FILTER = 1; pub const GET_ACTION_AVAIL = 2; pub const GET_NOTIF_SIZES = 3; /// Bitflags for the SET_MODE_FILTER operation. pub const FILTER_FLAG = struct { pub const TSYNC = 1 << 0; pub const LOG = 1 << 1; pub const SPEC_ALLOW = 1 << 2; pub const NEW_LISTENER = 1 << 3; pub const TSYNC_ESRCH = 1 << 4; }; /// Action values for seccomp BPF programs. /// The lower 16-bits are for optional return data. /// The upper 16-bits are ordered from least permissive values to most. pub const RET = struct { /// Kill the process. pub const KILL_PROCESS = 0x80000000; /// Kill the thread. pub const KILL_THREAD = 0x00000000; pub const KILL = KILL_THREAD; /// Disallow and force a SIGSYS. pub const TRAP = 0x00030000; /// Return an errno. pub const ERRNO = 0x00050000; /// Forward the syscall to a userspace supervisor to make a decision. pub const USER_NOTIF = 0x7fc00000; /// Pass to a tracer or disallow. pub const TRACE = 0x7ff00000; /// Allow after logging. pub const LOG = 0x7ffc0000; /// Allow. pub const ALLOW = 0x7fff0000; // Masks for the return value sections. pub const ACTION_FULL = 0xffff0000; pub const ACTION = 0x7fff0000; pub const DATA = 0x0000ffff; }; pub const IOCTL_NOTIF = struct { pub const RECV = IOCTL.IOWR('!', 0, notif); pub const SEND = IOCTL.IOWR('!', 1, notif_resp); pub const ID_VALID = IOCTL.IOW('!', 2, u64); pub const ADDFD = IOCTL.IOW('!', 3, notif_addfd); }; /// Tells the kernel that the supervisor allows the syscall to continue. pub const USER_NOTIF_FLAG_CONTINUE = 1 << 0; /// See seccomp_unotify(2). pub const ADDFD_FLAG = struct { pub const SETFD = 1 << 0; pub const SEND = 1 << 1; }; pub const data = extern struct { /// The system call number. nr: c_int, /// The CPU architecture/system call convention. /// One of the values defined in `std.os.linux.AUDIT`. arch: u32, instruction_pointer: u64, arg0: u64, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64, }; /// Used with the ::GET_NOTIF_SIZES command to check if the kernel structures /// have changed. pub const notif_sizes = extern struct { /// Size of ::notif. notif: u16, /// Size of ::resp. notif_resp: u16, /// Size of ::data. data: u16, }; pub const notif = extern struct { /// Unique notification cookie for each filter. id: u64, /// ID of the thread that triggered the notification. pid: u32, /// Bitmask for event information. Currently set to zero. flags: u32, /// The current system call data. data: data, }; /// The decision payload the supervisor process sends to the kernel. pub const notif_resp = extern struct { /// The filter cookie. id: u64, /// The return value for a spoofed syscall. val: i64, /// Set to zero for a spoofed success or a negative error number for a /// failure. @"error": i32, /// Bitmask containing the decision. Either USER_NOTIF_FLAG_CONTINUE to /// allow the syscall or zero to spoof the return values. flags: u32, }; pub const notif_addfd = extern struct { id: u64, flags: u32, srcfd: u32, newfd: u32, newfd_flags: u32, };
lib/std/os/linux/seccomp.zig
const std = @import("std"); const c = @cImport({@cInclude("X11/Xlib.h");}); const print = std.debug.warn; pub fn main() anyerror!void { var args = std.process.ArgIteratorPosix.init(); _ = args.skip(); var arg_one = args.next() orelse return usage(); if (arg_one.len <=1 or arg_one[0] != '-') return usage(); switch(arg_one[1]) { 'k','R','q' => return send_command(arg_one[1], 0), //'c' => { // if (arg_one.len != 2) usageclient(); // switch (arg_one[2]){ // 'n' => return, // 'p' => return, // else => return, // } //}, else => return usage() } } fn send_command(command: u8, arg: u8) !void { var display: *c.Display = c.XOpenDisplay(null) orelse return; // TODO Error defer _ = c.XCloseDisplay(display); var root = c.XDefaultRootWindow(display); var ev :c.XEvent = undefined; ev.xclient.type = c.ClientMessage; ev.xclient.window = root; // This is our "protocol": One byte opcode, one byte argument ev.xclient.message_type = c.XInternAtom(display, "ZWM_CLIENT_COMMAND", c.False); ev.xclient.format = 8; ev.xclient.data.b[0] = command; ev.xclient.data.b[1] = arg; // Send this message to all clients which have selected for // "SubstructureRedirectMask" on the root window. By definition, // this is the window manager. print("Sending command {}, arg {}\n", .{command, arg}); _ = c.XSendEvent(display, root, c.False, c.SubstructureRedirectMask, &ev); _ = c.XSync(display, c.False); return; } fn usage() void { print("Usage: client COMMAND [OPTION]\n\n", .{}); print("-h [OPTIONS]\t--help\n\n",.{}); // print("-f\t\t--floating-toggle\n", .{}); // print("-F\t\t--fullscreen-toggle\n", .{}); print("-k\t\t--kill-client\n", .{}); // print("-r [OPTIONS]\t--resize\n", .{}); // print("-c [OPTIONS]\t--client\n", .{}); // -p --prev / -n --next // print("-w [OPTIONS]\t--workspace\n", .{}); // print("-l [OPTIONS]\t--layout\n\n",.{}); print("-R\t\t--restart\n",.{}); print("-q\t\t--quit\n",.{}); } fn usageclient() void { // print("-cn --next-client\n", .{}); }
src/client.zig
const std = @import("std"); const bedrock = @import("bedrock.zig"); export fn searchInit( world_seed: i64, gen_type: BedrockGenType, x0: i32, y0: i32, z0: i32, x1: i32, y1: i32, z1: i32, ) ?*AsyncSearcher { const gen = switch (gen_type) { .overworld_floor => bedrock.GradientGenerator.overworldFloor(world_seed), .nether_floor => bedrock.GradientGenerator.netherFloor(world_seed), .nether_ceiling => bedrock.GradientGenerator.netherCeiling(world_seed), }; const finder = bedrock.PatternFinder{ .gen = gen, .pattern = &.{&.{ // TODO: un-hardcode &.{ .bedrock, .bedrock, .bedrock }, &.{ .bedrock, .bedrock, .bedrock }, &.{ .bedrock, .bedrock, .bedrock }, }}, }; return AsyncSearcher.init( std.heap.page_allocator, finder, .{ .x = x0, .y = y0, .z = z0 }, .{ .x = x1, .y = y1, .z = z1 }, ) catch null; } const BedrockGenType = enum(u8) { overworld_floor, nether_floor, nether_ceiling, }; export fn searchStep(searcher: *AsyncSearcher) bool { return searcher.step(); } export fn searchProgress(searcher: *AsyncSearcher) f64 { return searcher.progress; } export fn searchDeinit(searcher: *AsyncSearcher) void { searcher.deinit(); } const AsyncSearcher = struct { allocator: *std.mem.Allocator, progress: f64 = 0, done: bool = false, frame: anyframe = undefined, frame_storage: @Frame(search) = undefined, pub fn init( allocator: *std.mem.Allocator, finder: bedrock.PatternFinder, a: bedrock.Point, b: bedrock.Point, ) !*AsyncSearcher { const self = try allocator.create(AsyncSearcher); self.* = .{ .allocator = allocator }; self.frame_storage = async self.search(finder, a, b); return self; } pub fn deinit(self: *AsyncSearcher) void { self.allocator.destroy(self); } pub fn step(self: *AsyncSearcher) bool { if (!self.done) { resume self.frame; } return !self.done; } fn yield(self: *AsyncSearcher) void { suspend { self.frame = @frame(); } } fn search( self: *AsyncSearcher, finder: bedrock.PatternFinder, a: bedrock.Point, b: bedrock.Point, ) void { self.yield(); finder.search(a, b, self, reportResult, reportProgress); self.done = true; } pub fn reportResult(_: *AsyncSearcher, p: bedrock.Point) void { resultCallback(p.x, p.y, p.z); } pub fn reportProgress(self: *AsyncSearcher, completed: u64, total: u64) void { const resolution = 10_000; const progress = resolution * completed / total; const fraction = @intToFloat(f64, progress) / resolution; self.progress = fraction; self.yield(); } }; extern "bedrock" fn resultCallback(x: i32, y: i32, z: i32) void;
src/web.zig
const std = @import("std"); const assert = std.debug.assert; const zp = @import("../../zplay.zig"); const gl = zp.deps.gl; const alg = zp.deps.alg; const Vec2 = alg.Vec2; const Vec3 = alg.Vec3; const Vec4 = alg.Vec4; const Mat4 = alg.Mat4; const Self = @This(); const allocator = std.heap.raw_c_allocator; /// id of shader program id: gl.GLuint = undefined, /// uniform location cache /// Q: Why use string cache? /// A: Because we don't know where the given uniform name resides in(static, stack, heap), /// which means it could be disappeared/invalid in anytime! So, we clone it to make sure /// the memory is valid as long as shader is living. uniform_locs: std.StringHashMap(gl.GLint) = undefined, string_cache: std.ArrayList([]u8) = undefined, /// current active shader var current: gl.GLuint = 0; /// init shader program pub fn init( vs_source: [:0]const u8, fs_source: [:0]const u8, ) Self { var program: Self = undefined; var success: gl.GLint = undefined; var shader_log: [512]gl.GLchar = undefined; var log_size: gl.GLsizei = undefined; // vertex shader var vshader = gl.createShader(gl.GL_VERTEX_SHADER); defer gl.deleteShader(vshader); gl.shaderSource(vshader, 1, &vs_source.ptr, null); gl.compileShader(vshader); gl.getShaderiv(vshader, gl.GL_COMPILE_STATUS, &success); if (success == 0) { gl.getShaderInfoLog(vshader, 512, &log_size, &shader_log); std.debug.panic( "compile vertex shader failed, error log:\n{s}" ++ "\n\n>>>>> full shader source <<<<<\n{s}\n", .{ shader_log[0..@intCast(u32, log_size)], prettifySource(vs_source) }, ); } gl.util.checkError(); // fragment shader var fshader = gl.createShader(gl.GL_FRAGMENT_SHADER); defer gl.deleteShader(fshader); gl.shaderSource(fshader, 1, &fs_source.ptr, null); gl.compileShader(fshader); gl.getShaderiv(fshader, gl.GL_COMPILE_STATUS, &success); if (success == 0) { gl.getShaderInfoLog(fshader, 512, &log_size, &shader_log); std.debug.panic( "compile fragment shader failed, error log:\n{s}" ++ "\n\n>>>>> full shader source <<<<<\n{s}\n", .{ shader_log[0..@intCast(u32, log_size)], prettifySource(fs_source) }, ); } gl.util.checkError(); // link program program.id = gl.createProgram(); gl.attachShader(program.id, vshader); gl.attachShader(program.id, fshader); gl.linkProgram(program.id); gl.getProgramiv(program.id, gl.GL_LINK_STATUS, &success); if (success == 0) { gl.getProgramInfoLog(program.id, 512, &log_size, &shader_log); std.debug.panic( "link shader program failed, error log:\n{s}" ++ "\n\n>>>>> vertex shader source <<<<<\n{s}" ++ "\n\n>>>>> fragment shader source <<<<<\n{s}\n", .{ shader_log[0..@intCast(u32, log_size)], prettifySource(vs_source), prettifySource(fs_source) }, ); } gl.util.checkError(); // init uniform location cache program.uniform_locs = std.StringHashMap(gl.GLint).init(allocator); program.string_cache = std.ArrayList([]u8).init(allocator); return program; } /// deinitialize shader program pub fn deinit(self: *Self) void { gl.deleteProgram(self.id); self.id = undefined; self.uniform_locs.deinit(); for (self.string_cache.items) |s| { allocator.free(s); } self.string_cache.deinit(); gl.util.checkError(); } /// start using shader program pub fn use(self: Self) void { current = self.id; gl.useProgram(self.id); gl.util.checkError(); } /// stop using shader program pub fn disuse(self: Self) void { _ = self; current = 0; gl.useProgram(0); gl.util.checkError(); } /// check if shader is being used pub fn isUsing(self: Self) bool { return self.id == current; } /// get uniform block index pub fn getUniformBlockIndex(self: *Self, name: [:0]const u8) gl.GLuint { var index: gl.GLuint = gl.getUniformBlockIndex(self.id, name.ptr); gl.util.checkError(); if (index == gl.GL_INVALID_INDEX) { std.debug.panic("can't find uniform block {s}", .{name}); } return index; } /// get uniform location (and cache them) pub fn getUniformLocation(self: *Self, name: [:0]const u8) gl.GLint { var loc: gl.GLint = undefined; if (self.uniform_locs.get(name)) |l| { // check cache first loc = l; } else { // query driver loc = gl.getUniformLocation(self.id, name.ptr); gl.util.checkError(); if (loc < 0) { std.debug.panic("can't find location of uniform {s}", .{name}); } // save into cache const cloned_name = allocator.dupe(u8, name) catch unreachable; self.uniform_locs.put(cloned_name, loc) catch unreachable; self.string_cache.append(cloned_name) catch unreachable; } return loc; } /// set uniform value with name pub fn setUniformByName(self: *Self, name: [:0]const u8, v: anytype) void { assert(self.id == current); var loc = self.getUniformLocation(name); self.setUniform(loc, v); } /// set uniform value with location pub fn setUniformByLocation(self: Self, loc: gl.GLuint, v: anytype) void { assert(self.id == current); self.setUniform(@intCast(gl.GLuint, loc), v); } /// internal generic function for setting uniform value fn setUniform(self: Self, loc: gl.GLint, v: anytype) void { _ = self; switch (@TypeOf(v)) { bool => gl.uniform1i(loc, gl.util.boolType(v)), i32, c_int, comptime_int, usize => gl.uniform1i(loc, @intCast(gl.GLint, v)), []i32 => gl.uniform1iv(loc, v.len, v.ptr), [2]i32 => gl.uniform2iv(loc, 1, &v), [3]i32 => gl.uniform3iv(loc, 1, &v), [4]i32 => gl.uniform4iv(loc, 1, &v), u32, c_uint => gl.uniform1ui(loc, @intCast(gl.GLuint, v)), []u32 => gl.uniform1uiv(loc, v.len, v.ptr), [2]u32 => gl.uniform2uiv(loc, 1, &v), [3]u32 => gl.uniform3uiv(loc, 1, &v), [4]u32 => gl.uniform4uiv(loc, 1, &v), comptime_float, f32 => gl.uniform1f(loc, @floatCast(gl.GLfloat, v)), []f32 => gl.uniform1fv(loc, v.len, v.ptr), [2]f32 => gl.uniform2fv(loc, 1, &v), [3]f32 => gl.uniform3fv(loc, 1, &v), [4]f32 => gl.uniform4fv(loc, 1, &v), Vec2 => gl.uniform2f(loc, v.x, v.y), Vec3 => gl.uniform3f(loc, v.x, v.y, v.z), Vec4 => gl.uniform4f(loc, v.x, v.y, v.z, v.w), Mat4 => gl.uniformMatrix4fv(loc, 1, gl.GL_FALSE, v.getData()), else => std.debug.panic("unsupported type {s}", .{@typeName(@TypeOf(v))}), } gl.util.checkError(); } /// set default value for attribute pub fn setAttributeDefaultValue(self: Self, _loc: gl.GLint, v: anytype) void { assert(self.id == current); const loc = @intCast(gl.GLuint, _loc); switch (@TypeOf(v)) { Vec2 => gl.vertexAttrib2f(loc, v.x, v.y), Vec3 => gl.vertexAttrib3f(loc, v.x, v.y, v.z), Vec4 => gl.vertexAttrib4f(loc, v.x, v.y, v.z, v.w), f32 => gl.vertexAttrib1f(loc, v), i16 => gl.vertexAttrib1s(loc, v), f64 => gl.vertexAttrib1d(loc, v), i32, c_int, comptime_int, usize => gl.vertexAttribI1i(loc, @intCast(gl.GLint, v)), u32, c_uint => gl.vertexAttribI1ui(loc, @intCast(gl.GLuint, v)), [1]f32 => gl.vertexAttrib1fv(loc, &v), [1]i16 => gl.vertexAttrib1sv(loc, &v), [1]f64 => gl.vertexAttrib1dv(loc, &v), [1]i32, [1]c_int => gl.vertexAttribI1iv(loc, @ptrCast([*c]gl.GLint, &v)), [1]u32, [1]c_uint => gl.vertexAttribI1uiv(loc, @ptrCast([*c]gl.GLuint, &v)), [2]f32 => gl.vertexAttrib2fv(loc, &v), [2]i16 => gl.vertexAttrib2sv(loc, &v), [2]f64 => gl.vertexAttrib2dv(loc, &v), [2]i32, [2]c_int => gl.vertexAttribI2iv(loc, @ptrCast([*c]gl.GLint, &v)), [2]u32, [2]c_uint => gl.vertexAttribI2uiv(loc, @ptrCast([*c]gl.GLuint, &v)), [3]f32 => gl.vertexAttrib3fv(loc, &v), [3]i16 => gl.vertexAttrib3sv(loc, &v), [3]f64 => gl.vertexAttrib3dv(loc, &v), [3]i32, [3]c_int => gl.vertexAttribI3iv(loc, @ptrCast([*c]gl.GLint, &v)), [3]u32, [3]c_uint => gl.vertexAttribI3uiv(loc, @ptrCast([*c]gl.GLuint, &v)), [4]f32 => gl.vertexAttrib4fv(loc, &v), [4]i16 => gl.vertexAttrib4sv(loc, &v), [4]f64 => gl.vertexAttrib4dv(loc, &v), [4]i32, [4]c_int => gl.vertexAttrib4iv(loc, @ptrCast([*c]gl.GLint, &v)), [4]i8 => gl.vertexAttrib4bv(loc, &v), [4]u8 => gl.vertexAttrib4ubv(loc, &v), [4]u16 => gl.vertexAttrib4usv(loc, &v), [4]u32, [4]c_uint => gl.vertexAttrib4uiv(loc, @ptrCast([*c]gl.GLuint, &v)), else => std.debug.panic("unsupported type {s}", .{@typeName(@TypeOf(v))}), } gl.util.checkError(); } /// caller is responsible for freeing the returned buffer fn prettifySource(source: [:0]const u8) []u8 { const buf = allocator.alloc(u8, 16 * 1024) catch unreachable; var line_num: u32 = 1; var it = std.mem.split(u8, source, "\n"); var off: u32 = 0; while (it.next()) |s| : (line_num += 1) { const ws = std.fmt.bufPrint(buf[off..], "{d:0>4}| {s}\n", .{ line_num, s }) catch unreachable; off += @intCast(u32, ws.len); } std.debug.print("line_num is {d} {d}\n", .{ line_num, off }); return buf[0..off]; }
src/graphics/common/ShaderProgram.zig
const std = @import("std"); const shared = @import("../shared.zig"); const lib = @import("../../main.zig"); const c = @cImport({ @cDefine("GLFW_INCLUDE_ES3", {}); @cInclude("GLFW/glfw3.h"); }); const gl = c; const lasting_allocator = lib.internal.lasting_allocator; const EventType = shared.BackendEventType; var activeWindows = std.ArrayList(*c.GLFWwindow).init(lasting_allocator); pub const GuiWidget = struct { userdata: usize = 0, width: u32 = 0, height: u32 = 0, pub fn init(allocator: *std.mem.Allocator) !*GuiWidget { const self = try allocator.create(GuiWidget); return self; } }; pub const MessageType = enum { Information, Warning, Error }; pub fn showNativeMessageDialog(msgType: MessageType, comptime fmt: []const u8, args: anytype) void { const msg = std.fmt.allocPrintZ(lib.internal.scratch_allocator, fmt, args) catch { std.log.err("Could not launch message dialog, original text: " ++ fmt, args); return; }; defer lib.internal.scratch_allocator.free(msg); std.log.info("native message dialog (TODO): ({}) {s}", .{ msgType, msg }); } pub const PeerType = *GuiWidget; pub const MouseButton = enum { Left, Middle, Right }; pub fn init() !void { if (c.glfwInit() != 1) { return error.InitializationError; } } pub fn unexpectedGlError() !void { switch (c.glGetError()) { c.GL_INVALID_OPERATION => { return error.InvalidOperation; }, c.GL_INVALID_ENUM => { return error.InvalidEnum; }, else => |id| { std.log.warn("Unknown GL error: {d}", .{id}); return error.Unexpected; }, } } const Shader = struct { id: c.GLuint, pub fn create(shaderType: c.GLenum, source: [:0]const u8) !Shader { const id = c.glCreateShader(shaderType); if (id == 0) { try unexpectedGlError(); } c.glShaderSource(id, 1, &[_][*c]const u8{source}, null); return Shader{ .id = id }; } pub fn compile(self: Shader) !void { c.glCompileShader(self.id); var result: c.GLint = undefined; var infoLogLen: c_int = 0; c.glGetShaderiv(self.id, c.GL_COMPILE_STATUS, &result); c.glGetShaderiv(self.id, c.GL_INFO_LOG_LENGTH, &infoLogLen); if (infoLogLen > 0) { const infoLog = try lib.internal.scratch_allocator.allocSentinel(u8, @intCast(usize, infoLogLen), 0); defer lib.internal.scratch_allocator.free(infoLog); c.glGetShaderInfoLog(self.id, infoLogLen, null, infoLog.ptr); std.log.crit("shader compile error:\n{s}", .{infoLog}); return error.ShaderError; } } }; pub const Window = struct { window: *c.GLFWwindow, pub fn create() !Window { c.glfwWindowHint(c.GLFW_CLIENT_API, c.GLFW_OPENGL_ES_API); c.glfwWindowHint(c.GLFW_CONTEXT_VERSION_MAJOR, 3); c.glfwWindowHint(c.GLFW_CONTEXT_VERSION_MINOR, 0); c.glfwWindowHint(c.GLFW_OPENGL_PROFILE, c.GLFW_OPENGL_ANY_PROFILE); c.glfwWindowHint(c.GLFW_VISIBLE, c.GLFW_FALSE); //c.glfwWindowHint(c.GLFW_CONTEXT_ROBUSTNESS, c.GLFW_LOSE_CONTEXT_ON_RESET); const window = c.glfwCreateWindow(640, 400, "", null, null) orelse return error.InitializationError; c.glfwMakeContextCurrent(window); c.glfwSwapInterval(0); _ = c.glfwSetWindowRefreshCallback(window, drawWindow); var vao: c.GLuint = undefined; c.glGenVertexArrays(1, &vao); c.glBindVertexArray(vao); const bufferData = [_]f32{ -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, }; var vbo: c.GLuint = undefined; c.glGenBuffers(1, &vbo); c.glBindBuffer(c.GL_ARRAY_BUFFER, vbo); c.glBufferData(c.GL_ARRAY_BUFFER, @sizeOf(@TypeOf(bufferData)), &bufferData, c.GL_STATIC_DRAW); c.glEnableVertexAttribArray(0); c.glBindBuffer(c.GL_ARRAY_BUFFER, vbo); c.glVertexAttribPointer(0, 2, c.GL_FLOAT, c.GL_FALSE, 0, null); std.log.info("vbo: {d}", .{vbo}); const vertex = try Shader.create(c.GL_VERTEX_SHADER, @embedFile("shaders/vertex.glsl")); try vertex.compile(); const fragment = try Shader.create(c.GL_FRAGMENT_SHADER, @embedFile("shaders/fragment.glsl")); try fragment.compile(); const program = c.glCreateProgram(); c.glAttachShader(program, vertex.id); c.glAttachShader(program, fragment.id); c.glLinkProgram(program); c.glUseProgram(program); std.log.info("program: {d}", .{program}); try activeWindows.append(window); return Window{ .window = window }; } pub fn show(self: *Window) void { c.glfwShowWindow(self.window); } pub fn resize(self: *Window, width: c_int, height: c_int) void { c.glfwSetWindowSize(self.window, width, height); } pub fn setChild(self: *Window, peer: PeerType) void { _ = self; _ = peer; } }; pub fn Events(comptime T: type) type { return struct { const Self = @This(); pub fn setupEvents() !void {} pub inline fn setUserData(self: *T, data: anytype) void { comptime { if (!std.meta.trait.isSingleItemPtr(@TypeOf(data))) { @compileError(std.fmt.comptimePrint("Expected single item pointer, got {s}", .{@typeName(@TypeOf(data))})); } } self.peer.userdata = @ptrToInt(data); } pub inline fn setCallback(self: *T, comptime eType: EventType, cb: anytype) !void { _ = cb; _ = self; //const data = getEventUserData(self.peer); switch (eType) { .Click => {}, .Draw => {}, .MouseButton => {}, .Scroll => {}, .TextChanged => {}, .Resize => {}, .KeyType => {}, } } pub fn setOpacity(self: *T, opacity: f64) void { _ = self; _ = opacity; } /// Requests a redraw pub fn requestDraw(self: *T) !void { _ = self; // TODO } pub fn getWidth(self: *const T) c_int { _ = self; //return c.gtk_widget_get_allocated_width(self.peer); return 0; } pub fn getHeight(self: *const T) c_int { _ = self; //return c.gtk_widget_get_allocated_height(self.peer); return 0; } }; } pub const TextField = struct { peer: *GuiWidget, pub usingnamespace Events(TextField); pub fn create() !TextField { return TextField{ .peer = try GuiWidget.init(lasting_allocator) }; } pub fn setText(self: *TextField, text: []const u8) void { _ = self; _ = text; } pub fn getText(self: *TextField) [:0]const u8 { _ = self; return ""; } }; pub const Button = struct { peer: *GuiWidget, pub usingnamespace Events(Button); pub fn create() !Button { return Button{ .peer = try GuiWidget.init(lasting_allocator) }; } pub fn setLabel(self: *Button, label: [:0]const u8) void { _ = self; _ = label; } }; pub const Container = struct { peer: *GuiWidget, pub usingnamespace Events(Container); pub fn create() !Container { return Container{ .peer = try GuiWidget.init(lasting_allocator) }; } pub fn add(self: *Container, peer: PeerType) void { _ = self; _ = peer; } pub fn move(self: *const Container, peer: PeerType, x: u32, y: u32) void { _ = self; _ = peer; _ = x; _ = y; } pub fn resize(self: *const Container, peer: PeerType, w: u32, h: u32) void { _ = w; _ = h; _ = peer; _ = self; } }; pub const Canvas = struct { pub const DrawContext = struct {}; }; fn drawWindow(cWindow: ?*c.GLFWwindow) callconv(.C) void { const window = cWindow.?; var width: c_int = undefined; var height: c_int = undefined; c.glfwGetFramebufferSize(window, &width, &height); c.glViewport(0, 0, width, height); c.glClear(c.GL_COLOR_BUFFER_BIT | c.GL_DEPTH_BUFFER_BIT); c.glUseProgram(3); c.glEnableVertexAttribArray(0); c.glVertexAttribPointer(0, 2, c.GL_FLOAT, c.GL_FALSE, 0, null); c.glBindBuffer(c.GL_ARRAY_BUFFER, 1); c.glDrawArrays(c.GL_TRIANGLES, 0, 3); c.glfwSwapBuffers(window); } pub fn runStep(step: shared.EventLoopStep) bool { for (activeWindows.items) |window| { c.glfwMakeContextCurrent(window); if (c.glfwWindowShouldClose(window) != 0) { // TODO: remove window from list c.glfwDestroyWindow(window); return false; } else { switch (step) { .Asynchronous => c.glfwPollEvents(), .Blocking => c.glfwWaitEvents(), } // TODO: check if something changed before drawing drawWindow(window); } } return activeWindows.items.len > 0; }
src/backends/gles/backend.zig
const std = @import("std"); const assert = std.debug.assert; const mem = std.mem; pub fn version_from_build(build: []const u8) !std.builtin.Version { // build format: // 19E287 (example) // xxyzzz // // major = 10 // minor = x - 4 = 19 - 4 = 15 // patch = ascii(y) - 'A' = 'E' - 'A' = 69 - 65 = 4 // answer: 10.15.4 // // note: patch is typical but with some older releases (before 10.8) zzz is considered // never return anything below 10.0.0 var result = std.builtin.Version{ .major = 10, .minor = 0, .patch = 0 }; // parse format-x var yindex: usize = 0; { while (yindex < build.len) : (yindex += 1) { if (build[yindex] < '0' or build[yindex] > '9') break; } if (yindex == 0) return result; const x = std.fmt.parseUnsigned(u16, build[0..yindex], 10) catch return error.InvalidVersion; if (x < 4) return result; result.minor = x - 4; } // parse format-y, format-z { // expect two more if (build.len < yindex + 2) return error.InvalidVersion; const y = build[yindex]; if (y < 'A') return error.InvalidVersion; var zend = yindex + 1; while (zend < build.len) { if (build[zend] < '0' or build[zend] > '9') break; zend += 1; } if (zend == yindex + 1) return error.InvalidVersion; const z = std.fmt.parseUnsigned(u16, build[yindex + 1 .. zend], 10) catch return error.InvalidVersion; result.patch = switch (result.minor) { // TODO: compiler complains without explicit @as() coercion 0 => @as(u32, switch (y) { // Cheetah: 10.0 'K' => 0, 'L' => 1, 'P' => @as(u32, block: { if (z < 13) break :block 2; break :block 3; }), 'Q' => 4, else => return error.InvalidVersion, }), 1 => @as(u32, switch (y) { // Puma: 10.1 'G' => 0, 'M' => 1, 'P' => 2, 'Q' => @as(u32, block: { if (z < 125) break :block 3; break :block 4; }), 'S' => 5, else => return error.InvalidVersion, }), 2 => @as(u32, switch (y) { // Jaguar: 10.2 'C' => 0, 'D' => 1, 'F' => 2, 'G' => 3, 'I' => 4, 'L' => @as(u32, block: { if (z < 60) break :block 5; break :block 6; }), 'R' => @as(u32, block: { if (z < 73) break :block 7; break :block 8; }), 'S' => 8, else => return error.InvalidVersion, }), 3 => @as(u32, switch (y) { // Panther: 10.3 'B' => 0, 'C' => 1, 'D' => 2, 'F' => 3, 'H' => 4, 'M' => 5, 'R' => 6, 'S' => 7, 'U' => 8, 'W' => 9, else => return error.InvalidVersion, }), 4 => @as(u32, switch (y) { // Tiger: 10.4 'A' => 0, 'B' => 1, 'C', 'E', => 2, 'F' => 3, 'G' => @as(u32, block: { if (z >= 1454) break :block 5; break :block 4; }), 'H' => 5, 'I' => 6, 'J', 'K', 'N', => 7, 'L' => 8, 'P' => 9, 'R' => 10, 'S' => 11, else => return error.InvalidVersion, }), 5 => @as(u32, switch (y) { // Leopard: 10.5 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'J' => 7, 'L' => 8, else => return error.InvalidVersion, }), 6 => @as(u32, switch (y) { // Snow Leopard: 10.6 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'F' => 4, 'H' => 5, 'J' => @as(u32, block: { if (z < 869) break :block 6; break :block 7; }), 'K' => 8, else => return error.InvalidVersion, }), 7 => @as(u32, switch (y) { // Snow Leopard: 10.6 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'G' => 5, else => return error.InvalidVersion, }), else => y - 'A', }; } return result; } test "version_from_build" { // see https://en.wikipedia.org/wiki/MacOS_version_history#Releases const known = [_][2][]const u8{ .{ "4K78", "10.0.0" }, .{ "4L13", "10.0.1" }, .{ "4P12", "10.0.2" }, .{ "4P13", "10.0.3" }, .{ "4Q12", "10.0.4" }, .{ "5G64", "10.1.0" }, .{ "5M28", "10.1.1" }, .{ "5P48", "10.1.2" }, .{ "5Q45", "10.1.3" }, .{ "5Q125", "10.1.4" }, .{ "5S60", "10.1.5" }, .{ "6C115", "10.2.0" }, .{ "6C115a", "10.2.0" }, .{ "6D52", "10.2.1" }, .{ "6F21", "10.2.2" }, .{ "6G30", "10.2.3" }, .{ "6G37", "10.2.3" }, .{ "6G50", "10.2.3" }, .{ "6I32", "10.2.4" }, .{ "6L29", "10.2.5" }, .{ "6L60", "10.2.6" }, .{ "6R65", "10.2.7" }, .{ "6R73", "10.2.8" }, .{ "6S90", "10.2.8" }, .{ "7B85", "10.3.0" }, .{ "7B86", "10.3.0" }, .{ "7C107", "10.3.1" }, .{ "7D24", "10.3.2" }, .{ "7D28", "10.3.2" }, .{ "7F44", "10.3.3" }, .{ "7H63", "10.3.4" }, .{ "7M34", "10.3.5" }, .{ "7R28", "10.3.6" }, .{ "7S215", "10.3.7" }, .{ "7U16", "10.3.8" }, .{ "7W98", "10.3.9" }, .{ "8A428", "10.4.0" }, .{ "8A432", "10.4.0" }, .{ "8B15", "10.4.1" }, .{ "8B17", "10.4.1" }, .{ "8C46", "10.4.2" }, .{ "8C47", "10.4.2" }, .{ "8E102", "10.4.2" }, .{ "8E45", "10.4.2" }, .{ "8E90", "10.4.2" }, .{ "8F46", "10.4.3" }, .{ "8G32", "10.4.4" }, .{ "8G1165", "10.4.4" }, .{ "8H14", "10.4.5" }, .{ "8G1454", "10.4.5" }, .{ "8I127", "10.4.6" }, .{ "8I1119", "10.4.6" }, .{ "8J135", "10.4.7" }, .{ "8J2135a", "10.4.7" }, .{ "8K1079", "10.4.7" }, .{ "8N5107", "10.4.7" }, .{ "8L127", "10.4.8" }, .{ "8L2127", "10.4.8" }, .{ "8P135", "10.4.9" }, .{ "8P2137", "10.4.9" }, .{ "8R218", "10.4.10" }, .{ "8R2218", "10.4.10" }, .{ "8R2232", "10.4.10" }, .{ "8S165", "10.4.11" }, .{ "8S2167", "10.4.11" }, .{ "9A581", "10.5.0" }, .{ "9B18", "10.5.1" }, .{ "9C31", "10.5.2" }, .{ "9C7010", "10.5.2" }, .{ "9D34", "10.5.3" }, .{ "9E17", "10.5.4" }, .{ "9F33", "10.5.5" }, .{ "9G55", "10.5.6" }, .{ "9G66", "10.5.6" }, .{ "9J61", "10.5.7" }, .{ "9L30", "10.5.8" }, .{ "10A432", "10.6.0" }, .{ "10A433", "10.6.0" }, .{ "10B504", "10.6.1" }, .{ "10C540", "10.6.2" }, .{ "10D573", "10.6.3" }, .{ "10D575", "10.6.3" }, .{ "10D578", "10.6.3" }, .{ "10F569", "10.6.4" }, .{ "10H574", "10.6.5" }, .{ "10J567", "10.6.6" }, .{ "10J869", "10.6.7" }, .{ "10J3250", "10.6.7" }, .{ "10J4138", "10.6.7" }, .{ "10K540", "10.6.8" }, .{ "10K549", "10.6.8" }, .{ "11A511", "10.7.0" }, .{ "11A511s", "10.7.0" }, .{ "11A2061", "10.7.0" }, .{ "11A2063", "10.7.0" }, .{ "11B26", "10.7.1" }, .{ "11B2118", "10.7.1" }, .{ "11C74", "10.7.2" }, .{ "11D50", "10.7.3" }, .{ "11E53", "10.7.4" }, .{ "11G56", "10.7.5" }, .{ "11G63", "10.7.5" }, .{ "12A269", "10.8.0" }, .{ "12B19", "10.8.1" }, .{ "12C54", "10.8.2" }, .{ "12C60", "10.8.2" }, .{ "12C2034", "10.8.2" }, .{ "12C3104", "10.8.2" }, .{ "12D78", "10.8.3" }, .{ "12E55", "10.8.4" }, .{ "12E3067", "10.8.4" }, .{ "12E4022", "10.8.4" }, .{ "12F37", "10.8.5" }, .{ "12F45", "10.8.5" }, .{ "12F2501", "10.8.5" }, .{ "12F2518", "10.8.5" }, .{ "12F2542", "10.8.5" }, .{ "12F2560", "10.8.5" }, .{ "13A603", "10.9.0" }, .{ "13B42", "10.9.1" }, .{ "13C64", "10.9.2" }, .{ "13C1021", "10.9.2" }, .{ "13D65", "10.9.3" }, .{ "13E28", "10.9.4" }, .{ "13F34", "10.9.5" }, .{ "13F1066", "10.9.5" }, .{ "13F1077", "10.9.5" }, .{ "13F1096", "10.9.5" }, .{ "13F1112", "10.9.5" }, .{ "13F1134", "10.9.5" }, .{ "13F1507", "10.9.5" }, .{ "13F1603", "10.9.5" }, .{ "13F1712", "10.9.5" }, .{ "13F1808", "10.9.5" }, .{ "13F1911", "10.9.5" }, .{ "14A389", "10.10.0" }, .{ "14B25", "10.10.1" }, .{ "14C109", "10.10.2" }, .{ "14C1510", "10.10.2" }, .{ "14C1514", "10.10.2" }, .{ "14C2043", "10.10.2" }, .{ "14C2513", "10.10.2" }, .{ "14D131", "10.10.3" }, .{ "14D136", "10.10.3" }, .{ "14E46", "10.10.4" }, .{ "14F27", "10.10.5" }, .{ "14F1021", "10.10.5" }, .{ "14F1505", "10.10.5" }, .{ "14F1509", "10.10.5" }, .{ "14F1605", "10.10.5" }, .{ "14F1713", "10.10.5" }, .{ "14F1808", "10.10.5" }, .{ "14F1909", "10.10.5" }, .{ "14F1912", "10.10.5" }, .{ "14F2009", "10.10.5" }, .{ "14F2109", "10.10.5" }, .{ "14F2315", "10.10.5" }, .{ "14F2411", "10.10.5" }, .{ "14F2511", "10.10.5" }, .{ "15A284", "10.11.0" }, .{ "15B42", "10.11.1" }, .{ "15C50", "10.11.2" }, .{ "15D21", "10.11.3" }, .{ "15E65", "10.11.4" }, .{ "15F34", "10.11.5" }, .{ "15G31", "10.11.6" }, .{ "15G1004", "10.11.6" }, .{ "15G1011", "10.11.6" }, .{ "15G1108", "10.11.6" }, .{ "15G1212", "10.11.6" }, .{ "15G1217", "10.11.6" }, .{ "15G1421", "10.11.6" }, .{ "15G1510", "10.11.6" }, .{ "15G1611", "10.11.6" }, .{ "15G17023", "10.11.6" }, .{ "15G18013", "10.11.6" }, .{ "15G19009", "10.11.6" }, .{ "15G20015", "10.11.6" }, .{ "15G21013", "10.11.6" }, .{ "15G22010", "10.11.6" }, .{ "16A323", "10.12.0" }, .{ "16B2555", "10.12.1" }, .{ "16B2657", "10.12.1" }, .{ "16C67", "10.12.2" }, .{ "16C68", "10.12.2" }, .{ "16D32", "10.12.3" }, .{ "16E195", "10.12.4" }, .{ "16F73", "10.12.5" }, .{ "16F2073", "10.12.5" }, .{ "16G29", "10.12.6" }, .{ "16G1036", "10.12.6" }, .{ "16G1114", "10.12.6" }, .{ "16G1212", "10.12.6" }, .{ "16G1314", "10.12.6" }, .{ "16G1408", "10.12.6" }, .{ "16G1510", "10.12.6" }, .{ "16G1618", "10.12.6" }, .{ "16G1710", "10.12.6" }, .{ "16G1815", "10.12.6" }, .{ "16G1917", "10.12.6" }, .{ "16G1918", "10.12.6" }, .{ "16G2016", "10.12.6" }, .{ "16G2127", "10.12.6" }, .{ "16G2128", "10.12.6" }, .{ "16G2136", "10.12.6" }, .{ "17A365", "10.13.0" }, .{ "17A405", "10.13.0" }, .{ "17B48", "10.13.1" }, .{ "17B1002", "10.13.1" }, .{ "17B1003", "10.13.1" }, .{ "17C88", "10.13.2" }, .{ "17C89", "10.13.2" }, .{ "17C205", "10.13.2" }, .{ "17C2205", "10.13.2" }, .{ "17D47", "10.13.3" }, .{ "17D2047", "10.13.3" }, .{ "17D102", "10.13.3" }, .{ "17D2102", "10.13.3" }, .{ "17E199", "10.13.4" }, .{ "17E202", "10.13.4" }, .{ "17F77", "10.13.5" }, .{ "17G65", "10.13.6" }, .{ "17G2208", "10.13.6" }, .{ "17G3025", "10.13.6" }, .{ "17G4015", "10.13.6" }, .{ "17G5019", "10.13.6" }, .{ "17G6029", "10.13.6" }, .{ "17G6030", "10.13.6" }, .{ "17G7024", "10.13.6" }, .{ "17G8029", "10.13.6" }, .{ "17G8030", "10.13.6" }, .{ "17G8037", "10.13.6" }, .{ "17G9016", "10.13.6" }, .{ "17G10021", "10.13.6" }, .{ "17G11023", "10.13.6" }, .{ "17G12034", "10.13.6" }, .{ "18A391", "10.14.0" }, .{ "18B75", "10.14.1" }, .{ "18B2107", "10.14.1" }, .{ "18B3094", "10.14.1" }, .{ "18C54", "10.14.2" }, .{ "18D42", "10.14.3" }, .{ "18D43", "10.14.3" }, .{ "18D109", "10.14.3" }, .{ "18E226", "10.14.4" }, .{ "18E227", "10.14.4" }, .{ "18F132", "10.14.5" }, .{ "18G84", "10.14.6" }, .{ "18G87", "10.14.6" }, .{ "18G95", "10.14.6" }, .{ "18G103", "10.14.6" }, .{ "18G1012", "10.14.6" }, .{ "18G2022", "10.14.6" }, .{ "18G3020", "10.14.6" }, .{ "18G4032", "10.14.6" }, .{ "19A583", "10.15.0" }, .{ "19A602", "10.15.0" }, .{ "19A603", "10.15.0" }, .{ "19B88", "10.15.1" }, .{ "19C57", "10.15.2" }, .{ "19D76", "10.15.3" }, .{ "19E266", "10.15.4" }, .{ "19E287", "10.15.4" }, }; for (known) |pair| { var buf: [32]u8 = undefined; const ver = try version_from_build(pair[0]); const sver = try std.fmt.bufPrint(buf[0..], "{}.{}.{}", .{ ver.major, ver.minor, ver.patch }); std.testing.expect(std.mem.eql(u8, sver, pair[1])); } } /// Detect SDK path on Darwin. /// Calls `xcrun --show-sdk-path` which result can be used to specify /// `-syslibroot` param of the linker. /// The caller needs to free the resulting path slice. pub fn getSDKPath(allocator: *mem.Allocator) ![]u8 { assert(std.Target.current.isDarwin()); const argv = &[_][]const u8{ "xcrun", "--show-sdk-path" }; const result = try std.ChildProcess.exec(.{ .allocator = allocator, .argv = argv }); defer { allocator.free(result.stderr); allocator.free(result.stdout); } if (result.stderr.len != 0) { std.log.err("unexpected 'xcrun --show-sdk-path' stderr: {}", .{result.stderr}); } if (result.term.Exited != 0) { return error.ProcessTerminated; } const syslibroot = mem.trimRight(u8, result.stdout, "\r\n"); return mem.dupe(allocator, u8, syslibroot); }
lib/std/zig/system/macos.zig
const std = @import("index.zig"); const debug = std.debug; const assert = debug.assert; const math = std.math; const mem = std.mem; const Allocator = mem.Allocator; const builtin = @import("builtin"); const want_modification_safety = builtin.mode != builtin.Mode.ReleaseFast; const debug_u32 = if (want_modification_safety) u32 else void; pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u32, comptime eql: fn (a: K, b: K) bool) type { return struct { entries: []Entry, size: usize, max_distance_from_start_index: usize, allocator: *Allocator, // this is used to detect bugs where a hashtable is edited while an iterator is running. modification_count: debug_u32, const Self = this; pub const Entry = struct { used: bool, distance_from_start_index: usize, key: K, value: V, }; pub const Iterator = struct { hm: *const Self, // how many items have we returned count: usize, // iterator through the entry array index: usize, // used to detect concurrent modification initial_modification_count: debug_u32, pub fn next(it: *Iterator) ?*Entry { if (want_modification_safety) { assert(it.initial_modification_count == it.hm.modification_count); // concurrent modification } if (it.count >= it.hm.size) return null; while (it.index < it.hm.entries.len) : (it.index += 1) { const entry = &it.hm.entries[it.index]; if (entry.used) { it.index += 1; it.count += 1; return entry; } } unreachable; // no next item } // Reset the iterator to the initial index pub fn reset(it: *Iterator) void { it.count = 0; it.index = 0; // Resetting the modification count too it.initial_modification_count = it.hm.modification_count; } }; pub fn init(allocator: *Allocator) Self { return Self{ .entries = []Entry{}, .allocator = allocator, .size = 0, .max_distance_from_start_index = 0, .modification_count = if (want_modification_safety) 0 else {}, }; } pub fn deinit(hm: *const Self) void { hm.allocator.free(hm.entries); } pub fn clear(hm: *Self) void { for (hm.entries) |*entry| { entry.used = false; } hm.size = 0; hm.max_distance_from_start_index = 0; hm.incrementModificationCount(); } pub fn count(hm: *const Self) usize { return hm.size; } /// Returns the value that was already there. pub fn put(hm: *Self, key: K, value: *const V) !?V { if (hm.entries.len == 0) { try hm.initCapacity(16); } hm.incrementModificationCount(); // if we get too full (60%), double the capacity if (hm.size * 5 >= hm.entries.len * 3) { const old_entries = hm.entries; try hm.initCapacity(hm.entries.len * 2); // dump all of the old elements into the new table for (old_entries) |*old_entry| { if (old_entry.used) { _ = hm.internalPut(old_entry.key, old_entry.value); } } hm.allocator.free(old_entries); } return hm.internalPut(key, value); } pub fn get(hm: *const Self, key: K) ?*Entry { if (hm.entries.len == 0) { return null; } return hm.internalGet(key); } pub fn contains(hm: *const Self, key: K) bool { return hm.get(key) != null; } pub fn remove(hm: *Self, key: K) ?*Entry { if (hm.entries.len == 0) return null; hm.incrementModificationCount(); const start_index = hm.keyToIndex(key); { var roll_over: usize = 0; while (roll_over <= hm.max_distance_from_start_index) : (roll_over += 1) { const index = (start_index + roll_over) % hm.entries.len; var entry = &hm.entries[index]; if (!entry.used) return null; if (!eql(entry.key, key)) continue; while (roll_over < hm.entries.len) : (roll_over += 1) { const next_index = (start_index + roll_over + 1) % hm.entries.len; const next_entry = &hm.entries[next_index]; if (!next_entry.used or next_entry.distance_from_start_index == 0) { entry.used = false; hm.size -= 1; return entry; } entry.* = next_entry.*; entry.distance_from_start_index -= 1; entry = next_entry; } unreachable; // shifting everything in the table } } return null; } pub fn iterator(hm: *const Self) Iterator { return Iterator{ .hm = hm, .count = 0, .index = 0, .initial_modification_count = hm.modification_count, }; } fn initCapacity(hm: *Self, capacity: usize) !void { hm.entries = try hm.allocator.alloc(Entry, capacity); hm.size = 0; hm.max_distance_from_start_index = 0; for (hm.entries) |*entry| { entry.used = false; } } fn incrementModificationCount(hm: *Self) void { if (want_modification_safety) { hm.modification_count +%= 1; } } /// Returns the value that was already there. fn internalPut(hm: *Self, orig_key: K, orig_value: *const V) ?V { var key = orig_key; var value = orig_value.*; const start_index = hm.keyToIndex(key); var roll_over: usize = 0; var distance_from_start_index: usize = 0; while (roll_over < hm.entries.len) : ({ roll_over += 1; distance_from_start_index += 1; }) { const index = (start_index + roll_over) % hm.entries.len; const entry = &hm.entries[index]; if (entry.used and !eql(entry.key, key)) { if (entry.distance_from_start_index < distance_from_start_index) { // robin hood to the rescue const tmp = entry.*; hm.max_distance_from_start_index = math.max(hm.max_distance_from_start_index, distance_from_start_index); entry.* = Entry{ .used = true, .distance_from_start_index = distance_from_start_index, .key = key, .value = value, }; key = tmp.key; value = tmp.value; distance_from_start_index = tmp.distance_from_start_index; } continue; } var result: ?V = null; if (entry.used) { result = entry.value; } else { // adding an entry. otherwise overwriting old value with // same key hm.size += 1; } hm.max_distance_from_start_index = math.max(distance_from_start_index, hm.max_distance_from_start_index); entry.* = Entry{ .used = true, .distance_from_start_index = distance_from_start_index, .key = key, .value = value, }; return result; } unreachable; // put into a full map } fn internalGet(hm: *const Self, key: K) ?*Entry { const start_index = hm.keyToIndex(key); { var roll_over: usize = 0; while (roll_over <= hm.max_distance_from_start_index) : (roll_over += 1) { const index = (start_index + roll_over) % hm.entries.len; const entry = &hm.entries[index]; if (!entry.used) return null; if (eql(entry.key, key)) return entry; } } return null; } fn keyToIndex(hm: *const Self, key: K) usize { return usize(hash(key)) % hm.entries.len; } }; } test "basic hash map usage" { var direct_allocator = std.heap.DirectAllocator.init(); defer direct_allocator.deinit(); var map = HashMap(i32, i32, hash_i32, eql_i32).init(&direct_allocator.allocator); defer map.deinit(); assert((map.put(1, 11) catch unreachable) == null); assert((map.put(2, 22) catch unreachable) == null); assert((map.put(3, 33) catch unreachable) == null); assert((map.put(4, 44) catch unreachable) == null); assert((map.put(5, 55) catch unreachable) == null); assert((map.put(5, 66) catch unreachable).? == 55); assert((map.put(5, 55) catch unreachable).? == 66); assert(map.contains(2)); assert(map.get(2).?.value == 22); _ = map.remove(2); assert(map.remove(2) == null); assert(map.get(2) == null); } test "iterator hash map" { var direct_allocator = std.heap.DirectAllocator.init(); defer direct_allocator.deinit(); var reset_map = HashMap(i32, i32, hash_i32, eql_i32).init(&direct_allocator.allocator); defer reset_map.deinit(); assert((reset_map.put(1, 11) catch unreachable) == null); assert((reset_map.put(2, 22) catch unreachable) == null); assert((reset_map.put(3, 33) catch unreachable) == null); var keys = []i32{ 1, 2, 3, }; var values = []i32{ 11, 22, 33, }; var it = reset_map.iterator(); var count: usize = 0; while (it.next()) |next| { assert(next.key == keys[count]); assert(next.value == values[count]); count += 1; } assert(count == 3); assert(it.next() == null); it.reset(); count = 0; while (it.next()) |next| { assert(next.key == keys[count]); assert(next.value == values[count]); count += 1; if (count == 2) break; } it.reset(); var entry = it.next().?; assert(entry.key == keys[0]); assert(entry.value == values[0]); } fn hash_i32(x: i32) u32 { return @bitCast(u32, x); } fn eql_i32(a: i32, b: i32) bool { return a == b; }
std/hash_map.zig
const Mir = @This(); const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const bits = @import("bits.zig"); const Register = bits.Register; instructions: std.MultiArrayList(Inst).Slice, /// The meaning of this data is determined by `Inst.Tag` value. extra: []const u32, pub const Inst = struct { tag: Tag, /// The meaning of this depends on `tag`. data: Data, pub const Tag = enum(u16) { /// Add (immediate) add_immediate, /// Branch conditionally b_cond, /// Branch b, /// Branch with Link bl, /// Branch with Link to Register blr, /// Breakpoint brk, /// Pseudo-instruction: Call extern call_extern, /// Compare (immediate) cmp_immediate, /// Compare (shifted register) cmp_shifted_register, /// Conditional set cset, /// Pseudo-instruction: End of prologue dbg_prologue_end, /// Pseudo-instruction: Beginning of epilogue dbg_epilogue_begin, /// Pseudo-instruction: Update debug line dbg_line, /// Pseudo-instruction: Load memory /// /// Payload is `LoadMemory` load_memory, /// Load Pair of Registers ldp, /// Load Register // TODO: split into ldr_immediate and ldr_register ldr, /// Load Register Byte // TODO: split into ldrb_immediate and ldrb_register ldrb, /// Load Register Halfword // TODO: split into ldrh_immediate and ldrh_register ldrh, /// Move (to/from SP) mov_to_from_sp, /// Move (register) mov_register, /// Move wide with keep movk, /// Move wide with zero movz, /// No Operation nop, /// Return from subroutine ret, /// Store Pair of Registers stp, /// Store Register // TODO: split into str_immediate and str_register str, /// Store Register Byte // TODO: split into strb_immediate and strb_register strb, /// Store Register Halfword // TODO: split into strh_immediate and strh_register strh, /// Subtract (immediate) sub_immediate, /// Supervisor Call svc, }; /// The position of an MIR instruction within the `Mir` instructions array. pub const Index = u32; /// All instructions have a 4-byte payload, which is contained within /// this union. `Tag` determines which union field is active, as well as /// how to interpret the data within. pub const Data = union { /// No additional data /// /// Used by e.g. nop nop: void, /// Another instruction /// /// Used by e.g. b inst: Index, /// An extern function /// /// Used by e.g. call_extern extern_fn: u32, /// A 16-bit immediate value. /// /// Used by e.g. svc imm16: u16, /// Index into `extra`. Meaning of what can be found there is context-dependent. /// /// Used by e.g. load_memory payload: u32, /// A register /// /// Used by e.g. blr reg: Register, /// Another instruction and a condition /// /// Used by e.g. b_cond inst_cond: struct { inst: Index, cond: bits.Instruction.Condition, }, /// A register, an unsigned 16-bit immediate, and an optional shift /// /// Used by e.g. movz r_imm16_sh: struct { rd: Register, imm16: u16, hw: u2 = 0, }, /// Two registers /// /// Used by e.g. mov_register rr: struct { rd: Register, rn: Register, }, /// Two registers, an unsigned 12-bit immediate, and an optional shift /// /// Used by e.g. sub_immediate rr_imm12_sh: struct { rd: Register, rn: Register, imm12: u12, sh: u1 = 0, }, /// Three registers and a shift (shift type and 6-bit amount) /// /// Used by e.g. cmp_shifted_register rrr_imm6_shift: struct { rd: Register, rn: Register, rm: Register, imm6: u6, shift: bits.Instruction.AddSubtractShiftedRegisterShift, }, /// Three registers and a condition /// /// Used by e.g. cset rrr_cond: struct { rd: Register, rn: Register, rm: Register, cond: bits.Instruction.Condition, }, /// Three registers and a LoadStoreOffset /// /// Used by e.g. str_register load_store_register: struct { rt: Register, rn: Register, offset: bits.Instruction.LoadStoreOffset, }, /// Three registers and a LoadStorePairOffset /// /// Used by e.g. stp load_store_register_pair: struct { rt: Register, rt2: Register, rn: Register, offset: bits.Instruction.LoadStorePairOffset, }, /// Debug info: line and column /// /// Used by e.g. dbg_line dbg_line_column: struct { line: u32, column: u32, }, }; // Make sure we don't accidentally make instructions bigger than expected. // Note that in Debug builds, Zig is allowed to insert a secret field for safety checks. // comptime { // if (builtin.mode != .Debug) { // assert(@sizeOf(Inst) == 8); // } // } }; pub fn deinit(mir: *Mir, gpa: *std.mem.Allocator) void { mir.instructions.deinit(gpa); gpa.free(mir.extra); mir.* = undefined; } /// Returns the requested data, as well as the new index which is at the start of the /// trailers for the object. pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end: usize } { const fields = std.meta.fields(T); var i: usize = index; var result: T = undefined; inline for (fields) |field| { @field(result, field.name) = switch (field.field_type) { u32 => mir.extra[i], i32 => @bitCast(i32, mir.extra[i]), else => @compileError("bad field type"), }; i += 1; } return .{ .data = result, .end = i, }; } pub const LoadMemory = struct { register: u32, addr: u32, };
src/arch/aarch64/Mir.zig
const std = @import("../../std.zig"); const debug = std.debug; const math = std.math; const mem = std.mem; const testing = std.testing; const Allocator = mem.Allocator; const bn = @import("int.zig"); const Limb = bn.Limb; const DoubleLimb = bn.DoubleLimb; const Int = bn.Int; /// An arbitrary-precision rational number. /// /// Memory is allocated as needed for operations to ensure full precision is kept. The precision /// of a Rational is only bounded by memory. /// /// Rational's are always normalized. That is, for a Rational r = p/q where p and q are integers, /// gcd(p, q) = 1 always. pub const Rational = struct { /// Numerator. Determines the sign of the Rational. p: Int, /// Denominator. Sign is ignored. q: Int, /// Create a new Rational. A small amount of memory will be allocated on initialization. /// This will be 2 * Int.default_capacity. pub fn init(a: *Allocator) !Rational { return Rational{ .p = try Int.init(a), .q = try Int.initSet(a, 1), }; } /// Frees all memory associated with a Rational. pub fn deinit(self: *Rational) void { self.p.deinit(); self.q.deinit(); } /// Set a Rational from a primitive integer type. pub fn setInt(self: *Rational, a: var) !void { try self.p.set(a); try self.q.set(1); } /// Set a Rational from a string of the form `A/B` where A and B are base-10 integers. pub fn setFloatString(self: *Rational, str: []const u8) !void { // TODO: Accept a/b fractions and exponent form if (str.len == 0) { return error.InvalidFloatString; } const State = enum { Integer, Fractional, }; var state = State.Integer; var point: ?usize = null; var start: usize = 0; if (str[0] == '-') { start += 1; } for (str) |c, i| { switch (state) { State.Integer => { switch (c) { '.' => { state = State.Fractional; point = i; }, '0'...'9' => { // okay }, else => { return error.InvalidFloatString; }, } }, State.Fractional => { switch (c) { '0'...'9' => { // okay }, else => { return error.InvalidFloatString; }, } }, } } // TODO: batch the multiplies by 10 if (point) |i| { try self.p.setString(10, str[0..i]); const base = Int.initFixed(([_]Limb{10})[0..]); var j: usize = start; while (j < str.len - i - 1) : (j += 1) { try self.p.mul(self.p, base); } try self.q.setString(10, str[i + 1 ..]); try self.p.add(self.p, self.q); try self.q.set(1); var k: usize = i + 1; while (k < str.len) : (k += 1) { try self.q.mul(self.q, base); } try self.reduce(); } else { try self.p.setString(10, str[0..]); try self.q.set(1); } } /// Set a Rational from a floating-point value. The rational will have enough precision to /// completely represent the provided float. pub fn setFloat(self: *Rational, comptime T: type, f: T) !void { // Translated from golang.go/src/math/big/rat.go. debug.assert(@typeInfo(T) == .Float); const UnsignedIntType = std.meta.IntType(false, T.bit_count); const f_bits = @bitCast(UnsignedIntType, f); const exponent_bits = math.floatExponentBits(T); const exponent_bias = (1 << (exponent_bits - 1)) - 1; const mantissa_bits = math.floatMantissaBits(T); const exponent_mask = (1 << exponent_bits) - 1; const mantissa_mask = (1 << mantissa_bits) - 1; var exponent = @intCast(i16, (f_bits >> mantissa_bits) & exponent_mask); var mantissa = f_bits & mantissa_mask; switch (exponent) { exponent_mask => { return error.NonFiniteFloat; }, 0 => { // denormal exponent -= exponent_bias - 1; }, else => { // normal mantissa |= 1 << mantissa_bits; exponent -= exponent_bias; }, } var shift: i16 = mantissa_bits - exponent; // factor out powers of two early from rational while (mantissa & 1 == 0 and shift > 0) { mantissa >>= 1; shift -= 1; } try self.p.set(mantissa); self.p.setSign(f >= 0); try self.q.set(1); if (shift >= 0) { try self.q.shiftLeft(self.q, @intCast(usize, shift)); } else { try self.p.shiftLeft(self.p, @intCast(usize, -shift)); } try self.reduce(); } /// Return a floating-point value that is the closest value to a Rational. /// /// The result may not be exact if the Rational is too precise or too large for the /// target type. pub fn toFloat(self: Rational, comptime T: type) !T { // Translated from golang.go/src/math/big/rat.go. // TODO: Indicate whether the result is not exact. debug.assert(@typeInfo(T) == .Float); const fsize = T.bit_count; const BitReprType = std.meta.IntType(false, T.bit_count); const msize = math.floatMantissaBits(T); const msize1 = msize + 1; const msize2 = msize1 + 1; const esize = math.floatExponentBits(T); const ebias = (1 << (esize - 1)) - 1; const emin = 1 - ebias; const emax = ebias; if (self.p.eqZero()) { return 0; } // 1. left-shift a or sub so that a/b is in [1 << msize1, 1 << (msize2 + 1)] var exp = @intCast(isize, self.p.bitCountTwosComp()) - @intCast(isize, self.q.bitCountTwosComp()); var a2 = try self.p.clone(); defer a2.deinit(); var b2 = try self.q.clone(); defer b2.deinit(); const shift = msize2 - exp; if (shift >= 0) { try a2.shiftLeft(a2, @intCast(usize, shift)); } else { try b2.shiftLeft(b2, @intCast(usize, -shift)); } // 2. compute quotient and remainder var q = try Int.init(self.p.allocator.?); defer q.deinit(); // unused var r = try Int.init(self.p.allocator.?); defer r.deinit(); try Int.divTrunc(&q, &r, a2, b2); var mantissa = extractLowBits(q, BitReprType); var have_rem = r.len() > 0; // 3. q didn't fit in msize2 bits, redo division b2 << 1 if (mantissa >> msize2 == 1) { if (mantissa & 1 == 1) { have_rem = true; } mantissa >>= 1; exp += 1; } if (mantissa >> msize1 != 1) { // NOTE: This can be hit if the limb size is small (u8/16). @panic("unexpected bits in result"); } // 4. Rounding if (emin - msize <= exp and exp <= emin) { // denormal const shift1 = @intCast(math.Log2Int(BitReprType), emin - (exp - 1)); const lost_bits = mantissa & ((@intCast(BitReprType, 1) << shift1) - 1); have_rem = have_rem or lost_bits != 0; mantissa >>= shift1; exp = 2 - ebias; } // round q using round-half-to-even var exact = !have_rem; if (mantissa & 1 != 0) { exact = false; if (have_rem or (mantissa & 2 != 0)) { mantissa += 1; if (mantissa >= 1 << msize2) { // 11...1 => 100...0 mantissa >>= 1; exp += 1; } } } mantissa >>= 1; const f = math.scalbn(@intToFloat(T, mantissa), @intCast(i32, exp - msize1)); if (math.isInf(f)) { exact = false; } return if (self.p.isPositive()) f else -f; } /// Set a rational from an integer ratio. pub fn setRatio(self: *Rational, p: var, q: var) !void { try self.p.set(p); try self.q.set(q); self.p.setSign(@boolToInt(self.p.isPositive()) ^ @boolToInt(self.q.isPositive()) == 0); self.q.setSign(true); try self.reduce(); if (self.q.eqZero()) { @panic("cannot set rational with denominator = 0"); } } /// Set a Rational directly from an Int. pub fn copyInt(self: *Rational, a: Int) !void { try self.p.copy(a); try self.q.set(1); } /// Set a Rational directly from a ratio of two Int's. pub fn copyRatio(self: *Rational, a: Int, b: Int) !void { try self.p.copy(a); try self.q.copy(b); self.p.setSign(@boolToInt(self.p.isPositive()) ^ @boolToInt(self.q.isPositive()) == 0); self.q.setSign(true); try self.reduce(); } /// Make a Rational positive. pub fn abs(r: *Rational) void { r.p.abs(); } /// Negate the sign of a Rational. pub fn negate(r: *Rational) void { r.p.negate(); } /// Efficiently swap a Rational with another. This swaps the limb pointers and a full copy is not /// performed. The address of the limbs field will not be the same after this function. pub fn swap(r: *Rational, other: *Rational) void { r.p.swap(&other.p); r.q.swap(&other.q); } /// Returns math.Order.lt, math.Order.eq, math.Order.gt if a < b, a == b or a /// > b respectively. pub fn cmp(a: Rational, b: Rational) !math.Order { return cmpInternal(a, b, true); } /// Returns math.Order.lt, math.Order.eq, math.Order.gt if |a| < |b|, |a| == /// |b| or |a| > |b| respectively. pub fn cmpAbs(a: Rational, b: Rational) !math.Order { return cmpInternal(a, b, false); } // p/q > x/y iff p*y > x*q fn cmpInternal(a: Rational, b: Rational, is_abs: bool) !math.Order { // TODO: Would a div compare algorithm of sorts be viable and quicker? Can we avoid // the memory allocations here? var q = try Int.init(a.p.allocator.?); defer q.deinit(); var p = try Int.init(b.p.allocator.?); defer p.deinit(); try q.mul(a.p, b.q); try p.mul(b.p, a.q); return if (is_abs) q.cmpAbs(p) else q.cmp(p); } /// rma = a + b. /// /// rma, a and b may be aliases. However, it is more efficient if rma does not alias a or b. /// /// Returns an error if memory could not be allocated. pub fn add(rma: *Rational, a: Rational, b: Rational) !void { var r = rma; var aliased = rma.p.limbs.ptr == a.p.limbs.ptr or rma.p.limbs.ptr == b.p.limbs.ptr; var sr: Rational = undefined; if (aliased) { sr = try Rational.init(rma.p.allocator.?); r = &sr; aliased = true; } defer if (aliased) { rma.swap(r); r.deinit(); }; try r.p.mul(a.p, b.q); try r.q.mul(b.p, a.q); try r.p.add(r.p, r.q); try r.q.mul(a.q, b.q); try r.reduce(); } /// rma = a - b. /// /// rma, a and b may be aliases. However, it is more efficient if rma does not alias a or b. /// /// Returns an error if memory could not be allocated. pub fn sub(rma: *Rational, a: Rational, b: Rational) !void { var r = rma; var aliased = rma.p.limbs.ptr == a.p.limbs.ptr or rma.p.limbs.ptr == b.p.limbs.ptr; var sr: Rational = undefined; if (aliased) { sr = try Rational.init(rma.p.allocator.?); r = &sr; aliased = true; } defer if (aliased) { rma.swap(r); r.deinit(); }; try r.p.mul(a.p, b.q); try r.q.mul(b.p, a.q); try r.p.sub(r.p, r.q); try r.q.mul(a.q, b.q); try r.reduce(); } /// rma = a * b. /// /// rma, a and b may be aliases. However, it is more efficient if rma does not alias a or b. /// /// Returns an error if memory could not be allocated. pub fn mul(r: *Rational, a: Rational, b: Rational) !void { try r.p.mul(a.p, b.p); try r.q.mul(a.q, b.q); try r.reduce(); } /// rma = a / b. /// /// rma, a and b may be aliases. However, it is more efficient if rma does not alias a or b. /// /// Returns an error if memory could not be allocated. pub fn div(r: *Rational, a: Rational, b: Rational) !void { if (b.p.eqZero()) { @panic("division by zero"); } try r.p.mul(a.p, b.q); try r.q.mul(b.p, a.q); try r.reduce(); } /// Invert the numerator and denominator fields of a Rational. p/q => q/p. pub fn invert(r: *Rational) void { Int.swap(&r.p, &r.q); } // reduce r/q such that gcd(r, q) = 1 fn reduce(r: *Rational) !void { var a = try Int.init(r.p.allocator.?); defer a.deinit(); const sign = r.p.isPositive(); r.p.abs(); try a.gcd(r.p, r.q); r.p.setSign(sign); const one = Int.initFixed(([_]Limb{1})[0..]); if (a.cmp(one) != .eq) { var unused = try Int.init(r.p.allocator.?); defer unused.deinit(); // TODO: divexact would be useful here // TODO: don't copy r.q for div try Int.divTrunc(&r.p, &unused, r.p, a); try Int.divTrunc(&r.q, &unused, r.q, a); } } }; fn extractLowBits(a: Int, comptime T: type) T { testing.expect(@typeInfo(T) == .Int); if (T.bit_count <= Limb.bit_count) { return @truncate(T, a.limbs[0]); } else { var r: T = 0; comptime var i: usize = 0; // Remainder is always 0 since if T.bit_count >= Limb.bit_count -> Limb | T and both // are powers of two. inline while (i < T.bit_count / Limb.bit_count) : (i += 1) { r |= math.shl(T, a.limbs[i], i * Limb.bit_count); } return r; } } test "big.rational extractLowBits" { var a = try Int.initSet(testing.allocator, 0x11112222333344441234567887654321); defer a.deinit(); const a1 = extractLowBits(a, u8); testing.expect(a1 == 0x21); const a2 = extractLowBits(a, u16); testing.expect(a2 == 0x4321); const a3 = extractLowBits(a, u32); testing.expect(a3 == 0x87654321); const a4 = extractLowBits(a, u64); testing.expect(a4 == 0x1234567887654321); const a5 = extractLowBits(a, u128); testing.expect(a5 == 0x11112222333344441234567887654321); } test "big.rational set" { var a = try Rational.init(testing.allocator); defer a.deinit(); try a.setInt(5); testing.expect((try a.p.to(u32)) == 5); testing.expect((try a.q.to(u32)) == 1); try a.setRatio(7, 3); testing.expect((try a.p.to(u32)) == 7); testing.expect((try a.q.to(u32)) == 3); try a.setRatio(9, 3); testing.expect((try a.p.to(i32)) == 3); testing.expect((try a.q.to(i32)) == 1); try a.setRatio(-9, 3); testing.expect((try a.p.to(i32)) == -3); testing.expect((try a.q.to(i32)) == 1); try a.setRatio(9, -3); testing.expect((try a.p.to(i32)) == -3); testing.expect((try a.q.to(i32)) == 1); try a.setRatio(-9, -3); testing.expect((try a.p.to(i32)) == 3); testing.expect((try a.q.to(i32)) == 1); } test "big.rational setFloat" { var a = try Rational.init(testing.allocator); defer a.deinit(); try a.setFloat(f64, 2.5); testing.expect((try a.p.to(i32)) == 5); testing.expect((try a.q.to(i32)) == 2); try a.setFloat(f32, -2.5); testing.expect((try a.p.to(i32)) == -5); testing.expect((try a.q.to(i32)) == 2); try a.setFloat(f32, 3.141593); // = 3.14159297943115234375 testing.expect((try a.p.to(u32)) == 3294199); testing.expect((try a.q.to(u32)) == 1048576); try a.setFloat(f64, 72.141593120712409172417410926841290461290467124); // = 72.1415931207124145885245525278151035308837890625 testing.expect((try a.p.to(u128)) == 5076513310880537); testing.expect((try a.q.to(u128)) == 70368744177664); } test "big.rational setFloatString" { var a = try Rational.init(testing.allocator); defer a.deinit(); try a.setFloatString("72.14159312071241458852455252781510353"); // = 72.1415931207124145885245525278151035308837890625 testing.expect((try a.p.to(u128)) == 7214159312071241458852455252781510353); testing.expect((try a.q.to(u128)) == 100000000000000000000000000000000000); } test "big.rational toFloat" { var a = try Rational.init(testing.allocator); defer a.deinit(); // = 3.14159297943115234375 try a.setRatio(3294199, 1048576); testing.expect((try a.toFloat(f64)) == 3.14159297943115234375); // = 72.1415931207124145885245525278151035308837890625 try a.setRatio(5076513310880537, 70368744177664); testing.expect((try a.toFloat(f64)) == 72.141593120712409172417410926841290461290467124); } test "big.rational set/to Float round-trip" { var a = try Rational.init(testing.allocator); defer a.deinit(); var prng = std.rand.DefaultPrng.init(0x5EED); var i: usize = 0; while (i < 512) : (i += 1) { const r = prng.random.float(f64); try a.setFloat(f64, r); testing.expect((try a.toFloat(f64)) == r); } } test "big.rational copy" { var a = try Rational.init(testing.allocator); defer a.deinit(); const b = try Int.initSet(testing.allocator, 5); defer b.deinit(); try a.copyInt(b); testing.expect((try a.p.to(u32)) == 5); testing.expect((try a.q.to(u32)) == 1); const c = try Int.initSet(testing.allocator, 7); defer c.deinit(); const d = try Int.initSet(testing.allocator, 3); defer d.deinit(); try a.copyRatio(c, d); testing.expect((try a.p.to(u32)) == 7); testing.expect((try a.q.to(u32)) == 3); const e = try Int.initSet(testing.allocator, 9); defer e.deinit(); const f = try Int.initSet(testing.allocator, 3); defer f.deinit(); try a.copyRatio(e, f); testing.expect((try a.p.to(u32)) == 3); testing.expect((try a.q.to(u32)) == 1); } test "big.rational negate" { var a = try Rational.init(testing.allocator); defer a.deinit(); try a.setInt(-50); testing.expect((try a.p.to(i32)) == -50); testing.expect((try a.q.to(i32)) == 1); a.negate(); testing.expect((try a.p.to(i32)) == 50); testing.expect((try a.q.to(i32)) == 1); a.negate(); testing.expect((try a.p.to(i32)) == -50); testing.expect((try a.q.to(i32)) == 1); } test "big.rational abs" { var a = try Rational.init(testing.allocator); defer a.deinit(); try a.setInt(-50); testing.expect((try a.p.to(i32)) == -50); testing.expect((try a.q.to(i32)) == 1); a.abs(); testing.expect((try a.p.to(i32)) == 50); testing.expect((try a.q.to(i32)) == 1); a.abs(); testing.expect((try a.p.to(i32)) == 50); testing.expect((try a.q.to(i32)) == 1); } test "big.rational swap" { var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); defer b.deinit(); try a.setRatio(50, 23); try b.setRatio(17, 3); testing.expect((try a.p.to(u32)) == 50); testing.expect((try a.q.to(u32)) == 23); testing.expect((try b.p.to(u32)) == 17); testing.expect((try b.q.to(u32)) == 3); a.swap(&b); testing.expect((try a.p.to(u32)) == 17); testing.expect((try a.q.to(u32)) == 3); testing.expect((try b.p.to(u32)) == 50); testing.expect((try b.q.to(u32)) == 23); } test "big.rational cmp" { var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); defer b.deinit(); try a.setRatio(500, 231); try b.setRatio(18903, 8584); testing.expect((try a.cmp(b)) == .lt); try a.setRatio(890, 10); try b.setRatio(89, 1); testing.expect((try a.cmp(b)) == .eq); } test "big.rational add single-limb" { var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); defer b.deinit(); try a.setRatio(500, 231); try b.setRatio(18903, 8584); testing.expect((try a.cmp(b)) == .lt); try a.setRatio(890, 10); try b.setRatio(89, 1); testing.expect((try a.cmp(b)) == .eq); } test "big.rational add" { var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); defer b.deinit(); var r = try Rational.init(testing.allocator); defer r.deinit(); try a.setRatio(78923, 23341); try b.setRatio(123097, 12441414); try a.add(a, b); try r.setRatio(984786924199, 290395044174); testing.expect((try a.cmp(r)) == .eq); } test "big.rational sub" { var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); defer b.deinit(); var r = try Rational.init(testing.allocator); defer r.deinit(); try a.setRatio(78923, 23341); try b.setRatio(123097, 12441414); try a.sub(a, b); try r.setRatio(979040510045, 290395044174); testing.expect((try a.cmp(r)) == .eq); } test "big.rational mul" { var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); defer b.deinit(); var r = try Rational.init(testing.allocator); defer r.deinit(); try a.setRatio(78923, 23341); try b.setRatio(123097, 12441414); try a.mul(a, b); try r.setRatio(571481443, 17082061422); testing.expect((try a.cmp(r)) == .eq); } test "big.rational div" { var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); defer b.deinit(); var r = try Rational.init(testing.allocator); defer r.deinit(); try a.setRatio(78923, 23341); try b.setRatio(123097, 12441414); try a.div(a, b); try r.setRatio(75531824394, 221015929); testing.expect((try a.cmp(r)) == .eq); } test "big.rational div" { var a = try Rational.init(testing.allocator); defer a.deinit(); var r = try Rational.init(testing.allocator); defer r.deinit(); try a.setRatio(78923, 23341); a.invert(); try r.setRatio(23341, 78923); testing.expect((try a.cmp(r)) == .eq); try a.setRatio(-78923, 23341); a.invert(); try r.setRatio(-23341, 78923); testing.expect((try a.cmp(r)) == .eq); }
lib/std/math/big/rational.zig
const std = @import("std"); const mem = std.mem; const simd = @import("simd.zig"); const testing = std.testing; const Section = struct { pub const Type = enum { Template, Variable, Content, Yield, }; content: []const u8, type: Type, start: usize, end: usize, pub fn is(comptime self: Section, comptime name: []const u8) bool { return self.type == .Yield and mem.eql(u8, self.content, name); } pub fn render(comptime self: Section, context: anytype, stream: anytype) @TypeOf(stream).Error!void { switch (self.type) { .Content => { try stream.writeAll(self.content); }, .Variable => { // TODO: Support arbitrary lookups const v = if (comptime mem.eql(u8, self.content, "self")) context else if (comptime mem.indexOf(u8, self.content, ".")) |offset| @field(@field(context, self.content[0..offset]), self.content[offset + 1 ..]) else @field(context, self.content); // TODO: Escape const T = @TypeOf(v); switch (@typeInfo(T)) { .ComptimeInt, .Int, .ComptimeFloat, .Float => { // {s} says unknown format string?? try stream.print("{}", .{v}); }, else => { try stream.print("{s}", .{v}); }, } }, .Template => { // TODO: Support sub contexts... const subtemplate = @embedFile(self.content); try stream.writeAll(subtemplate); }, .Yield => {}, } } }; pub fn parse(comptime Context: type, comptime template: []const u8) []const Section { _ = Context; @setEvalBranchQuota(100000); // Count number of sections this will probably be off comptime var max_sections: usize = 2; comptime { var vars = simd.split(template, "{{"); while (vars.next()) |_| { max_sections += 1; } var blocks = simd.split(template, "{%"); while (blocks.next()) |_| { max_sections += 1; } } // Now parse each section comptime var sections: [max_sections]Section = undefined; comptime var pos: usize = 0; comptime var index: usize = 0; while (simd.indexOfPos(u8, template, pos, "{")) |i| { if (i != pos) { // Content before sections[index] = Section{ .content = template[pos..i], .type = .Content, .start = pos, .end = i }; index += 1; } const remainder = template[i..]; if (mem.startsWith(u8, remainder, "{{")) { const start = i + 2; if (simd.indexOfPos(u8, template, start, "}}")) |end| { const format = std.mem.trim(u8, template[start..end], " "); pos = end + 2; sections[index] = Section{ .content = format, .type = .Variable, .start = i, .end = pos, }; index += 1; continue; } @compileError("Incomplete variable expression"); } else if (mem.startsWith(u8, remainder, "{%")) { if (mem.startsWith(u8, remainder, "{% yield ")) { const start = i + 9; if (simd.indexOfPos(u8, template, start, "%}")) |end| { pos = end + 2; sections[index] = Section{ .content = mem.trim(u8, template[start..end], " "), .type = .Yield, .start = i, .end = pos, }; index += 1; continue; } @compileError("Incomplete yield declaration at " ++ template[i..]); } else if (mem.startsWith(u8, remainder, "{% include ")) { const start = i + 12; if (simd.indexOfPos(u8, template, start, "%}")) |end| { pos = end + 2; sections[index] = Section{ .content = mem.trim(u8, template[start..end], " "), .type = .Template, .start = i, .end = pos, }; index += 1; continue; } @compileError("Incomplete include declaration"); } @compileError("Incomplete template"); } else { pos = i + 1; } } // Final section if (pos < template.len) { sections[index] = Section{ .content = template[pos..], .type = .Content, .start = pos, .end = template.len, }; index += 1; } return sections[0..index]; } /// /// Generate a template that supports some what "django" like formatting /// - Use {{ field }} or {{ field.subfield }} for varibles /// - Use {% include 'path/to/another/template' %} to embed a template /// - Use {% yield 'blockname' %} to return to your code to manually render stuff pub fn Template(comptime Context: type, comptime template: []const u8) type { return struct { pub const ContextType = Context; pub const source = template; pub const sections = parse(Context, template); const Self = @This(); pub fn dump() void { std.debug.warn("Template (length = {d})\n", .{template.len}); inline for (sections) |s| { std.debug.warn("{s} (\"{s}\")\n", .{ s, template[s.start..s.end] }); } } // Render the whole template ignoring any yield statements pub fn render(context: Context, stream: anytype) @TypeOf(stream).Error!void { inline for (sections) |s| { try s.render(context, stream); } } }; } pub fn FileTemplate(comptime Context: type, comptime filename: []const u8) type { return Template(Context, @embedFile(filename)); } fn expectRender(comptime T: type, context: anytype, result: []const u8) !void { var buf: [4096]u8 = undefined; var stream = std.io.fixedBufferStream(&buf); try T.render(context, stream.writer()); try testing.expectEqualStrings(result, stream.getWritten()); } test "template-variable" { const Context = struct { name: []const u8, }; const Tmpl = Template(Context, "Hello {{name}}!"); try expectRender(Tmpl, .{ .name = "World" }, "Hello World!"); } // // test "template-variable-self" { // const Context = struct { // name: []const u8, // }; // const Tmpl = Template(Context, "{{self}}!"); // try expectRender(Tmpl, .{.name="World"}, "Context{ .name = World }!"); // } test "template-variable-nested" { const User = struct { name: []const u8, }; const Context = struct { user: User, }; const Tmpl = Template(Context, "Hello {{user.name}}!"); try expectRender(Tmpl, .{ .user = User{ .name = "World" } }, "Hello World!"); } test "template-multiple-variables" { const Context = struct { name: []const u8, age: u8, }; const Tmpl = Template(Context, "User {{name}} is {{age}}!"); try expectRender(Tmpl, .{ .name = "Bob", .age = 74 }, "User Bob is 74!"); } test "template-variables-whitespace-is-ignored" { const Context = struct { name: []const u8, age: u8, }; const Tmpl = Template(Context, "User {{ name }} is {{ age}}!"); try expectRender(Tmpl, .{ .name = "Bob", .age = 74 }, "User Bob is 74!"); } test "template-yield" { var buf: [4096]u8 = undefined; var stream = std.io.fixedBufferStream(&buf); var writer = stream.writer(); const Context = struct { unused: u8 = 0, }; const template = Template(Context, "Before {% yield one %} after"); const context = Context{}; inline for (template.sections) |s| { if (s.is("one")) { try writer.writeAll("then"); } else { try s.render(context, writer); } } try testing.expectEqualStrings("Before then after", stream.getWritten()); } test "template-yield-variables" { var buf: [4096]u8 = undefined; var stream = std.io.fixedBufferStream(&buf); var writer = stream.writer(); const Context = struct { what: []const u8 = "base", }; const template = Template(Context, "All {% yield name %} {{what}} are belong to {% yield who %}"); //T.dump(); const context = Context{}; inline for (template.sections) |s| { if (s.is("name")) { try writer.writeAll("your"); } else if (s.is("who")) { try writer.writeAll("us"); } else { try s.render(context, writer); } } try testing.expectEqualStrings("All your base are belong to us", stream.getWritten()); }
src/template.zig
const std = @import("std.zig"); const mem = std.mem; const builtin = std.builtin; /// TODO Nearly all the functions in this namespace would be /// better off if https://github.com/ziglang/zig/issues/425 /// was solved. pub const Target = union(enum) { Native: void, Cross: Cross, pub const Os = enum { freestanding, ananas, cloudabi, dragonfly, freebsd, fuchsia, ios, kfreebsd, linux, lv2, macosx, netbsd, openbsd, solaris, windows, haiku, minix, rtems, nacl, cnk, aix, cuda, nvcl, amdhsa, ps4, elfiamcu, tvos, watchos, mesa3d, contiki, amdpal, hermit, hurd, wasi, emscripten, uefi, other, }; pub const Arch = union(enum) { arm: Arm32, armeb: Arm32, aarch64: Arm64, aarch64_be: Arm64, aarch64_32: Arm64, arc, avr, bpfel, bpfeb, hexagon, mips, mipsel, mips64, mips64el, msp430, powerpc, powerpc64, powerpc64le, r600, amdgcn, riscv32, riscv64, sparc, sparcv9, sparcel, s390x, tce, tcele, thumb: Arm32, thumbeb: Arm32, i386, x86_64, xcore, nvptx, nvptx64, le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba: Kalimba, shave, lanai, wasm32, wasm64, renderscript32, renderscript64, pub const Arm32 = enum { v8_5a, v8_4a, v8_3a, v8_2a, v8_1a, v8, v8r, v8m_baseline, v8m_mainline, v8_1m_mainline, v7, v7em, v7m, v7s, v7k, v7ve, v6, v6m, v6k, v6t2, v5, v5te, v4t, }; pub const Arm64 = enum { v8_5a, v8_4a, v8_3a, v8_2a, v8_1a, v8, v8r, v8m_baseline, v8m_mainline, }; pub const Kalimba = enum { v5, v4, v3, }; pub const Mips = enum { r6, }; pub fn toElfMachine(arch: Arch) std.elf.EM { return switch (arch) { .avr => ._AVR, .msp430 => ._MSP430, .arc => ._ARC, .arm => ._ARM, .armeb => ._ARM, .hexagon => ._HEXAGON, .le32 => ._NONE, .mips => ._MIPS, .mipsel => ._MIPS_RS3_LE, .powerpc => ._PPC, .r600 => ._NONE, .riscv32 => ._RISCV, .sparc => ._SPARC, .sparcel => ._SPARC, .tce => ._NONE, .tcele => ._NONE, .thumb => ._ARM, .thumbeb => ._ARM, .i386 => ._386, .xcore => ._XCORE, .nvptx => ._NONE, .amdil => ._NONE, .hsail => ._NONE, .spir => ._NONE, .kalimba => ._CSR_KALIMBA, .shave => ._NONE, .lanai => ._LANAI, .wasm32 => ._NONE, .renderscript32 => ._NONE, .aarch64_32 => ._AARCH64, .aarch64 => ._AARCH64, .aarch64_be => ._AARCH64, .mips64 => ._MIPS, .mips64el => ._MIPS_RS3_LE, .powerpc64 => ._PPC64, .powerpc64le => ._PPC64, .riscv64 => ._RISCV, .x86_64 => ._X86_64, .nvptx64 => ._NONE, .le64 => ._NONE, .amdil64 => ._NONE, .hsail64 => ._NONE, .spir64 => ._NONE, .wasm64 => ._NONE, .renderscript64 => ._NONE, .amdgcn => ._NONE, .bpfel => ._BPF, .bpfeb => ._BPF, .sparcv9 => ._SPARCV9, .s390x => ._S390, }; } pub fn endian(arch: Arch) builtin.Endian { return switch (arch) { .avr, .arm, .aarch64_32, .aarch64, .amdgcn, .amdil, .amdil64, .bpfel, .hexagon, .hsail, .hsail64, .kalimba, .le32, .le64, .mipsel, .mips64el, .msp430, .nvptx, .nvptx64, .sparcel, .tcele, .powerpc64le, .r600, .riscv32, .riscv64, .i386, .x86_64, .wasm32, .wasm64, .xcore, .thumb, .spir, .spir64, .renderscript32, .renderscript64, .shave, => .Little, .arc, .armeb, .aarch64_be, .bpfeb, .mips, .mips64, .powerpc, .powerpc64, .thumbeb, .sparc, .sparcv9, .tce, .lanai, .s390x, => .Big, }; } }; pub const Abi = enum { none, gnu, gnuabin32, gnuabi64, gnueabi, gnueabihf, gnux32, code16, eabi, eabihf, elfv1, elfv2, android, musl, musleabi, musleabihf, msvc, itanium, cygnus, coreclr, simulator, macabi, }; pub const ObjectFormat = enum { unknown, coff, elf, macho, wasm, }; pub const SubSystem = enum { Console, Windows, Posix, Native, EfiApplication, EfiBootServiceDriver, EfiRom, EfiRuntimeDriver, }; pub const Cross = struct { arch: Arch, os: Os, abi: Abi, }; pub const current = Target{ .Cross = Cross{ .arch = builtin.arch, .os = builtin.os, .abi = builtin.abi, }, }; pub const stack_align = 16; pub fn zigTriple(self: Target, allocator: *mem.Allocator) ![]u8 { return std.fmt.allocPrint(allocator, "{}{}-{}-{}", .{ @tagName(self.getArch()), Target.archSubArchName(self.getArch()), @tagName(self.getOs()), @tagName(self.getAbi()), }); } /// Returned slice must be freed by the caller. pub fn vcpkgTriplet(allocator: *mem.Allocator, target: Target, linkage: std.build.VcpkgLinkage) ![]const u8 { const arch = switch (target.getArch()) { .i386 => "x86", .x86_64 => "x64", .arm, .armeb, .thumb, .thumbeb, .aarch64_32, => "arm", .aarch64, .aarch64_be, => "arm64", else => return error.VcpkgNoSuchArchitecture, }; const os = switch (target.getOs()) { .windows => "windows", .linux => "linux", .macosx => "macos", else => return error.VcpkgNoSuchOs, }; if (linkage == .Static) { return try mem.join(allocator, "-", &[_][]const u8{ arch, os, "static" }); } else { return try mem.join(allocator, "-", &[_][]const u8{ arch, os }); } } pub fn allocDescription(self: Target, allocator: *mem.Allocator) ![]u8 { // TODO is there anything else worthy of the description that is not // already captured in the triple? return self.zigTriple(allocator); } pub fn zigTripleNoSubArch(self: Target, allocator: *mem.Allocator) ![]u8 { return std.fmt.allocPrint(allocator, "{}-{}-{}", .{ @tagName(self.getArch()), @tagName(self.getOs()), @tagName(self.getAbi()), }); } pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 { return std.fmt.allocPrint(allocator, "{}-{}-{}", .{ @tagName(self.getArch()), @tagName(self.getOs()), @tagName(self.getAbi()), }); } pub fn parse(text: []const u8) !Target { var it = mem.separate(text, "-"); const arch_name = it.next() orelse return error.MissingArchitecture; const os_name = it.next() orelse return error.MissingOperatingSystem; const abi_name = it.next(); var cross = Cross{ .arch = try parseArchSub(arch_name), .os = try parseOs(os_name), .abi = undefined, }; cross.abi = if (abi_name) |n| try parseAbi(n) else defaultAbi(cross.arch, cross.os); return Target{ .Cross = cross }; } pub fn defaultAbi(arch: Arch, target_os: Os) Abi { switch (arch) { .wasm32, .wasm64 => return .musl, else => {}, } switch (target_os) { .freestanding, .ananas, .cloudabi, .dragonfly, .lv2, .solaris, .haiku, .minix, .rtems, .nacl, .cnk, .aix, .cuda, .nvcl, .amdhsa, .ps4, .elfiamcu, .mesa3d, .contiki, .amdpal, .hermit, .other, => return .eabi, .openbsd, .macosx, .freebsd, .ios, .tvos, .watchos, .fuchsia, .kfreebsd, .netbsd, .hurd, => return .gnu, .windows, .uefi, => return .msvc, .linux, .wasi, .emscripten, => return .musl, } } pub const ParseArchSubError = error{ UnknownArchitecture, UnknownSubArchitecture, }; pub fn parseArchSub(text: []const u8) ParseArchSubError!Arch { const info = @typeInfo(Arch); inline for (info.Union.fields) |field| { if (mem.eql(u8, text, field.name)) { if (field.field_type == void) { return @as(Arch, @field(Arch, field.name)); } else { const sub_info = @typeInfo(field.field_type); inline for (sub_info.Enum.fields) |sub_field| { const combined = field.name ++ sub_field.name; if (mem.eql(u8, text, combined)) { return @unionInit(Arch, field.name, @field(field.field_type, sub_field.name)); } } return error.UnknownSubArchitecture; } } } return error.UnknownArchitecture; } pub fn parseOs(text: []const u8) !Os { const info = @typeInfo(Os); inline for (info.Enum.fields) |field| { if (mem.eql(u8, text, field.name)) { return @field(Os, field.name); } } return error.UnknownOperatingSystem; } pub fn parseAbi(text: []const u8) !Abi { const info = @typeInfo(Abi); inline for (info.Enum.fields) |field| { if (mem.eql(u8, text, field.name)) { return @field(Abi, field.name); } } return error.UnknownApplicationBinaryInterface; } fn archSubArchName(arch: Arch) []const u8 { return switch (arch) { .arm => |sub| @tagName(sub), .armeb => |sub| @tagName(sub), .thumb => |sub| @tagName(sub), .thumbeb => |sub| @tagName(sub), .aarch64 => |sub| @tagName(sub), .aarch64_be => |sub| @tagName(sub), .kalimba => |sub| @tagName(sub), else => "", }; } pub fn subArchName(self: Target) []const u8 { switch (self) { .Native => return archSubArchName(builtin.arch), .Cross => |cross| return archSubArchName(cross.arch), } } pub fn oFileExt(self: Target) []const u8 { return switch (self.getAbi()) { .msvc => ".obj", else => ".o", }; } pub fn exeFileExt(self: Target) []const u8 { if (self.isWindows()) { return ".exe"; } else if (self.isUefi()) { return ".efi"; } else if (self.isWasm()) { return ".wasm"; } else { return ""; } } pub fn staticLibSuffix(self: Target) []const u8 { if (self.isWasm()) { return ".wasm"; } switch (self.getAbi()) { .msvc => return ".lib", else => return ".a", } } pub fn dynamicLibSuffix(self: Target) []const u8 { if (self.isDarwin()) { return ".dylib"; } switch (self.getOs()) { .windows => return ".dll", else => return ".so", } } pub fn libPrefix(self: Target) []const u8 { if (self.isWasm()) { return ""; } switch (self.getAbi()) { .msvc => return "", else => return "lib", } } pub fn getOs(self: Target) Os { return switch (self) { .Native => builtin.os, .Cross => |t| t.os, }; } pub fn getArch(self: Target) Arch { switch (self) { .Native => return builtin.arch, .Cross => |t| return t.arch, } } pub fn getAbi(self: Target) Abi { switch (self) { .Native => return builtin.abi, .Cross => |t| return t.abi, } } pub fn isMinGW(self: Target) bool { return self.isWindows() and self.isGnu(); } pub fn isGnu(self: Target) bool { return switch (self.getAbi()) { .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => true, else => false, }; } pub fn isMusl(self: Target) bool { return switch (self.getAbi()) { .musl, .musleabi, .musleabihf => true, else => false, }; } pub fn isDarwin(self: Target) bool { return switch (self.getOs()) { .ios, .macosx, .watchos, .tvos => true, else => false, }; } pub fn isWindows(self: Target) bool { return switch (self.getOs()) { .windows => true, else => false, }; } pub fn isLinux(self: Target) bool { return switch (self.getOs()) { .linux => true, else => false, }; } pub fn isUefi(self: Target) bool { return switch (self.getOs()) { .uefi => true, else => false, }; } pub fn isWasm(self: Target) bool { return switch (self.getArch()) { .wasm32, .wasm64 => true, else => false, }; } pub fn isFreeBSD(self: Target) bool { return switch (self.getOs()) { .freebsd => true, else => false, }; } pub fn isNetBSD(self: Target) bool { return switch (self.getOs()) { .netbsd => true, else => false, }; } pub fn wantSharedLibSymLinks(self: Target) bool { return !self.isWindows(); } pub fn osRequiresLibC(self: Target) bool { return self.isDarwin() or self.isFreeBSD() or self.isNetBSD(); } pub fn getArchPtrBitWidth(self: Target) u32 { switch (self.getArch()) { .avr, .msp430, => return 16, .arc, .arm, .armeb, .hexagon, .le32, .mips, .mipsel, .powerpc, .r600, .riscv32, .sparc, .sparcel, .tce, .tcele, .thumb, .thumbeb, .i386, .xcore, .nvptx, .amdil, .hsail, .spir, .kalimba, .shave, .lanai, .wasm32, .renderscript32, .aarch64_32, => return 32, .aarch64, .aarch64_be, .mips64, .mips64el, .powerpc64, .powerpc64le, .riscv64, .x86_64, .nvptx64, .le64, .amdil64, .hsail64, .spir64, .wasm64, .renderscript64, .amdgcn, .bpfel, .bpfeb, .sparcv9, .s390x, => return 64, } } pub fn supportsNewStackCall(self: Target) bool { return !self.isWasm(); } pub const Executor = union(enum) { native, qemu: []const u8, wine: []const u8, wasmtime: []const u8, unavailable, }; pub fn getExternalExecutor(self: Target) Executor { if (@as(@TagType(Target), self) == .Native) return .native; // If the target OS matches the host OS, we can use QEMU to emulate a foreign architecture. if (self.getOs() == builtin.os) { return switch (self.getArch()) { .aarch64 => Executor{ .qemu = "qemu-aarch64" }, .aarch64_be => Executor{ .qemu = "qemu-aarch64_be" }, .arm => Executor{ .qemu = "qemu-arm" }, .armeb => Executor{ .qemu = "qemu-armeb" }, .i386 => Executor{ .qemu = "qemu-i386" }, .mips => Executor{ .qemu = "qemu-mips" }, .mipsel => Executor{ .qemu = "qemu-mipsel" }, .mips64 => Executor{ .qemu = "qemu-mips64" }, .mips64el => Executor{ .qemu = "qemu-mips64el" }, .powerpc => Executor{ .qemu = "qemu-ppc" }, .powerpc64 => Executor{ .qemu = "qemu-ppc64" }, .powerpc64le => Executor{ .qemu = "qemu-ppc64le" }, .riscv32 => Executor{ .qemu = "qemu-riscv32" }, .riscv64 => Executor{ .qemu = "qemu-riscv64" }, .s390x => Executor{ .qemu = "qemu-s390x" }, .sparc => Executor{ .qemu = "qemu-sparc" }, .x86_64 => Executor{ .qemu = "qemu-x86_64" }, else => return .unavailable, }; } if (self.isWindows()) { switch (self.getArchPtrBitWidth()) { 32 => return Executor{ .wine = "wine" }, 64 => return Executor{ .wine = "wine64" }, else => return .unavailable, } } if (self.getOs() == .wasi) { switch (self.getArchPtrBitWidth()) { 32 => return Executor{ .wasmtime = "wasmtime" }, else => return .unavailable, } } return .unavailable; } };
lib/std/target.zig
const std = @import("std.zig"); const builtin = @import("builtin"); pub const Transition = struct { ts: i64, timetype: *Timetype, }; pub const Timetype = struct { offset: i32, flags: u8, name_data: [6:0]u8, pub fn name(self: Timetype) [:0]const u8 { return std.mem.sliceTo(self.name_data[0..], 0); } pub fn isDst(self: Timetype) bool { return (self.flags & 0x01) > 0; } pub fn standardTimeIndicator(self: Timetype) bool { return (self.flags & 0x02) > 0; } pub fn utIndicator(self: Timetype) bool { return (self.flags & 0x04) > 0; } }; pub const Leapsecond = struct { occurrence: i48, correction: i16, }; pub const Tz = struct { allocator: std.mem.Allocator, transitions: []const Transition, timetypes: []const Timetype, leapseconds: []const Leapsecond, footer: ?[]const u8, const Header = extern struct { magic: [4]u8, version: u8, reserved: [15]u8, counts: extern struct { isutcnt: u32, isstdcnt: u32, leapcnt: u32, timecnt: u32, typecnt: u32, charcnt: u32, }, }; pub fn parse(allocator: std.mem.Allocator, reader: anytype) !Tz { var legacy_header = try reader.readStruct(Header); if (!std.mem.eql(u8, &legacy_header.magic, "TZif")) return error.BadHeader; if (legacy_header.version != 0 and legacy_header.version != '2' and legacy_header.version != '3') return error.BadVersion; if (builtin.target.cpu.arch.endian() != std.builtin.Endian.Big) { std.mem.byteSwapAllFields(@TypeOf(legacy_header.counts), &legacy_header.counts); } if (legacy_header.version == 0) { return parseBlock(allocator, reader, legacy_header, true); } else { // If the format is modern, just skip over the legacy data const skipv = legacy_header.counts.timecnt * 5 + legacy_header.counts.typecnt * 6 + legacy_header.counts.charcnt + legacy_header.counts.leapcnt * 8 + legacy_header.counts.isstdcnt + legacy_header.counts.isutcnt; try reader.skipBytes(skipv, .{}); var header = try reader.readStruct(Header); if (!std.mem.eql(u8, &header.magic, "TZif")) return error.BadHeader; if (header.version != '2' and header.version != '3') return error.BadVersion; if (builtin.target.cpu.arch.endian() != std.builtin.Endian.Big) { std.mem.byteSwapAllFields(@TypeOf(header.counts), &header.counts); } return parseBlock(allocator, reader, header, false); } } fn parseBlock(allocator: std.mem.Allocator, reader: anytype, header: Header, legacy: bool) !Tz { if (header.counts.isstdcnt != 0 and header.counts.isstdcnt != header.counts.typecnt) return error.Malformed; // rfc8536: isstdcnt [...] MUST either be zero or equal to "typecnt" if (header.counts.isutcnt != 0 and header.counts.isutcnt != header.counts.typecnt) return error.Malformed; // rfc8536: isutcnt [...] MUST either be zero or equal to "typecnt" if (header.counts.typecnt == 0) return error.Malformed; // rfc8536: typecnt [...] MUST NOT be zero if (header.counts.charcnt == 0) return error.Malformed; // rfc8536: charcnt [...] MUST NOT be zero if (header.counts.charcnt > 256 + 6) return error.Malformed; // Not explicitly banned by rfc8536 but nonsensical var leapseconds = try allocator.alloc(Leapsecond, header.counts.leapcnt); errdefer allocator.free(leapseconds); var transitions = try allocator.alloc(Transition, header.counts.timecnt); errdefer allocator.free(transitions); var timetypes = try allocator.alloc(Timetype, header.counts.typecnt); errdefer allocator.free(timetypes); // Parse transition types var i: usize = 0; while (i < header.counts.timecnt) : (i += 1) { transitions[i].ts = if (legacy) try reader.readIntBig(i32) else try reader.readIntBig(i64); } i = 0; while (i < header.counts.timecnt) : (i += 1) { const tt = try reader.readByte(); if (tt >= timetypes.len) return error.Malformed; // rfc8536: Each type index MUST be in the range [0, "typecnt" - 1] transitions[i].timetype = &timetypes[tt]; } // Parse time types i = 0; while (i < header.counts.typecnt) : (i += 1) { const offset = try reader.readIntBig(i32); if (offset < -2147483648) return error.Malformed; // rfc8536: utoff [...] MUST NOT be -2**31 const dst = try reader.readByte(); if (dst != 0 and dst != 1) return error.Malformed; // rfc8536: (is)dst [...] The value MUST be 0 or 1. const idx = try reader.readByte(); if (idx > header.counts.charcnt - 1) return error.Malformed; // rfc8536: (desig)idx [...] Each index MUST be in the range [0, "charcnt" - 1] timetypes[i] = .{ .offset = offset, .flags = dst, .name_data = undefined, }; // Temporarily cache idx in name_data to be processed after we've read the designator names below timetypes[i].name_data[0] = idx; } var designators_data: [256 + 6]u8 = undefined; try reader.readNoEof(designators_data[0..header.counts.charcnt]); const designators = designators_data[0..header.counts.charcnt]; if (designators[designators.len - 1] != 0) return error.Malformed; // rfc8536: charcnt [...] includes the trailing NUL (0x00) octet // Iterate through the timetypes again, setting the designator names for (timetypes) |*tt| { const name = std.mem.sliceTo(designators[tt.name_data[0]..], 0); // We are mandating the "SHOULD" 6-character limit so we can pack the struct better, and to conform to POSIX. if (name.len > 6) return error.Malformed; // rfc8536: Time zone designations SHOULD consist of at least three (3) and no more than six (6) ASCII characters. std.mem.copy(u8, tt.name_data[0..], name); tt.name_data[name.len] = 0; } // Parse leap seconds i = 0; while (i < header.counts.leapcnt) : (i += 1) { const occur: i64 = if (legacy) try reader.readIntBig(i32) else try reader.readIntBig(i64); if (occur < 0) return error.Malformed; // rfc8536: occur [...] MUST be nonnegative if (i > 0 and leapseconds[i - 1].occurrence + 2419199 > occur) return error.Malformed; // rfc8536: occur [...] each later value MUST be at least 2419199 greater than the previous value if (occur > std.math.maxInt(i48)) return error.Malformed; // Unreasonably far into the future const corr = try reader.readIntBig(i32); if (i == 0 and corr != -1 and corr != 1) return error.Malformed; // rfc8536: The correction value in the first leap-second record, if present, MUST be either one (1) or minus one (-1) if (i > 0 and leapseconds[i - 1].correction != corr + 1 and leapseconds[i - 1].correction != corr - 1) return error.Malformed; // rfc8536: The correction values in adjacent leap-second records MUST differ by exactly one (1) if (corr > std.math.maxInt(i16)) return error.Malformed; // Unreasonably large correction leapseconds[i] = .{ .occurrence = @intCast(i48, occur), .correction = @intCast(i16, corr), }; } // Parse standard/wall indicators i = 0; while (i < header.counts.isstdcnt) : (i += 1) { const stdtime = try reader.readByte(); if (stdtime == 1) { timetypes[i].flags |= 0x02; } } // Parse UT/local indicators i = 0; while (i < header.counts.isutcnt) : (i += 1) { const ut = try reader.readByte(); if (ut == 1) { timetypes[i].flags |= 0x04; if (!timetypes[i].standardTimeIndicator()) return error.Malformed; // rfc8536: standard/wall value MUST be one (1) if the UT/local value is one (1) } } // Footer var footer: ?[]u8 = null; if (!legacy) { if ((try reader.readByte()) != '\n') return error.Malformed; // An rfc8536 footer must start with a newline var footerdata_buf: [128]u8 = undefined; const footer_mem = reader.readUntilDelimiter(&footerdata_buf, '\n') catch |err| switch (err) { error.StreamTooLong => return error.OverlargeFooter, // Read more than 128 bytes, much larger than any reasonable POSIX TZ string else => return err, }; if (footer_mem.len != 0) { footer = try allocator.dupe(u8, footer_mem); } } errdefer if (footer) |ft| allocator.free(ft); return Tz{ .allocator = allocator, .transitions = transitions, .timetypes = timetypes, .leapseconds = leapseconds, .footer = footer, }; } pub fn deinit(self: *Tz) void { if (self.footer) |footer| { self.allocator.free(footer); } self.allocator.free(self.leapseconds); self.allocator.free(self.transitions); self.allocator.free(self.timetypes); } }; test "slim" { if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO const data = @embedFile("tz/asia_tokyo.tzif"); var in_stream = std.io.fixedBufferStream(data); var tz = try std.Tz.parse(std.testing.allocator, in_stream.reader()); defer tz.deinit(); try std.testing.expectEqual(tz.transitions.len, 9); try std.testing.expect(std.mem.eql(u8, tz.transitions[3].timetype.name(), "JDT")); try std.testing.expectEqual(tz.transitions[5].ts, -620298000); // 1950-05-06 15:00:00 UTC try std.testing.expectEqual(tz.leapseconds[13].occurrence, 567993613); // 1988-01-01 00:00:00 UTC (+23s in TAI, and +13 in the data since it doesn't store the initial 10 second offset) } test "fat" { if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO const data = @embedFile("tz/antarctica_davis.tzif"); var in_stream = std.io.fixedBufferStream(data); var tz = try std.Tz.parse(std.testing.allocator, in_stream.reader()); defer tz.deinit(); try std.testing.expectEqual(tz.transitions.len, 8); try std.testing.expect(std.mem.eql(u8, tz.transitions[3].timetype.name(), "+05")); try std.testing.expectEqual(tz.transitions[4].ts, 1268251224); // 2010-03-10 20:00:00 UTC } test "legacy" { if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO // Taken from Slackware 8.0, from 2001 const data = @embedFile("tz/europe_vatican.tzif"); var in_stream = std.io.fixedBufferStream(data); var tz = try std.Tz.parse(std.testing.allocator, in_stream.reader()); defer tz.deinit(); try std.testing.expectEqual(tz.transitions.len, 170); try std.testing.expect(std.mem.eql(u8, tz.transitions[69].timetype.name(), "CET")); try std.testing.expectEqual(tz.transitions[123].ts, 1414285200); // 2014-10-26 01:00:00 UTC }
lib/std/tz.zig
const std = @import("std"); /// Exports the C interface for SDL pub const c = @import("sdl-native"); // pub const image = @import("image.zig"); pub const gl = @import("gl.zig"); pub const Error = error{SdlError}; const log = std.log.scoped(.sdl2); pub fn makeError() error{SdlError} { if (c.SDL_GetError()) |ptr| { log.debug("{s}\n", .{ std.mem.span(ptr), }); } return error.SdlError; } pub const Rectangle = extern struct { x: c_int, y: c_int, width: c_int, height: c_int, fn getSdlPtr(r: *Rectangle) *c.SDL_Rect { return @ptrCast(*c.SDL_Rect, r); } fn getConstSdlPtr(r: Rectangle) *const c.SDL_Rect { return @ptrCast(*const c.SDL_Rect, &r); } }; pub const Point = extern struct { x: c_int, y: c_int, }; pub const Size = extern struct { width: c_int, height: c_int, }; pub const Color = extern struct { pub const black = rgb(0x00, 0x00, 0x00); pub const white = rgb(0xFF, 0xFF, 0xFF); pub const red = rgb(0xFF, 0x00, 0x00); pub const green = rgb(0x00, 0xFF, 0x00); pub const blue = rgb(0x00, 0x00, 0xFF); pub const magenta = rgb(0xFF, 0x00, 0xFF); pub const cyan = rgb(0x00, 0xFF, 0xFF); pub const yellow = rgb(0xFF, 0xFF, 0x00); r: u8, g: u8, b: u8, a: u8, /// returns a initialized color struct with alpha = 255 pub fn rgb(r: u8, g: u8, b: u8) Color { return Color{ .r = r, .g = g, .b = b, .a = 255 }; } /// returns a initialized color struct pub fn rgba(r: u8, g: u8, b: u8, a: u8) Color { return Color{ .r = r, .g = g, .b = b, .a = a }; } /// parses a hex string color literal. /// allowed formats are: /// - `RGB` /// - `RGBA` /// - `#RGB` /// - `#RGBA` /// - `RRGGBB` /// - `#RRGGBB` /// - `RRGGBBAA` /// - `#RRGGBBAA` pub fn parse(str: []const u8) error{ UnknownFormat, InvalidCharacter, Overflow, }!Color { switch (str.len) { // RGB 3 => { const r = try std.fmt.parseInt(u8, str[0..1], 16); const g = try std.fmt.parseInt(u8, str[1..2], 16); const b = try std.fmt.parseInt(u8, str[2..3], 16); return rgb( r | (r << 4), g | (g << 4), b | (b << 4), ); }, // #RGB, RGBA 4 => { if (str[0] == '#') return parse(str[1..]); const r = try std.fmt.parseInt(u8, str[0..1], 16); const g = try std.fmt.parseInt(u8, str[1..2], 16); const b = try std.fmt.parseInt(u8, str[2..3], 16); const a = try std.fmt.parseInt(u8, str[3..4], 16); // bit-expand the patters to a uniform range return rgba( r | (r << 4), g | (g << 4), b | (b << 4), a | (a << 4), ); }, // #RGBA 5 => return parse(str[1..]), // RRGGBB 6 => { const r = try std.fmt.parseInt(u8, str[0..2], 16); const g = try std.fmt.parseInt(u8, str[2..4], 16); const b = try std.fmt.parseInt(u8, str[4..6], 16); return rgb(r, g, b); }, // #RRGGBB 7 => return parse(str[1..]), // RRGGBBAA 8 => { const r = try std.fmt.parseInt(u8, str[0..2], 16); const g = try std.fmt.parseInt(u8, str[2..4], 16); const b = try std.fmt.parseInt(u8, str[4..6], 16); const a = try std.fmt.parseInt(u8, str[6..8], 16); return rgba(r, g, b, a); }, // #RRGGBBAA 9 => return parse(str[1..]), else => return error.UnknownFormat, } } }; pub const InitFlags = struct { pub const everything = InitFlags{ .timer = true, .audio = true, .video = true, .joystick = true, .haptic = true, .game_controller = true, .events = true, .sensor = true, }; timer: bool = false, audio: bool = false, video: bool = false, joystick: bool = false, haptic: bool = false, game_controller: bool = false, events: bool = false, sensor: bool = false, pub fn from_u32(flags: u32) InitFlags { return .{ .timer = (flags & c.SDL_INIT_TIMER) != 0, .audio = (flags & c.SDL_INIT_AUDIO) != 0, .video = (flags & c.SDL_INIT_VIDEO) != 0, .joystick = (flags & c.SDL_INIT_JOYSTICK) != 0, .haptic = (flags & c.SDL_INIT_HAPTIC) != 0, .game_controller = (flags & c.SDL_INIT_GAMECONTROLLER) != 0, .events = (flags & c.SDL_INIT_EVENTS) != 0, .sensor = (flags & c.SDL_INIT_SENSOR) != 0, }; } pub fn as_u32(self: InitFlags) u32 { return (if (self.timer) @as(u32, c.SDL_INIT_TIMER) else 0) | (if (self.audio) @as(u32, c.SDL_INIT_AUDIO) else 0) | (if (self.video) @as(u32, c.SDL_INIT_VIDEO) else 0) | (if (self.joystick) @as(u32, c.SDL_INIT_JOYSTICK) else 0) | (if (self.haptic) @as(u32, c.SDL_INIT_HAPTIC) else 0) | (if (self.game_controller) @as(u32, c.SDL_INIT_GAMECONTROLLER) else 0) | (if (self.events) @as(u32, c.SDL_INIT_EVENTS) else 0) | (if (self.sensor) @as(u32, c.SDL_INIT_SENSOR) else 0); } }; pub fn init(flags: InitFlags) !void { if (c.SDL_Init(flags.as_u32()) < 0) return makeError(); } pub fn wasInit(flags: InitFlags) InitFlags { return InitFlags.from_u32(c.SDL_WasInit(flags.as_u32())); } pub fn quit() void { c.SDL_Quit(); } pub fn getError() ?[]const u8 { if (c.SDL_GetError()) |err| { return std.mem.span(err); } else { return null; } } pub const Window = struct { ptr: *c.SDL_Window, pub fn fromID(wid: u32) ?Window { return if (c.SDL_GetWindowFromID(wid)) |ptr| Window{ .ptr = ptr } else null; } pub fn destroy(w: Window) void { c.SDL_DestroyWindow(w.ptr); } pub fn getSize(w: Window) Size { var s: Size = undefined; c.SDL_GetWindowSize(w.ptr, &s.width, &s.height); return s; } pub fn getSurface(w: Window) !Surface { var surface_ptr = c.SDL_GetWindowSurface(w.ptr) orelse return makeError(); return Surface{ .ptr = surface_ptr }; } pub fn updateSurface(w: Window) !void { if (c.SDL_UpdateWindowSurface(w.ptr) < 0) return makeError(); } }; pub const WindowPosition = union(enum) { default: void, centered: void, absolute: c_int, }; pub const WindowFlags = struct { /// fullscreen window fullscreen: bool = false, // SDL_WINDOW_FULLSCREEN, /// fullscreen window at the current desktop resolution, fullscreen_desktop: bool = false, // SDL_WINDOW_FULLSCREEN_DESKTOP /// window usable with OpenGL context opengl: bool = false, // SDL_WINDOW_OPENGL, /// window is visible, shown: bool = false, // SDL_WINDOW_SHOWN, /// window is not visible hidden: bool = false, // SDL_WINDOW_HIDDEN, /// no window decoration borderless: bool = false, // SDL_WINDOW_BORDERLESS, /// window can be resized resizable: bool = false, // SDL_WINDOW_RESIZABLE, /// window is minimized minimized: bool = false, // SDL_WINDOW_MINIMIZED, /// window is maximized maximized: bool = false, // SDL_WINDOW_MAXIMIZED, /// window has grabbed input focus input_grabbed: bool = false, // SDL_WINDOW_INPUT_GRABBED, /// window has input focus input_focus: bool = false, //SDL_WINDOW_INPUT_FOCUS, /// window has mouse focus mouse_focus: bool = false, //SDL_WINDOW_MOUSE_FOCUS, /// window not created by SDL foreign: bool = false, //SDL_WINDOW_FOREIGN, /// window should be created in high-DPI mode if supported (>= SDL 2.0.1) allow_high_dpi: bool = false, //SDL_WINDOW_ALLOW_HIGHDPI, /// window has mouse captured (unrelated to INPUT_GRABBED, >= SDL 2.0.4) mouse_capture: bool = false, //SDL_WINDOW_MOUSE_CAPTURE, /// window should always be above others (X11 only, >= SDL 2.0.5) always_on_top: bool = false, //SDL_WINDOW_ALWAYS_ON_TOP, /// window should not be added to the taskbar (X11 only, >= SDL 2.0.5) skip_taskbar: bool = false, //SDL_WINDOW_SKIP_TASKBAR, /// window should be treated as a utility window (X11 only, >= SDL 2.0.5) utility: bool = false, //SDL_WINDOW_UTILITY, /// window should be treated as a tooltip (X11 only, >= SDL 2.0.5) tooltip: bool = false, //SDL_WINDOW_TOOLTIP, /// window should be treated as a popup menu (X11 only, >= SDL 2.0.5) popup_menu: bool = false, //SDL_WINDOW_POPUP_MENU, // fn fromInteger(val: c_uint) WindowFlags { // // TODO: Implement // @panic("niy"); // } fn toInteger(wf: WindowFlags) c_int { var val: c_int = 0; if (wf.fullscreen) val |= c.SDL_WINDOW_FULLSCREEN; if (wf.fullscreen_desktop) val |= c.SDL_WINDOW_FULLSCREEN_DESKTOP; if (wf.opengl) val |= c.SDL_WINDOW_OPENGL; if (wf.shown) val |= c.SDL_WINDOW_SHOWN; if (wf.hidden) val |= c.SDL_WINDOW_HIDDEN; if (wf.borderless) val |= c.SDL_WINDOW_BORDERLESS; if (wf.resizable) val |= c.SDL_WINDOW_RESIZABLE; if (wf.minimized) val |= c.SDL_WINDOW_MINIMIZED; if (wf.maximized) val |= c.SDL_WINDOW_MAXIMIZED; if (wf.input_grabbed) val |= c.SDL_WINDOW_INPUT_GRABBED; if (wf.input_focus) val |= c.SDL_WINDOW_INPUT_FOCUS; if (wf.mouse_focus) val |= c.SDL_WINDOW_MOUSE_FOCUS; if (wf.foreign) val |= c.SDL_WINDOW_FOREIGN; if (wf.allow_high_dpi) val |= c.SDL_WINDOW_ALLOW_HIGHDPI; if (wf.mouse_capture) val |= c.SDL_WINDOW_MOUSE_CAPTURE; if (wf.always_on_top) val |= c.SDL_WINDOW_ALWAYS_ON_TOP; if (wf.skip_taskbar) val |= c.SDL_WINDOW_SKIP_TASKBAR; if (wf.utility) val |= c.SDL_WINDOW_UTILITY; if (wf.tooltip) val |= c.SDL_WINDOW_TOOLTIP; if (wf.popup_menu) val |= c.SDL_WINDOW_POPUP_MENU; return val; } }; pub fn createWindow( title: [:0]const u8, x: WindowPosition, y: WindowPosition, width: usize, height: usize, flags: WindowFlags, ) !Window { return Window{ .ptr = c.SDL_CreateWindow( title, switch (x) { .default => c.SDL_WINDOWPOS_UNDEFINED_MASK, .centered => c.SDL_WINDOWPOS_CENTERED_MASK, .absolute => |v| v, }, switch (y) { .default => c.SDL_WINDOWPOS_UNDEFINED_MASK, .centered => c.SDL_WINDOWPOS_CENTERED_MASK, .absolute => |v| v, }, @intCast(c_int, width), @intCast(c_int, height), @intCast(u32, flags.toInteger()), ) orelse return makeError(), }; } pub const Surface = struct { ptr: *c.SDL_Surface, pub fn destroy(s: Surface) void { c.SDL_FreeSurface(s.ptr); } pub fn setColorKey(s: Surface, flag: c_int, color: Color) !void { if (c.SDL_SetColorKey(s.ptr, flag, c.SDL_MapRGBA(s.ptr.*.format, color.r, color.g, color.b, color.a)) < 0) return makeError(); } pub fn fillRect(s: *Surface, rect: ?*Rectangle, color: Color) !void { const rect_ptr = if (rect) |_rect| _rect.getSdlPtr() else null; if (c.SDL_FillRect(s.ptr, rect_ptr, c.SDL_MapRGBA(s.ptr.*.format, color.r, color.g, color.b, color.a)) < 0) return makeError(); } }; pub fn createRgbSurfaceWithFormat(width: u31, height: u31, bit_depth: u31, format: PixelFormatEnum) !Surface { return Surface{ .ptr = c.SDL_CreateRGBSurfaceWithFormat(0, width, height, bit_depth, @enumToInt(format)) orelse return error.SdlError }; } pub fn blitScaled(src: Surface, src_rectangle: ?*Rectangle, dest: Surface, dest_rectangle: ?*Rectangle) !void { if (c.SDL_BlitScaled( src.ptr, if (src_rectangle) |rect| rect.getSdlPtr() else null, dest.ptr, if (dest_rectangle) |rect| rect.getSdlPtr() else null, ) < 0) return error.SdlError; } pub const Renderer = struct { ptr: *c.SDL_Renderer, pub fn destroy(ren: Renderer) void { c.SDL_DestroyRenderer(ren.ptr); } pub fn clear(ren: Renderer) !void { if (c.SDL_RenderClear(ren.ptr) != 0) return makeError(); } pub fn present(ren: Renderer) void { c.SDL_RenderPresent(ren.ptr); } pub fn copy(ren: Renderer, tex: Texture, dstRect: ?Rectangle, srcRect: ?Rectangle) !void { if (c.SDL_RenderCopy(ren.ptr, tex.ptr, if (srcRect) |r| r.getConstSdlPtr() else null, if (dstRect) |r| r.getConstSdlPtr() else null) < 0) return makeError(); } pub fn setScale(ren: Renderer, x: f32, y: f32) !void { if (c.SDL_RenderSetScale(ren.ptr, x, y) > 0) return makeError(); } pub fn drawLine(ren: Renderer, x0: i32, y0: i32, x1: i32, y1: i32) !void { if (c.SDL_RenderDrawLine(ren.ptr, x0, y0, x1, y1) < 0) return makeError(); } pub fn drawPoint(ren: Renderer, x: i32, y: i32) !void { if (c.SDL_RenderDrawPoint(ren.ptr, x, y) < 0) return makeError(); } pub fn fillRect(ren: Renderer, rect: Rectangle) !void { if (c.SDL_RenderFillRect(ren.ptr, rect.getConstSdlPtr()) < 0) return makeError(); } pub fn drawRect(ren: Renderer, rect: Rectangle) !void { if (c.SDL_RenderDrawRect(ren.ptr, rect.getConstSdlPtr()) < 0) return makeError(); } pub fn setColor(ren: Renderer, color: Color) !void { if (c.SDL_SetRenderDrawColor(ren.ptr, color.r, color.g, color.b, color.a) < 0) return makeError(); } pub fn setColorRGB(ren: Renderer, r: u8, g: u8, b: u8) !void { if (c.SDL_SetRenderDrawColor(ren.ptr, r, g, b, 255) < 0) return makeError(); } pub fn setColorRGBA(ren: Renderer, r: u8, g: u8, b: u8, a: u8) !void { if (c.SDL_SetRenderDrawColor(ren.ptr, r, g, b, a) < 0) return makeError(); } pub fn setDrawBlendMode(ren: Renderer, blendMode: c.SDL_BlendMode) !void { if (c.SDL_SetRenderDrawBlendMode(ren.ptr, blendMode) < 0) return makeError(); } pub const OutputSize = struct { width_pixels: c_int, height_pixels: c_int }; pub fn getOutputSize(ren: Renderer) !OutputSize { var width_pixels: c_int = undefined; var height_pixels: c_int = undefined; if (c.SDL_GetRendererOutputSize(ren.ptr, &width_pixels, &height_pixels) < 0) return makeError(); return OutputSize{ .width_pixels = width_pixels, .height_pixels = height_pixels }; } pub fn getInfo(ren: Renderer) !c.SDL_RendererInfo { var result: c.SDL_RendererInfo = undefined; if (c.SDL_GetRendererInfo(ren.ptr, &result) < 0) return makeError(); return result; } }; pub const RendererFlags = struct { software: bool = false, accelerated: bool = false, present_vsync: bool = false, target_texture: bool = false, fn toInteger(rf: RendererFlags) c_int { var val: c_int = 0; if (rf.software) val |= c.SDL_RENDERER_SOFTWARE; if (rf.accelerated) val |= c.SDL_RENDERER_ACCELERATED; if (rf.present_vsync) val |= c.SDL_RENDERER_PRESENTVSYNC; if (rf.target_texture) val |= c.SDL_RENDERER_TARGETTEXTURE; return val; } }; pub fn createRenderer(window: Window, index: ?u31, flags: RendererFlags) !Renderer { return Renderer{ .ptr = c.SDL_CreateRenderer( window.ptr, if (index) |idx| @intCast(c_int, idx) else -1, @intCast(u32, flags.toInteger()), ) orelse return makeError(), }; } pub const Texture = struct { pub const PixelData = struct { texture: *c.SDL_Texture, pixels: [*]u8, stride: usize, pub fn scanline(self: *@This(), y: usize, comptime Pixel: type) [*]Pixel { return @ptrCast([*]Pixel, self.pixels + y * self.stride); } pub fn release(self: *@This()) void { c.SDL_UnlockTexture(self.texture); self.* = undefined; } }; ptr: *c.SDL_Texture, pub fn destroy(tex: Texture) void { c.SDL_DestroyTexture(tex.ptr); } pub fn lock(tex: Texture, rectangle: ?Rectangle) !PixelData { var ptr: ?*anyopaque = undefined; var pitch: c_int = undefined; if (c.SDL_LockTexture( tex.ptr, if (rectangle) |rect| rect.getConstSdlPtr() else null, &ptr, &pitch, ) != 0) { return makeError(); } return PixelData{ .texture = tex.ptr, .stride = @intCast(usize, pitch), .pixels = @ptrCast([*]u8, ptr), }; } pub fn update(texture: Texture, pixels: []const u8, pitch: usize, rectangle: ?Rectangle) !void { if (c.SDL_UpdateTexture( texture.ptr, if (rectangle) |rect| rect.getConstSdlPtr() else null, pixels.ptr, @intCast(c_int, pitch), ) != 0) return makeError(); } const Info = struct { width: usize, height: usize, access: Access, format: PixelFormatEnum, }; pub fn query(tex: Texture) !Info { var format: u32 = undefined; var w: c_int = undefined; var h: c_int = undefined; var access: c_int = undefined; if (c.SDL_QueryTexture(tex.ptr, &format, &access, &w, &h) < 0) return makeError(); return Info{ .width = @intCast(usize, w), .height = @intCast(usize, h), .access = @intToEnum(Access, access), .format = @intToEnum(PixelFormatEnum, format), }; } pub fn resetColorMod(tex: Texture) !void { try tex.setColorMod(Color.white); } pub fn setColorMod(tex: Texture, color: Color) !void { if (c.SDL_SetTextureColorMod(tex.ptr, color.r, color.g, color.b) < 0) return makeError(); if (c.SDL_SetTextureAlphaMod(tex.ptr, color.a) < 0) return makeError(); } pub fn setColorModRGB(tex: Texture, r: u8, g: u8, b: u8) !void { try tex.setColorMod(Color.rgb(r, g, b)); } pub fn setColorModRGBA(tex: Texture, r: u8, g: u8, b: u8, a: u8) !void { try tex.setColorMod(Color.rgba(r, g, b, a)); } pub const Format = PixelFormatEnum; pub const Access = enum(c_int) { static = c.SDL_TEXTUREACCESS_STATIC, streaming = c.SDL_TEXTUREACCESS_STREAMING, target = c.SDL_TEXTUREACCESS_TARGET, }; }; pub const PixelFormatEnum = enum(u32) { index1_lsb = c.SDL_PIXELFORMAT_INDEX1LSB, index1_msb = c.SDL_PIXELFORMAT_INDEX1MSB, index4_lsb = c.SDL_PIXELFORMAT_INDEX4LSB, index4_msb = c.SDL_PIXELFORMAT_INDEX4MSB, index8 = c.SDL_PIXELFORMAT_INDEX8, rgb332 = c.SDL_PIXELFORMAT_RGB332, rgb444 = c.SDL_PIXELFORMAT_RGB444, rgb555 = c.SDL_PIXELFORMAT_RGB555, bgr555 = c.SDL_PIXELFORMAT_BGR555, argb4444 = c.SDL_PIXELFORMAT_ARGB4444, rgba4444 = c.SDL_PIXELFORMAT_RGBA4444, abgr4444 = c.SDL_PIXELFORMAT_ABGR4444, bgra4444 = c.SDL_PIXELFORMAT_BGRA4444, argb1555 = c.SDL_PIXELFORMAT_ARGB1555, rgba5551 = c.SDL_PIXELFORMAT_RGBA5551, abgr1555 = c.SDL_PIXELFORMAT_ABGR1555, bgra5551 = c.SDL_PIXELFORMAT_BGRA5551, rgb565 = c.SDL_PIXELFORMAT_RGB565, bgr565 = c.SDL_PIXELFORMAT_BGR565, rgb24 = c.SDL_PIXELFORMAT_RGB24, bgr24 = c.SDL_PIXELFORMAT_BGR24, rgb888 = c.SDL_PIXELFORMAT_RGB888, rgbx8888 = c.SDL_PIXELFORMAT_RGBX8888, bgr888 = c.SDL_PIXELFORMAT_BGR888, bgrx8888 = c.SDL_PIXELFORMAT_BGRX8888, argb8888 = c.SDL_PIXELFORMAT_ARGB8888, rgba8888 = c.SDL_PIXELFORMAT_RGBA8888, abgr8888 = c.SDL_PIXELFORMAT_ABGR8888, bgra8888 = c.SDL_PIXELFORMAT_BGRA8888, argb2101010 = c.SDL_PIXELFORMAT_ARGB2101010, yv12 = c.SDL_PIXELFORMAT_YV12, iyuv = c.SDL_PIXELFORMAT_IYUV, yuy2 = c.SDL_PIXELFORMAT_YUY2, uyvy = c.SDL_PIXELFORMAT_UYVY, yvyu = c.SDL_PIXELFORMAT_YVYU, nv12 = c.SDL_PIXELFORMAT_NV12, nv21 = c.SDL_PIXELFORMAT_NV21, externalOES = c.SDL_PIXELFORMAT_EXTERNAL_OES, }; pub fn createTexture(renderer: Renderer, format: PixelFormatEnum, access: Texture.Access, width: usize, height: usize) !Texture { const texptr = c.SDL_CreateTexture( renderer.ptr, @enumToInt(format), @enumToInt(access), @intCast(c_int, width), @intCast(c_int, height), ) orelse return makeError(); return Texture{ .ptr = texptr, }; } pub fn createTextureFromSurface(renderer: Renderer, surface: Surface) !Texture { const texptr = c.SDL_CreateTextureFromSurface( renderer.ptr, surface.ptr, ) orelse return makeError(); return Texture{ .ptr = texptr, }; } pub const WindowEvent = struct { const Type = enum(u8) { none = c.SDL_WINDOWEVENT_NONE, shown = c.SDL_WINDOWEVENT_SHOWN, hidden = c.SDL_WINDOWEVENT_HIDDEN, exposed = c.SDL_WINDOWEVENT_EXPOSED, moved = c.SDL_WINDOWEVENT_MOVED, resized = c.SDL_WINDOWEVENT_RESIZED, size_changed = c.SDL_WINDOWEVENT_SIZE_CHANGED, minimized = c.SDL_WINDOWEVENT_MINIMIZED, maximized = c.SDL_WINDOWEVENT_MAXIMIZED, restored = c.SDL_WINDOWEVENT_RESTORED, enter = c.SDL_WINDOWEVENT_ENTER, leave = c.SDL_WINDOWEVENT_LEAVE, focus_gained = c.SDL_WINDOWEVENT_FOCUS_GAINED, focus_lost = c.SDL_WINDOWEVENT_FOCUS_LOST, close = c.SDL_WINDOWEVENT_CLOSE, take_focus = c.SDL_WINDOWEVENT_TAKE_FOCUS, hit_test = c.SDL_WINDOWEVENT_HIT_TEST, _, }; const Data = union(Type) { shown: void, hidden: void, exposed: void, moved: Point, resized: Size, size_changed: Size, minimized: void, maximized: void, restored: void, enter: void, leave: void, focus_gained: void, focus_lost: void, close: void, take_focus: void, hit_test: void, none: void, }; timestamp: u32, window_id: u32, type: Data, fn fromNative(ev: c.SDL_WindowEvent) WindowEvent { return WindowEvent{ .timestamp = ev.timestamp, .window_id = ev.windowID, .type = switch (@intToEnum(Type, ev.event)) { .shown => Data{ .shown = {} }, .hidden => Data{ .hidden = {} }, .exposed => Data{ .exposed = {} }, .moved => Data{ .moved = Point{ .x = ev.data1, .y = ev.data2 } }, .resized => Data{ .resized = Size{ .width = ev.data1, .height = ev.data2 } }, .size_changed => Data{ .size_changed = Size{ .width = ev.data1, .height = ev.data2 } }, .minimized => Data{ .minimized = {} }, .maximized => Data{ .maximized = {} }, .restored => Data{ .restored = {} }, .enter => Data{ .enter = {} }, .leave => Data{ .leave = {} }, .focus_gained => Data{ .focus_gained = {} }, .focus_lost => Data{ .focus_lost = {} }, .close => Data{ .close = {} }, .take_focus => Data{ .take_focus = {} }, .hit_test => Data{ .hit_test = {} }, else => Data{ .none = {} }, }, }; } }; pub const KeyModifierBit = enum(u16) { left_shift = c.KMOD_LSHIFT, right_shift = c.KMOD_RSHIFT, left_control = c.KMOD_LCTRL, right_control = c.KMOD_RCTRL, ///left alternate left_alt = c.KMOD_LALT, ///right alternate right_alt = c.KMOD_RALT, left_gui = c.KMOD_LGUI, right_gui = c.KMOD_RGUI, ///numeric lock num_lock = c.KMOD_NUM, ///capital letters lock caps_lock = c.KMOD_CAPS, mode = c.KMOD_MODE, ///scroll lock (= previous value c.KMOD_RESERVED) scroll_lock = c.KMOD_SCROLL, }; pub const KeyModifierSet = struct { storage: u16, pub fn fromNative(native: u16) KeyModifierSet { return .{ .storage = native }; } pub fn toNative(self: KeyModifierSet) u16 { return self.storage; } pub fn get(self: KeyModifierSet, modifier: KeyModifierBit) bool { return (self.storage & @enumToInt(modifier)) != 0; } pub fn set(self: *KeyModifierSet, modifier: KeyModifierBit) void { self.storage |= @enumToInt(modifier); } pub fn clear(self: *KeyModifierSet, modifier: KeyModifierBit) void { self.storage &= ~@enumToInt(modifier); } }; pub const KeyboardEvent = struct { pub const KeyState = enum(u8) { released = c.SDL_RELEASED, pressed = c.SDL_PRESSED, }; timestamp: u32, window_id: u32, key_state: KeyState, is_repeat: bool, scancode: Scancode, keycode: Keycode, modifiers: KeyModifierSet, pub fn fromNative(native: c.SDL_KeyboardEvent) KeyboardEvent { switch (native.type) { else => unreachable, c.SDL_KEYDOWN, c.SDL_KEYUP => {}, } return .{ .timestamp = native.timestamp, .window_id = native.windowID, .key_state = @intToEnum(KeyState, native.state), .is_repeat = native.repeat != 0, .scancode = @intToEnum(Scancode, native.keysym.scancode), .keycode = @intToEnum(Keycode, native.keysym.sym), .modifiers = KeyModifierSet.fromNative(native.keysym.mod), }; } }; pub const MouseButton = enum(u3) { left = c.SDL_BUTTON_LEFT, middle = c.SDL_BUTTON_MIDDLE, right = c.SDL_BUTTON_RIGHT, extra_1 = c.SDL_BUTTON_X1, extra_2 = c.SDL_BUTTON_X2, }; pub const MouseButtonState = struct { pub const NativeBitField = u32; // All known values would fit in a u5, // do we want to truncate it to that? pub const Storage = NativeBitField; storage: Storage, fn maskForButton(button_id: MouseButton) Storage { const mask = c.SDL_BUTTON(@enumToInt(button_id)); const mask_unsigned = @bitCast(NativeBitField, mask); return @intCast(Storage, mask_unsigned); } pub fn getPressed(self: MouseButtonState, button_id: MouseButton) bool { return (self.storage & maskForButton(button_id)) != 0; } pub fn setPressed(self: MouseButtonState, button_id: MouseButton) void { self.storage |= maskForButton(button_id); } pub fn setUnpressed(self: *MouseButtonState, button_id: MouseButton) void { self.storage &= ~maskForButton(button_id); } pub fn fromNative(native: NativeBitField) MouseButtonState { return .{ .storage = @intCast(Storage, native) }; } pub fn toNative(self: MouseButtonState) NativeBitField { return self.storage; } }; pub const MouseMotionEvent = struct { timestamp: u32, /// originally named `windowID` window_id: u32, /// originally named `which`; /// if it comes from a touch input device, /// the value is c.SDL_TOUCH_MOUSEID, /// in which case a TouchFingerEvent was also generated. mouse_instance_id: u32, /// from original field named `state` button_state: MouseButtonState, x: i32, y: i32, /// originally named `xrel`, /// difference of position since last reported MouseMotionEvent, /// ignores screen boundaries if relative mouse mode is enabled /// (see c.SDL_SetRelativeMouseMode) delta_x: i32, /// originally named `yrel`, /// difference of position since last reported MouseMotionEvent, /// ignores screen boundaries if relative mouse mode is enabled /// (see c.SDL_SetRelativeMouseMode) delta_y: i32, pub fn fromNative(native: c.SDL_MouseMotionEvent) MouseMotionEvent { std.debug.assert(native.type == c.SDL_MOUSEMOTION); return .{ .timestamp = native.timestamp, .window_id = native.windowID, .mouse_instance_id = native.which, .button_state = MouseButtonState.fromNative(native.state), .x = native.x, .y = native.y, .delta_x = native.xrel, .delta_y = native.yrel, }; } }; pub const MouseButtonEvent = struct { pub const ButtonState = enum(u8) { released = c.SDL_RELEASED, pressed = c.SDL_PRESSED, }; timestamp: u32, /// originally named `windowID` window_id: u32, /// originally named `which`, /// if it comes from a touch input device, /// the value is c.SDL_TOUCH_MOUSEID, /// in which case a TouchFingerEvent was also generated. mouse_instance_id: u32, button: MouseButton, state: ButtonState, clicks: u8, x: i32, y: i32, pub fn fromNative(native: c.SDL_MouseButtonEvent) MouseButtonEvent { switch (native.type) { else => unreachable, c.SDL_MOUSEBUTTONDOWN, c.SDL_MOUSEBUTTONUP => {}, } return .{ .timestamp = native.timestamp, .window_id = native.windowID, .mouse_instance_id = native.which, .button = @intToEnum(MouseButton, native.button), .state = @intToEnum(ButtonState, native.state), .clicks = native.clicks, .x = native.x, .y = native.y, }; } }; pub const MouseWheelEvent = struct { pub const Direction = enum(u8) { normal = c.SDL_MOUSEWHEEL_NORMAL, flipped = c.SDL_MOUSEWHEEL_FLIPPED, }; timestamp: u32, /// originally named `windowID` window_id: u32, /// originally named `which`, /// if it comes from a touch input device, /// the value is c.SDL_TOUCH_MOUSEID, /// in which case a TouchFingerEvent was also generated. mouse_instance_id: u32, /// originally named `x`, /// the amount scrolled horizontally, /// positive to the right and negative to the left, /// unless field `direction` has value `.flipped`, /// in which case the signs are reversed. delta_x: i32, /// originally named `y`, /// the amount scrolled vertically, /// positive away from the user and negative towards the user, /// unless field `direction` has value `.flipped`, /// in which case the signs are reversed. delta_y: i32, /// On macOS, devices are often by default configured to have /// "natural" scrolling direction, which flips the sign of both delta values. /// In this case, this field will have value `.flipped` instead of `.normal`. direction: Direction, pub fn fromNative(native: c.SDL_MouseWheelEvent) MouseWheelEvent { std.debug.assert(native.type == c.SDL_MOUSEWHEEL); return .{ .timestamp = native.timestamp, .window_id = native.windowID, .mouse_instance_id = native.which, .delta_x = native.x, .delta_y = native.y, .direction = @intToEnum(Direction, @intCast(u8, native.direction)), }; } }; pub const EventType = std.meta.Tag(Event); pub const Event = union(enum) { pub const CommonEvent = c.SDL_CommonEvent; pub const DisplayEvent = c.SDL_DisplayEvent; pub const TextEditingEvent = c.SDL_TextEditingEvent; pub const TextInputEvent = c.SDL_TextInputEvent; pub const JoyAxisEvent = c.SDL_JoyAxisEvent; pub const JoyBallEvent = c.SDL_JoyBallEvent; pub const JoyHatEvent = c.SDL_JoyHatEvent; pub const JoyButtonEvent = c.SDL_JoyButtonEvent; pub const JoyDeviceEvent = c.SDL_JoyDeviceEvent; pub const ControllerAxisEvent = c.SDL_ControllerAxisEvent; pub const ControllerButtonEvent = c.SDL_ControllerButtonEvent; pub const ControllerDeviceEvent = c.SDL_ControllerDeviceEvent; pub const AudioDeviceEvent = c.SDL_AudioDeviceEvent; pub const SensorEvent = c.SDL_SensorEvent; pub const QuitEvent = c.SDL_QuitEvent; pub const UserEvent = c.SDL_UserEvent; pub const SysWMEvent = c.SDL_SysWMEvent; pub const TouchFingerEvent = c.SDL_TouchFingerEvent; pub const MultiGestureEvent = c.SDL_MultiGestureEvent; pub const DollarGestureEvent = c.SDL_DollarGestureEvent; pub const DropEvent = c.SDL_DropEvent; clip_board_update: CommonEvent, app_did_enter_background: CommonEvent, app_did_enter_foreground: CommonEvent, app_will_enter_foreground: CommonEvent, app_will_enter_background: CommonEvent, app_low_memory: CommonEvent, app_terminating: CommonEvent, render_targets_reset: CommonEvent, render_device_reset: CommonEvent, key_map_changed: CommonEvent, display: DisplayEvent, window: WindowEvent, key_down: KeyboardEvent, key_up: KeyboardEvent, text_editing: TextEditingEvent, text_input: TextInputEvent, mouse_motion: MouseMotionEvent, mouse_button_down: MouseButtonEvent, mouse_button_up: MouseButtonEvent, mouse_wheel: MouseWheelEvent, joy_axis_motion: JoyAxisEvent, joy_ball_motion: JoyBallEvent, joy_hat_motion: JoyHatEvent, joy_button_down: JoyButtonEvent, joy_button_up: JoyButtonEvent, joy_device_added: JoyDeviceEvent, joy_device_removed: JoyDeviceEvent, controller_axis_motion: ControllerAxisEvent, controller_button_down: ControllerButtonEvent, controller_button_up: ControllerButtonEvent, controller_device_added: ControllerDeviceEvent, controller_device_removed: ControllerDeviceEvent, controller_device_remapped: ControllerDeviceEvent, audio_device_added: AudioDeviceEvent, audio_device_removed: AudioDeviceEvent, sensor_update: SensorEvent, quit: QuitEvent, sys_wm: SysWMEvent, finger_down: TouchFingerEvent, finger_up: TouchFingerEvent, finger_motion: TouchFingerEvent, multi_gesture: MultiGestureEvent, dollar_gesture: DollarGestureEvent, dollar_record: DollarGestureEvent, drop_file: DropEvent, drop_text: DropEvent, drop_begin: DropEvent, drop_complete: DropEvent, // user: UserEvent, pub fn from(raw: c.SDL_Event) Event { return switch (raw.type) { c.SDL_QUIT => Event{ .quit = raw.quit }, c.SDL_APP_TERMINATING => Event{ .app_terminating = raw.common }, c.SDL_APP_LOWMEMORY => Event{ .app_low_memory = raw.common }, c.SDL_APP_WILLENTERBACKGROUND => Event{ .app_will_enter_background = raw.common }, c.SDL_APP_DIDENTERBACKGROUND => Event{ .app_did_enter_background = raw.common }, c.SDL_APP_WILLENTERFOREGROUND => Event{ .app_will_enter_foreground = raw.common }, c.SDL_APP_DIDENTERFOREGROUND => Event{ .app_did_enter_foreground = raw.common }, c.SDL_DISPLAYEVENT => Event{ .display = raw.display }, c.SDL_WINDOWEVENT => Event{ .window = WindowEvent.fromNative(raw.window) }, c.SDL_SYSWMEVENT => Event{ .sys_wm = raw.syswm }, c.SDL_KEYDOWN => Event{ .key_down = KeyboardEvent.fromNative(raw.key) }, c.SDL_KEYUP => Event{ .key_up = KeyboardEvent.fromNative(raw.key) }, c.SDL_TEXTEDITING => Event{ .text_editing = raw.edit }, c.SDL_TEXTINPUT => Event{ .text_input = raw.text }, c.SDL_KEYMAPCHANGED => Event{ .key_map_changed = raw.common }, c.SDL_MOUSEMOTION => Event{ .mouse_motion = MouseMotionEvent.fromNative(raw.motion) }, c.SDL_MOUSEBUTTONDOWN => Event{ .mouse_button_down = MouseButtonEvent.fromNative(raw.button) }, c.SDL_MOUSEBUTTONUP => Event{ .mouse_button_up = MouseButtonEvent.fromNative(raw.button) }, c.SDL_MOUSEWHEEL => Event{ .mouse_wheel = MouseWheelEvent.fromNative(raw.wheel) }, c.SDL_JOYAXISMOTION => Event{ .joy_axis_motion = raw.jaxis }, c.SDL_JOYBALLMOTION => Event{ .joy_ball_motion = raw.jball }, c.SDL_JOYHATMOTION => Event{ .joy_hat_motion = raw.jhat }, c.SDL_JOYBUTTONDOWN => Event{ .joy_button_down = raw.jbutton }, c.SDL_JOYBUTTONUP => Event{ .joy_button_up = raw.jbutton }, c.SDL_JOYDEVICEADDED => Event{ .joy_device_added = raw.jdevice }, c.SDL_JOYDEVICEREMOVED => Event{ .joy_device_removed = raw.jdevice }, c.SDL_CONTROLLERAXISMOTION => Event{ .controller_axis_motion = raw.caxis }, c.SDL_CONTROLLERBUTTONDOWN => Event{ .controller_button_down = raw.cbutton }, c.SDL_CONTROLLERBUTTONUP => Event{ .controller_button_up = raw.cbutton }, c.SDL_CONTROLLERDEVICEADDED => Event{ .controller_device_added = raw.cdevice }, c.SDL_CONTROLLERDEVICEREMOVED => Event{ .controller_device_removed = raw.cdevice }, c.SDL_CONTROLLERDEVICEREMAPPED => Event{ .controller_device_remapped = raw.cdevice }, c.SDL_FINGERDOWN => Event{ .finger_down = raw.tfinger }, c.SDL_FINGERUP => Event{ .finger_up = raw.tfinger }, c.SDL_FINGERMOTION => Event{ .finger_motion = raw.tfinger }, c.SDL_DOLLARGESTURE => Event{ .dollar_gesture = raw.dgesture }, c.SDL_DOLLARRECORD => Event{ .dollar_record = raw.dgesture }, c.SDL_MULTIGESTURE => Event{ .multi_gesture = raw.mgesture }, c.SDL_CLIPBOARDUPDATE => Event{ .clip_board_update = raw.common }, c.SDL_DROPFILE => Event{ .drop_file = raw.drop }, c.SDL_DROPTEXT => Event{ .drop_text = raw.drop }, c.SDL_DROPBEGIN => Event{ .drop_begin = raw.drop }, c.SDL_DROPCOMPLETE => Event{ .drop_complete = raw.drop }, c.SDL_AUDIODEVICEADDED => Event{ .audio_device_added = raw.adevice }, c.SDL_AUDIODEVICEREMOVED => Event{ .audio_device_removed = raw.adevice }, c.SDL_SENSORUPDATE => Event{ .sensor_update = raw.sensor }, c.SDL_RENDER_TARGETS_RESET => Event{ .render_targets_reset = raw.common }, c.SDL_RENDER_DEVICE_RESET => Event{ .render_device_reset = raw.common }, else => @panic("Unsupported event type detected!"), }; } }; /// This function should only be called from /// the thread that initialized the video subsystem. pub fn pumpEvents() void { c.SDL_PumpEvents(); } pub fn pollEvent() ?Event { var ev: c.SDL_Event = undefined; if (c.SDL_PollEvent(&ev) != 0) return Event.from(ev); return null; } pub fn pollNativeEvent() ?c.SDL_Event { var ev: c.SDL_Event = undefined; if (c.SDL_PollEvent(&ev) != 0) return ev; return null; } /// Waits indefinitely to pump a new event into the queue. /// May not conserve energy on some systems, in some versions/situations. /// This function should only be called from /// the thread that initialized the video subsystem. pub fn waitEvent() !Event { var ev: c.SDL_Event = undefined; if (c.SDL_WaitEvent(&ev) != 0) return Event.from(ev); return makeError(); } /// Waits `timeout` milliseconds /// to pump the next available event into the queue. /// May not conserve energy on some systems, in some versions/situations. /// This function should only be called from /// the thread that initialized the video subsystem. pub fn waitEventTimeout(timeout: usize) ?Event { var ev: c.SDL_Event = undefined; if (c.SDL_WaitEventTimeout(&ev, @intCast(c_int, timeout)) != 0) return Event.from(ev); return null; } pub const MouseState = struct { x: c_int, y: c_int, buttons: MouseButtonState, }; pub fn getMouseState() MouseState { var ms: MouseState = undefined; const buttons = c.SDL_GetMouseState(&ms.x, &ms.y); ms.buttons = MouseButtonState.fromNative(buttons); return ms; } pub const Scancode = enum(c.SDL_Scancode) { unknown = c.SDL_SCANCODE_UNKNOWN, a = c.SDL_SCANCODE_A, b = c.SDL_SCANCODE_B, c = c.SDL_SCANCODE_C, d = c.SDL_SCANCODE_D, e = c.SDL_SCANCODE_E, f = c.SDL_SCANCODE_F, g = c.SDL_SCANCODE_G, h = c.SDL_SCANCODE_H, i = c.SDL_SCANCODE_I, j = c.SDL_SCANCODE_J, k = c.SDL_SCANCODE_K, l = c.SDL_SCANCODE_L, m = c.SDL_SCANCODE_M, n = c.SDL_SCANCODE_N, o = c.SDL_SCANCODE_O, p = c.SDL_SCANCODE_P, q = c.SDL_SCANCODE_Q, r = c.SDL_SCANCODE_R, s = c.SDL_SCANCODE_S, t = c.SDL_SCANCODE_T, u = c.SDL_SCANCODE_U, v = c.SDL_SCANCODE_V, w = c.SDL_SCANCODE_W, x = c.SDL_SCANCODE_X, y = c.SDL_SCANCODE_Y, z = c.SDL_SCANCODE_Z, @"1" = c.SDL_SCANCODE_1, @"2" = c.SDL_SCANCODE_2, @"3" = c.SDL_SCANCODE_3, @"4" = c.SDL_SCANCODE_4, @"5" = c.SDL_SCANCODE_5, @"6" = c.SDL_SCANCODE_6, @"7" = c.SDL_SCANCODE_7, @"8" = c.SDL_SCANCODE_8, @"9" = c.SDL_SCANCODE_9, @"0" = c.SDL_SCANCODE_0, @"return" = c.SDL_SCANCODE_RETURN, escape = c.SDL_SCANCODE_ESCAPE, backspace = c.SDL_SCANCODE_BACKSPACE, tab = c.SDL_SCANCODE_TAB, space = c.SDL_SCANCODE_SPACE, minus = c.SDL_SCANCODE_MINUS, equals = c.SDL_SCANCODE_EQUALS, left_bracket = c.SDL_SCANCODE_LEFTBRACKET, right_bracket = c.SDL_SCANCODE_RIGHTBRACKET, backslash = c.SDL_SCANCODE_BACKSLASH, non_us_hash = c.SDL_SCANCODE_NONUSHASH, semicolon = c.SDL_SCANCODE_SEMICOLON, apostrophe = c.SDL_SCANCODE_APOSTROPHE, grave = c.SDL_SCANCODE_GRAVE, comma = c.SDL_SCANCODE_COMMA, period = c.SDL_SCANCODE_PERIOD, slash = c.SDL_SCANCODE_SLASH, ///capital letters lock caps_lock = c.SDL_SCANCODE_CAPSLOCK, f1 = c.SDL_SCANCODE_F1, f2 = c.SDL_SCANCODE_F2, f3 = c.SDL_SCANCODE_F3, f4 = c.SDL_SCANCODE_F4, f5 = c.SDL_SCANCODE_F5, f6 = c.SDL_SCANCODE_F6, f7 = c.SDL_SCANCODE_F7, f8 = c.SDL_SCANCODE_F8, f9 = c.SDL_SCANCODE_F9, f10 = c.SDL_SCANCODE_F10, f11 = c.SDL_SCANCODE_F11, f12 = c.SDL_SCANCODE_F12, print_screen = c.SDL_SCANCODE_PRINTSCREEN, scroll_lock = c.SDL_SCANCODE_SCROLLLOCK, pause = c.SDL_SCANCODE_PAUSE, insert = c.SDL_SCANCODE_INSERT, home = c.SDL_SCANCODE_HOME, page_up = c.SDL_SCANCODE_PAGEUP, delete = c.SDL_SCANCODE_DELETE, end = c.SDL_SCANCODE_END, page_down = c.SDL_SCANCODE_PAGEDOWN, right = c.SDL_SCANCODE_RIGHT, left = c.SDL_SCANCODE_LEFT, down = c.SDL_SCANCODE_DOWN, up = c.SDL_SCANCODE_UP, ///numeric lock, "Clear" key on Apple keyboards num_lock_clear = c.SDL_SCANCODE_NUMLOCKCLEAR, keypad_divide = c.SDL_SCANCODE_KP_DIVIDE, keypad_multiply = c.SDL_SCANCODE_KP_MULTIPLY, keypad_minus = c.SDL_SCANCODE_KP_MINUS, keypad_plus = c.SDL_SCANCODE_KP_PLUS, keypad_enter = c.SDL_SCANCODE_KP_ENTER, keypad_1 = c.SDL_SCANCODE_KP_1, keypad_2 = c.SDL_SCANCODE_KP_2, keypad_3 = c.SDL_SCANCODE_KP_3, keypad_4 = c.SDL_SCANCODE_KP_4, keypad_5 = c.SDL_SCANCODE_KP_5, keypad_6 = c.SDL_SCANCODE_KP_6, keypad_7 = c.SDL_SCANCODE_KP_7, keypad_8 = c.SDL_SCANCODE_KP_8, keypad_9 = c.SDL_SCANCODE_KP_9, keypad_0 = c.SDL_SCANCODE_KP_0, keypad_period = c.SDL_SCANCODE_KP_PERIOD, non_us_backslash = c.SDL_SCANCODE_NONUSBACKSLASH, application = c.SDL_SCANCODE_APPLICATION, power = c.SDL_SCANCODE_POWER, keypad_equals = c.SDL_SCANCODE_KP_EQUALS, f13 = c.SDL_SCANCODE_F13, f14 = c.SDL_SCANCODE_F14, f15 = c.SDL_SCANCODE_F15, f16 = c.SDL_SCANCODE_F16, f17 = c.SDL_SCANCODE_F17, f18 = c.SDL_SCANCODE_F18, f19 = c.SDL_SCANCODE_F19, f20 = c.SDL_SCANCODE_F20, f21 = c.SDL_SCANCODE_F21, f22 = c.SDL_SCANCODE_F22, f23 = c.SDL_SCANCODE_F23, f24 = c.SDL_SCANCODE_F24, execute = c.SDL_SCANCODE_EXECUTE, help = c.SDL_SCANCODE_HELP, menu = c.SDL_SCANCODE_MENU, select = c.SDL_SCANCODE_SELECT, stop = c.SDL_SCANCODE_STOP, again = c.SDL_SCANCODE_AGAIN, undo = c.SDL_SCANCODE_UNDO, cut = c.SDL_SCANCODE_CUT, copy = c.SDL_SCANCODE_COPY, paste = c.SDL_SCANCODE_PASTE, find = c.SDL_SCANCODE_FIND, mute = c.SDL_SCANCODE_MUTE, volume_up = c.SDL_SCANCODE_VOLUMEUP, volume_down = c.SDL_SCANCODE_VOLUMEDOWN, keypad_comma = c.SDL_SCANCODE_KP_COMMA, keypad_equals_as_400 = c.SDL_SCANCODE_KP_EQUALSAS400, international_1 = c.SDL_SCANCODE_INTERNATIONAL1, international_2 = c.SDL_SCANCODE_INTERNATIONAL2, international_3 = c.SDL_SCANCODE_INTERNATIONAL3, international_4 = c.SDL_SCANCODE_INTERNATIONAL4, international_5 = c.SDL_SCANCODE_INTERNATIONAL5, international_6 = c.SDL_SCANCODE_INTERNATIONAL6, international_7 = c.SDL_SCANCODE_INTERNATIONAL7, international_8 = c.SDL_SCANCODE_INTERNATIONAL8, international_9 = c.SDL_SCANCODE_INTERNATIONAL9, language_1 = c.SDL_SCANCODE_LANG1, language_2 = c.SDL_SCANCODE_LANG2, language_3 = c.SDL_SCANCODE_LANG3, language_4 = c.SDL_SCANCODE_LANG4, language_5 = c.SDL_SCANCODE_LANG5, language_6 = c.SDL_SCANCODE_LANG6, language_7 = c.SDL_SCANCODE_LANG7, language_8 = c.SDL_SCANCODE_LANG8, language_9 = c.SDL_SCANCODE_LANG9, alternate_erase = c.SDL_SCANCODE_ALTERASE, ///aka "Attention" system_request = c.SDL_SCANCODE_SYSREQ, cancel = c.SDL_SCANCODE_CANCEL, clear = c.SDL_SCANCODE_CLEAR, prior = c.SDL_SCANCODE_PRIOR, return_2 = c.SDL_SCANCODE_RETURN2, separator = c.SDL_SCANCODE_SEPARATOR, out = c.SDL_SCANCODE_OUT, ///Don't know what this stands for, operator? operation? operating system? Couldn't find it anywhere. oper = c.SDL_SCANCODE_OPER, ///technically named "Clear/Again" clear_again = c.SDL_SCANCODE_CLEARAGAIN, ///aka "CrSel/Props" (properties) cursor_selection = c.SDL_SCANCODE_CRSEL, extend_selection = c.SDL_SCANCODE_EXSEL, keypad_00 = c.SDL_SCANCODE_KP_00, keypad_000 = c.SDL_SCANCODE_KP_000, thousands_separator = c.SDL_SCANCODE_THOUSANDSSEPARATOR, decimal_separator = c.SDL_SCANCODE_DECIMALSEPARATOR, currency_unit = c.SDL_SCANCODE_CURRENCYUNIT, currency_subunit = c.SDL_SCANCODE_CURRENCYSUBUNIT, keypad_left_parenthesis = c.SDL_SCANCODE_KP_LEFTPAREN, keypad_right_parenthesis = c.SDL_SCANCODE_KP_RIGHTPAREN, keypad_left_brace = c.SDL_SCANCODE_KP_LEFTBRACE, keypad_right_brace = c.SDL_SCANCODE_KP_RIGHTBRACE, keypad_tab = c.SDL_SCANCODE_KP_TAB, keypad_backspace = c.SDL_SCANCODE_KP_BACKSPACE, keypad_a = c.SDL_SCANCODE_KP_A, keypad_b = c.SDL_SCANCODE_KP_B, keypad_c = c.SDL_SCANCODE_KP_C, keypad_d = c.SDL_SCANCODE_KP_D, keypad_e = c.SDL_SCANCODE_KP_E, keypad_f = c.SDL_SCANCODE_KP_F, ///keypad exclusive or keypad_xor = c.SDL_SCANCODE_KP_XOR, keypad_power = c.SDL_SCANCODE_KP_POWER, keypad_percent = c.SDL_SCANCODE_KP_PERCENT, keypad_less = c.SDL_SCANCODE_KP_LESS, keypad_greater = c.SDL_SCANCODE_KP_GREATER, keypad_ampersand = c.SDL_SCANCODE_KP_AMPERSAND, keypad_double_ampersand = c.SDL_SCANCODE_KP_DBLAMPERSAND, keypad_vertical_bar = c.SDL_SCANCODE_KP_VERTICALBAR, keypad_double_vertical_bar = c.SDL_SCANCODE_KP_DBLVERTICALBAR, keypad_colon = c.SDL_SCANCODE_KP_COLON, keypad_hash = c.SDL_SCANCODE_KP_HASH, keypad_space = c.SDL_SCANCODE_KP_SPACE, keypad_at_sign = c.SDL_SCANCODE_KP_AT, keypad_exclamation_mark = c.SDL_SCANCODE_KP_EXCLAM, keypad_memory_store = c.SDL_SCANCODE_KP_MEMSTORE, keypad_memory_recall = c.SDL_SCANCODE_KP_MEMRECALL, keypad_memory_clear = c.SDL_SCANCODE_KP_MEMCLEAR, keypad_memory_add = c.SDL_SCANCODE_KP_MEMADD, keypad_memory_subtract = c.SDL_SCANCODE_KP_MEMSUBTRACT, keypad_memory_multiply = c.SDL_SCANCODE_KP_MEMMULTIPLY, keypad_memory_divide = c.SDL_SCANCODE_KP_MEMDIVIDE, keypad_plus_minus = c.SDL_SCANCODE_KP_PLUSMINUS, keypad_clear = c.SDL_SCANCODE_KP_CLEAR, keypad_clear_entry = c.SDL_SCANCODE_KP_CLEARENTRY, keypad_binary = c.SDL_SCANCODE_KP_BINARY, keypad_octal = c.SDL_SCANCODE_KP_OCTAL, keypad_decimal = c.SDL_SCANCODE_KP_DECIMAL, keypad_hexadecimal = c.SDL_SCANCODE_KP_HEXADECIMAL, left_control = c.SDL_SCANCODE_LCTRL, left_shift = c.SDL_SCANCODE_LSHIFT, ///left alternate left_alt = c.SDL_SCANCODE_LALT, left_gui = c.SDL_SCANCODE_LGUI, right_control = c.SDL_SCANCODE_RCTRL, right_shift = c.SDL_SCANCODE_RSHIFT, ///right alternate right_alt = c.SDL_SCANCODE_RALT, right_gui = c.SDL_SCANCODE_RGUI, mode = c.SDL_SCANCODE_MODE, audio_next = c.SDL_SCANCODE_AUDIONEXT, audio_previous = c.SDL_SCANCODE_AUDIOPREV, audio_stop = c.SDL_SCANCODE_AUDIOSTOP, audio_play = c.SDL_SCANCODE_AUDIOPLAY, audio_mute = c.SDL_SCANCODE_AUDIOMUTE, media_select = c.SDL_SCANCODE_MEDIASELECT, www = c.SDL_SCANCODE_WWW, mail = c.SDL_SCANCODE_MAIL, calculator = c.SDL_SCANCODE_CALCULATOR, computer = c.SDL_SCANCODE_COMPUTER, application_control_search = c.SDL_SCANCODE_AC_SEARCH, application_control_home = c.SDL_SCANCODE_AC_HOME, application_control_back = c.SDL_SCANCODE_AC_BACK, application_control_forward = c.SDL_SCANCODE_AC_FORWARD, application_control_stop = c.SDL_SCANCODE_AC_STOP, application_control_refresh = c.SDL_SCANCODE_AC_REFRESH, application_control_bookmarks = c.SDL_SCANCODE_AC_BOOKMARKS, brightness_down = c.SDL_SCANCODE_BRIGHTNESSDOWN, brightness_up = c.SDL_SCANCODE_BRIGHTNESSUP, display_switch = c.SDL_SCANCODE_DISPLAYSWITCH, keyboard_illumination_toggle = c.SDL_SCANCODE_KBDILLUMTOGGLE, keyboard_illumination_down = c.SDL_SCANCODE_KBDILLUMDOWN, keyboard_illumination_up = c.SDL_SCANCODE_KBDILLUMUP, eject = c.SDL_SCANCODE_EJECT, sleep = c.SDL_SCANCODE_SLEEP, application_1 = c.SDL_SCANCODE_APP1, application_2 = c.SDL_SCANCODE_APP2, audio_rewind = c.SDL_SCANCODE_AUDIOREWIND, audio_fast_forward = c.SDL_SCANCODE_AUDIOFASTFORWARD, _, }; pub const KeyboardState = struct { states: []const u8, pub fn isPressed(ks: KeyboardState, scancode: Scancode) bool { return ks.states[@intCast(usize, @enumToInt(scancode))] != 0; } }; pub fn getKeyboardState() KeyboardState { var len: c_int = undefined; const slice = c.SDL_GetKeyboardState(&len); return KeyboardState{ .states = slice[0..@intCast(usize, len)], }; } pub const getModState = getKeyboardModifierState; pub fn getKeyboardModifierState() KeyModifierSet { return KeyModifierSet.fromNative(@intCast(u16, c.SDL_GetModState())); } pub const Keycode = enum(c.SDL_Keycode) { unknown = c.SDLK_UNKNOWN, @"return" = c.SDLK_RETURN, escape = c.SDLK_ESCAPE, backspace = c.SDLK_BACKSPACE, tab = c.SDLK_TAB, space = c.SDLK_SPACE, exclamation_mark = c.SDLK_EXCLAIM, quote = c.SDLK_QUOTEDBL, hash = c.SDLK_HASH, percent = c.SDLK_PERCENT, dollar = c.SDLK_DOLLAR, ampersand = c.SDLK_AMPERSAND, apostrophe = c.SDLK_QUOTE, left_parenthesis = c.SDLK_LEFTPAREN, right_parenthesis = c.SDLK_RIGHTPAREN, asterisk = c.SDLK_ASTERISK, plus = c.SDLK_PLUS, comma = c.SDLK_COMMA, minus = c.SDLK_MINUS, period = c.SDLK_PERIOD, slash = c.SDLK_SLASH, @"0" = c.SDLK_0, @"1" = c.SDLK_1, @"2" = c.SDLK_2, @"3" = c.SDLK_3, @"4" = c.SDLK_4, @"5" = c.SDLK_5, @"6" = c.SDLK_6, @"7" = c.SDLK_7, @"8" = c.SDLK_8, @"9" = c.SDLK_9, colon = c.SDLK_COLON, semicolon = c.SDLK_SEMICOLON, less = c.SDLK_LESS, equals = c.SDLK_EQUALS, greater = c.SDLK_GREATER, question_mark = c.SDLK_QUESTION, at_sign = c.SDLK_AT, left_bracket = c.SDLK_LEFTBRACKET, backslash = c.SDLK_BACKSLASH, right_bracket = c.SDLK_RIGHTBRACKET, caret = c.SDLK_CARET, underscore = c.SDLK_UNDERSCORE, grave = c.SDLK_BACKQUOTE, a = c.SDLK_a, b = c.SDLK_b, c = c.SDLK_c, d = c.SDLK_d, e = c.SDLK_e, f = c.SDLK_f, g = c.SDLK_g, h = c.SDLK_h, i = c.SDLK_i, j = c.SDLK_j, k = c.SDLK_k, l = c.SDLK_l, m = c.SDLK_m, n = c.SDLK_n, o = c.SDLK_o, p = c.SDLK_p, q = c.SDLK_q, r = c.SDLK_r, s = c.SDLK_s, t = c.SDLK_t, u = c.SDLK_u, v = c.SDLK_v, w = c.SDLK_w, x = c.SDLK_x, y = c.SDLK_y, z = c.SDLK_z, ///capital letters lock caps_lock = c.SDLK_CAPSLOCK, f1 = c.SDLK_F1, f2 = c.SDLK_F2, f3 = c.SDLK_F3, f4 = c.SDLK_F4, f5 = c.SDLK_F5, f6 = c.SDLK_F6, f7 = c.SDLK_F7, f8 = c.SDLK_F8, f9 = c.SDLK_F9, f10 = c.SDLK_F10, f11 = c.SDLK_F11, f12 = c.SDLK_F12, print_screen = c.SDLK_PRINTSCREEN, scroll_lock = c.SDLK_SCROLLLOCK, pause = c.SDLK_PAUSE, insert = c.SDLK_INSERT, home = c.SDLK_HOME, page_up = c.SDLK_PAGEUP, delete = c.SDLK_DELETE, end = c.SDLK_END, page_down = c.SDLK_PAGEDOWN, right = c.SDLK_RIGHT, left = c.SDLK_LEFT, down = c.SDLK_DOWN, up = c.SDLK_UP, ///numeric lock, "Clear" key on Apple keyboards num_lock_clear = c.SDLK_NUMLOCKCLEAR, keypad_divide = c.SDLK_KP_DIVIDE, keypad_multiply = c.SDLK_KP_MULTIPLY, keypad_minus = c.SDLK_KP_MINUS, keypad_plus = c.SDLK_KP_PLUS, keypad_enter = c.SDLK_KP_ENTER, keypad_1 = c.SDLK_KP_1, keypad_2 = c.SDLK_KP_2, keypad_3 = c.SDLK_KP_3, keypad_4 = c.SDLK_KP_4, keypad_5 = c.SDLK_KP_5, keypad_6 = c.SDLK_KP_6, keypad_7 = c.SDLK_KP_7, keypad_8 = c.SDLK_KP_8, keypad_9 = c.SDLK_KP_9, keypad_0 = c.SDLK_KP_0, keypad_period = c.SDLK_KP_PERIOD, application = c.SDLK_APPLICATION, power = c.SDLK_POWER, keypad_equals = c.SDLK_KP_EQUALS, f13 = c.SDLK_F13, f14 = c.SDLK_F14, f15 = c.SDLK_F15, f16 = c.SDLK_F16, f17 = c.SDLK_F17, f18 = c.SDLK_F18, f19 = c.SDLK_F19, f20 = c.SDLK_F20, f21 = c.SDLK_F21, f22 = c.SDLK_F22, f23 = c.SDLK_F23, f24 = c.SDLK_F24, execute = c.SDLK_EXECUTE, help = c.SDLK_HELP, menu = c.SDLK_MENU, select = c.SDLK_SELECT, stop = c.SDLK_STOP, again = c.SDLK_AGAIN, undo = c.SDLK_UNDO, cut = c.SDLK_CUT, copy = c.SDLK_COPY, paste = c.SDLK_PASTE, find = c.SDLK_FIND, mute = c.SDLK_MUTE, volume_up = c.SDLK_VOLUMEUP, volume_down = c.SDLK_VOLUMEDOWN, keypad_comma = c.SDLK_KP_COMMA, keypad_equals_as_400 = c.SDLK_KP_EQUALSAS400, alternate_erase = c.SDLK_ALTERASE, ///aka "Attention" system_request = c.SDLK_SYSREQ, cancel = c.SDLK_CANCEL, clear = c.SDLK_CLEAR, prior = c.SDLK_PRIOR, return_2 = c.SDLK_RETURN2, separator = c.SDLK_SEPARATOR, out = c.SDLK_OUT, ///Don't know what this stands for, operator? operation? operating system? Couldn't find it anywhere. oper = c.SDLK_OPER, ///technically named "Clear/Again" clear_again = c.SDLK_CLEARAGAIN, ///aka "CrSel/Props" (properties) cursor_selection = c.SDLK_CRSEL, extend_selection = c.SDLK_EXSEL, keypad_00 = c.SDLK_KP_00, keypad_000 = c.SDLK_KP_000, thousands_separator = c.SDLK_THOUSANDSSEPARATOR, decimal_separator = c.SDLK_DECIMALSEPARATOR, currency_unit = c.SDLK_CURRENCYUNIT, currency_subunit = c.SDLK_CURRENCYSUBUNIT, keypad_left_parenthesis = c.SDLK_KP_LEFTPAREN, keypad_right_parenthesis = c.SDLK_KP_RIGHTPAREN, keypad_left_brace = c.SDLK_KP_LEFTBRACE, keypad_right_brace = c.SDLK_KP_RIGHTBRACE, keypad_tab = c.SDLK_KP_TAB, keypad_backspace = c.SDLK_KP_BACKSPACE, keypad_a = c.SDLK_KP_A, keypad_b = c.SDLK_KP_B, keypad_c = c.SDLK_KP_C, keypad_d = c.SDLK_KP_D, keypad_e = c.SDLK_KP_E, keypad_f = c.SDLK_KP_F, ///keypad exclusive or keypad_xor = c.SDLK_KP_XOR, keypad_power = c.SDLK_KP_POWER, keypad_percent = c.SDLK_KP_PERCENT, keypad_less = c.SDLK_KP_LESS, keypad_greater = c.SDLK_KP_GREATER, keypad_ampersand = c.SDLK_KP_AMPERSAND, keypad_double_ampersand = c.SDLK_KP_DBLAMPERSAND, keypad_vertical_bar = c.SDLK_KP_VERTICALBAR, keypad_double_vertical_bar = c.SDLK_KP_DBLVERTICALBAR, keypad_colon = c.SDLK_KP_COLON, keypad_hash = c.SDLK_KP_HASH, keypad_space = c.SDLK_KP_SPACE, keypad_at_sign = c.SDLK_KP_AT, keypad_exclamation_mark = c.SDLK_KP_EXCLAM, keypad_memory_store = c.SDLK_KP_MEMSTORE, keypad_memory_recall = c.SDLK_KP_MEMRECALL, keypad_memory_clear = c.SDLK_KP_MEMCLEAR, keypad_memory_add = c.SDLK_KP_MEMADD, keypad_memory_subtract = c.SDLK_KP_MEMSUBTRACT, keypad_memory_multiply = c.SDLK_KP_MEMMULTIPLY, keypad_memory_divide = c.SDLK_KP_MEMDIVIDE, keypad_plus_minus = c.SDLK_KP_PLUSMINUS, keypad_clear = c.SDLK_KP_CLEAR, keypad_clear_entry = c.SDLK_KP_CLEARENTRY, keypad_binary = c.SDLK_KP_BINARY, keypad_octal = c.SDLK_KP_OCTAL, keypad_decimal = c.SDLK_KP_DECIMAL, keypad_hexadecimal = c.SDLK_KP_HEXADECIMAL, left_control = c.SDLK_LCTRL, left_shift = c.SDLK_LSHIFT, ///left alternate left_alt = c.SDLK_LALT, left_gui = c.SDLK_LGUI, right_control = c.SDLK_RCTRL, right_shift = c.SDLK_RSHIFT, ///right alternate right_alt = c.SDLK_RALT, right_gui = c.SDLK_RGUI, mode = c.SDLK_MODE, audio_next = c.SDLK_AUDIONEXT, audio_previous = c.SDLK_AUDIOPREV, audio_stop = c.SDLK_AUDIOSTOP, audio_play = c.SDLK_AUDIOPLAY, audio_mute = c.SDLK_AUDIOMUTE, media_select = c.SDLK_MEDIASELECT, www = c.SDLK_WWW, mail = c.SDLK_MAIL, calculator = c.SDLK_CALCULATOR, computer = c.SDLK_COMPUTER, application_control_search = c.SDLK_AC_SEARCH, application_control_home = c.SDLK_AC_HOME, application_control_back = c.SDLK_AC_BACK, application_control_forward = c.SDLK_AC_FORWARD, application_control_stop = c.SDLK_AC_STOP, application_control_refresh = c.SDLK_AC_REFRESH, application_control_bookmarks = c.SDLK_AC_BOOKMARKS, brightness_down = c.SDLK_BRIGHTNESSDOWN, brightness_up = c.SDLK_BRIGHTNESSUP, display_switch = c.SDLK_DISPLAYSWITCH, keyboard_illumination_toggle = c.SDLK_KBDILLUMTOGGLE, keyboard_illumination_down = c.SDLK_KBDILLUMDOWN, keyboard_illumination_up = c.SDLK_KBDILLUMUP, eject = c.SDLK_EJECT, sleep = c.SDLK_SLEEP, application_1 = c.SDLK_APP1, application_2 = c.SDLK_APP2, audio_rewind = c.SDLK_AUDIOREWIND, audio_fast_forward = c.SDLK_AUDIOFASTFORWARD, _, }; pub fn getTicks() usize { return c.SDL_GetTicks(); } pub fn delay(ms: u32) void { c.SDL_Delay(ms); } test "platform independent declarations" { std.testing.refAllDecls(@This()); } pub fn numJoysticks() !u31 { const num = c.SDL_NumJoysticks(); if (num < 0) return error.SdlError; return @intCast(u31, num); } pub const GameController = struct { ptr: *c.SDL_GameController, pub fn open(joystick_index: u31) !GameController { return GameController{ .ptr = c.SDL_GameControllerOpen(joystick_index) orelse return error.SdlError, }; } pub fn close(self: GameController) void { c.SDL_GameControllerClose(self.ptr); } pub fn nameForIndex(joystick_index: u31) ?[:0]const u8 { return std.mem.span(c.SDL_GameControllerNameForIndex(joystick_index)); } pub const Button = enum(i32) { a = c.SDL_CONTROLLER_BUTTON_A, b = c.SDL_CONTROLLER_BUTTON_B, x = c.SDL_CONTROLLER_BUTTON_X, y = c.SDL_CONTROLLER_BUTTON_Y, back = c.SDL_CONTROLLER_BUTTON_BACK, guide = c.SDL_CONTROLLER_BUTTON_GUIDE, start = c.SDL_CONTROLLER_BUTTON_START, left_stick = c.SDL_CONTROLLER_BUTTON_LEFTSTICK, right_stick = c.SDL_CONTROLLER_BUTTON_RIGHTSTICK, left_shoulder = c.SDL_CONTROLLER_BUTTON_LEFTSHOULDER, right_shoulder = c.SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, dpad_up = c.SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_down = c.SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_left = c.SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_right = c.SDL_CONTROLLER_BUTTON_DPAD_RIGHT, /// Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button misc_1 = c.SDL_CONTROLLER_BUTTON_MISC1, /// Xbox Elite paddle P1 paddle_1 = c.SDL_CONTROLLER_BUTTON_PADDLE1, /// Xbox Elite paddle P2 paddle_2 = c.SDL_CONTROLLER_BUTTON_PADDLE2, /// Xbox Elite paddle P3 paddle_3 = c.SDL_CONTROLLER_BUTTON_PADDLE3, /// Xbox Elite paddle P4 paddle_4 = c.SDL_CONTROLLER_BUTTON_PADDLE4, /// PS4/PS5 touchpad button touchpad = c.SDL_CONTROLLER_BUTTON_TOUCHPAD, }; pub const Axis = enum(i32) { left_x = c.SDL_CONTROLLER_AXIS_LEFTX, left_y = c.SDL_CONTROLLER_AXIS_LEFTY, right_x = c.SDL_CONTROLLER_AXIS_RIGHTX, right_y = c.SDL_CONTROLLER_AXIS_RIGHTY, trigger_left = c.SDL_CONTROLLER_AXIS_TRIGGERLEFT, trigger_right = c.SDL_CONTROLLER_AXIS_TRIGGERRIGHT, }; }; pub const AudioDevice = struct { pub fn makeUninitialized() AudioDevice { return .{ .id = 0, }; } id: c.SDL_AudioDeviceID, pub fn isInitialized(self: AudioDevice) bool { return self.id != 0; } pub fn close(self: AudioDevice) void { c.SDL_CloseAudioDevice(self.id); } pub fn pause(self: AudioDevice, do_pause: bool) void { c.SDL_PauseAudioDevice(self.id, @boolToInt(do_pause)); } }; const is_little_endian = @import("builtin").target.cpu.arch.endian() == .Little; pub const AudioFormat = struct { pub const @"u8" = AudioFormat{ .sample_length_bits = 8, }; pub const s8 = AudioFormat{ .sample_length_bits = 8, .is_signed = true, }; pub const u16_lsb = AudioFormat{ .sample_length_bits = 16, }; pub const s16_lsb = AudioFormat{ .sample_length_bits = 16, .is_signed = true, }; pub const u16_msb = AudioFormat{ .sample_length_bits = 16, .is_big_endian = true, }; pub const s16_msb = AudioFormat{ .sample_length_bits = 16, .is_big_endian = true, .is_signed = true, }; pub const @"u16" = u16_lsb; pub const s16 = s16_lsb; pub const u16_sys = if (is_little_endian) u16_lsb else u16_msb; pub const s16_sys = if (is_little_endian) s16_lsb else s16_msb; pub const s32_lsb = AudioFormat{ .sample_length_bits = 32, .is_signed = true, }; pub const s32_msb = AudioFormat{ .sample_length_bits = 32, .is_big_endian = true, .is_signed = true, }; pub const s32 = s32_lsb; pub const s32_sys = if (is_little_endian) s32_lsb else s32_msb; pub const f32_lsb = AudioFormat{ .sample_length_bits = 32, .is_float = true, .is_signed = true, }; pub const f32_msb = AudioFormat{ .sample_length_bits = 32, .is_float = true, .is_big_endian = true, .is_signed = true, }; pub const @"f32" = f32_lsb; pub const f32_sys = if (is_little_endian) f32_lsb else f32_msb; sample_length_bits: u8 = 32, is_float: bool = false, is_big_endian: bool = false, is_signed: bool = false, pub fn fromNative(native_packed: u16) AudioFormat { return .{ .sample_length_bits = unpackSampleLengthBits(native_packed), .is_float = unpackFloat(native_packed), .is_big_endian = unpackBigEndian(native_packed), .is_signed = unpackSigned(native_packed), }; } pub fn toNative(format: AudioFormat) u16 { return (if (format.is_signed) @as(u16, c.SDL_AUDIO_MASK_SIGNED) else 0) | (if (format.is_big_endian) @as(u16, c.SDL_AUDIO_MASK_ENDIAN) else 0) | (if (format.is_float) @as(u16, c.SDL_AUDIO_MASK_DATATYPE) else 0) | format.sample_length_bits; } pub fn unpackSampleLengthBits(native_packed: u16) u8 { return @intCast(u8, native_packed & @as(u8, c.SDL_AUDIO_MASK_BITSIZE)); } pub fn unpackFloat(native_packed: u16) bool { return (native_packed & @as(u16, c.SDL_AUDIO_MASK_DATATYPE)) != 0; } pub fn unpackBigEndian(native_packed: u16) bool { return (native_packed & @as(u16, c.SDL_AUDIO_MASK_ENDIAN)) != 0; } pub fn unpackSigned(native_packed: u16) bool { return (native_packed & @as(u16, c.SDL_AUDIO_MASK_SIGNED)) != 0; } }; pub const AudioSpecRequest = struct { ///in Hz, 0 obtains a supported value, values < 0 are not sane, values > 48000 are discouraged ///(field originally named "freq") sample_rate: c_int = 0, ///AudioFormat.fromNative(0) obtains a supported standard format, like s16 buffer_format: AudioFormat = AudioFormat.fromNative(0), ///0 obtains a supported value, otherwise either 1 (mono), 2 (stereo), 4 (quad), 6 (5.1 surround), or 8 (7.1 surround) channel_count: u8 = 0, ///frame = channel_count number of samples; ///0 obtains a supported value, f.e. 46ms worth of buffer, ///otherwise must be a power of two! buffer_size_in_frames: u16 = 0, ///periodically called to fill the audio buffer; ///may be null for use in queueing mode (call c.SDL_QueueAudio periodically) callback: c.SDL_AudioCallback, ///passed to .callback userdata: ?*anyopaque, }; pub const AudioSpecResponse = struct { ///in Hz, values <= 0 are not sane ///(field originally named "freq") sample_rate: c_int, buffer_format: AudioFormat, ///either 1 (mono), 2 (stereo), 4 (quadrophonic), 6 (5.1 surround), or 8 (7.1 surround) channel_count: u8, ///frame = channel_count number of samples; ///will be a power of two ///(field originally named "samples") buffer_size_in_frames: u16, ///(field originally named "size") buffer_size_in_bytes: u32, }; pub const OpenAudioDeviceAllowedChanges = struct { pub const everything = .{ .sample_rate = true, .buffer_format = true, .channel_count = true, .buffer_size = true }; sample_rate: bool = false, buffer_format: bool = false, channel_count: bool = false, buffer_size: bool = false, pub fn toNative(self: OpenAudioDeviceAllowedChanges) c_int { return (if (self.sample_rate) c.SDL_AUDIO_ALLOW_FREQUENCY_CHANGE else 0) | (if (self.buffer_format) c.SDL_AUDIO_ALLOW_FORMAT_CHANGE else 0) | (if (self.channel_count) c.SDL_AUDIO_ALLOW_CHANNELS_CHANGE else 0) | (if (self.buffer_size) c.SDL_AUDIO_ALLOW_SAMPLES_CHANGE else 0); } }; pub const OpenAudioDeviceOptions = struct { device_name: ?[*:0]const u8 = null, is_capture: bool = false, desired_spec: AudioSpecRequest, allowed_changes_from_desired: OpenAudioDeviceAllowedChanges = .{}, }; pub const OpenAudioDeviceResult = struct { device: AudioDevice, obtained_spec: AudioSpecResponse, }; pub fn openAudioDevice(options: OpenAudioDeviceOptions) !OpenAudioDeviceResult { const desired_spec = std.mem.zeroInit(c.SDL_AudioSpec, .{ .freq = options.desired_spec.sample_rate, .format = options.desired_spec.buffer_format.toNative(), .channels = options.desired_spec.channel_count, .samples = options.desired_spec.buffer_size_in_frames, .callback = options.desired_spec.callback, .userdata = options.desired_spec.userdata, }); var obtained_spec = std.mem.zeroInit(c.SDL_AudioSpec, .{}); switch (c.SDL_OpenAudioDevice(options.device_name, @boolToInt(options.is_capture), &desired_spec, &obtained_spec, options.allowed_changes_from_desired.toNative())) { 0 => return makeError(), else => |device_id| return OpenAudioDeviceResult{ .device = .{ .id = device_id, }, .obtained_spec = .{ .sample_rate = obtained_spec.freq, .buffer_format = AudioFormat.fromNative(obtained_spec.format), .channel_count = obtained_spec.channels, .buffer_size_in_frames = obtained_spec.samples, .buffer_size_in_bytes = obtained_spec.size, }, }, } } pub const SystemCursor = enum(c_uint) { arrow = c.SDL_SYSTEM_CURSOR_ARROW, ibeam = c.SDL_SYSTEM_CURSOR_IBEAM, wait = c.SDL_SYSTEM_CURSOR_WAIT, crosshair = c.SDL_SYSTEM_CURSOR_CROSSHAIR, wait_arrow = c.SDL_SYSTEM_CURSOR_WAITARROW, size_nwse = c.SDL_SYSTEM_CURSOR_SIZENWSE, size_nesw = c.SDL_SYSTEM_CURSOR_SIZENESW, size_we = c.SDL_SYSTEM_CURSOR_SIZEWE, size_ns = c.SDL_SYSTEM_CURSOR_SIZENS, size_all = c.SDL_SYSTEM_CURSOR_SIZEALL, size_no = c.SDL_SYSTEM_CURSOR_NO, hand = c.SDL_SYSTEM_CURSOR_HAND, }; pub const Cursor = struct { ptr: *c.SDL_Cursor, pub fn destroy(self: *Cursor) void { c.SDL_FreeCursor(self.ptr); } }; pub fn createCursor(data: []const u8, mask: []const u8, width: u32, height: u32, hot_x: i32, hot_y: i32) !Cursor { std.debug.assert(data.len >= width * height); std.debug.assert(mask.len >= width * height); return Cursor{ .ptr = c.SDL_CreateCursor( data.ptr, mask.ptr, @intCast(c_int, width), @intCast(c_int, height), hot_x, hot_y, ) orelse return makeError(), }; } pub fn createColorCursor(surface: Surface, hot_x: i32, hot_y: i32) !Cursor { return Cursor{ .ptr = c.SDL_CreateColorCursor(surface.ptr, hot_x, hot_y) orelse return makeError(), }; } pub fn createSystemCursor(id: SystemCursor) !Cursor { return Cursor{ .ptr = c.SDL_CreateSystemCursor(@enumToInt(id)) orelse return makeError(), }; } pub fn setCursor(cursor: ?Cursor) void { c.SDL_SetCursor(if (cursor) |cur| cur.ptr else null); } pub fn getCursor() !Cursor { return Cursor{ .ptr = c.SDL_GetCursor() orelse return makeError(), }; } pub fn getDefaultCursor() !Cursor { return Cursor{ .ptr = c.SDL_GetDefaultCursor() orelse return makeError(), }; } pub fn showCursor(toggle: ?bool) !bool { const t = if (toggle) |show| @boolToInt(show) else c.SDL_QUERY; const ret = c.SDL_ShowCursor(t); if (ret < 0) { return makeError(); } else return ret == c.SDL_ENABLE; }
src/wrapper/sdl.zig
const std = @import("std"); const gk = @import("gamekit"); const gfx = gk.gfx; const imgui = @import("imgui"); pub const enable_imgui = true; var clear_color = gk.math.Color.aya; var camera: gk.utils.Camera = undefined; var tex: gfx.Texture = undefined; pub fn main() !void { try gk.run(.{ .init = init, .update = update, .render = render, }); } fn init() !void { camera = gk.utils.Camera.init(); } fn update() !void { imgui.igShowDemoWindow(null); if (gk.input.keyDown(.a)) { camera.pos.x += 100 * gk.time.dt(); } else if (gk.input.keyDown(.d)) { camera.pos.x -= 100 * gk.time.dt(); } if (gk.input.keyDown(.w)) { camera.pos.y -= 100 * gk.time.dt(); } else if (gk.input.keyDown(.s)) { camera.pos.y += 100 * gk.time.dt(); } } fn render() !void { gfx.beginPass(.{ .color = clear_color, .trans_mat = camera.transMat() }); imgui.igText("WASD moves camera " ++ imgui.icons.camera); var color = clear_color.asArray(); if (imgui.igColorEdit4("Clear Color", &color[0], imgui.ImGuiColorEditFlags_NoInputs)) { clear_color = gk.math.Color.fromRgba(color[0], color[1], color[2], color[3]); } var buf: [255]u8 = undefined; var str = try std.fmt.bufPrintZ(&buf, "Camera Pos: {d:.2}, {d:.2}", .{ camera.pos.x, camera.pos.y }); imgui.igText(str); var mouse = gk.input.mousePos(); var world = camera.screenToWorld(mouse); str = try std.fmt.bufPrintZ(&buf, "Mouse Pos: {d:.2}, {d:.2}", .{ mouse.x, mouse.y }); imgui.igText(str); str = try std.fmt.bufPrintZ(&buf, "World Pos: {d:.2}, {d:.2}", .{ world.x, world.y }); imgui.igText(str); if (imgui.ogButton("Camera Pos to 0,0")) camera.pos = .{}; if (imgui.ogButton("Camera Pos to screen center")) { const size = gk.window.size(); camera.pos = .{ .x = @intToFloat(f32, size.w) * 0.5, .y = @intToFloat(f32, size.h) * 0.5 }; } gfx.draw.point(.{}, 40, gk.math.Color.white); gfx.endPass(); }
examples/clear_imgui.zig
pub const LIBID_WUApiLib = Guid.initString("b596cc9f-56e5-419e-a622-e01bb457431e"); pub const UPDATE_LOCKDOWN_WEBSITE_ACCESS = @as(u32, 1); pub const WU_S_SERVICE_STOP = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359297)); pub const WU_S_SELFUPDATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359298)); pub const WU_S_UPDATE_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359299)); pub const WU_S_MARKED_FOR_DISCONNECT = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359300)); pub const WU_S_REBOOT_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359301)); pub const WU_S_ALREADY_INSTALLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359302)); pub const WU_S_ALREADY_UNINSTALLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359303)); pub const WU_S_ALREADY_DOWNLOADED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359304)); pub const WU_S_SOME_UPDATES_SKIPPED_ON_BATTERY = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359305)); pub const WU_S_ALREADY_REVERTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359306)); pub const WU_S_SEARCH_CRITERIA_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2359312)); pub const WU_S_UH_INSTALLSTILLPENDING = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2367509)); pub const WU_S_UH_DOWNLOAD_SIZE_CALCULATED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2367510)); pub const WU_S_SIH_NOOP = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2379777)); pub const WU_S_DM_ALREADYDOWNLOADING = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2383873)); pub const WU_S_METADATA_SKIPPED_BY_ENFORCEMENTMODE = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2388225)); pub const WU_S_METADATA_IGNORED_SIGNATURE_VERIFICATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2388226)); pub const WU_S_SEARCH_LOAD_SHEDDING = @import("../zig.zig").typedConst(HRESULT, @as(i32, 2392065)); pub const WU_E_NO_SERVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124351)); pub const WU_E_MAX_CAPACITY_REACHED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124350)); pub const WU_E_UNKNOWN_ID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124349)); pub const WU_E_NOT_INITIALIZED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124348)); pub const WU_E_RANGEOVERLAP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124347)); pub const WU_E_TOOMANYRANGES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124346)); pub const WU_E_INVALIDINDEX = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124345)); pub const WU_E_ITEMNOTFOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124344)); pub const WU_E_OPERATIONINPROGRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124343)); pub const WU_E_COULDNOTCANCEL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124342)); pub const WU_E_CALL_CANCELLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124341)); pub const WU_E_NOOP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124340)); pub const WU_E_XML_MISSINGDATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124339)); pub const WU_E_XML_INVALID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124338)); pub const WU_E_CYCLE_DETECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124337)); pub const WU_E_TOO_DEEP_RELATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124336)); pub const WU_E_INVALID_RELATIONSHIP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124335)); pub const WU_E_REG_VALUE_INVALID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124334)); pub const WU_E_DUPLICATE_ITEM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124333)); pub const WU_E_INVALID_INSTALL_REQUESTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124332)); pub const WU_E_INSTALL_NOT_ALLOWED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124330)); pub const WU_E_NOT_APPLICABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124329)); pub const WU_E_NO_USERTOKEN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124328)); pub const WU_E_EXCLUSIVE_INSTALL_CONFLICT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124327)); pub const WU_E_POLICY_NOT_SET = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124326)); pub const WU_E_SELFUPDATE_IN_PROGRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124325)); pub const WU_E_INVALID_UPDATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124323)); pub const WU_E_SERVICE_STOP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124322)); pub const WU_E_NO_CONNECTION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124321)); pub const WU_E_NO_INTERACTIVE_USER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124320)); pub const WU_E_TIME_OUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124319)); pub const WU_E_ALL_UPDATES_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124318)); pub const WU_E_EULAS_DECLINED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124317)); pub const WU_E_NO_UPDATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124316)); pub const WU_E_USER_ACCESS_DISABLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124315)); pub const WU_E_INVALID_UPDATE_TYPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124314)); pub const WU_E_URL_TOO_LONG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124313)); pub const WU_E_UNINSTALL_NOT_ALLOWED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124312)); pub const WU_E_INVALID_PRODUCT_LICENSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124311)); pub const WU_E_MISSING_HANDLER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124310)); pub const WU_E_LEGACYSERVER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124309)); pub const WU_E_BIN_SOURCE_ABSENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124308)); pub const WU_E_SOURCE_ABSENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124307)); pub const WU_E_WU_DISABLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124306)); pub const WU_E_CALL_CANCELLED_BY_POLICY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124305)); pub const WU_E_INVALID_PROXY_SERVER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124304)); pub const WU_E_INVALID_FILE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124303)); pub const WU_E_INVALID_CRITERIA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124302)); pub const WU_E_EULA_UNAVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124301)); pub const WU_E_DOWNLOAD_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124300)); pub const WU_E_UPDATE_NOT_PROCESSED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124299)); pub const WU_E_INVALID_OPERATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124298)); pub const WU_E_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124297)); pub const WU_E_WINHTTP_INVALID_FILE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124296)); pub const WU_E_TOO_MANY_RESYNC = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124295)); pub const WU_E_NO_SERVER_CORE_SUPPORT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124288)); pub const WU_E_SYSPREP_IN_PROGRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124287)); pub const WU_E_UNKNOWN_SERVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124286)); pub const WU_E_NO_UI_SUPPORT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124285)); pub const WU_E_PER_MACHINE_UPDATE_ACCESS_DENIED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124284)); pub const WU_E_UNSUPPORTED_SEARCHSCOPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124283)); pub const WU_E_BAD_FILE_URL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124282)); pub const WU_E_REVERT_NOT_ALLOWED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124281)); pub const WU_E_INVALID_NOTIFICATION_INFO = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124280)); pub const WU_E_OUTOFRANGE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124279)); pub const WU_E_SETUP_IN_PROGRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124278)); pub const WU_E_ORPHANED_DOWNLOAD_JOB = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124277)); pub const WU_E_LOW_BATTERY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124276)); pub const WU_E_INFRASTRUCTUREFILE_INVALID_FORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124275)); pub const WU_E_INFRASTRUCTUREFILE_REQUIRES_SSL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124274)); pub const WU_E_IDLESHUTDOWN_OPCOUNT_DISCOVERY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124273)); pub const WU_E_IDLESHUTDOWN_OPCOUNT_SEARCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124272)); pub const WU_E_IDLESHUTDOWN_OPCOUNT_DOWNLOAD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124271)); pub const WU_E_IDLESHUTDOWN_OPCOUNT_INSTALL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124270)); pub const WU_E_IDLESHUTDOWN_OPCOUNT_OTHER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124269)); pub const WU_E_INTERACTIVE_CALL_CANCELLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124268)); pub const WU_E_AU_CALL_CANCELLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124267)); pub const WU_E_SYSTEM_UNSUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124266)); pub const WU_E_NO_SUCH_HANDLER_PLUGIN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124265)); pub const WU_E_INVALID_SERIALIZATION_VERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124264)); pub const WU_E_NETWORK_COST_EXCEEDS_POLICY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124263)); pub const WU_E_CALL_CANCELLED_BY_HIDE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124262)); pub const WU_E_CALL_CANCELLED_BY_INVALID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124261)); pub const WU_E_INVALID_VOLUMEID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124260)); pub const WU_E_UNRECOGNIZED_VOLUMEID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124259)); pub const WU_E_EXTENDEDERROR_NOTSET = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124258)); pub const WU_E_EXTENDEDERROR_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124257)); pub const WU_E_IDLESHUTDOWN_OPCOUNT_SERVICEREGISTRATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124256)); pub const WU_E_FILETRUST_SHA2SIGNATURE_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124255)); pub const WU_E_UPDATE_NOT_APPROVED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124254)); pub const WU_E_CALL_CANCELLED_BY_INTERACTIVE_SEARCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124253)); pub const WU_E_INSTALL_JOB_RESUME_NOT_ALLOWED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124252)); pub const WU_E_INSTALL_JOB_NOT_SUSPENDED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124251)); pub const WU_E_INSTALL_USERCONTEXT_ACCESSDENIED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145124250)); pub const WU_E_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145120257)); pub const WU_E_MSI_WRONG_VERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145120255)); pub const WU_E_MSI_NOT_CONFIGURED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145120254)); pub const WU_E_MSP_DISABLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145120253)); pub const WU_E_MSI_WRONG_APP_CONTEXT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145120252)); pub const WU_E_MSI_NOT_PRESENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145120251)); pub const WU_E_MSP_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116161)); pub const WU_E_PT_SOAPCLIENT_BASE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107968)); pub const WU_E_PT_SOAPCLIENT_INITIALIZE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107967)); pub const WU_E_PT_SOAPCLIENT_OUTOFMEMORY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107966)); pub const WU_E_PT_SOAPCLIENT_GENERATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107965)); pub const WU_E_PT_SOAPCLIENT_CONNECT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107964)); pub const WU_E_PT_SOAPCLIENT_SEND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107963)); pub const WU_E_PT_SOAPCLIENT_SERVER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107962)); pub const WU_E_PT_SOAPCLIENT_SOAPFAULT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107961)); pub const WU_E_PT_SOAPCLIENT_PARSEFAULT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107960)); pub const WU_E_PT_SOAPCLIENT_READ = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107959)); pub const WU_E_PT_SOAPCLIENT_PARSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107958)); pub const WU_E_PT_SOAP_VERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107957)); pub const WU_E_PT_SOAP_MUST_UNDERSTAND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107956)); pub const WU_E_PT_SOAP_CLIENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107955)); pub const WU_E_PT_SOAP_SERVER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107954)); pub const WU_E_PT_WMI_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107953)); pub const WU_E_PT_EXCEEDED_MAX_SERVER_TRIPS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107952)); pub const WU_E_PT_SUS_SERVER_NOT_SET = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107951)); pub const WU_E_PT_DOUBLE_INITIALIZATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107950)); pub const WU_E_PT_INVALID_COMPUTER_NAME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107949)); pub const WU_E_PT_REFRESH_CACHE_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107947)); pub const WU_E_PT_HTTP_STATUS_BAD_REQUEST = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107946)); pub const WU_E_PT_HTTP_STATUS_DENIED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107945)); pub const WU_E_PT_HTTP_STATUS_FORBIDDEN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107944)); pub const WU_E_PT_HTTP_STATUS_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107943)); pub const WU_E_PT_HTTP_STATUS_BAD_METHOD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107942)); pub const WU_E_PT_HTTP_STATUS_PROXY_AUTH_REQ = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107941)); pub const WU_E_PT_HTTP_STATUS_REQUEST_TIMEOUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107940)); pub const WU_E_PT_HTTP_STATUS_CONFLICT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107939)); pub const WU_E_PT_HTTP_STATUS_GONE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107938)); pub const WU_E_PT_HTTP_STATUS_SERVER_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107937)); pub const WU_E_PT_HTTP_STATUS_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107936)); pub const WU_E_PT_HTTP_STATUS_BAD_GATEWAY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107935)); pub const WU_E_PT_HTTP_STATUS_SERVICE_UNAVAIL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107934)); pub const WU_E_PT_HTTP_STATUS_GATEWAY_TIMEOUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107933)); pub const WU_E_PT_HTTP_STATUS_VERSION_NOT_SUP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107932)); pub const WU_E_PT_FILE_LOCATIONS_CHANGED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107931)); pub const WU_E_PT_REGISTRATION_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107930)); pub const WU_E_PT_NO_AUTH_PLUGINS_REQUESTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107929)); pub const WU_E_PT_NO_AUTH_COOKIES_CREATED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107928)); pub const WU_E_PT_INVALID_CONFIG_PROP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107927)); pub const WU_E_PT_CONFIG_PROP_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107926)); pub const WU_E_PT_HTTP_STATUS_NOT_MAPPED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107925)); pub const WU_E_PT_WINHTTP_NAME_NOT_RESOLVED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107924)); pub const WU_E_PT_LOAD_SHEDDING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107923)); pub const WU_E_PT_SAME_REDIR_ID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103827)); pub const WU_E_PT_NO_MANAGED_RECOVER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103826)); pub const WU_E_PT_ECP_SUCCEEDED_WITH_ERRORS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107921)); pub const WU_E_PT_ECP_INIT_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107920)); pub const WU_E_PT_ECP_INVALID_FILE_FORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107919)); pub const WU_E_PT_ECP_INVALID_METADATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107918)); pub const WU_E_PT_ECP_FAILURE_TO_EXTRACT_DIGEST = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107917)); pub const WU_E_PT_ECP_FAILURE_TO_DECOMPRESS_CAB_FILE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107916)); pub const WU_E_PT_ECP_FILE_LOCATION_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107915)); pub const WU_E_PT_CATALOG_SYNC_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123274)); pub const WU_E_PT_SECURITY_VERIFICATION_FAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123273)); pub const WU_E_PT_ENDPOINT_UNREACHABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123272)); pub const WU_E_PT_INVALID_FORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123271)); pub const WU_E_PT_INVALID_URL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123270)); pub const WU_E_PT_NWS_NOT_LOADED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123269)); pub const WU_E_PT_PROXY_AUTH_SCHEME_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123268)); pub const WU_E_SERVICEPROP_NOTAVAIL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123267)); pub const WU_E_PT_ENDPOINT_REFRESH_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123266)); pub const WU_E_PT_ENDPOINTURL_NOTAVAIL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123265)); pub const WU_E_PT_ENDPOINT_DISCONNECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123264)); pub const WU_E_PT_INVALID_OPERATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123263)); pub const WU_E_PT_OBJECT_FAULTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123262)); pub const WU_E_PT_NUMERIC_OVERFLOW = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123261)); pub const WU_E_PT_OPERATION_ABORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123260)); pub const WU_E_PT_OPERATION_ABANDONED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123259)); pub const WU_E_PT_QUOTA_EXCEEDED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123258)); pub const WU_E_PT_NO_TRANSLATION_AVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123257)); pub const WU_E_PT_ADDRESS_IN_USE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123256)); pub const WU_E_PT_ADDRESS_NOT_AVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123255)); pub const WU_E_PT_OTHER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123254)); pub const WU_E_PT_SECURITY_SYSTEM_FAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145123253)); pub const WU_E_PT_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103873)); pub const WU_E_REDIRECTOR_LOAD_XML = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103871)); pub const WU_E_REDIRECTOR_S_FALSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103870)); pub const WU_E_REDIRECTOR_ID_SMALLER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103869)); pub const WU_E_REDIRECTOR_UNKNOWN_SERVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103868)); pub const WU_E_REDIRECTOR_UNSUPPORTED_CONTENTTYPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103867)); pub const WU_E_REDIRECTOR_INVALID_RESPONSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103866)); pub const WU_E_REDIRECTOR_ATTRPROVIDER_EXCEEDED_MAX_NAMEVALUE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103864)); pub const WU_E_REDIRECTOR_ATTRPROVIDER_INVALID_NAME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103863)); pub const WU_E_REDIRECTOR_ATTRPROVIDER_INVALID_VALUE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103862)); pub const WU_E_REDIRECTOR_SLS_GENERIC_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103861)); pub const WU_E_REDIRECTOR_CONNECT_POLICY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103860)); pub const WU_E_REDIRECTOR_ONLINE_DISALLOWED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103859)); pub const WU_E_REDIRECTOR_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103617)); pub const WU_E_SIH_VERIFY_DOWNLOAD_ENGINE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103615)); pub const WU_E_SIH_VERIFY_DOWNLOAD_PAYLOAD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103614)); pub const WU_E_SIH_VERIFY_STAGE_ENGINE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103613)); pub const WU_E_SIH_VERIFY_STAGE_PAYLOAD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103612)); pub const WU_E_SIH_ACTION_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103611)); pub const WU_E_SIH_SLS_PARSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103610)); pub const WU_E_SIH_INVALIDHASH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103609)); pub const WU_E_SIH_NO_ENGINE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103608)); pub const WU_E_SIH_POST_REBOOT_INSTALL_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103607)); pub const WU_E_SIH_POST_REBOOT_NO_CACHED_SLS_RESPONSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103606)); pub const WU_E_SIH_PARSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103605)); pub const WU_E_SIH_SECURITY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103604)); pub const WU_E_SIH_PPL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103603)); pub const WU_E_SIH_POLICY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103602)); pub const WU_E_SIH_STDEXCEPTION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103601)); pub const WU_E_SIH_NONSTDEXCEPTION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103600)); pub const WU_E_SIH_ENGINE_EXCEPTION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103599)); pub const WU_E_SIH_BLOCKED_FOR_PLATFORM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103598)); pub const WU_E_SIH_ANOTHER_INSTANCE_RUNNING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103597)); pub const WU_E_SIH_DNSRESILIENCY_OFF = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103596)); pub const WU_E_SIH_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145103361)); pub const WU_E_DRV_PRUNED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145075199)); pub const WU_E_DRV_NOPROP_OR_LEGACY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145075198)); pub const WU_E_DRV_REG_MISMATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145075197)); pub const WU_E_DRV_NO_METADATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145075196)); pub const WU_E_DRV_MISSING_ATTRIBUTE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145075195)); pub const WU_E_DRV_SYNC_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145075194)); pub const WU_E_DRV_NO_PRINTER_CONTENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145075193)); pub const WU_E_DRV_DEVICE_PROBLEM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145075192)); pub const WU_E_DRV_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071105)); pub const WU_E_DS_SHUTDOWN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091584)); pub const WU_E_DS_INUSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091583)); pub const WU_E_DS_INVALID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091582)); pub const WU_E_DS_TABLEMISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091581)); pub const WU_E_DS_TABLEINCORRECT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091580)); pub const WU_E_DS_INVALIDTABLENAME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091579)); pub const WU_E_DS_BADVERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091578)); pub const WU_E_DS_NODATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091577)); pub const WU_E_DS_MISSINGDATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091576)); pub const WU_E_DS_MISSINGREF = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091575)); pub const WU_E_DS_UNKNOWNHANDLER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091574)); pub const WU_E_DS_CANTDELETE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091573)); pub const WU_E_DS_LOCKTIMEOUTEXPIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091572)); pub const WU_E_DS_NOCATEGORIES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091571)); pub const WU_E_DS_ROWEXISTS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091570)); pub const WU_E_DS_STOREFILELOCKED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091569)); pub const WU_E_DS_CANNOTREGISTER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091568)); pub const WU_E_DS_UNABLETOSTART = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091567)); pub const WU_E_DS_DUPLICATEUPDATEID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091565)); pub const WU_E_DS_UNKNOWNSERVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091564)); pub const WU_E_DS_SERVICEEXPIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091563)); pub const WU_E_DS_DECLINENOTALLOWED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091562)); pub const WU_E_DS_TABLESESSIONMISMATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091561)); pub const WU_E_DS_SESSIONLOCKMISMATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091560)); pub const WU_E_DS_NEEDWINDOWSSERVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091559)); pub const WU_E_DS_INVALIDOPERATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091558)); pub const WU_E_DS_SCHEMAMISMATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091557)); pub const WU_E_DS_RESETREQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091556)); pub const WU_E_DS_IMPERSONATED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091555)); pub const WU_E_DS_DATANOTAVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091554)); pub const WU_E_DS_DATANOTLOADED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091553)); pub const WU_E_DS_NODATA_NOSUCHREVISION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091552)); pub const WU_E_DS_NODATA_NOSUCHUPDATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091551)); pub const WU_E_DS_NODATA_EULA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091550)); pub const WU_E_DS_NODATA_SERVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091549)); pub const WU_E_DS_NODATA_COOKIE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091548)); pub const WU_E_DS_NODATA_TIMER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091547)); pub const WU_E_DS_NODATA_CCR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091546)); pub const WU_E_DS_NODATA_FILE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091545)); pub const WU_E_DS_NODATA_DOWNLOADJOB = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091544)); pub const WU_E_DS_NODATA_TMI = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091543)); pub const WU_E_DS_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145087489)); pub const WU_E_INVENTORY_PARSEFAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145087487)); pub const WU_E_INVENTORY_GET_INVENTORY_TYPE_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145087486)); pub const WU_E_INVENTORY_RESULT_UPLOAD_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145087485)); pub const WU_E_INVENTORY_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145087484)); pub const WU_E_INVENTORY_WMI_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145087483)); pub const WU_E_AU_NOSERVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145083392)); pub const WU_E_AU_NONLEGACYSERVER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145083390)); pub const WU_E_AU_LEGACYCLIENTDISABLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145083389)); pub const WU_E_AU_PAUSED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145083388)); pub const WU_E_AU_NO_REGISTERED_SERVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145083387)); pub const WU_E_AU_DETECT_SVCID_MISMATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145083386)); pub const WU_E_REBOOT_IN_PROGRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145083385)); pub const WU_E_AU_OOBE_IN_PROGRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145083384)); pub const WU_E_AU_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079297)); pub const WU_E_UH_REMOTEUNAVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116160)); pub const WU_E_UH_LOCALONLY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116159)); pub const WU_E_UH_UNKNOWNHANDLER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116158)); pub const WU_E_UH_REMOTEALREADYACTIVE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116157)); pub const WU_E_UH_DOESNOTSUPPORTACTION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116156)); pub const WU_E_UH_WRONGHANDLER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116155)); pub const WU_E_UH_INVALIDMETADATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116154)); pub const WU_E_UH_INSTALLERHUNG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116153)); pub const WU_E_UH_OPERATIONCANCELLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116152)); pub const WU_E_UH_BADHANDLERXML = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116151)); pub const WU_E_UH_CANREQUIREINPUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116150)); pub const WU_E_UH_INSTALLERFAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116149)); pub const WU_E_UH_FALLBACKTOSELFCONTAINED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116148)); pub const WU_E_UH_NEEDANOTHERDOWNLOAD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116147)); pub const WU_E_UH_NOTIFYFAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116146)); pub const WU_E_UH_INCONSISTENT_FILE_NAMES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116145)); pub const WU_E_UH_FALLBACKERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116144)); pub const WU_E_UH_TOOMANYDOWNLOADREQUESTS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116143)); pub const WU_E_UH_UNEXPECTEDCBSRESPONSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116142)); pub const WU_E_UH_BADCBSPACKAGEID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116141)); pub const WU_E_UH_POSTREBOOTSTILLPENDING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116140)); pub const WU_E_UH_POSTREBOOTRESULTUNKNOWN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116139)); pub const WU_E_UH_POSTREBOOTUNEXPECTEDSTATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116138)); pub const WU_E_UH_NEW_SERVICING_STACK_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116137)); pub const WU_E_UH_CALLED_BACK_FAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116136)); pub const WU_E_UH_CUSTOMINSTALLER_INVALID_SIGNATURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116135)); pub const WU_E_UH_UNSUPPORTED_INSTALLCONTEXT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116134)); pub const WU_E_UH_INVALID_TARGETSESSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116133)); pub const WU_E_UH_DECRYPTFAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116132)); pub const WU_E_UH_HANDLER_DISABLEDUNTILREBOOT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116131)); pub const WU_E_UH_APPX_NOT_PRESENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116130)); pub const WU_E_UH_NOTREADYTOCOMMIT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116129)); pub const WU_E_UH_APPX_INVALID_PACKAGE_VOLUME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116128)); pub const WU_E_UH_APPX_DEFAULT_PACKAGE_VOLUME_UNAVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116127)); pub const WU_E_UH_APPX_INSTALLED_PACKAGE_VOLUME_UNAVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116126)); pub const WU_E_UH_APPX_PACKAGE_FAMILY_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116125)); pub const WU_E_UH_APPX_SYSTEM_VOLUME_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145116124)); pub const WU_E_UH_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145112065)); pub const WU_E_DM_URLNOTAVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099775)); pub const WU_E_DM_INCORRECTFILEHASH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099774)); pub const WU_E_DM_UNKNOWNALGORITHM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099773)); pub const WU_E_DM_NEEDDOWNLOADREQUEST = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099772)); pub const WU_E_DM_NONETWORK = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099771)); pub const WU_E_DM_WRONGBITSVERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099770)); pub const WU_E_DM_NOTDOWNLOADED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099769)); pub const WU_E_DM_FAILTOCONNECTTOBITS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099768)); pub const WU_E_DM_BITSTRANSFERERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099767)); pub const WU_E_DM_DOWNLOADLOCATIONCHANGED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099766)); pub const WU_E_DM_CONTENTCHANGED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099765)); pub const WU_E_DM_DOWNLOADLIMITEDBYUPDATESIZE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099764)); pub const WU_E_DM_UNAUTHORIZED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099762)); pub const WU_E_DM_BG_ERROR_TOKEN_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099761)); pub const WU_E_DM_DOWNLOADSANDBOXNOTFOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099760)); pub const WU_E_DM_DOWNLOADFILEPATHUNKNOWN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099759)); pub const WU_E_DM_DOWNLOADFILEMISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099758)); pub const WU_E_DM_UPDATEREMOVED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099757)); pub const WU_E_DM_READRANGEFAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099756)); pub const WU_E_DM_UNAUTHORIZED_NO_USER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099754)); pub const WU_E_DM_UNAUTHORIZED_LOCAL_USER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099753)); pub const WU_E_DM_UNAUTHORIZED_DOMAIN_USER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099752)); pub const WU_E_DM_UNAUTHORIZED_MSA_USER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099751)); pub const WU_E_DM_FALLINGBACKTOBITS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099750)); pub const WU_E_DM_DOWNLOAD_VOLUME_CONFLICT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099749)); pub const WU_E_DM_SANDBOX_HASH_MISMATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099748)); pub const WU_E_DM_HARDRESERVEID_CONFLICT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099747)); pub const WU_E_DM_DOSVC_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145099746)); pub const WU_E_DM_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095681)); pub const WU_E_SETUP_INVALID_INFDATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071103)); pub const WU_E_SETUP_INVALID_IDENTDATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071102)); pub const WU_E_SETUP_ALREADY_INITIALIZED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071101)); pub const WU_E_SETUP_NOT_INITIALIZED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071100)); pub const WU_E_SETUP_SOURCE_VERSION_MISMATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071099)); pub const WU_E_SETUP_TARGET_VERSION_GREATER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071098)); pub const WU_E_SETUP_REGISTRATION_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071097)); pub const WU_E_SELFUPDATE_SKIP_ON_FAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071096)); pub const WU_E_SETUP_SKIP_UPDATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071095)); pub const WU_E_SETUP_UNSUPPORTED_CONFIGURATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071094)); pub const WU_E_SETUP_BLOCKED_CONFIGURATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071093)); pub const WU_E_SETUP_REBOOT_TO_FIX = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071092)); pub const WU_E_SETUP_ALREADYRUNNING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071091)); pub const WU_E_SETUP_REBOOTREQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071090)); pub const WU_E_SETUP_HANDLER_EXEC_FAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071089)); pub const WU_E_SETUP_INVALID_REGISTRY_DATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071088)); pub const WU_E_SELFUPDATE_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071087)); pub const WU_E_SELFUPDATE_REQUIRED_ADMIN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071086)); pub const WU_E_SETUP_WRONG_SERVER_VERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071085)); pub const WU_E_SETUP_DEFERRABLE_REBOOT_PENDING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071084)); pub const WU_E_SETUP_NON_DEFERRABLE_REBOOT_PENDING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071083)); pub const WU_E_SETUP_FAIL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145071082)); pub const WU_E_SETUP_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145067009)); pub const WU_E_EE_UNKNOWN_EXPRESSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145067007)); pub const WU_E_EE_INVALID_EXPRESSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145067006)); pub const WU_E_EE_MISSING_METADATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145067005)); pub const WU_E_EE_INVALID_VERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145067004)); pub const WU_E_EE_NOT_INITIALIZED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145067003)); pub const WU_E_EE_INVALID_ATTRIBUTEDATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145067002)); pub const WU_E_EE_CLUSTER_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145067001)); pub const WU_E_EE_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145062913)); pub const WU_E_INSTALLATION_RESULTS_UNKNOWN_VERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145112063)); pub const WU_E_INSTALLATION_RESULTS_INVALID_DATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145112062)); pub const WU_E_INSTALLATION_RESULTS_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145112061)); pub const WU_E_TRAYICON_FAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145112060)); pub const WU_E_NON_UI_MODE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107971)); pub const WU_E_WUCLTUI_UNSUPPORTED_VERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107970)); pub const WU_E_AUCLIENT_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145107969)); pub const WU_E_REPORTER_EVENTCACHECORRUPT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145062911)); pub const WU_E_REPORTER_EVENTNAMESPACEPARSEFAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145062910)); pub const WU_E_INVALID_EVENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145062909)); pub const WU_E_SERVER_BUSY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145062908)); pub const WU_E_CALLBACK_COOKIE_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145062907)); pub const WU_E_REPORTER_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145058817)); pub const WU_E_OL_INVALID_SCANFILE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095679)); pub const WU_E_OL_NEWCLIENT_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095678)); pub const WU_E_INVALID_EVENT_PAYLOAD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095677)); pub const WU_E_INVALID_EVENT_PAYLOADSIZE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095676)); pub const WU_E_SERVICE_NOT_REGISTERED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095675)); pub const WU_E_OL_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145091585)); pub const WU_E_METADATA_NOOP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095424)); pub const WU_E_METADATA_CONFIG_INVALID_BINARY_ENCODING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095423)); pub const WU_E_METADATA_FETCH_CONFIG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095422)); pub const WU_E_METADATA_INVALID_PARAMETER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095420)); pub const WU_E_METADATA_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095419)); pub const WU_E_METADATA_NO_VERIFICATION_DATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095418)); pub const WU_E_METADATA_BAD_FRAGMENTSIGNING_CONFIG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095417)); pub const WU_E_METADATA_FAILURE_PROCESSING_FRAGMENTSIGNING_CONFIG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095416)); pub const WU_E_METADATA_XML_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095392)); pub const WU_E_METADATA_XML_FRAGMENTSIGNING_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095391)); pub const WU_E_METADATA_XML_MODE_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095390)); pub const WU_E_METADATA_XML_MODE_INVALID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095389)); pub const WU_E_METADATA_XML_VALIDITY_INVALID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095388)); pub const WU_E_METADATA_XML_LEAFCERT_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095387)); pub const WU_E_METADATA_XML_INTERMEDIATECERT_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095386)); pub const WU_E_METADATA_XML_LEAFCERT_ID_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095385)); pub const WU_E_METADATA_XML_BASE64CERDATA_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095384)); pub const WU_E_METADATA_BAD_SIGNATURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095360)); pub const WU_E_METADATA_UNSUPPORTED_HASH_ALG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095359)); pub const WU_E_METADATA_SIGNATURE_VERIFY_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095358)); pub const WU_E_METADATATRUST_CERTIFICATECHAIN_VERIFICATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095344)); pub const WU_E_METADATATRUST_UNTRUSTED_CERTIFICATECHAIN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095343)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095328)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_VERIFICATION_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095327)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_UNTRUSTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095326)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_VALIDITY_WINDOW = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095325)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_SIGNATURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095324)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_CERTCHAIN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095323)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_REFRESHONLINE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095322)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_ALL_BAD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095321)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_NODATA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095320)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_CACHELOOKUP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095319)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_VALIDITYWINDOW_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095298)); pub const WU_E_METADATA_TIMESTAMP_TOKEN_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095297)); pub const WU_E_METADATA_CERT_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095296)); pub const WU_E_METADATA_LEAFCERT_BAD_TRANSPORT_ENCODING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095295)); pub const WU_E_METADATA_INTCERT_BAD_TRANSPORT_ENCODING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095294)); pub const WU_E_METADATA_CERT_UNTRUSTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145095293)); pub const WU_E_WUTASK_INPROGRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079295)); pub const WU_E_WUTASK_STATUS_DISABLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079294)); pub const WU_E_WUTASK_NOT_STARTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079293)); pub const WU_E_WUTASK_RETRY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079292)); pub const WU_E_WUTASK_CANCELINSTALL_DISALLOWED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079291)); pub const WU_E_UNKNOWN_HARDWARECAPABILITY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079039)); pub const WU_E_BAD_XML_HARDWARECAPABILITY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079038)); pub const WU_E_WMI_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079037)); pub const WU_E_UPDATE_MERGE_NOT_ALLOWED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079036)); pub const WU_E_SKIPPED_UPDATE_INSTALLATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145079035)); pub const WU_E_SLS_INVALID_REVISION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145078783)); pub const WU_E_FILETRUST_DUALSIGNATURE_RSA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145078527)); pub const WU_E_FILETRUST_DUALSIGNATURE_ECC = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145078526)); pub const WU_E_TRUST_SUBJECT_NOT_TRUSTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145078525)); pub const WU_E_TRUST_PROVIDER_UNKNOWN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145078524)); //-------------------------------------------------------------------------------- // Section: Types (109) //-------------------------------------------------------------------------------- const CLSID_StringCollection_Value = @import("../zig.zig").Guid.initString("72c97d74-7c3b-40ae-b77d-abdb22eba6fb"); pub const CLSID_StringCollection = &CLSID_StringCollection_Value; const CLSID_UpdateSearcher_Value = @import("../zig.zig").Guid.initString("b699e5e8-67ff-4177-88b0-3684a3388bfb"); pub const CLSID_UpdateSearcher = &CLSID_UpdateSearcher_Value; const CLSID_WebProxy_Value = @import("../zig.zig").Guid.initString("650503cf-9108-4ddc-a2ce-6c2341e1c582"); pub const CLSID_WebProxy = &CLSID_WebProxy_Value; const CLSID_SystemInformation_Value = @import("../zig.zig").Guid.initString("c01b9ba0-bea7-41ba-b604-d0a36f469133"); pub const CLSID_SystemInformation = &CLSID_SystemInformation_Value; const CLSID_WindowsUpdateAgentInfo_Value = @import("../zig.zig").Guid.initString("c2e88c2f-6f5b-4aaa-894b-55c847ad3a2d"); pub const CLSID_WindowsUpdateAgentInfo = &CLSID_WindowsUpdateAgentInfo_Value; const CLSID_AutomaticUpdates_Value = @import("../zig.zig").Guid.initString("bfe18e9c-6d87-4450-b37c-e02f0b373803"); pub const CLSID_AutomaticUpdates = &CLSID_AutomaticUpdates_Value; const CLSID_UpdateCollection_Value = @import("../zig.zig").Guid.initString("13639463-00db-4646-803d-528026140d88"); pub const CLSID_UpdateCollection = &CLSID_UpdateCollection_Value; const CLSID_UpdateDownloader_Value = @import("../zig.zig").Guid.initString("5baf654a-5a07-4264-a255-9ff54c7151e7"); pub const CLSID_UpdateDownloader = &CLSID_UpdateDownloader_Value; const CLSID_UpdateInstaller_Value = @import("../zig.zig").Guid.initString("d2e0fe7f-d23e-48e1-93c0-6fa8cc346474"); pub const CLSID_UpdateInstaller = &CLSID_UpdateInstaller_Value; const CLSID_UpdateSession_Value = @import("../zig.zig").Guid.initString("4cb43d7f-7eee-4906-8698-60da1c38f2fe"); pub const CLSID_UpdateSession = &CLSID_UpdateSession_Value; const CLSID_UpdateServiceManager_Value = @import("../zig.zig").Guid.initString("f8d253d9-89a4-4daa-87b6-1168369f0b21"); pub const CLSID_UpdateServiceManager = &CLSID_UpdateServiceManager_Value; const CLSID_InstallationAgent_Value = @import("../zig.zig").Guid.initString("317e92fc-1679-46fd-a0b5-f08914dd8623"); pub const CLSID_InstallationAgent = &CLSID_InstallationAgent_Value; pub const AutomaticUpdatesNotificationLevel = enum(i32) { NotConfigured = 0, Disabled = 1, NotifyBeforeDownload = 2, NotifyBeforeInstallation = 3, ScheduledInstallation = 4, }; pub const aunlNotConfigured = AutomaticUpdatesNotificationLevel.NotConfigured; pub const aunlDisabled = AutomaticUpdatesNotificationLevel.Disabled; pub const aunlNotifyBeforeDownload = AutomaticUpdatesNotificationLevel.NotifyBeforeDownload; pub const aunlNotifyBeforeInstallation = AutomaticUpdatesNotificationLevel.NotifyBeforeInstallation; pub const aunlScheduledInstallation = AutomaticUpdatesNotificationLevel.ScheduledInstallation; pub const AutomaticUpdatesScheduledInstallationDay = enum(i32) { Day = 0, Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7, }; pub const ausidEveryDay = AutomaticUpdatesScheduledInstallationDay.Day; pub const ausidEverySunday = AutomaticUpdatesScheduledInstallationDay.Sunday; pub const ausidEveryMonday = AutomaticUpdatesScheduledInstallationDay.Monday; pub const ausidEveryTuesday = AutomaticUpdatesScheduledInstallationDay.Tuesday; pub const ausidEveryWednesday = AutomaticUpdatesScheduledInstallationDay.Wednesday; pub const ausidEveryThursday = AutomaticUpdatesScheduledInstallationDay.Thursday; pub const ausidEveryFriday = AutomaticUpdatesScheduledInstallationDay.Friday; pub const ausidEverySaturday = AutomaticUpdatesScheduledInstallationDay.Saturday; pub const DownloadPhase = enum(i32) { Initializing = 1, Downloading = 2, Verifying = 3, }; pub const dphInitializing = DownloadPhase.Initializing; pub const dphDownloading = DownloadPhase.Downloading; pub const dphVerifying = DownloadPhase.Verifying; pub const DownloadPriority = enum(i32) { Low = 1, Normal = 2, High = 3, ExtraHigh = 4, }; pub const dpLow = DownloadPriority.Low; pub const dpNormal = DownloadPriority.Normal; pub const dpHigh = DownloadPriority.High; pub const dpExtraHigh = DownloadPriority.ExtraHigh; pub const AutoSelectionMode = enum(i32) { LetWindowsUpdateDecide = 0, AutoSelectIfDownloaded = 1, NeverAutoSelect = 2, AlwaysAutoSelect = 3, }; pub const asLetWindowsUpdateDecide = AutoSelectionMode.LetWindowsUpdateDecide; pub const asAutoSelectIfDownloaded = AutoSelectionMode.AutoSelectIfDownloaded; pub const asNeverAutoSelect = AutoSelectionMode.NeverAutoSelect; pub const asAlwaysAutoSelect = AutoSelectionMode.AlwaysAutoSelect; pub const AutoDownloadMode = enum(i32) { LetWindowsUpdateDecide = 0, NeverAutoDownload = 1, AlwaysAutoDownload = 2, }; pub const adLetWindowsUpdateDecide = AutoDownloadMode.LetWindowsUpdateDecide; pub const adNeverAutoDownload = AutoDownloadMode.NeverAutoDownload; pub const adAlwaysAutoDownload = AutoDownloadMode.AlwaysAutoDownload; pub const InstallationImpact = enum(i32) { Normal = 0, Minor = 1, RequiresExclusiveHandling = 2, }; pub const iiNormal = InstallationImpact.Normal; pub const iiMinor = InstallationImpact.Minor; pub const iiRequiresExclusiveHandling = InstallationImpact.RequiresExclusiveHandling; pub const InstallationRebootBehavior = enum(i32) { NeverReboots = 0, AlwaysRequiresReboot = 1, CanRequestReboot = 2, }; pub const irbNeverReboots = InstallationRebootBehavior.NeverReboots; pub const irbAlwaysRequiresReboot = InstallationRebootBehavior.AlwaysRequiresReboot; pub const irbCanRequestReboot = InstallationRebootBehavior.CanRequestReboot; pub const OperationResultCode = enum(i32) { NotStarted = 0, InProgress = 1, Succeeded = 2, SucceededWithErrors = 3, Failed = 4, Aborted = 5, }; pub const orcNotStarted = OperationResultCode.NotStarted; pub const orcInProgress = OperationResultCode.InProgress; pub const orcSucceeded = OperationResultCode.Succeeded; pub const orcSucceededWithErrors = OperationResultCode.SucceededWithErrors; pub const orcFailed = OperationResultCode.Failed; pub const orcAborted = OperationResultCode.Aborted; pub const ServerSelection = enum(i32) { Default = 0, ManagedServer = 1, WindowsUpdate = 2, Others = 3, }; pub const ssDefault = ServerSelection.Default; pub const ssManagedServer = ServerSelection.ManagedServer; pub const ssWindowsUpdate = ServerSelection.WindowsUpdate; pub const ssOthers = ServerSelection.Others; pub const UpdateType = enum(i32) { Software = 1, Driver = 2, }; pub const utSoftware = UpdateType.Software; pub const utDriver = UpdateType.Driver; pub const UpdateOperation = enum(i32) { Installation = 1, Uninstallation = 2, }; pub const uoInstallation = UpdateOperation.Installation; pub const uoUninstallation = UpdateOperation.Uninstallation; pub const DeploymentAction = enum(i32) { None = 0, Installation = 1, Uninstallation = 2, Detection = 3, OptionalInstallation = 4, }; pub const daNone = DeploymentAction.None; pub const daInstallation = DeploymentAction.Installation; pub const daUninstallation = DeploymentAction.Uninstallation; pub const daDetection = DeploymentAction.Detection; pub const daOptionalInstallation = DeploymentAction.OptionalInstallation; pub const UpdateExceptionContext = enum(i32) { General = 1, WindowsDriver = 2, WindowsInstaller = 3, SearchIncomplete = 4, }; pub const uecGeneral = UpdateExceptionContext.General; pub const uecWindowsDriver = UpdateExceptionContext.WindowsDriver; pub const uecWindowsInstaller = UpdateExceptionContext.WindowsInstaller; pub const uecSearchIncomplete = UpdateExceptionContext.SearchIncomplete; pub const AutomaticUpdatesUserType = enum(i32) { CurrentUser = 1, LocalAdministrator = 2, }; pub const auutCurrentUser = AutomaticUpdatesUserType.CurrentUser; pub const auutLocalAdministrator = AutomaticUpdatesUserType.LocalAdministrator; pub const AutomaticUpdatesPermissionType = enum(i32) { SetNotificationLevel = 1, DisableAutomaticUpdates = 2, SetIncludeRecommendedUpdates = 3, SetFeaturedUpdatesEnabled = 4, SetNonAdministratorsElevated = 5, }; pub const auptSetNotificationLevel = AutomaticUpdatesPermissionType.SetNotificationLevel; pub const auptDisableAutomaticUpdates = AutomaticUpdatesPermissionType.DisableAutomaticUpdates; pub const auptSetIncludeRecommendedUpdates = AutomaticUpdatesPermissionType.SetIncludeRecommendedUpdates; pub const auptSetFeaturedUpdatesEnabled = AutomaticUpdatesPermissionType.SetFeaturedUpdatesEnabled; pub const auptSetNonAdministratorsElevated = AutomaticUpdatesPermissionType.SetNonAdministratorsElevated; pub const UpdateServiceRegistrationState = enum(i32) { NotRegistered = 1, RegistrationPending = 2, Registered = 3, }; pub const usrsNotRegistered = UpdateServiceRegistrationState.NotRegistered; pub const usrsRegistrationPending = UpdateServiceRegistrationState.RegistrationPending; pub const usrsRegistered = UpdateServiceRegistrationState.Registered; pub const SearchScope = enum(i32) { Default = 0, MachineOnly = 1, CurrentUserOnly = 2, MachineAndCurrentUser = 3, MachineAndAllUsers = 4, AllUsers = 5, }; pub const searchScopeDefault = SearchScope.Default; pub const searchScopeMachineOnly = SearchScope.MachineOnly; pub const searchScopeCurrentUserOnly = SearchScope.CurrentUserOnly; pub const searchScopeMachineAndCurrentUser = SearchScope.MachineAndCurrentUser; pub const searchScopeMachineAndAllUsers = SearchScope.MachineAndAllUsers; pub const searchScopeAllUsers = SearchScope.AllUsers; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateLockdown_Value = @import("../zig.zig").Guid.initString("a976c28d-75a1-42aa-94ae-8af8b872089a"); pub const IID_IUpdateLockdown = &IID_IUpdateLockdown_Value; pub const IUpdateLockdown = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, LockDown: fn( self: *const IUpdateLockdown, flags: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateLockdown_LockDown(self: *const T, flags: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateLockdown.VTable, self.vtable).LockDown(@ptrCast(*const IUpdateLockdown, self), flags); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IStringCollection_Value = @import("../zig.zig").Guid.initString("eff90582-2ddc-480f-a06d-60f3fbc362c3"); pub const IID_IStringCollection = &IID_IStringCollection_Value; pub const IStringCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const IStringCollection, index: i32, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Item: fn( self: *const IStringCollection, index: i32, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const IStringCollection, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IStringCollection, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReadOnly: fn( self: *const IStringCollection, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Add: fn( self: *const IStringCollection, value: ?BSTR, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clear: fn( self: *const IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Copy: fn( self: *const IStringCollection, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Insert: fn( self: *const IStringCollection, index: i32, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveAt: fn( self: *const IStringCollection, index: 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 IStringCollection_get_Item(self: *const T, index: i32, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).get_Item(@ptrCast(*const IStringCollection, self), index, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_put_Item(self: *const T, index: i32, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).put_Item(@ptrCast(*const IStringCollection, self), index, value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_get__NewEnum(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IStringCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_get_Count(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).get_Count(@ptrCast(*const IStringCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_get_ReadOnly(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).get_ReadOnly(@ptrCast(*const IStringCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_Add(self: *const T, value: ?BSTR, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).Add(@ptrCast(*const IStringCollection, self), value, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_Clear(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).Clear(@ptrCast(*const IStringCollection, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_Copy(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).Copy(@ptrCast(*const IStringCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_Insert(self: *const T, index: i32, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).Insert(@ptrCast(*const IStringCollection, self), index, value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IStringCollection_RemoveAt(self: *const T, index: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IStringCollection.VTable, self.vtable).RemoveAt(@ptrCast(*const IStringCollection, self), index); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWebProxy_Value = @import("../zig.zig").Guid.initString("174c81fe-aecd-4dae-b8a0-2c6318dd86a8"); pub const IID_IWebProxy = &IID_IWebProxy_Value; pub const IWebProxy = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Address: fn( self: *const IWebProxy, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Address: fn( self: *const IWebProxy, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BypassList: fn( self: *const IWebProxy, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BypassList: fn( self: *const IWebProxy, value: ?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BypassProxyOnLocal: fn( self: *const IWebProxy, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BypassProxyOnLocal: fn( self: *const IWebProxy, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReadOnly: fn( self: *const IWebProxy, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UserName: fn( self: *const IWebProxy, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_UserName: fn( self: *const IWebProxy, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetPassword: fn( self: *const IWebProxy, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PromptForCredentials: fn( self: *const IWebProxy, parentWindow: ?*IUnknown, title: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PromptForCredentialsFromHwnd: fn( self: *const IWebProxy, parentWindow: ?HWND, title: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoDetect: fn( self: *const IWebProxy, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoDetect: fn( self: *const IWebProxy, value: i16, ) 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 IWebProxy_get_Address(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).get_Address(@ptrCast(*const IWebProxy, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_put_Address(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).put_Address(@ptrCast(*const IWebProxy, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_get_BypassList(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).get_BypassList(@ptrCast(*const IWebProxy, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_put_BypassList(self: *const T, value: ?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).put_BypassList(@ptrCast(*const IWebProxy, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_get_BypassProxyOnLocal(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).get_BypassProxyOnLocal(@ptrCast(*const IWebProxy, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_put_BypassProxyOnLocal(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).put_BypassProxyOnLocal(@ptrCast(*const IWebProxy, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_get_ReadOnly(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).get_ReadOnly(@ptrCast(*const IWebProxy, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_get_UserName(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).get_UserName(@ptrCast(*const IWebProxy, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_put_UserName(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).put_UserName(@ptrCast(*const IWebProxy, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_SetPassword(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).SetPassword(@ptrCast(*const IWebProxy, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_PromptForCredentials(self: *const T, parentWindow: ?*IUnknown, title: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).PromptForCredentials(@ptrCast(*const IWebProxy, self), parentWindow, title); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_PromptForCredentialsFromHwnd(self: *const T, parentWindow: ?HWND, title: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).PromptForCredentialsFromHwnd(@ptrCast(*const IWebProxy, self), parentWindow, title); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_get_AutoDetect(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).get_AutoDetect(@ptrCast(*const IWebProxy, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWebProxy_put_AutoDetect(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWebProxy.VTable, self.vtable).put_AutoDetect(@ptrCast(*const IWebProxy, self), value); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_ISystemInformation_Value = @import("../zig.zig").Guid.initString("ade87bf7-7b56-4275-8fab-b9b0e591844b"); pub const IID_ISystemInformation = &IID_ISystemInformation_Value; pub const ISystemInformation = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_OemHardwareSupportLink: fn( self: *const ISystemInformation, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RebootRequired: fn( self: *const ISystemInformation, retval: ?*i16, ) 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 ISystemInformation_get_OemHardwareSupportLink(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ISystemInformation.VTable, self.vtable).get_OemHardwareSupportLink(@ptrCast(*const ISystemInformation, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISystemInformation_get_RebootRequired(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ISystemInformation.VTable, self.vtable).get_RebootRequired(@ptrCast(*const ISystemInformation, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWindowsUpdateAgentInfo_Value = @import("../zig.zig").Guid.initString("85713fa1-7796-4fa2-be3b-e2d6124dd373"); pub const IID_IWindowsUpdateAgentInfo = &IID_IWindowsUpdateAgentInfo_Value; pub const IWindowsUpdateAgentInfo = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, GetInfo: fn( self: *const IWindowsUpdateAgentInfo, varInfoIdentifier: VARIANT, retval: ?*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 IWindowsUpdateAgentInfo_GetInfo(self: *const T, varInfoIdentifier: VARIANT, retval: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsUpdateAgentInfo.VTable, self.vtable).GetInfo(@ptrCast(*const IWindowsUpdateAgentInfo, self), varInfoIdentifier, retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IAutomaticUpdatesResults_Value = @import("../zig.zig").Guid.initString("e7a4d634-7942-4dd9-a111-82228ba33901"); pub const IID_IAutomaticUpdatesResults = &IID_IAutomaticUpdatesResults_Value; pub const IAutomaticUpdatesResults = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastSearchSuccessDate: fn( self: *const IAutomaticUpdatesResults, retval: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastInstallationSuccessDate: fn( self: *const IAutomaticUpdatesResults, retval: ?*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 IAutomaticUpdatesResults_get_LastSearchSuccessDate(self: *const T, retval: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesResults.VTable, self.vtable).get_LastSearchSuccessDate(@ptrCast(*const IAutomaticUpdatesResults, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesResults_get_LastInstallationSuccessDate(self: *const T, retval: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesResults.VTable, self.vtable).get_LastInstallationSuccessDate(@ptrCast(*const IAutomaticUpdatesResults, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IAutomaticUpdatesSettings_Value = @import("../zig.zig").Guid.initString("2ee48f22-af3c-405f-8970-f71be12ee9a2"); pub const IID_IAutomaticUpdatesSettings = &IID_IAutomaticUpdatesSettings_Value; pub const IAutomaticUpdatesSettings = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NotificationLevel: fn( self: *const IAutomaticUpdatesSettings, retval: ?*AutomaticUpdatesNotificationLevel, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NotificationLevel: fn( self: *const IAutomaticUpdatesSettings, value: AutomaticUpdatesNotificationLevel, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReadOnly: fn( self: *const IAutomaticUpdatesSettings, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Required: fn( self: *const IAutomaticUpdatesSettings, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ScheduledInstallationDay: fn( self: *const IAutomaticUpdatesSettings, retval: ?*AutomaticUpdatesScheduledInstallationDay, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ScheduledInstallationDay: fn( self: *const IAutomaticUpdatesSettings, value: AutomaticUpdatesScheduledInstallationDay, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ScheduledInstallationTime: fn( self: *const IAutomaticUpdatesSettings, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ScheduledInstallationTime: fn( self: *const IAutomaticUpdatesSettings, value: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Refresh: fn( self: *const IAutomaticUpdatesSettings, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Save: fn( self: *const IAutomaticUpdatesSettings, ) 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 IAutomaticUpdatesSettings_get_NotificationLevel(self: *const T, retval: ?*AutomaticUpdatesNotificationLevel) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).get_NotificationLevel(@ptrCast(*const IAutomaticUpdatesSettings, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_put_NotificationLevel(self: *const T, value: AutomaticUpdatesNotificationLevel) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).put_NotificationLevel(@ptrCast(*const IAutomaticUpdatesSettings, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_get_ReadOnly(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).get_ReadOnly(@ptrCast(*const IAutomaticUpdatesSettings, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_get_Required(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).get_Required(@ptrCast(*const IAutomaticUpdatesSettings, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_get_ScheduledInstallationDay(self: *const T, retval: ?*AutomaticUpdatesScheduledInstallationDay) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).get_ScheduledInstallationDay(@ptrCast(*const IAutomaticUpdatesSettings, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_put_ScheduledInstallationDay(self: *const T, value: AutomaticUpdatesScheduledInstallationDay) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).put_ScheduledInstallationDay(@ptrCast(*const IAutomaticUpdatesSettings, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_get_ScheduledInstallationTime(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).get_ScheduledInstallationTime(@ptrCast(*const IAutomaticUpdatesSettings, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_put_ScheduledInstallationTime(self: *const T, value: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).put_ScheduledInstallationTime(@ptrCast(*const IAutomaticUpdatesSettings, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_Refresh(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).Refresh(@ptrCast(*const IAutomaticUpdatesSettings, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings_Save(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings.VTable, self.vtable).Save(@ptrCast(*const IAutomaticUpdatesSettings, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IAutomaticUpdatesSettings2_Value = @import("../zig.zig").Guid.initString("6abc136a-c3ca-4384-8171-cb2b1e59b8dc"); pub const IID_IAutomaticUpdatesSettings2 = &IID_IAutomaticUpdatesSettings2_Value; pub const IAutomaticUpdatesSettings2 = extern struct { pub const VTable = extern struct { base: IAutomaticUpdatesSettings.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IncludeRecommendedUpdates: fn( self: *const IAutomaticUpdatesSettings2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_IncludeRecommendedUpdates: fn( self: *const IAutomaticUpdatesSettings2, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CheckPermission: fn( self: *const IAutomaticUpdatesSettings2, userType: AutomaticUpdatesUserType, permissionType: AutomaticUpdatesPermissionType, userHasPermission: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IAutomaticUpdatesSettings.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings2_get_IncludeRecommendedUpdates(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings2.VTable, self.vtable).get_IncludeRecommendedUpdates(@ptrCast(*const IAutomaticUpdatesSettings2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings2_put_IncludeRecommendedUpdates(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings2.VTable, self.vtable).put_IncludeRecommendedUpdates(@ptrCast(*const IAutomaticUpdatesSettings2, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings2_CheckPermission(self: *const T, userType: AutomaticUpdatesUserType, permissionType: AutomaticUpdatesPermissionType, userHasPermission: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings2.VTable, self.vtable).CheckPermission(@ptrCast(*const IAutomaticUpdatesSettings2, self), userType, permissionType, userHasPermission); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IAutomaticUpdatesSettings3_Value = @import("../zig.zig").Guid.initString("b587f5c3-f57e-485f-bbf5-0d181c5cd0dc"); pub const IID_IAutomaticUpdatesSettings3 = &IID_IAutomaticUpdatesSettings3_Value; pub const IAutomaticUpdatesSettings3 = extern struct { pub const VTable = extern struct { base: IAutomaticUpdatesSettings2.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NonAdministratorsElevated: fn( self: *const IAutomaticUpdatesSettings3, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NonAdministratorsElevated: fn( self: *const IAutomaticUpdatesSettings3, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FeaturedUpdatesEnabled: fn( self: *const IAutomaticUpdatesSettings3, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FeaturedUpdatesEnabled: fn( self: *const IAutomaticUpdatesSettings3, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IAutomaticUpdatesSettings2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings3_get_NonAdministratorsElevated(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings3.VTable, self.vtable).get_NonAdministratorsElevated(@ptrCast(*const IAutomaticUpdatesSettings3, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings3_put_NonAdministratorsElevated(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings3.VTable, self.vtable).put_NonAdministratorsElevated(@ptrCast(*const IAutomaticUpdatesSettings3, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings3_get_FeaturedUpdatesEnabled(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings3.VTable, self.vtable).get_FeaturedUpdatesEnabled(@ptrCast(*const IAutomaticUpdatesSettings3, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdatesSettings3_put_FeaturedUpdatesEnabled(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdatesSettings3.VTable, self.vtable).put_FeaturedUpdatesEnabled(@ptrCast(*const IAutomaticUpdatesSettings3, self), value); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IAutomaticUpdates_Value = @import("../zig.zig").Guid.initString("673425bf-c082-4c7c-bdfd-569464b8e0ce"); pub const IID_IAutomaticUpdates = &IID_IAutomaticUpdates_Value; pub const IAutomaticUpdates = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, DetectNow: fn( self: *const IAutomaticUpdates, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Pause: fn( self: *const IAutomaticUpdates, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Resume: fn( self: *const IAutomaticUpdates, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ShowSettingsDialog: fn( self: *const IAutomaticUpdates, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Settings: fn( self: *const IAutomaticUpdates, retval: ?*?*IAutomaticUpdatesSettings, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceEnabled: fn( self: *const IAutomaticUpdates, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnableService: fn( self: *const IAutomaticUpdates, ) 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 IAutomaticUpdates_DetectNow(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdates.VTable, self.vtable).DetectNow(@ptrCast(*const IAutomaticUpdates, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdates_Pause(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdates.VTable, self.vtable).Pause(@ptrCast(*const IAutomaticUpdates, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdates_Resume(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdates.VTable, self.vtable).Resume(@ptrCast(*const IAutomaticUpdates, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdates_ShowSettingsDialog(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdates.VTable, self.vtable).ShowSettingsDialog(@ptrCast(*const IAutomaticUpdates, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdates_get_Settings(self: *const T, retval: ?*?*IAutomaticUpdatesSettings) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdates.VTable, self.vtable).get_Settings(@ptrCast(*const IAutomaticUpdates, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdates_get_ServiceEnabled(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdates.VTable, self.vtable).get_ServiceEnabled(@ptrCast(*const IAutomaticUpdates, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdates_EnableService(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdates.VTable, self.vtable).EnableService(@ptrCast(*const IAutomaticUpdates, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IAutomaticUpdates2_Value = @import("../zig.zig").Guid.initString("4a2f5c31-cfd9-410e-b7fb-29a653973a0f"); pub const IID_IAutomaticUpdates2 = &IID_IAutomaticUpdates2_Value; pub const IAutomaticUpdates2 = extern struct { pub const VTable = extern struct { base: IAutomaticUpdates.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Results: fn( self: *const IAutomaticUpdates2, retval: ?*?*IAutomaticUpdatesResults, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IAutomaticUpdates.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IAutomaticUpdates2_get_Results(self: *const T, retval: ?*?*IAutomaticUpdatesResults) callconv(.Inline) HRESULT { return @ptrCast(*const IAutomaticUpdates2.VTable, self.vtable).get_Results(@ptrCast(*const IAutomaticUpdates2, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateIdentity_Value = @import("../zig.zig").Guid.initString("46297823-9940-4c09-aed9-cd3ea6d05968"); pub const IID_IUpdateIdentity = &IID_IUpdateIdentity_Value; pub const IUpdateIdentity = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RevisionNumber: fn( self: *const IUpdateIdentity, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UpdateID: fn( self: *const IUpdateIdentity, retval: ?*?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 IUpdateIdentity_get_RevisionNumber(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateIdentity.VTable, self.vtable).get_RevisionNumber(@ptrCast(*const IUpdateIdentity, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateIdentity_get_UpdateID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateIdentity.VTable, self.vtable).get_UpdateID(@ptrCast(*const IUpdateIdentity, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IImageInformation_Value = @import("../zig.zig").Guid.initString("7c907864-346c-4aeb-8f3f-57da289f969f"); pub const IID_IImageInformation = &IID_IImageInformation_Value; pub const IImageInformation = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AltText: fn( self: *const IImageInformation, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Height: fn( self: *const IImageInformation, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Source: fn( self: *const IImageInformation, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Width: fn( self: *const IImageInformation, retval: ?*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 IImageInformation_get_AltText(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IImageInformation.VTable, self.vtable).get_AltText(@ptrCast(*const IImageInformation, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IImageInformation_get_Height(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IImageInformation.VTable, self.vtable).get_Height(@ptrCast(*const IImageInformation, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IImageInformation_get_Source(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IImageInformation.VTable, self.vtable).get_Source(@ptrCast(*const IImageInformation, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IImageInformation_get_Width(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IImageInformation.VTable, self.vtable).get_Width(@ptrCast(*const IImageInformation, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_ICategory_Value = @import("../zig.zig").Guid.initString("81ddc1b8-9d35-47a6-b471-5b80f519223b"); pub const IID_ICategory = &IID_ICategory_Value; pub const ICategory = 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 ICategory, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CategoryID: fn( self: *const ICategory, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Children: fn( self: *const ICategory, retval: ?*?*ICategoryCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Description: fn( self: *const ICategory, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Image: fn( self: *const ICategory, retval: ?*?*IImageInformation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Order: fn( self: *const ICategory, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Parent: fn( self: *const ICategory, retval: ?*?*ICategory, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Type: fn( self: *const ICategory, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Updates: fn( self: *const ICategory, retval: ?*?*IUpdateCollection, ) 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 ICategory_get_Name(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_Name(@ptrCast(*const ICategory, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategory_get_CategoryID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_CategoryID(@ptrCast(*const ICategory, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategory_get_Children(self: *const T, retval: ?*?*ICategoryCollection) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_Children(@ptrCast(*const ICategory, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategory_get_Description(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_Description(@ptrCast(*const ICategory, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategory_get_Image(self: *const T, retval: ?*?*IImageInformation) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_Image(@ptrCast(*const ICategory, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategory_get_Order(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_Order(@ptrCast(*const ICategory, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategory_get_Parent(self: *const T, retval: ?*?*ICategory) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_Parent(@ptrCast(*const ICategory, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategory_get_Type(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_Type(@ptrCast(*const ICategory, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategory_get_Updates(self: *const T, retval: ?*?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const ICategory.VTable, self.vtable).get_Updates(@ptrCast(*const ICategory, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_ICategoryCollection_Value = @import("../zig.zig").Guid.initString("3a56bfb8-576c-43f7-9335-fe4838fd7e37"); pub const IID_ICategoryCollection = &IID_ICategoryCollection_Value; pub const ICategoryCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const ICategoryCollection, index: i32, retval: ?*?*ICategory, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const ICategoryCollection, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const ICategoryCollection, retval: ?*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 ICategoryCollection_get_Item(self: *const T, index: i32, retval: ?*?*ICategory) callconv(.Inline) HRESULT { return @ptrCast(*const ICategoryCollection.VTable, self.vtable).get_Item(@ptrCast(*const ICategoryCollection, self), index, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategoryCollection_get__NewEnum(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const ICategoryCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const ICategoryCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICategoryCollection_get_Count(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ICategoryCollection.VTable, self.vtable).get_Count(@ptrCast(*const ICategoryCollection, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationBehavior_Value = @import("../zig.zig").Guid.initString("d9a59339-e245-4dbd-9686-4d5763e39624"); pub const IID_IInstallationBehavior = &IID_IInstallationBehavior_Value; pub const IInstallationBehavior = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CanRequestUserInput: fn( self: *const IInstallationBehavior, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Impact: fn( self: *const IInstallationBehavior, retval: ?*InstallationImpact, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RebootBehavior: fn( self: *const IInstallationBehavior, retval: ?*InstallationRebootBehavior, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RequiresNetworkConnectivity: fn( self: *const IInstallationBehavior, retval: ?*i16, ) 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 IInstallationBehavior_get_CanRequestUserInput(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationBehavior.VTable, self.vtable).get_CanRequestUserInput(@ptrCast(*const IInstallationBehavior, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationBehavior_get_Impact(self: *const T, retval: ?*InstallationImpact) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationBehavior.VTable, self.vtable).get_Impact(@ptrCast(*const IInstallationBehavior, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationBehavior_get_RebootBehavior(self: *const T, retval: ?*InstallationRebootBehavior) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationBehavior.VTable, self.vtable).get_RebootBehavior(@ptrCast(*const IInstallationBehavior, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationBehavior_get_RequiresNetworkConnectivity(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationBehavior.VTable, self.vtable).get_RequiresNetworkConnectivity(@ptrCast(*const IInstallationBehavior, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateDownloadContent_Value = @import("../zig.zig").Guid.initString("54a2cb2d-9a0c-48b6-8a50-9abb69ee2d02"); pub const IID_IUpdateDownloadContent = &IID_IUpdateDownloadContent_Value; pub const IUpdateDownloadContent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DownloadUrl: fn( self: *const IUpdateDownloadContent, retval: ?*?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 IUpdateDownloadContent_get_DownloadUrl(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloadContent.VTable, self.vtable).get_DownloadUrl(@ptrCast(*const IUpdateDownloadContent, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateDownloadContent2_Value = @import("../zig.zig").Guid.initString("c97ad11b-f257-420b-9d9f-377f733f6f68"); pub const IID_IUpdateDownloadContent2 = &IID_IUpdateDownloadContent2_Value; pub const IUpdateDownloadContent2 = extern struct { pub const VTable = extern struct { base: IUpdateDownloadContent.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsDeltaCompressedContent: fn( self: *const IUpdateDownloadContent2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateDownloadContent.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloadContent2_get_IsDeltaCompressedContent(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloadContent2.VTable, self.vtable).get_IsDeltaCompressedContent(@ptrCast(*const IUpdateDownloadContent2, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateDownloadContentCollection_Value = @import("../zig.zig").Guid.initString("bc5513c8-b3b8-4bf7-a4d4-361c0d8c88ba"); pub const IID_IUpdateDownloadContentCollection = &IID_IUpdateDownloadContentCollection_Value; pub const IUpdateDownloadContentCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const IUpdateDownloadContentCollection, index: i32, retval: ?*?*IUpdateDownloadContent, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const IUpdateDownloadContentCollection, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IUpdateDownloadContentCollection, retval: ?*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 IUpdateDownloadContentCollection_get_Item(self: *const T, index: i32, retval: ?*?*IUpdateDownloadContent) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloadContentCollection.VTable, self.vtable).get_Item(@ptrCast(*const IUpdateDownloadContentCollection, self), index, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloadContentCollection_get__NewEnum(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloadContentCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IUpdateDownloadContentCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloadContentCollection_get_Count(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloadContentCollection.VTable, self.vtable).get_Count(@ptrCast(*const IUpdateDownloadContentCollection, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdate_Value = @import("../zig.zig").Guid.initString("6a92b07a-d821-4682-b423-5c805022cc4d"); pub const IID_IUpdate = &IID_IUpdate_Value; pub const IUpdate = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Title: fn( self: *const IUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoSelectOnWebSites: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BundledUpdates: fn( self: *const IUpdate, retval: ?*?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CanRequireSource: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Categories: fn( self: *const IUpdate, retval: ?*?*ICategoryCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Deadline: fn( self: *const IUpdate, retval: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DeltaCompressedContentAvailable: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DeltaCompressedContentPreferred: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Description: fn( self: *const IUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EulaAccepted: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EulaText: fn( self: *const IUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HandlerID: fn( self: *const IUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Identity: fn( self: *const IUpdate, retval: ?*?*IUpdateIdentity, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Image: fn( self: *const IUpdate, retval: ?*?*IImageInformation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_InstallationBehavior: fn( self: *const IUpdate, retval: ?*?*IInstallationBehavior, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsBeta: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsDownloaded: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsHidden: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_IsHidden: fn( self: *const IUpdate, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsInstalled: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsMandatory: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsUninstallable: fn( self: *const IUpdate, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Languages: fn( self: *const IUpdate, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastDeploymentChangeTime: fn( self: *const IUpdate, retval: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxDownloadSize: fn( self: *const IUpdate, retval: ?*DECIMAL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MinDownloadSize: fn( self: *const IUpdate, retval: ?*DECIMAL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MoreInfoUrls: fn( self: *const IUpdate, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MsrcSeverity: fn( self: *const IUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RecommendedCpuSpeed: fn( self: *const IUpdate, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RecommendedHardDiskSpace: fn( self: *const IUpdate, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RecommendedMemory: fn( self: *const IUpdate, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReleaseNotes: fn( self: *const IUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SecurityBulletinIDs: fn( self: *const IUpdate, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SupersededUpdateIDs: fn( self: *const IUpdate, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SupportUrl: fn( self: *const IUpdate, retval: ?*?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 IUpdate, retval: ?*UpdateType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UninstallationNotes: fn( self: *const IUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UninstallationBehavior: fn( self: *const IUpdate, retval: ?*?*IInstallationBehavior, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UninstallationSteps: fn( self: *const IUpdate, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_KBArticleIDs: fn( self: *const IUpdate, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AcceptEula: fn( self: *const IUpdate, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DeploymentAction: fn( self: *const IUpdate, retval: ?*DeploymentAction, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CopyFromCache: fn( self: *const IUpdate, path: ?BSTR, toExtractCabFiles: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DownloadPriority: fn( self: *const IUpdate, retval: ?*DownloadPriority, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DownloadContents: fn( self: *const IUpdate, retval: ?*?*IUpdateDownloadContentCollection, ) 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 IUpdate_get_Title(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_Title(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_AutoSelectOnWebSites(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_AutoSelectOnWebSites(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_BundledUpdates(self: *const T, retval: ?*?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_BundledUpdates(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_CanRequireSource(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_CanRequireSource(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_Categories(self: *const T, retval: ?*?*ICategoryCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_Categories(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_Deadline(self: *const T, retval: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_Deadline(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_DeltaCompressedContentAvailable(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_DeltaCompressedContentAvailable(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_DeltaCompressedContentPreferred(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_DeltaCompressedContentPreferred(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_Description(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_Description(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_EulaAccepted(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_EulaAccepted(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_EulaText(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_EulaText(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_HandlerID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_HandlerID(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_Identity(self: *const T, retval: ?*?*IUpdateIdentity) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_Identity(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_Image(self: *const T, retval: ?*?*IImageInformation) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_Image(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_InstallationBehavior(self: *const T, retval: ?*?*IInstallationBehavior) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_InstallationBehavior(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_IsBeta(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_IsBeta(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_IsDownloaded(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_IsDownloaded(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_IsHidden(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_IsHidden(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_put_IsHidden(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).put_IsHidden(@ptrCast(*const IUpdate, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_IsInstalled(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_IsInstalled(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_IsMandatory(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_IsMandatory(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_IsUninstallable(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_IsUninstallable(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_Languages(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_Languages(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_LastDeploymentChangeTime(self: *const T, retval: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_LastDeploymentChangeTime(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_MaxDownloadSize(self: *const T, retval: ?*DECIMAL) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_MaxDownloadSize(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_MinDownloadSize(self: *const T, retval: ?*DECIMAL) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_MinDownloadSize(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_MoreInfoUrls(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_MoreInfoUrls(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_MsrcSeverity(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_MsrcSeverity(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_RecommendedCpuSpeed(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_RecommendedCpuSpeed(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_RecommendedHardDiskSpace(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_RecommendedHardDiskSpace(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_RecommendedMemory(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_RecommendedMemory(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_ReleaseNotes(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_ReleaseNotes(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_SecurityBulletinIDs(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_SecurityBulletinIDs(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_SupersededUpdateIDs(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_SupersededUpdateIDs(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_SupportUrl(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_SupportUrl(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_Type(self: *const T, retval: ?*UpdateType) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_Type(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_UninstallationNotes(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_UninstallationNotes(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_UninstallationBehavior(self: *const T, retval: ?*?*IInstallationBehavior) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_UninstallationBehavior(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_UninstallationSteps(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_UninstallationSteps(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_KBArticleIDs(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_KBArticleIDs(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_AcceptEula(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).AcceptEula(@ptrCast(*const IUpdate, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_DeploymentAction(self: *const T, retval: ?*DeploymentAction) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_DeploymentAction(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_CopyFromCache(self: *const T, path: ?BSTR, toExtractCabFiles: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).CopyFromCache(@ptrCast(*const IUpdate, self), path, toExtractCabFiles); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_DownloadPriority(self: *const T, retval: ?*DownloadPriority) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_DownloadPriority(@ptrCast(*const IUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate_get_DownloadContents(self: *const T, retval: ?*?*IUpdateDownloadContentCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate.VTable, self.vtable).get_DownloadContents(@ptrCast(*const IUpdate, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWindowsDriverUpdate_Value = @import("../zig.zig").Guid.initString("b383cd1a-5ce9-4504-9f63-764b1236f191"); pub const IID_IWindowsDriverUpdate = &IID_IWindowsDriverUpdate_Value; pub const IWindowsDriverUpdate = extern struct { pub const VTable = extern struct { base: IUpdate.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverClass: fn( self: *const IWindowsDriverUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverHardwareID: fn( self: *const IWindowsDriverUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverManufacturer: fn( self: *const IWindowsDriverUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverModel: fn( self: *const IWindowsDriverUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverProvider: fn( self: *const IWindowsDriverUpdate, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverVerDate: fn( self: *const IWindowsDriverUpdate, retval: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DeviceProblemNumber: fn( self: *const IWindowsDriverUpdate, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DeviceStatus: fn( self: *const IWindowsDriverUpdate, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdate.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate_get_DriverClass(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate.VTable, self.vtable).get_DriverClass(@ptrCast(*const IWindowsDriverUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate_get_DriverHardwareID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate.VTable, self.vtable).get_DriverHardwareID(@ptrCast(*const IWindowsDriverUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate_get_DriverManufacturer(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate.VTable, self.vtable).get_DriverManufacturer(@ptrCast(*const IWindowsDriverUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate_get_DriverModel(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate.VTable, self.vtable).get_DriverModel(@ptrCast(*const IWindowsDriverUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate_get_DriverProvider(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate.VTable, self.vtable).get_DriverProvider(@ptrCast(*const IWindowsDriverUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate_get_DriverVerDate(self: *const T, retval: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate.VTable, self.vtable).get_DriverVerDate(@ptrCast(*const IWindowsDriverUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate_get_DeviceProblemNumber(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate.VTable, self.vtable).get_DeviceProblemNumber(@ptrCast(*const IWindowsDriverUpdate, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate_get_DeviceStatus(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate.VTable, self.vtable).get_DeviceStatus(@ptrCast(*const IWindowsDriverUpdate, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdate2_Value = @import("../zig.zig").Guid.initString("144fe9b0-d23d-4a8b-8634-fb4457533b7a"); pub const IID_IUpdate2 = &IID_IUpdate2_Value; pub const IUpdate2 = extern struct { pub const VTable = extern struct { base: IUpdate.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RebootRequired: fn( self: *const IUpdate2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsPresent: fn( self: *const IUpdate2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CveIDs: fn( self: *const IUpdate2, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CopyToCache: fn( self: *const IUpdate2, pFiles: ?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdate.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate2_get_RebootRequired(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate2.VTable, self.vtable).get_RebootRequired(@ptrCast(*const IUpdate2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate2_get_IsPresent(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate2.VTable, self.vtable).get_IsPresent(@ptrCast(*const IUpdate2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate2_get_CveIDs(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate2.VTable, self.vtable).get_CveIDs(@ptrCast(*const IUpdate2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate2_CopyToCache(self: *const T, pFiles: ?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate2.VTable, self.vtable).CopyToCache(@ptrCast(*const IUpdate2, self), pFiles); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdate3_Value = @import("../zig.zig").Guid.initString("112eda6b-95b3-476f-9d90-aee82c6b8181"); pub const IID_IUpdate3 = &IID_IUpdate3_Value; pub const IUpdate3 = extern struct { pub const VTable = extern struct { base: IUpdate2.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BrowseOnly: fn( self: *const IUpdate3, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdate2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate3_get_BrowseOnly(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate3.VTable, self.vtable).get_BrowseOnly(@ptrCast(*const IUpdate3, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdate4_Value = @import("../zig.zig").Guid.initString("27e94b0d-5139-49a2-9a61-93522dc54652"); pub const IID_IUpdate4 = &IID_IUpdate4_Value; pub const IUpdate4 = extern struct { pub const VTable = extern struct { base: IUpdate3.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PerUser: fn( self: *const IUpdate4, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdate3.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate4_get_PerUser(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate4.VTable, self.vtable).get_PerUser(@ptrCast(*const IUpdate4, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdate5_Value = @import("../zig.zig").Guid.initString("c1c2f21a-d2f4-4902-b5c6-8a081c19a890"); pub const IID_IUpdate5 = &IID_IUpdate5_Value; pub const IUpdate5 = extern struct { pub const VTable = extern struct { base: IUpdate4.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoSelection: fn( self: *const IUpdate5, retval: ?*AutoSelectionMode, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoDownload: fn( self: *const IUpdate5, retval: ?*AutoDownloadMode, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdate4.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate5_get_AutoSelection(self: *const T, retval: ?*AutoSelectionMode) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate5.VTable, self.vtable).get_AutoSelection(@ptrCast(*const IUpdate5, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdate5_get_AutoDownload(self: *const T, retval: ?*AutoDownloadMode) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdate5.VTable, self.vtable).get_AutoDownload(@ptrCast(*const IUpdate5, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWindowsDriverUpdate2_Value = @import("../zig.zig").Guid.initString("615c4269-7a48-43bd-96b7-bf6ca27d6c3e"); pub const IID_IWindowsDriverUpdate2 = &IID_IWindowsDriverUpdate2_Value; pub const IWindowsDriverUpdate2 = extern struct { pub const VTable = extern struct { base: IWindowsDriverUpdate.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RebootRequired: fn( self: *const IWindowsDriverUpdate2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsPresent: fn( self: *const IWindowsDriverUpdate2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CveIDs: fn( self: *const IWindowsDriverUpdate2, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CopyToCache: fn( self: *const IWindowsDriverUpdate2, pFiles: ?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IWindowsDriverUpdate.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate2_get_RebootRequired(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate2.VTable, self.vtable).get_RebootRequired(@ptrCast(*const IWindowsDriverUpdate2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate2_get_IsPresent(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate2.VTable, self.vtable).get_IsPresent(@ptrCast(*const IWindowsDriverUpdate2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate2_get_CveIDs(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate2.VTable, self.vtable).get_CveIDs(@ptrCast(*const IWindowsDriverUpdate2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate2_CopyToCache(self: *const T, pFiles: ?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate2.VTable, self.vtable).CopyToCache(@ptrCast(*const IWindowsDriverUpdate2, self), pFiles); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWindowsDriverUpdate3_Value = @import("../zig.zig").Guid.initString("49ebd502-4a96-41bd-9e3e-4c5057f4250c"); pub const IID_IWindowsDriverUpdate3 = &IID_IWindowsDriverUpdate3_Value; pub const IWindowsDriverUpdate3 = extern struct { pub const VTable = extern struct { base: IWindowsDriverUpdate2.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BrowseOnly: fn( self: *const IWindowsDriverUpdate3, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IWindowsDriverUpdate2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate3_get_BrowseOnly(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate3.VTable, self.vtable).get_BrowseOnly(@ptrCast(*const IWindowsDriverUpdate3, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWindowsDriverUpdateEntry_Value = @import("../zig.zig").Guid.initString("ed8bfe40-a60b-42ea-9652-817dfcfa23ec"); pub const IID_IWindowsDriverUpdateEntry = &IID_IWindowsDriverUpdateEntry_Value; pub const IWindowsDriverUpdateEntry = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverClass: fn( self: *const IWindowsDriverUpdateEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverHardwareID: fn( self: *const IWindowsDriverUpdateEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverManufacturer: fn( self: *const IWindowsDriverUpdateEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverModel: fn( self: *const IWindowsDriverUpdateEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverProvider: fn( self: *const IWindowsDriverUpdateEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DriverVerDate: fn( self: *const IWindowsDriverUpdateEntry, retval: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DeviceProblemNumber: fn( self: *const IWindowsDriverUpdateEntry, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DeviceStatus: fn( self: *const IWindowsDriverUpdateEntry, retval: ?*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 IWindowsDriverUpdateEntry_get_DriverClass(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntry.VTable, self.vtable).get_DriverClass(@ptrCast(*const IWindowsDriverUpdateEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntry_get_DriverHardwareID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntry.VTable, self.vtable).get_DriverHardwareID(@ptrCast(*const IWindowsDriverUpdateEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntry_get_DriverManufacturer(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntry.VTable, self.vtable).get_DriverManufacturer(@ptrCast(*const IWindowsDriverUpdateEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntry_get_DriverModel(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntry.VTable, self.vtable).get_DriverModel(@ptrCast(*const IWindowsDriverUpdateEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntry_get_DriverProvider(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntry.VTable, self.vtable).get_DriverProvider(@ptrCast(*const IWindowsDriverUpdateEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntry_get_DriverVerDate(self: *const T, retval: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntry.VTable, self.vtable).get_DriverVerDate(@ptrCast(*const IWindowsDriverUpdateEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntry_get_DeviceProblemNumber(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntry.VTable, self.vtable).get_DeviceProblemNumber(@ptrCast(*const IWindowsDriverUpdateEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntry_get_DeviceStatus(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntry.VTable, self.vtable).get_DeviceStatus(@ptrCast(*const IWindowsDriverUpdateEntry, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWindowsDriverUpdateEntryCollection_Value = @import("../zig.zig").Guid.initString("0d521700-a372-4bef-828b-3d00c10adebd"); pub const IID_IWindowsDriverUpdateEntryCollection = &IID_IWindowsDriverUpdateEntryCollection_Value; pub const IWindowsDriverUpdateEntryCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const IWindowsDriverUpdateEntryCollection, index: i32, retval: ?*?*IWindowsDriverUpdateEntry, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const IWindowsDriverUpdateEntryCollection, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IWindowsDriverUpdateEntryCollection, retval: ?*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 IWindowsDriverUpdateEntryCollection_get_Item(self: *const T, index: i32, retval: ?*?*IWindowsDriverUpdateEntry) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntryCollection.VTable, self.vtable).get_Item(@ptrCast(*const IWindowsDriverUpdateEntryCollection, self), index, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntryCollection_get__NewEnum(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntryCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IWindowsDriverUpdateEntryCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdateEntryCollection_get_Count(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdateEntryCollection.VTable, self.vtable).get_Count(@ptrCast(*const IWindowsDriverUpdateEntryCollection, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWindowsDriverUpdate4_Value = @import("../zig.zig").Guid.initString("004c6a2b-0c19-4c69-9f5c-a269b2560db9"); pub const IID_IWindowsDriverUpdate4 = &IID_IWindowsDriverUpdate4_Value; pub const IWindowsDriverUpdate4 = extern struct { pub const VTable = extern struct { base: IWindowsDriverUpdate3.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_WindowsDriverUpdateEntries: fn( self: *const IWindowsDriverUpdate4, retval: ?*?*IWindowsDriverUpdateEntryCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PerUser: fn( self: *const IWindowsDriverUpdate4, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IWindowsDriverUpdate3.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate4_get_WindowsDriverUpdateEntries(self: *const T, retval: ?*?*IWindowsDriverUpdateEntryCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate4.VTable, self.vtable).get_WindowsDriverUpdateEntries(@ptrCast(*const IWindowsDriverUpdate4, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate4_get_PerUser(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate4.VTable, self.vtable).get_PerUser(@ptrCast(*const IWindowsDriverUpdate4, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IWindowsDriverUpdate5_Value = @import("../zig.zig").Guid.initString("70cf5c82-8642-42bb-9dbc-0cfd263c6c4f"); pub const IID_IWindowsDriverUpdate5 = &IID_IWindowsDriverUpdate5_Value; pub const IWindowsDriverUpdate5 = extern struct { pub const VTable = extern struct { base: IWindowsDriverUpdate4.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoSelection: fn( self: *const IWindowsDriverUpdate5, retval: ?*AutoSelectionMode, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoDownload: fn( self: *const IWindowsDriverUpdate5, retval: ?*AutoDownloadMode, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IWindowsDriverUpdate4.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate5_get_AutoSelection(self: *const T, retval: ?*AutoSelectionMode) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate5.VTable, self.vtable).get_AutoSelection(@ptrCast(*const IWindowsDriverUpdate5, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWindowsDriverUpdate5_get_AutoDownload(self: *const T, retval: ?*AutoDownloadMode) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowsDriverUpdate5.VTable, self.vtable).get_AutoDownload(@ptrCast(*const IWindowsDriverUpdate5, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateCollection_Value = @import("../zig.zig").Guid.initString("07f7438c-7709-4ca5-b518-91279288134e"); pub const IID_IUpdateCollection = &IID_IUpdateCollection_Value; pub const IUpdateCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const IUpdateCollection, index: i32, retval: ?*?*IUpdate, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Item: fn( self: *const IUpdateCollection, index: i32, value: ?*IUpdate, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const IUpdateCollection, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IUpdateCollection, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReadOnly: fn( self: *const IUpdateCollection, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Add: fn( self: *const IUpdateCollection, value: ?*IUpdate, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clear: fn( self: *const IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Copy: fn( self: *const IUpdateCollection, retval: ?*?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Insert: fn( self: *const IUpdateCollection, index: i32, value: ?*IUpdate, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveAt: fn( self: *const IUpdateCollection, index: 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 IUpdateCollection_get_Item(self: *const T, index: i32, retval: ?*?*IUpdate) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).get_Item(@ptrCast(*const IUpdateCollection, self), index, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_put_Item(self: *const T, index: i32, value: ?*IUpdate) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).put_Item(@ptrCast(*const IUpdateCollection, self), index, value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_get__NewEnum(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IUpdateCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_get_Count(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).get_Count(@ptrCast(*const IUpdateCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_get_ReadOnly(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).get_ReadOnly(@ptrCast(*const IUpdateCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_Add(self: *const T, value: ?*IUpdate, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).Add(@ptrCast(*const IUpdateCollection, self), value, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_Clear(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).Clear(@ptrCast(*const IUpdateCollection, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_Copy(self: *const T, retval: ?*?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).Copy(@ptrCast(*const IUpdateCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_Insert(self: *const T, index: i32, value: ?*IUpdate) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).Insert(@ptrCast(*const IUpdateCollection, self), index, value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateCollection_RemoveAt(self: *const T, index: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateCollection.VTable, self.vtable).RemoveAt(@ptrCast(*const IUpdateCollection, self), index); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateException_Value = @import("../zig.zig").Guid.initString("a376dd5e-09d4-427f-af7c-fed5b6e1c1d6"); pub const IID_IUpdateException = &IID_IUpdateException_Value; pub const IUpdateException = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Message: fn( self: *const IUpdateException, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HResult: fn( self: *const IUpdateException, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Context: fn( self: *const IUpdateException, retval: ?*UpdateExceptionContext, ) 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 IUpdateException_get_Message(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateException.VTable, self.vtable).get_Message(@ptrCast(*const IUpdateException, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateException_get_HResult(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateException.VTable, self.vtable).get_HResult(@ptrCast(*const IUpdateException, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateException_get_Context(self: *const T, retval: ?*UpdateExceptionContext) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateException.VTable, self.vtable).get_Context(@ptrCast(*const IUpdateException, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInvalidProductLicenseException_Value = @import("../zig.zig").Guid.initString("a37d00f5-7bb0-4953-b414-f9e98326f2e8"); pub const IID_IInvalidProductLicenseException = &IID_IInvalidProductLicenseException_Value; pub const IInvalidProductLicenseException = extern struct { pub const VTable = extern struct { base: IUpdateException.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Product: fn( self: *const IInvalidProductLicenseException, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateException.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInvalidProductLicenseException_get_Product(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IInvalidProductLicenseException.VTable, self.vtable).get_Product(@ptrCast(*const IInvalidProductLicenseException, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateExceptionCollection_Value = @import("../zig.zig").Guid.initString("503626a3-8e14-4729-9355-0fe664bd2321"); pub const IID_IUpdateExceptionCollection = &IID_IUpdateExceptionCollection_Value; pub const IUpdateExceptionCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const IUpdateExceptionCollection, index: i32, retval: ?*?*IUpdateException, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const IUpdateExceptionCollection, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IUpdateExceptionCollection, retval: ?*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 IUpdateExceptionCollection_get_Item(self: *const T, index: i32, retval: ?*?*IUpdateException) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateExceptionCollection.VTable, self.vtable).get_Item(@ptrCast(*const IUpdateExceptionCollection, self), index, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateExceptionCollection_get__NewEnum(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateExceptionCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IUpdateExceptionCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateExceptionCollection_get_Count(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateExceptionCollection.VTable, self.vtable).get_Count(@ptrCast(*const IUpdateExceptionCollection, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_ISearchResult_Value = @import("../zig.zig").Guid.initString("d40cff62-e08c-4498-941a-01e25f0fd33c"); pub const IID_ISearchResult = &IID_ISearchResult_Value; pub const ISearchResult = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResultCode: fn( self: *const ISearchResult, retval: ?*OperationResultCode, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RootCategories: fn( self: *const ISearchResult, retval: ?*?*ICategoryCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Updates: fn( self: *const ISearchResult, retval: ?*?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Warnings: fn( self: *const ISearchResult, retval: ?*?*IUpdateExceptionCollection, ) 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 ISearchResult_get_ResultCode(self: *const T, retval: ?*OperationResultCode) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchResult.VTable, self.vtable).get_ResultCode(@ptrCast(*const ISearchResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISearchResult_get_RootCategories(self: *const T, retval: ?*?*ICategoryCollection) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchResult.VTable, self.vtable).get_RootCategories(@ptrCast(*const ISearchResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISearchResult_get_Updates(self: *const T, retval: ?*?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchResult.VTable, self.vtable).get_Updates(@ptrCast(*const ISearchResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISearchResult_get_Warnings(self: *const T, retval: ?*?*IUpdateExceptionCollection) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchResult.VTable, self.vtable).get_Warnings(@ptrCast(*const ISearchResult, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_ISearchJob_Value = @import("../zig.zig").Guid.initString("7366ea16-7a1a-4ea2-b042-973d3e9cd99b"); pub const IID_ISearchJob = &IID_ISearchJob_Value; pub const ISearchJob = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AsyncState: fn( self: *const ISearchJob, retval: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsCompleted: fn( self: *const ISearchJob, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CleanUp: fn( self: *const ISearchJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RequestAbort: fn( self: *const ISearchJob, ) 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 ISearchJob_get_AsyncState(self: *const T, retval: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchJob.VTable, self.vtable).get_AsyncState(@ptrCast(*const ISearchJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISearchJob_get_IsCompleted(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchJob.VTable, self.vtable).get_IsCompleted(@ptrCast(*const ISearchJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISearchJob_CleanUp(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchJob.VTable, self.vtable).CleanUp(@ptrCast(*const ISearchJob, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISearchJob_RequestAbort(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchJob.VTable, self.vtable).RequestAbort(@ptrCast(*const ISearchJob, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_ISearchCompletedCallbackArgs_Value = @import("../zig.zig").Guid.initString("a700a634-2850-4c47-938a-9e4b6e5af9a6"); pub const IID_ISearchCompletedCallbackArgs = &IID_ISearchCompletedCallbackArgs_Value; pub const ISearchCompletedCallbackArgs = 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()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_ISearchCompletedCallback_Value = @import("../zig.zig").Guid.initString("88aee058-d4b0-4725-a2f1-814a67ae964c"); pub const IID_ISearchCompletedCallback = &IID_ISearchCompletedCallback_Value; pub const ISearchCompletedCallback = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Invoke: fn( self: *const ISearchCompletedCallback, searchJob: ?*ISearchJob, callbackArgs: ?*ISearchCompletedCallbackArgs, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISearchCompletedCallback_Invoke(self: *const T, searchJob: ?*ISearchJob, callbackArgs: ?*ISearchCompletedCallbackArgs) callconv(.Inline) HRESULT { return @ptrCast(*const ISearchCompletedCallback.VTable, self.vtable).Invoke(@ptrCast(*const ISearchCompletedCallback, self), searchJob, callbackArgs); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateHistoryEntry_Value = @import("../zig.zig").Guid.initString("be56a644-af0e-4e0e-a311-c1d8e695cbff"); pub const IID_IUpdateHistoryEntry = &IID_IUpdateHistoryEntry_Value; pub const IUpdateHistoryEntry = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Operation: fn( self: *const IUpdateHistoryEntry, retval: ?*UpdateOperation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResultCode: fn( self: *const IUpdateHistoryEntry, retval: ?*OperationResultCode, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HResult: fn( self: *const IUpdateHistoryEntry, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Date: fn( self: *const IUpdateHistoryEntry, retval: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UpdateIdentity: fn( self: *const IUpdateHistoryEntry, retval: ?*?*IUpdateIdentity, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Title: fn( self: *const IUpdateHistoryEntry, retval: ?*?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 IUpdateHistoryEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UnmappedResultCode: fn( self: *const IUpdateHistoryEntry, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClientApplicationID: fn( self: *const IUpdateHistoryEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServerSelection: fn( self: *const IUpdateHistoryEntry, retval: ?*ServerSelection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceID: fn( self: *const IUpdateHistoryEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UninstallationSteps: fn( self: *const IUpdateHistoryEntry, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UninstallationNotes: fn( self: *const IUpdateHistoryEntry, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SupportUrl: fn( self: *const IUpdateHistoryEntry, retval: ?*?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 IUpdateHistoryEntry_get_Operation(self: *const T, retval: ?*UpdateOperation) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_Operation(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_ResultCode(self: *const T, retval: ?*OperationResultCode) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_ResultCode(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_HResult(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_HResult(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_Date(self: *const T, retval: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_Date(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_UpdateIdentity(self: *const T, retval: ?*?*IUpdateIdentity) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_UpdateIdentity(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_Title(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_Title(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_Description(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_Description(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_UnmappedResultCode(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_UnmappedResultCode(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_ClientApplicationID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_ClientApplicationID(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_ServerSelection(self: *const T, retval: ?*ServerSelection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_ServerSelection(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_ServiceID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_ServiceID(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_UninstallationSteps(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_UninstallationSteps(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_UninstallationNotes(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_UninstallationNotes(@ptrCast(*const IUpdateHistoryEntry, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry_get_SupportUrl(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry.VTable, self.vtable).get_SupportUrl(@ptrCast(*const IUpdateHistoryEntry, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateHistoryEntry2_Value = @import("../zig.zig").Guid.initString("c2bfb780-4539-4132-ab8c-0a8772013ab6"); pub const IID_IUpdateHistoryEntry2 = &IID_IUpdateHistoryEntry2_Value; pub const IUpdateHistoryEntry2 = extern struct { pub const VTable = extern struct { base: IUpdateHistoryEntry.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Categories: fn( self: *const IUpdateHistoryEntry2, retval: ?*?*ICategoryCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateHistoryEntry.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntry2_get_Categories(self: *const T, retval: ?*?*ICategoryCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntry2.VTable, self.vtable).get_Categories(@ptrCast(*const IUpdateHistoryEntry2, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateHistoryEntryCollection_Value = @import("../zig.zig").Guid.initString("a7f04f3c-a290-435b-aadf-a116c3357a5c"); pub const IID_IUpdateHistoryEntryCollection = &IID_IUpdateHistoryEntryCollection_Value; pub const IUpdateHistoryEntryCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const IUpdateHistoryEntryCollection, index: i32, retval: ?*?*IUpdateHistoryEntry, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const IUpdateHistoryEntryCollection, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IUpdateHistoryEntryCollection, retval: ?*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 IUpdateHistoryEntryCollection_get_Item(self: *const T, index: i32, retval: ?*?*IUpdateHistoryEntry) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntryCollection.VTable, self.vtable).get_Item(@ptrCast(*const IUpdateHistoryEntryCollection, self), index, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntryCollection_get__NewEnum(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntryCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IUpdateHistoryEntryCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateHistoryEntryCollection_get_Count(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateHistoryEntryCollection.VTable, self.vtable).get_Count(@ptrCast(*const IUpdateHistoryEntryCollection, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateSearcher_Value = @import("../zig.zig").Guid.initString("8f45abf1-f9ae-4b95-a933-f0f66e5056ea"); pub const IID_IUpdateSearcher = &IID_IUpdateSearcher_Value; pub const IUpdateSearcher = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CanAutomaticallyUpgradeService: fn( self: *const IUpdateSearcher, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CanAutomaticallyUpgradeService: fn( self: *const IUpdateSearcher, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClientApplicationID: fn( self: *const IUpdateSearcher, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ClientApplicationID: fn( self: *const IUpdateSearcher, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IncludePotentiallySupersededUpdates: fn( self: *const IUpdateSearcher, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_IncludePotentiallySupersededUpdates: fn( self: *const IUpdateSearcher, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServerSelection: fn( self: *const IUpdateSearcher, retval: ?*ServerSelection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ServerSelection: fn( self: *const IUpdateSearcher, value: ServerSelection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, BeginSearch: fn( self: *const IUpdateSearcher, criteria: ?BSTR, onCompleted: ?*IUnknown, state: VARIANT, retval: ?*?*ISearchJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EndSearch: fn( self: *const IUpdateSearcher, searchJob: ?*ISearchJob, retval: ?*?*ISearchResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EscapeString: fn( self: *const IUpdateSearcher, unescaped: ?BSTR, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, QueryHistory: fn( self: *const IUpdateSearcher, startIndex: i32, count: i32, retval: ?*?*IUpdateHistoryEntryCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Search: fn( self: *const IUpdateSearcher, criteria: ?BSTR, retval: ?*?*ISearchResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Online: fn( self: *const IUpdateSearcher, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Online: fn( self: *const IUpdateSearcher, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetTotalHistoryCount: fn( self: *const IUpdateSearcher, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceID: fn( self: *const IUpdateSearcher, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ServiceID: fn( self: *const IUpdateSearcher, value: ?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 IUpdateSearcher_get_CanAutomaticallyUpgradeService(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).get_CanAutomaticallyUpgradeService(@ptrCast(*const IUpdateSearcher, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_put_CanAutomaticallyUpgradeService(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).put_CanAutomaticallyUpgradeService(@ptrCast(*const IUpdateSearcher, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_get_ClientApplicationID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).get_ClientApplicationID(@ptrCast(*const IUpdateSearcher, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_put_ClientApplicationID(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).put_ClientApplicationID(@ptrCast(*const IUpdateSearcher, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_get_IncludePotentiallySupersededUpdates(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).get_IncludePotentiallySupersededUpdates(@ptrCast(*const IUpdateSearcher, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_put_IncludePotentiallySupersededUpdates(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).put_IncludePotentiallySupersededUpdates(@ptrCast(*const IUpdateSearcher, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_get_ServerSelection(self: *const T, retval: ?*ServerSelection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).get_ServerSelection(@ptrCast(*const IUpdateSearcher, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_put_ServerSelection(self: *const T, value: ServerSelection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).put_ServerSelection(@ptrCast(*const IUpdateSearcher, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_BeginSearch(self: *const T, criteria: ?BSTR, onCompleted: ?*IUnknown, state: VARIANT, retval: ?*?*ISearchJob) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).BeginSearch(@ptrCast(*const IUpdateSearcher, self), criteria, onCompleted, state, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_EndSearch(self: *const T, searchJob: ?*ISearchJob, retval: ?*?*ISearchResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).EndSearch(@ptrCast(*const IUpdateSearcher, self), searchJob, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_EscapeString(self: *const T, unescaped: ?BSTR, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).EscapeString(@ptrCast(*const IUpdateSearcher, self), unescaped, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_QueryHistory(self: *const T, startIndex: i32, count: i32, retval: ?*?*IUpdateHistoryEntryCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).QueryHistory(@ptrCast(*const IUpdateSearcher, self), startIndex, count, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_Search(self: *const T, criteria: ?BSTR, retval: ?*?*ISearchResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).Search(@ptrCast(*const IUpdateSearcher, self), criteria, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_get_Online(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).get_Online(@ptrCast(*const IUpdateSearcher, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_put_Online(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).put_Online(@ptrCast(*const IUpdateSearcher, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_GetTotalHistoryCount(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).GetTotalHistoryCount(@ptrCast(*const IUpdateSearcher, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_get_ServiceID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).get_ServiceID(@ptrCast(*const IUpdateSearcher, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher_put_ServiceID(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher.VTable, self.vtable).put_ServiceID(@ptrCast(*const IUpdateSearcher, self), value); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateSearcher2_Value = @import("../zig.zig").Guid.initString("4cbdcb2d-1589-4beb-bd1c-3e582ff0add0"); pub const IID_IUpdateSearcher2 = &IID_IUpdateSearcher2_Value; pub const IUpdateSearcher2 = extern struct { pub const VTable = extern struct { base: IUpdateSearcher.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IgnoreDownloadPriority: fn( self: *const IUpdateSearcher2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_IgnoreDownloadPriority: fn( self: *const IUpdateSearcher2, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateSearcher.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher2_get_IgnoreDownloadPriority(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher2.VTable, self.vtable).get_IgnoreDownloadPriority(@ptrCast(*const IUpdateSearcher2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher2_put_IgnoreDownloadPriority(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher2.VTable, self.vtable).put_IgnoreDownloadPriority(@ptrCast(*const IUpdateSearcher2, self), value); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateSearcher3_Value = @import("../zig.zig").Guid.initString("04c6895d-eaf2-4034-97f3-311de9be413a"); pub const IID_IUpdateSearcher3 = &IID_IUpdateSearcher3_Value; pub const IUpdateSearcher3 = extern struct { pub const VTable = extern struct { base: IUpdateSearcher2.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SearchScope: fn( self: *const IUpdateSearcher3, retval: ?*SearchScope, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SearchScope: fn( self: *const IUpdateSearcher3, value: SearchScope, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateSearcher2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher3_get_SearchScope(self: *const T, retval: ?*SearchScope) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher3.VTable, self.vtable).get_SearchScope(@ptrCast(*const IUpdateSearcher3, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSearcher3_put_SearchScope(self: *const T, value: SearchScope) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSearcher3.VTable, self.vtable).put_SearchScope(@ptrCast(*const IUpdateSearcher3, self), value); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateDownloadResult_Value = @import("../zig.zig").Guid.initString("bf99af76-b575-42ad-8aa4-33cbb5477af1"); pub const IID_IUpdateDownloadResult = &IID_IUpdateDownloadResult_Value; pub const IUpdateDownloadResult = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HResult: fn( self: *const IUpdateDownloadResult, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResultCode: fn( self: *const IUpdateDownloadResult, retval: ?*OperationResultCode, ) 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 IUpdateDownloadResult_get_HResult(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloadResult.VTable, self.vtable).get_HResult(@ptrCast(*const IUpdateDownloadResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloadResult_get_ResultCode(self: *const T, retval: ?*OperationResultCode) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloadResult.VTable, self.vtable).get_ResultCode(@ptrCast(*const IUpdateDownloadResult, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDownloadResult_Value = @import("../zig.zig").Guid.initString("daa4fdd0-4727-4dbe-a1e7-745dca317144"); pub const IID_IDownloadResult = &IID_IDownloadResult_Value; pub const IDownloadResult = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HResult: fn( self: *const IDownloadResult, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResultCode: fn( self: *const IDownloadResult, retval: ?*OperationResultCode, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetUpdateResult: fn( self: *const IDownloadResult, updateIndex: i32, retval: ?*?*IUpdateDownloadResult, ) 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 IDownloadResult_get_HResult(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadResult.VTable, self.vtable).get_HResult(@ptrCast(*const IDownloadResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadResult_get_ResultCode(self: *const T, retval: ?*OperationResultCode) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadResult.VTable, self.vtable).get_ResultCode(@ptrCast(*const IDownloadResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadResult_GetUpdateResult(self: *const T, updateIndex: i32, retval: ?*?*IUpdateDownloadResult) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadResult.VTable, self.vtable).GetUpdateResult(@ptrCast(*const IDownloadResult, self), updateIndex, retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDownloadProgress_Value = @import("../zig.zig").Guid.initString("d31a5bac-f719-4178-9dbb-5e2cb47fd18a"); pub const IID_IDownloadProgress = &IID_IDownloadProgress_Value; pub const IDownloadProgress = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentUpdateBytesDownloaded: fn( self: *const IDownloadProgress, retval: ?*DECIMAL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentUpdateBytesToDownload: fn( self: *const IDownloadProgress, retval: ?*DECIMAL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentUpdateIndex: fn( self: *const IDownloadProgress, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PercentComplete: fn( self: *const IDownloadProgress, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalBytesDownloaded: fn( self: *const IDownloadProgress, retval: ?*DECIMAL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalBytesToDownload: fn( self: *const IDownloadProgress, retval: ?*DECIMAL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetUpdateResult: fn( self: *const IDownloadProgress, updateIndex: i32, retval: ?*?*IUpdateDownloadResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentUpdateDownloadPhase: fn( self: *const IDownloadProgress, retval: ?*DownloadPhase, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentUpdatePercentComplete: fn( self: *const IDownloadProgress, retval: ?*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 IDownloadProgress_get_CurrentUpdateBytesDownloaded(self: *const T, retval: ?*DECIMAL) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).get_CurrentUpdateBytesDownloaded(@ptrCast(*const IDownloadProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgress_get_CurrentUpdateBytesToDownload(self: *const T, retval: ?*DECIMAL) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).get_CurrentUpdateBytesToDownload(@ptrCast(*const IDownloadProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgress_get_CurrentUpdateIndex(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).get_CurrentUpdateIndex(@ptrCast(*const IDownloadProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgress_get_PercentComplete(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).get_PercentComplete(@ptrCast(*const IDownloadProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgress_get_TotalBytesDownloaded(self: *const T, retval: ?*DECIMAL) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).get_TotalBytesDownloaded(@ptrCast(*const IDownloadProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgress_get_TotalBytesToDownload(self: *const T, retval: ?*DECIMAL) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).get_TotalBytesToDownload(@ptrCast(*const IDownloadProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgress_GetUpdateResult(self: *const T, updateIndex: i32, retval: ?*?*IUpdateDownloadResult) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).GetUpdateResult(@ptrCast(*const IDownloadProgress, self), updateIndex, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgress_get_CurrentUpdateDownloadPhase(self: *const T, retval: ?*DownloadPhase) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).get_CurrentUpdateDownloadPhase(@ptrCast(*const IDownloadProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgress_get_CurrentUpdatePercentComplete(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgress.VTable, self.vtable).get_CurrentUpdatePercentComplete(@ptrCast(*const IDownloadProgress, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDownloadJob_Value = @import("../zig.zig").Guid.initString("c574de85-7358-43f6-aae8-8697e62d8ba7"); pub const IID_IDownloadJob = &IID_IDownloadJob_Value; pub const IDownloadJob = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AsyncState: fn( self: *const IDownloadJob, retval: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsCompleted: fn( self: *const IDownloadJob, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Updates: fn( self: *const IDownloadJob, retval: ?*?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CleanUp: fn( self: *const IDownloadJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetProgress: fn( self: *const IDownloadJob, retval: ?*?*IDownloadProgress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RequestAbort: fn( self: *const IDownloadJob, ) 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 IDownloadJob_get_AsyncState(self: *const T, retval: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadJob.VTable, self.vtable).get_AsyncState(@ptrCast(*const IDownloadJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadJob_get_IsCompleted(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadJob.VTable, self.vtable).get_IsCompleted(@ptrCast(*const IDownloadJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadJob_get_Updates(self: *const T, retval: ?*?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadJob.VTable, self.vtable).get_Updates(@ptrCast(*const IDownloadJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadJob_CleanUp(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadJob.VTable, self.vtable).CleanUp(@ptrCast(*const IDownloadJob, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadJob_GetProgress(self: *const T, retval: ?*?*IDownloadProgress) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadJob.VTable, self.vtable).GetProgress(@ptrCast(*const IDownloadJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadJob_RequestAbort(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadJob.VTable, self.vtable).RequestAbort(@ptrCast(*const IDownloadJob, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDownloadCompletedCallbackArgs_Value = @import("../zig.zig").Guid.initString("fa565b23-498c-47a0-979d-e7d5b1813360"); pub const IID_IDownloadCompletedCallbackArgs = &IID_IDownloadCompletedCallbackArgs_Value; pub const IDownloadCompletedCallbackArgs = 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()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDownloadCompletedCallback_Value = @import("../zig.zig").Guid.initString("77254866-9f5b-4c8e-b9e2-c77a8530d64b"); pub const IID_IDownloadCompletedCallback = &IID_IDownloadCompletedCallback_Value; pub const IDownloadCompletedCallback = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Invoke: fn( self: *const IDownloadCompletedCallback, downloadJob: ?*IDownloadJob, callbackArgs: ?*IDownloadCompletedCallbackArgs, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadCompletedCallback_Invoke(self: *const T, downloadJob: ?*IDownloadJob, callbackArgs: ?*IDownloadCompletedCallbackArgs) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadCompletedCallback.VTable, self.vtable).Invoke(@ptrCast(*const IDownloadCompletedCallback, self), downloadJob, callbackArgs); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDownloadProgressChangedCallbackArgs_Value = @import("../zig.zig").Guid.initString("324ff2c6-4981-4b04-9412-57481745ab24"); pub const IID_IDownloadProgressChangedCallbackArgs = &IID_IDownloadProgressChangedCallbackArgs_Value; pub const IDownloadProgressChangedCallbackArgs = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Progress: fn( self: *const IDownloadProgressChangedCallbackArgs, retval: ?*?*IDownloadProgress, ) 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 IDownloadProgressChangedCallbackArgs_get_Progress(self: *const T, retval: ?*?*IDownloadProgress) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgressChangedCallbackArgs.VTable, self.vtable).get_Progress(@ptrCast(*const IDownloadProgressChangedCallbackArgs, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDownloadProgressChangedCallback_Value = @import("../zig.zig").Guid.initString("8c3f1cdd-6173-4591-aebd-a56a53ca77c1"); pub const IID_IDownloadProgressChangedCallback = &IID_IDownloadProgressChangedCallback_Value; pub const IDownloadProgressChangedCallback = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Invoke: fn( self: *const IDownloadProgressChangedCallback, downloadJob: ?*IDownloadJob, callbackArgs: ?*IDownloadProgressChangedCallbackArgs, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDownloadProgressChangedCallback_Invoke(self: *const T, downloadJob: ?*IDownloadJob, callbackArgs: ?*IDownloadProgressChangedCallbackArgs) callconv(.Inline) HRESULT { return @ptrCast(*const IDownloadProgressChangedCallback.VTable, self.vtable).Invoke(@ptrCast(*const IDownloadProgressChangedCallback, self), downloadJob, callbackArgs); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateDownloader_Value = @import("../zig.zig").Guid.initString("68f1c6f9-7ecc-4666-a464-247fe12496c3"); pub const IID_IUpdateDownloader = &IID_IUpdateDownloader_Value; pub const IUpdateDownloader = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClientApplicationID: fn( self: *const IUpdateDownloader, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ClientApplicationID: fn( self: *const IUpdateDownloader, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsForced: fn( self: *const IUpdateDownloader, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_IsForced: fn( self: *const IUpdateDownloader, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Priority: fn( self: *const IUpdateDownloader, retval: ?*DownloadPriority, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Priority: fn( self: *const IUpdateDownloader, value: DownloadPriority, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Updates: fn( self: *const IUpdateDownloader, retval: ?*?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Updates: fn( self: *const IUpdateDownloader, value: ?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, BeginDownload: fn( self: *const IUpdateDownloader, onProgressChanged: ?*IUnknown, onCompleted: ?*IUnknown, state: VARIANT, retval: ?*?*IDownloadJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Download: fn( self: *const IUpdateDownloader, retval: ?*?*IDownloadResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EndDownload: fn( self: *const IUpdateDownloader, value: ?*IDownloadJob, retval: ?*?*IDownloadResult, ) 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 IUpdateDownloader_get_ClientApplicationID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).get_ClientApplicationID(@ptrCast(*const IUpdateDownloader, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_put_ClientApplicationID(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).put_ClientApplicationID(@ptrCast(*const IUpdateDownloader, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_get_IsForced(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).get_IsForced(@ptrCast(*const IUpdateDownloader, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_put_IsForced(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).put_IsForced(@ptrCast(*const IUpdateDownloader, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_get_Priority(self: *const T, retval: ?*DownloadPriority) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).get_Priority(@ptrCast(*const IUpdateDownloader, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_put_Priority(self: *const T, value: DownloadPriority) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).put_Priority(@ptrCast(*const IUpdateDownloader, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_get_Updates(self: *const T, retval: ?*?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).get_Updates(@ptrCast(*const IUpdateDownloader, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_put_Updates(self: *const T, value: ?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).put_Updates(@ptrCast(*const IUpdateDownloader, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_BeginDownload(self: *const T, onProgressChanged: ?*IUnknown, onCompleted: ?*IUnknown, state: VARIANT, retval: ?*?*IDownloadJob) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).BeginDownload(@ptrCast(*const IUpdateDownloader, self), onProgressChanged, onCompleted, state, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_Download(self: *const T, retval: ?*?*IDownloadResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).Download(@ptrCast(*const IUpdateDownloader, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateDownloader_EndDownload(self: *const T, value: ?*IDownloadJob, retval: ?*?*IDownloadResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateDownloader.VTable, self.vtable).EndDownload(@ptrCast(*const IUpdateDownloader, self), value, retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateInstallationResult_Value = @import("../zig.zig").Guid.initString("d940f0f8-3cbb-4fd0-993f-471e7f2328ad"); pub const IID_IUpdateInstallationResult = &IID_IUpdateInstallationResult_Value; pub const IUpdateInstallationResult = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HResult: fn( self: *const IUpdateInstallationResult, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RebootRequired: fn( self: *const IUpdateInstallationResult, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResultCode: fn( self: *const IUpdateInstallationResult, retval: ?*OperationResultCode, ) 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 IUpdateInstallationResult_get_HResult(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstallationResult.VTable, self.vtable).get_HResult(@ptrCast(*const IUpdateInstallationResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstallationResult_get_RebootRequired(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstallationResult.VTable, self.vtable).get_RebootRequired(@ptrCast(*const IUpdateInstallationResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstallationResult_get_ResultCode(self: *const T, retval: ?*OperationResultCode) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstallationResult.VTable, self.vtable).get_ResultCode(@ptrCast(*const IUpdateInstallationResult, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationResult_Value = @import("../zig.zig").Guid.initString("a43c56d6-7451-48d4-af96-b6cd2d0d9b7a"); pub const IID_IInstallationResult = &IID_IInstallationResult_Value; pub const IInstallationResult = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HResult: fn( self: *const IInstallationResult, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RebootRequired: fn( self: *const IInstallationResult, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResultCode: fn( self: *const IInstallationResult, retval: ?*OperationResultCode, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetUpdateResult: fn( self: *const IInstallationResult, updateIndex: i32, retval: ?*?*IUpdateInstallationResult, ) 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 IInstallationResult_get_HResult(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationResult.VTable, self.vtable).get_HResult(@ptrCast(*const IInstallationResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationResult_get_RebootRequired(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationResult.VTable, self.vtable).get_RebootRequired(@ptrCast(*const IInstallationResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationResult_get_ResultCode(self: *const T, retval: ?*OperationResultCode) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationResult.VTable, self.vtable).get_ResultCode(@ptrCast(*const IInstallationResult, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationResult_GetUpdateResult(self: *const T, updateIndex: i32, retval: ?*?*IUpdateInstallationResult) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationResult.VTable, self.vtable).GetUpdateResult(@ptrCast(*const IInstallationResult, self), updateIndex, retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationProgress_Value = @import("../zig.zig").Guid.initString("345c8244-43a3-4e32-a368-65f073b76f36"); pub const IID_IInstallationProgress = &IID_IInstallationProgress_Value; pub const IInstallationProgress = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentUpdateIndex: fn( self: *const IInstallationProgress, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentUpdatePercentComplete: fn( self: *const IInstallationProgress, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PercentComplete: fn( self: *const IInstallationProgress, retval: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetUpdateResult: fn( self: *const IInstallationProgress, updateIndex: i32, retval: ?*?*IUpdateInstallationResult, ) 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 IInstallationProgress_get_CurrentUpdateIndex(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationProgress.VTable, self.vtable).get_CurrentUpdateIndex(@ptrCast(*const IInstallationProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationProgress_get_CurrentUpdatePercentComplete(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationProgress.VTable, self.vtable).get_CurrentUpdatePercentComplete(@ptrCast(*const IInstallationProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationProgress_get_PercentComplete(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationProgress.VTable, self.vtable).get_PercentComplete(@ptrCast(*const IInstallationProgress, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationProgress_GetUpdateResult(self: *const T, updateIndex: i32, retval: ?*?*IUpdateInstallationResult) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationProgress.VTable, self.vtable).GetUpdateResult(@ptrCast(*const IInstallationProgress, self), updateIndex, retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationJob_Value = @import("../zig.zig").Guid.initString("5c209f0b-bad5-432a-9556-4699bed2638a"); pub const IID_IInstallationJob = &IID_IInstallationJob_Value; pub const IInstallationJob = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AsyncState: fn( self: *const IInstallationJob, retval: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsCompleted: fn( self: *const IInstallationJob, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Updates: fn( self: *const IInstallationJob, retval: ?*?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CleanUp: fn( self: *const IInstallationJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetProgress: fn( self: *const IInstallationJob, retval: ?*?*IInstallationProgress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RequestAbort: fn( self: *const IInstallationJob, ) 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 IInstallationJob_get_AsyncState(self: *const T, retval: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationJob.VTable, self.vtable).get_AsyncState(@ptrCast(*const IInstallationJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationJob_get_IsCompleted(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationJob.VTable, self.vtable).get_IsCompleted(@ptrCast(*const IInstallationJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationJob_get_Updates(self: *const T, retval: ?*?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationJob.VTable, self.vtable).get_Updates(@ptrCast(*const IInstallationJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationJob_CleanUp(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationJob.VTable, self.vtable).CleanUp(@ptrCast(*const IInstallationJob, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationJob_GetProgress(self: *const T, retval: ?*?*IInstallationProgress) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationJob.VTable, self.vtable).GetProgress(@ptrCast(*const IInstallationJob, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationJob_RequestAbort(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationJob.VTable, self.vtable).RequestAbort(@ptrCast(*const IInstallationJob, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationCompletedCallbackArgs_Value = @import("../zig.zig").Guid.initString("250e2106-8efb-4705-9653-ef13c581b6a1"); pub const IID_IInstallationCompletedCallbackArgs = &IID_IInstallationCompletedCallbackArgs_Value; pub const IInstallationCompletedCallbackArgs = 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()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationCompletedCallback_Value = @import("../zig.zig").Guid.initString("45f4f6f3-d602-4f98-9a8a-3efa152ad2d3"); pub const IID_IInstallationCompletedCallback = &IID_IInstallationCompletedCallback_Value; pub const IInstallationCompletedCallback = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Invoke: fn( self: *const IInstallationCompletedCallback, installationJob: ?*IInstallationJob, callbackArgs: ?*IInstallationCompletedCallbackArgs, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationCompletedCallback_Invoke(self: *const T, installationJob: ?*IInstallationJob, callbackArgs: ?*IInstallationCompletedCallbackArgs) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationCompletedCallback.VTable, self.vtable).Invoke(@ptrCast(*const IInstallationCompletedCallback, self), installationJob, callbackArgs); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationProgressChangedCallbackArgs_Value = @import("../zig.zig").Guid.initString("e4f14e1e-689d-4218-a0b9-bc189c484a01"); pub const IID_IInstallationProgressChangedCallbackArgs = &IID_IInstallationProgressChangedCallbackArgs_Value; pub const IInstallationProgressChangedCallbackArgs = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Progress: fn( self: *const IInstallationProgressChangedCallbackArgs, retval: ?*?*IInstallationProgress, ) 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 IInstallationProgressChangedCallbackArgs_get_Progress(self: *const T, retval: ?*?*IInstallationProgress) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationProgressChangedCallbackArgs.VTable, self.vtable).get_Progress(@ptrCast(*const IInstallationProgressChangedCallbackArgs, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationProgressChangedCallback_Value = @import("../zig.zig").Guid.initString("e01402d5-f8da-43ba-a012-38894bd048f1"); pub const IID_IInstallationProgressChangedCallback = &IID_IInstallationProgressChangedCallback_Value; pub const IInstallationProgressChangedCallback = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Invoke: fn( self: *const IInstallationProgressChangedCallback, installationJob: ?*IInstallationJob, callbackArgs: ?*IInstallationProgressChangedCallbackArgs, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInstallationProgressChangedCallback_Invoke(self: *const T, installationJob: ?*IInstallationJob, callbackArgs: ?*IInstallationProgressChangedCallbackArgs) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationProgressChangedCallback.VTable, self.vtable).Invoke(@ptrCast(*const IInstallationProgressChangedCallback, self), installationJob, callbackArgs); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateInstaller_Value = @import("../zig.zig").Guid.initString("7b929c68-ccdc-4226-96b1-8724600b54c2"); pub const IID_IUpdateInstaller = &IID_IUpdateInstaller_Value; pub const IUpdateInstaller = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClientApplicationID: fn( self: *const IUpdateInstaller, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ClientApplicationID: fn( self: *const IUpdateInstaller, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsForced: fn( self: *const IUpdateInstaller, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_IsForced: fn( self: *const IUpdateInstaller, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ParentHwnd: fn( self: *const IUpdateInstaller, retval: ?*?HWND, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ParentHwnd: fn( self: *const IUpdateInstaller, value: ?HWND, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ParentWindow: fn( self: *const IUpdateInstaller, value: ?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ParentWindow: fn( self: *const IUpdateInstaller, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Updates: fn( self: *const IUpdateInstaller, retval: ?*?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Updates: fn( self: *const IUpdateInstaller, value: ?*IUpdateCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, BeginInstall: fn( self: *const IUpdateInstaller, onProgressChanged: ?*IUnknown, onCompleted: ?*IUnknown, state: VARIANT, retval: ?*?*IInstallationJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, BeginUninstall: fn( self: *const IUpdateInstaller, onProgressChanged: ?*IUnknown, onCompleted: ?*IUnknown, state: VARIANT, retval: ?*?*IInstallationJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EndInstall: fn( self: *const IUpdateInstaller, value: ?*IInstallationJob, retval: ?*?*IInstallationResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EndUninstall: fn( self: *const IUpdateInstaller, value: ?*IInstallationJob, retval: ?*?*IInstallationResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Install: fn( self: *const IUpdateInstaller, retval: ?*?*IInstallationResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RunWizard: fn( self: *const IUpdateInstaller, dialogTitle: ?BSTR, retval: ?*?*IInstallationResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsBusy: fn( self: *const IUpdateInstaller, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Uninstall: fn( self: *const IUpdateInstaller, retval: ?*?*IInstallationResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AllowSourcePrompts: fn( self: *const IUpdateInstaller, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AllowSourcePrompts: fn( self: *const IUpdateInstaller, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RebootRequiredBeforeInstallation: fn( self: *const IUpdateInstaller, retval: ?*i16, ) 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 IUpdateInstaller_get_ClientApplicationID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).get_ClientApplicationID(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_put_ClientApplicationID(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).put_ClientApplicationID(@ptrCast(*const IUpdateInstaller, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_get_IsForced(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).get_IsForced(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_put_IsForced(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).put_IsForced(@ptrCast(*const IUpdateInstaller, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_get_ParentHwnd(self: *const T, retval: ?*?HWND) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).get_ParentHwnd(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_put_ParentHwnd(self: *const T, value: ?HWND) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).put_ParentHwnd(@ptrCast(*const IUpdateInstaller, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_put_ParentWindow(self: *const T, value: ?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).put_ParentWindow(@ptrCast(*const IUpdateInstaller, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_get_ParentWindow(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).get_ParentWindow(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_get_Updates(self: *const T, retval: ?*?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).get_Updates(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_put_Updates(self: *const T, value: ?*IUpdateCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).put_Updates(@ptrCast(*const IUpdateInstaller, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_BeginInstall(self: *const T, onProgressChanged: ?*IUnknown, onCompleted: ?*IUnknown, state: VARIANT, retval: ?*?*IInstallationJob) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).BeginInstall(@ptrCast(*const IUpdateInstaller, self), onProgressChanged, onCompleted, state, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_BeginUninstall(self: *const T, onProgressChanged: ?*IUnknown, onCompleted: ?*IUnknown, state: VARIANT, retval: ?*?*IInstallationJob) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).BeginUninstall(@ptrCast(*const IUpdateInstaller, self), onProgressChanged, onCompleted, state, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_EndInstall(self: *const T, value: ?*IInstallationJob, retval: ?*?*IInstallationResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).EndInstall(@ptrCast(*const IUpdateInstaller, self), value, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_EndUninstall(self: *const T, value: ?*IInstallationJob, retval: ?*?*IInstallationResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).EndUninstall(@ptrCast(*const IUpdateInstaller, self), value, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_Install(self: *const T, retval: ?*?*IInstallationResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).Install(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_RunWizard(self: *const T, dialogTitle: ?BSTR, retval: ?*?*IInstallationResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).RunWizard(@ptrCast(*const IUpdateInstaller, self), dialogTitle, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_get_IsBusy(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).get_IsBusy(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_Uninstall(self: *const T, retval: ?*?*IInstallationResult) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).Uninstall(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_get_AllowSourcePrompts(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).get_AllowSourcePrompts(@ptrCast(*const IUpdateInstaller, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_put_AllowSourcePrompts(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).put_AllowSourcePrompts(@ptrCast(*const IUpdateInstaller, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller_get_RebootRequiredBeforeInstallation(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller.VTable, self.vtable).get_RebootRequiredBeforeInstallation(@ptrCast(*const IUpdateInstaller, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateInstaller2_Value = @import("../zig.zig").Guid.initString("3442d4fe-224d-4cee-98cf-30e0c4d229e6"); pub const IID_IUpdateInstaller2 = &IID_IUpdateInstaller2_Value; pub const IUpdateInstaller2 = extern struct { pub const VTable = extern struct { base: IUpdateInstaller.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ForceQuiet: fn( self: *const IUpdateInstaller2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ForceQuiet: fn( self: *const IUpdateInstaller2, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateInstaller.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller2_get_ForceQuiet(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller2.VTable, self.vtable).get_ForceQuiet(@ptrCast(*const IUpdateInstaller2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller2_put_ForceQuiet(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller2.VTable, self.vtable).put_ForceQuiet(@ptrCast(*const IUpdateInstaller2, self), value); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows10.0.17134' const IID_IUpdateInstaller3_Value = @import("../zig.zig").Guid.initString("16d11c35-099a-48d0-8338-5fae64047f8e"); pub const IID_IUpdateInstaller3 = &IID_IUpdateInstaller3_Value; pub const IUpdateInstaller3 = extern struct { pub const VTable = extern struct { base: IUpdateInstaller2.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AttemptCloseAppsIfNecessary: fn( self: *const IUpdateInstaller3, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AttemptCloseAppsIfNecessary: fn( self: *const IUpdateInstaller3, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateInstaller2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller3_get_AttemptCloseAppsIfNecessary(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller3.VTable, self.vtable).get_AttemptCloseAppsIfNecessary(@ptrCast(*const IUpdateInstaller3, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller3_put_AttemptCloseAppsIfNecessary(self: *const T, value: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller3.VTable, self.vtable).put_AttemptCloseAppsIfNecessary(@ptrCast(*const IUpdateInstaller3, self), value); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows10.0.10240' const IID_IUpdateInstaller4_Value = @import("../zig.zig").Guid.initString("ef8208ea-2304-492d-9109-23813b0958e1"); pub const IID_IUpdateInstaller4 = &IID_IUpdateInstaller4_Value; pub const IUpdateInstaller4 = extern struct { pub const VTable = extern struct { base: IUpdateInstaller3.VTable, Commit: fn( self: *const IUpdateInstaller4, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateInstaller3.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateInstaller4_Commit(self: *const T, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateInstaller4.VTable, self.vtable).Commit(@ptrCast(*const IUpdateInstaller4, self), dwFlags); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateSession_Value = @import("../zig.zig").Guid.initString("816858a4-260d-4260-933a-2585f1abc76b"); pub const IID_IUpdateSession = &IID_IUpdateSession_Value; pub const IUpdateSession = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClientApplicationID: fn( self: *const IUpdateSession, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ClientApplicationID: fn( self: *const IUpdateSession, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReadOnly: fn( self: *const IUpdateSession, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_WebProxy: fn( self: *const IUpdateSession, retval: ?*?*IWebProxy, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_WebProxy: fn( self: *const IUpdateSession, value: ?*IWebProxy, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateUpdateSearcher: fn( self: *const IUpdateSession, retval: ?*?*IUpdateSearcher, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateUpdateDownloader: fn( self: *const IUpdateSession, retval: ?*?*IUpdateDownloader, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateUpdateInstaller: fn( self: *const IUpdateSession, retval: ?*?*IUpdateInstaller, ) 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 IUpdateSession_get_ClientApplicationID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession.VTable, self.vtable).get_ClientApplicationID(@ptrCast(*const IUpdateSession, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession_put_ClientApplicationID(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession.VTable, self.vtable).put_ClientApplicationID(@ptrCast(*const IUpdateSession, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession_get_ReadOnly(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession.VTable, self.vtable).get_ReadOnly(@ptrCast(*const IUpdateSession, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession_get_WebProxy(self: *const T, retval: ?*?*IWebProxy) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession.VTable, self.vtable).get_WebProxy(@ptrCast(*const IUpdateSession, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession_put_WebProxy(self: *const T, value: ?*IWebProxy) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession.VTable, self.vtable).put_WebProxy(@ptrCast(*const IUpdateSession, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession_CreateUpdateSearcher(self: *const T, retval: ?*?*IUpdateSearcher) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession.VTable, self.vtable).CreateUpdateSearcher(@ptrCast(*const IUpdateSession, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession_CreateUpdateDownloader(self: *const T, retval: ?*?*IUpdateDownloader) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession.VTable, self.vtable).CreateUpdateDownloader(@ptrCast(*const IUpdateSession, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession_CreateUpdateInstaller(self: *const T, retval: ?*?*IUpdateInstaller) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession.VTable, self.vtable).CreateUpdateInstaller(@ptrCast(*const IUpdateSession, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateSession2_Value = @import("../zig.zig").Guid.initString("91caf7b0-eb23-49ed-9937-c52d817f46f7"); pub const IID_IUpdateSession2 = &IID_IUpdateSession2_Value; pub const IUpdateSession2 = extern struct { pub const VTable = extern struct { base: IUpdateSession.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UserLocale: fn( self: *const IUpdateSession2, retval: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_UserLocale: fn( self: *const IUpdateSession2, lcid: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateSession.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession2_get_UserLocale(self: *const T, retval: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession2.VTable, self.vtable).get_UserLocale(@ptrCast(*const IUpdateSession2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession2_put_UserLocale(self: *const T, lcid: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession2.VTable, self.vtable).put_UserLocale(@ptrCast(*const IUpdateSession2, self), lcid); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateSession3_Value = @import("../zig.zig").Guid.initString("918efd1e-b5d8-4c90-8540-aeb9bdc56f9d"); pub const IID_IUpdateSession3 = &IID_IUpdateSession3_Value; pub const IUpdateSession3 = extern struct { pub const VTable = extern struct { base: IUpdateSession2.VTable, CreateUpdateServiceManager: fn( self: *const IUpdateSession3, retval: ?*?*IUpdateServiceManager2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, QueryHistory: fn( self: *const IUpdateSession3, criteria: ?BSTR, startIndex: i32, count: i32, retval: ?*?*IUpdateHistoryEntryCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateSession2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession3_CreateUpdateServiceManager(self: *const T, retval: ?*?*IUpdateServiceManager2) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession3.VTable, self.vtable).CreateUpdateServiceManager(@ptrCast(*const IUpdateSession3, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateSession3_QueryHistory(self: *const T, criteria: ?BSTR, startIndex: i32, count: i32, retval: ?*?*IUpdateHistoryEntryCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateSession3.VTable, self.vtable).QueryHistory(@ptrCast(*const IUpdateSession3, self), criteria, startIndex, count, retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateService_Value = @import("../zig.zig").Guid.initString("76b3b17e-aed6-4da5-85f0-83587f81abe3"); pub const IID_IUpdateService = &IID_IUpdateService_Value; pub const IUpdateService = 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 IUpdateService, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ContentValidationCert: fn( self: *const IUpdateService, retval: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ExpirationDate: fn( self: *const IUpdateService, retval: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsManaged: fn( self: *const IUpdateService, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsRegisteredWithAU: fn( self: *const IUpdateService, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IssueDate: fn( self: *const IUpdateService, retval: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_OffersWindowsUpdates: fn( self: *const IUpdateService, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RedirectUrls: fn( self: *const IUpdateService, retval: ?*?*IStringCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceID: fn( self: *const IUpdateService, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsScanPackageService: fn( self: *const IUpdateService, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CanRegisterWithAU: fn( self: *const IUpdateService, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceUrl: fn( self: *const IUpdateService, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SetupPrefix: fn( self: *const IUpdateService, retval: ?*?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 IUpdateService_get_Name(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_Name(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_ContentValidationCert(self: *const T, retval: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_ContentValidationCert(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_ExpirationDate(self: *const T, retval: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_ExpirationDate(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_IsManaged(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_IsManaged(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_IsRegisteredWithAU(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_IsRegisteredWithAU(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_IssueDate(self: *const T, retval: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_IssueDate(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_OffersWindowsUpdates(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_OffersWindowsUpdates(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_RedirectUrls(self: *const T, retval: ?*?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_RedirectUrls(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_ServiceID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_ServiceID(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_IsScanPackageService(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_IsScanPackageService(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_CanRegisterWithAU(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_CanRegisterWithAU(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_ServiceUrl(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_ServiceUrl(@ptrCast(*const IUpdateService, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService_get_SetupPrefix(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService.VTable, self.vtable).get_SetupPrefix(@ptrCast(*const IUpdateService, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateService2_Value = @import("../zig.zig").Guid.initString("1518b460-6518-4172-940f-c75883b24ceb"); pub const IID_IUpdateService2 = &IID_IUpdateService2_Value; pub const IUpdateService2 = extern struct { pub const VTable = extern struct { base: IUpdateService.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsDefaultAUService: fn( self: *const IUpdateService2, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateService.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateService2_get_IsDefaultAUService(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateService2.VTable, self.vtable).get_IsDefaultAUService(@ptrCast(*const IUpdateService2, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateServiceCollection_Value = @import("../zig.zig").Guid.initString("9b0353aa-0e52-44ff-b8b0-1f7fa0437f88"); pub const IID_IUpdateServiceCollection = &IID_IUpdateServiceCollection_Value; pub const IUpdateServiceCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const IUpdateServiceCollection, index: i32, retval: ?*?*IUpdateService, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const IUpdateServiceCollection, retval: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IUpdateServiceCollection, retval: ?*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 IUpdateServiceCollection_get_Item(self: *const T, index: i32, retval: ?*?*IUpdateService) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceCollection.VTable, self.vtable).get_Item(@ptrCast(*const IUpdateServiceCollection, self), index, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceCollection_get__NewEnum(self: *const T, retval: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IUpdateServiceCollection, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceCollection_get_Count(self: *const T, retval: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceCollection.VTable, self.vtable).get_Count(@ptrCast(*const IUpdateServiceCollection, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateServiceRegistration_Value = @import("../zig.zig").Guid.initString("dde02280-12b3-4e0b-937b-6747f6acb286"); pub const IID_IUpdateServiceRegistration = &IID_IUpdateServiceRegistration_Value; pub const IUpdateServiceRegistration = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RegistrationState: fn( self: *const IUpdateServiceRegistration, retval: ?*UpdateServiceRegistrationState, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceID: fn( self: *const IUpdateServiceRegistration, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsPendingRegistrationWithAU: fn( self: *const IUpdateServiceRegistration, retval: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Service: fn( self: *const IUpdateServiceRegistration, retval: ?*?*IUpdateService2, ) 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 IUpdateServiceRegistration_get_RegistrationState(self: *const T, retval: ?*UpdateServiceRegistrationState) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceRegistration.VTable, self.vtable).get_RegistrationState(@ptrCast(*const IUpdateServiceRegistration, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceRegistration_get_ServiceID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceRegistration.VTable, self.vtable).get_ServiceID(@ptrCast(*const IUpdateServiceRegistration, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceRegistration_get_IsPendingRegistrationWithAU(self: *const T, retval: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceRegistration.VTable, self.vtable).get_IsPendingRegistrationWithAU(@ptrCast(*const IUpdateServiceRegistration, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceRegistration_get_Service(self: *const T, retval: ?*?*IUpdateService2) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceRegistration.VTable, self.vtable).get_Service(@ptrCast(*const IUpdateServiceRegistration, self), retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateServiceManager_Value = @import("../zig.zig").Guid.initString("23857e3c-02ba-44a3-9423-b1c900805f37"); pub const IID_IUpdateServiceManager = &IID_IUpdateServiceManager_Value; pub const IUpdateServiceManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Services: fn( self: *const IUpdateServiceManager, retval: ?*?*IUpdateServiceCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddService: fn( self: *const IUpdateServiceManager, serviceID: ?BSTR, authorizationCabPath: ?BSTR, retval: ?*?*IUpdateService, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RegisterServiceWithAU: fn( self: *const IUpdateServiceManager, serviceID: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveService: fn( self: *const IUpdateServiceManager, serviceID: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnregisterServiceWithAU: fn( self: *const IUpdateServiceManager, serviceID: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddScanPackageService: fn( self: *const IUpdateServiceManager, serviceName: ?BSTR, scanFileLocation: ?BSTR, flags: i32, ppService: ?*?*IUpdateService, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetOption: fn( self: *const IUpdateServiceManager, optionName: ?BSTR, optionValue: 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 IUpdateServiceManager_get_Services(self: *const T, retval: ?*?*IUpdateServiceCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager.VTable, self.vtable).get_Services(@ptrCast(*const IUpdateServiceManager, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager_AddService(self: *const T, serviceID: ?BSTR, authorizationCabPath: ?BSTR, retval: ?*?*IUpdateService) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager.VTable, self.vtable).AddService(@ptrCast(*const IUpdateServiceManager, self), serviceID, authorizationCabPath, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager_RegisterServiceWithAU(self: *const T, serviceID: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager.VTable, self.vtable).RegisterServiceWithAU(@ptrCast(*const IUpdateServiceManager, self), serviceID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager_RemoveService(self: *const T, serviceID: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager.VTable, self.vtable).RemoveService(@ptrCast(*const IUpdateServiceManager, self), serviceID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager_UnregisterServiceWithAU(self: *const T, serviceID: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager.VTable, self.vtable).UnregisterServiceWithAU(@ptrCast(*const IUpdateServiceManager, self), serviceID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager_AddScanPackageService(self: *const T, serviceName: ?BSTR, scanFileLocation: ?BSTR, flags: i32, ppService: ?*?*IUpdateService) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager.VTable, self.vtable).AddScanPackageService(@ptrCast(*const IUpdateServiceManager, self), serviceName, scanFileLocation, flags, ppService); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager_SetOption(self: *const T, optionName: ?BSTR, optionValue: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager.VTable, self.vtable).SetOption(@ptrCast(*const IUpdateServiceManager, self), optionName, optionValue); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IUpdateServiceManager2_Value = @import("../zig.zig").Guid.initString("0bb8531d-7e8d-424f-986c-a0b8f60a3e7b"); pub const IID_IUpdateServiceManager2 = &IID_IUpdateServiceManager2_Value; pub const IUpdateServiceManager2 = extern struct { pub const VTable = extern struct { base: IUpdateServiceManager.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClientApplicationID: fn( self: *const IUpdateServiceManager2, retval: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ClientApplicationID: fn( self: *const IUpdateServiceManager2, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, QueryServiceRegistration: fn( self: *const IUpdateServiceManager2, serviceID: ?BSTR, retval: ?*?*IUpdateServiceRegistration, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddService2: fn( self: *const IUpdateServiceManager2, serviceID: ?BSTR, flags: i32, authorizationCabPath: ?BSTR, retval: ?*?*IUpdateServiceRegistration, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUpdateServiceManager.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager2_get_ClientApplicationID(self: *const T, retval: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager2.VTable, self.vtable).get_ClientApplicationID(@ptrCast(*const IUpdateServiceManager2, self), retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager2_put_ClientApplicationID(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager2.VTable, self.vtable).put_ClientApplicationID(@ptrCast(*const IUpdateServiceManager2, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager2_QueryServiceRegistration(self: *const T, serviceID: ?BSTR, retval: ?*?*IUpdateServiceRegistration) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager2.VTable, self.vtable).QueryServiceRegistration(@ptrCast(*const IUpdateServiceManager2, self), serviceID, retval); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUpdateServiceManager2_AddService2(self: *const T, serviceID: ?BSTR, flags: i32, authorizationCabPath: ?BSTR, retval: ?*?*IUpdateServiceRegistration) callconv(.Inline) HRESULT { return @ptrCast(*const IUpdateServiceManager2.VTable, self.vtable).AddService2(@ptrCast(*const IUpdateServiceManager2, self), serviceID, flags, authorizationCabPath, retval); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IInstallationAgent_Value = @import("../zig.zig").Guid.initString("925cbc18-a2ea-4648-bf1c-ec8badcfe20a"); pub const IID_IInstallationAgent = &IID_IInstallationAgent_Value; pub const IInstallationAgent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, RecordInstallationResult: fn( self: *const IInstallationAgent, installationResultCookie: ?BSTR, hresult: i32, extendedReportingData: ?*IStringCollection, ) 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 IInstallationAgent_RecordInstallationResult(self: *const T, installationResultCookie: ?BSTR, hresult: i32, extendedReportingData: ?*IStringCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IInstallationAgent.VTable, self.vtable).RecordInstallationResult(@ptrCast(*const IInstallationAgent, self), installationResultCookie, hresult, extendedReportingData); } };} pub usingnamespace MethodMixin(@This()); }; pub const UpdateLockdownOption = enum(i32) { s = 1, }; pub const uloForWebsiteAccess = UpdateLockdownOption.s; pub const AddServiceFlag = enum(i32) { AllowPendingRegistration = 1, AllowOnlineRegistration = 2, RegisterServiceWithAU = 4, }; pub const asfAllowPendingRegistration = AddServiceFlag.AllowPendingRegistration; pub const asfAllowOnlineRegistration = AddServiceFlag.AllowOnlineRegistration; pub const asfRegisterServiceWithAU = AddServiceFlag.RegisterServiceWithAU; pub const UpdateServiceOption = enum(i32) { e = 1, }; pub const usoNonVolatileService = UpdateServiceOption.e; //-------------------------------------------------------------------------------- // 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 (8) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const BSTR = @import("../foundation.zig").BSTR; const DECIMAL = @import("../foundation.zig").DECIMAL; const HRESULT = @import("../foundation.zig").HRESULT; const HWND = @import("../foundation.zig").HWND; const IDispatch = @import("../system/com.zig").IDispatch; const IUnknown = @import("../system/com.zig").IUnknown; 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/system/update_agent.zig
const std = @import("std"); const warn = std.debug.warn; const assert = std.debug.assert; const trace = @import("tracy.zig").trace; const Vector = std.meta.Vector; // ============================================ // Computation // ============================================ pub const Fixed = u16; const range_Fixed = (1 << @typeInfo(Fixed).Int.bits) - 1; //full precision for input pub const Real = f128; pub const Complex = std.math.Complex(Real); // f32 f64 f128 work fine, f16 llvm doesn't like (obvisously, fixed point with lots of bits would be needed to zoom further) fn MandelbrotComputer(comptime supersamples: usize, RealType: type) type { const vec_len = supersamples * supersamples; return struct { const Complexs = struct { re: Vector(vec_len, RealType), im: Vector(vec_len, RealType), }; const Reals = Vector(vec_len, RealType); fn magnitudes2(v: Complexs) Reals { return v.im * v.im + v.re * v.re; } // return total number of iterations before all sample points diverge (up to max_iter per point) fn computeTotalIterations(sample_points: Complexs, max_iter: u16) u32 { var z = Complexs{ .re = sample_points.re, .im = sample_points.im }; var der = Complexs{ .re = @splat(vec_len, @as(RealType, 1.0)), .im = @splat(vec_len, @as(RealType, 0.0)) }; var iters = @splat(vec_len, @as(u16, 0)); const limit = @splat(vec_len, @as(RealType, 5.0)); // must be >= 2*2 const eps_der2 = @splat(vec_len, @as(RealType, 0.000001)); const k2 = @splat(vec_len, @as(RealType, 2.0)); var i: u16 = 0; while (i < max_iter) : (i += 1) { // next der = 2*der*z der = next_der: { const tmp = Complexs{ .re = k2 * (z.re * der.re - z.im * der.im), .im = k2 * (z.re * der.im + z.im * der.re), }; break :next_der tmp; }; // next iter: z= z*z + point z = next_iter: { const z_squared = Complexs{ .re = z.re * z.re - z.im * z.im, .im = z.re * z.im * k2, }; break :next_iter Complexs{ .re = z_squared.re + sample_points.re, .im = z_squared.im + sample_points.im, }; }; // check for divergence / approx convergence // /!\ Using the opposite of 'diverged', because diverging computations will yield 'NaN' eventually, // and we use the fact that comparisons with Nan are always false and still want to account them as diverged. const boundeds = magnitudes2(z) < limit; const stabilizeds = magnitudes2(der) < eps_der2; const all_diverged = !@reduce(.Or, boundeds); const all_stabilized = @reduce(.And, stabilizeds); if (all_diverged) break; if (all_stabilized) { // approx. to avoid wasting iterations when inside the set iters = @splat(vec_len, max_iter); break; } const inc = @bitCast(Vector(vec_len, u1), boundeds); // == @boolToInt iters += @intCast(Vector(vec_len, u16), inc); } var total: u32 = 0; i = 0; while (i < vec_len) : (i += 1) { total += iters[i]; } return total; } fn computeOnePoint(col: u32, line: u32, width: u32, height: u32, rect: RectOriented, max_iter: u16) Fixed { const samples = comptime createSamplePattern(supersamples); var points: Complexs = undefined; { const cols = @splat(vec_len, @intToFloat(Real, col)); const lines = @splat(vec_len, @intToFloat(Real, line)); const iwidths = @splat(vec_len, 1.0 / @intToFloat(Real, width)); const iheights = @splat(vec_len, 1.0 / @intToFloat(Real, height)); const orig_res = @splat(vec_len, rect.origin.re); const orig_ims = @splat(vec_len, rect.origin.im); const axis_re_res = @splat(vec_len, rect.axis_re.re); const axis_re_ims = @splat(vec_len, rect.axis_re.im); const axis_im_res = @splat(vec_len, rect.axis_im.re); const axis_im_ims = @splat(vec_len, rect.axis_im.im); const xs = (cols + samples.xs) * iwidths; const ys = (lines + samples.ys) * iheights; const c_res = orig_res + (axis_re_res * xs + axis_im_res * ys); const c_ims = orig_ims + (axis_re_ims * xs + axis_im_ims * ys); inline for ([1]u1{0} ** vec_len) |_, i| { // TODO: @floatCast(Vector) not supported yet. points.re[i] = @floatCast(RealType, c_res[i]); points.im[i] = @floatCast(RealType, c_ims[i]); } } const total_iter = computeTotalIterations(points, max_iter); return @intCast(Fixed, (total_iter * @as(u64, range_Fixed)) / (vec_len * @as(u64, max_iter))); } }; } fn createSamplePattern(comptime n: u32) struct { xs: Vector(n * n, Real), ys: Vector(n * n, Real) } { const center = @intToFloat(Real, n - 1) * 0.5; const size = @intToFloat(Real, 2 + n); var xs: Vector(n * n, Real) = undefined; var ys: Vector(n * n, Real) = undefined; var j: u32 = 0; while (j < n) : (j += 1) { var i: u32 = 0; while (i < n) : (i += 1) { xs[i + n * j] = (@intToFloat(Real, i) - center) / size; ys[i + n * j] = (@intToFloat(Real, j) - center) / size; } } return .{ .xs = xs, .ys = ys }; } pub const RectOriented = struct { origin: Complex, axis_re: Complex, axis_im: Complex, }; const FnComputeOnePoint = fn (u32, u32, u32, u32, RectOriented, u16) Fixed; fn computeOneLine(line: u32, width: u32, height: u32, buf_line: []Fixed, max_iter: u16, func: FnComputeOnePoint, rect: RectOriented, interrupt: *const bool) void { // this will create a new task for the thread pool, and suspend back to the caller. std.event.Loop.startCpuBoundOperation(); // std.mem.set(Fixed, buf_line, 0); const tracy = trace(@src()); defer tracy.end(); var col: u32 = 0; while (col < width) : (col += 1) { if (interrupt.*) return; buf_line[col] = func(col, line, width, height, rect, max_iter); } } // compute the appartenance level of each points in buf pub const AsyncComputeStatus = enum { idle, computing, done }; pub fn computeLevels(buf: []Fixed, width: u32, height: u32, rect: RectOriented, max_iter: u16, supersamples: u32, real_bits: u32, status: *AsyncComputeStatus, interrupt: *const bool) void { assert(status.* == .idle); status.* = .computing; // choose comptime variant for runtime parameters const func = switch (real_bits) { 0...16 => switch (supersamples) { 1 => MandelbrotComputer(1, f16).computeOnePoint, 2 => MandelbrotComputer(2, f16).computeOnePoint, 3 => MandelbrotComputer(3, f16).computeOnePoint, 4 => MandelbrotComputer(4, f16).computeOnePoint, else => MandelbrotComputer(5, f16).computeOnePoint, }, 17...32 => switch (supersamples) { 1 => MandelbrotComputer(1, f32).computeOnePoint, 2 => MandelbrotComputer(2, f32).computeOnePoint, 3 => MandelbrotComputer(3, f32).computeOnePoint, 4 => MandelbrotComputer(4, f32).computeOnePoint, else => MandelbrotComputer(5, f32).computeOnePoint, }, 33...64 => switch (supersamples) { 1 => MandelbrotComputer(1, f64).computeOnePoint, 2 => MandelbrotComputer(2, f64).computeOnePoint, 3 => MandelbrotComputer(3, f64).computeOnePoint, 4 => MandelbrotComputer(4, f64).computeOnePoint, else => MandelbrotComputer(5, f64).computeOnePoint, }, else => switch (supersamples) { 1 => MandelbrotComputer(1, f128).computeOnePoint, 2 => MandelbrotComputer(2, f128).computeOnePoint, 3 => MandelbrotComputer(3, f128).computeOnePoint, 4 => MandelbrotComputer(4, f128).computeOnePoint, else => MandelbrotComputer(5, f128).computeOnePoint, }, }; var func_frames: [1500]@Frame(computeOneLine) = undefined; var line: u32 = 0; while (line < height) : (line += 1) { const buf_line = buf[line * width .. (line + 1) * width]; func_frames[line] = async computeOneLine(line, width, height, buf_line, max_iter, func, rect, interrupt); } line = 0; while (line < height) : (line += 1) { await func_frames[line]; } assert(status.* == .computing); status.* = .done; } pub fn drawSetAscii(rect: RectOriented) void { const tracy = trace(@src(), .{}); defer tracy.end(); const grayscale = " .:ioVM@"; const width = 120; const height = 40; var span: [width]u8 = undefined; var lin: u32 = 0; while (lin < height) : (lin += 1) { var col: u32 = 0; while (col < width) : (col += 1) { const level = MandelbrotComputer(3, f32).computeOnePoint(col, lin, width, height, rect, 150); span[col] = grayscale[(level * (grayscale.len - 1)) / range_Fixed]; } warn("{s}\n", .{span}); } } // ============================================ // rescale util // ============================================ fn rescaleLine(dest: []Fixed, orig: []const Fixed, old_width: u32, new_width: u32) void { if (new_width >= old_width) { var d: u32 = new_width; while (d > 0) : (d -= 1) { const o = (d * old_width - old_width / 2) / new_width; dest[d - 1] = orig[o]; } } else { var d: u32 = 0; while (d < new_width) : (d += 1) { const o = (d * old_width) / new_width; dest[d] = orig[o]; } } } pub fn rescaleLevels(buf: []Fixed, old_width: u32, old_height: u32, new_width: u32, new_height: u32) void { const tracy = trace(@src()); defer tracy.end(); if (new_height >= old_height) { var d: u32 = new_height; while (d > 0) : (d -= 1) { const o = (d * old_height - old_height / 2) / new_height; rescaleLine(buf[(d - 1) * new_width .. d * new_width], buf[o * old_width .. (o + 1) * old_width], old_width, new_width); } } else { var d: u32 = 0; while (d < new_height) : (d += 1) { const o = (d * old_height) / new_height; rescaleLine(buf[d * new_width .. (d + 1) * new_width], buf[o * old_width .. (o + 1) * old_width], old_width, new_width); } } } // ============================================ // Presentation // ============================================ fn saturate(v: f32) u8 { if (v <= 0.0) { return 0; } else if (v >= 1.0) { return 255; } else { return @floatToInt(u8, v * 255); } } fn saturate4(vals: anytype) Vector(4, u8) { return [_]u8{ saturate(vals[0]), saturate(vals[1]), saturate(vals[2]), saturate(vals[3]), }; // TODO: @shuffle + @floatToInt(vector)? } fn intToFloat4(comptime T: type, vals: anytype) Vector(4, T) { return [_]T{ @intToFloat(T, vals[0]), @intToFloat(T, vals[1]), @intToFloat(T, vals[2]), @intToFloat(T, vals[3]), }; } fn smootherstep4(x: Vector(4, f32)) Vector(4, f32) { const k6 = @splat(4, @as(f32, 6.0)); const k15 = @splat(4, @as(f32, 15.0)); const k10 = @splat(4, @as(f32, 10.0)); return x * x * x * (x * (x * k6 - k15) + k10); } fn halfsmootherstep4(x: Vector(4, f32)) Vector(4, f32) { const k2 = @splat(4, @as(f32, 2.0)); const k05 = @splat(4, @as(f32, 0.5)); return (smootherstep4(x * k05 + k05) - k05) * k2; } fn levelsToColors(level: Vector(4, u16)) Vector(4, u32) { const l0 = intToFloat4(f32, level); //const knorm = @splat(4, 1.0 / @as(f32, range_Fixed)); //const l = halfsmootherstep4(l0 * knorm); //const l = @sqrt(l0 * knorm); // faster and prettier... (but still expensive) // prettiest const knorm = @splat(4, 1.6667 / @log2(@as(f32, range_Fixed) + 1)); const l = @log2(l0 + @splat(4, @as(f32, 1.0))) * knorm; const k2 = @splat(4, @as(f32, 1.0 / 1.35)); const R = l; const G = (l * k2); const B = (l * k2 * k2); const kFF000000 = @splat(4, @as(u32, 0xFF000000)); const k000001 = @splat(4, @as(u32, 0x000001)); const k000100 = @splat(4, @as(u32, 0x000100)); const k010000 = @splat(4, @as(u32, 0x010000)); const ABGR = kFF000000 + k000001 * @intCast(Vector(4, u32), saturate4(R)) + k000100 * @intCast(Vector(4, u32), saturate4(G)) + k010000 * @intCast(Vector(4, u32), saturate4(B)); return ABGR; } pub fn computeColors(levels: []const Fixed, pixels: []Vector(4, u32), width: u32, height: u32) void { const tracy = trace(@src()); defer tracy.end(); var j: u32 = 0; while (j < height) : (j += 1) { var i: u32 = 0; while (i < width) : (i += 4) { const levels4 = @as(Vector(4, u16), levels[(j * width + i)..][0..4].*); pixels[(j * width + i) / 4] = levelsToColors(levels4); } } }
src/mandelbrot.zig
const builtin = @import("builtin"); const kernel = @import("root").kernel; const kutil = kernel.util; const print = kernel.print; const kthreading = kernel.threading; const putil = @import("util.zig"); // TODO: Zig Bug? unable to evaluate constant expression // const segments = @import("segments.zig"); // const kernel_code_selector = segments.kernel_code_selector; // const user_code_selector = segments.user_code_selector; const segments = @import("segments.zig"); const ps2 = @import("ps2.zig"); const system_calls = @import("system_calls.zig"); // Stack When the Interrupt is Handled ======================================== pub fn StackTemplate(comptime include_error_code: bool) type { return packed struct { const has_error_code = include_error_code; // Pushed by us using pusha edi: u32, esi: u32, ebp: u32, esp: u32, ebx: u32, edx: u32, ecx: u32, eax: u32, // Pushed by CPU // Pushed by some exceptions, but not others. error_code: if (include_error_code) u32 else void, eip: u32, cs: u32, eflags: u32, }; } pub const Stack = StackTemplate(false); pub const StackEc = StackTemplate(true); // Interrupt Descriptor Table ================================================ const Entry = packed struct { offset_0_15: u16 = 0, selector: u16 = 0, zero: u8 = 0, flags: u8 = 0, offset_16_31: u16 = 0, }; var table = table_init: { var entries: [256]Entry = undefined; for (entries) |*e| { e.* = Entry{}; } break :table_init entries; }; // TODO: Bochs error for interrupt 39 is missing default error messeage, figure // out why. const invalid_index = "Interrupt number is invalid"; var names = names_init: { var the_names: [table.len][]const u8 = undefined; for (the_names) |*i| { i.* = invalid_index; } break :names_init the_names; }; const TablePointer = packed struct { limit: u16, base: u32, }; var table_pointer: TablePointer = undefined; pub fn load() void { asm volatile ("lidtl (%[p])" : : [p] "{ax}" (&table_pointer)); } fn set_entry( name: []const u8, index: u8, handler: fn() void, selector: u16, flags: u8) void { const offset: u32 = @ptrToInt(handler); names[index] = name; print.debug_format( " - [{}]: \"{}\"\n" ++ " - selector: {:x} address: {:a} flags: {:x}\n", .{ index, name, selector, offset, flags}); // TODO: Print flag and selector meanings table[index].offset_0_15 = @intCast(u16, offset & 0xffff); table[index].offset_16_31= @intCast(u16, (offset & 0xffff0000) >> 16); table[index].selector = selector; table[index].flags = flags; } // TODO: Figure out what these are... pub const kernel_flags: u8 = 0x8e; pub const user_flags: u8 = kernel_flags | (3 << 5); // Interrupt Handler Generation ============================================== pub fn PanicMessage(comptime StackType: type) type { return struct { pub fn show(interrupt_number: u32, interrupt_stack: *const StackType) void { kernel.console.reset_terminal(); kernel.console.show_cursor(false); kernel.console.set_hex_colors(.Black, .Red); kernel.console.clear_screen(); const has_ec = StackType.has_error_code; const ec = interrupt_stack.error_code; print.format( \\==============================<!>Kernel Panic<!>============================== \\The system has encountered an unrecoverable error: \\ Interrupt Number: {} \\ , .{interrupt_number}); if (has_ec) { print.format(" Error Code: {}\n", .{ec}); } print.string(" Message: "); if (!is_exception(interrupt_number)) { print.string(kernel.panic_message); } else { print.string(get_name(interrupt_number)); if (has_ec and interrupt_number == 13) { // Explain General Protection Fault Cause const which_table = @intCast(u2, (ec >> 1) & 3); const table_index = (ec >> 3) & 8191; print.format("{} Caused By {}[{}]", .{ if ((ec & 1) == 1) @as([]const u8, " Externally") else @as([]const u8, ""), @as([]const u8, switch (which_table) { 0 => "GDT", 1 => "IDT", 2 => "LDT", 3 => "IDT", }), table_index}); if (which_table == 0) { // Print Selector if GDT print.format(" ({})", .{segments.get_name(table_index)}); } else if ((which_table & 1) == 1) { // Print Interrupt if IDT print.format(" ({})", .{get_name(table_index)}); } } else if (has_ec and interrupt_number == 14) { // Explain Page Fault Cause const what = if ((ec & 1) > 0) @as([]const u8, "Page Protection Violation") else @as([]const u8, "Missing Page"); const reserved = if ((ec & 8) > 0) @as([]const u8, " (Reserved bits set in directory entry)") else @as([]const u8, ""); const when = if ((ec & 16) > 0) @as([]const u8, "Fetching an Instruction From") else (if ((ec & 2) > 0) @as([]const u8, "Writing to") else @as([]const u8, "Reading From")); const user = if ((ec & 4) > 0) @as([]const u8, "User") else @as([]const u8, "Non-User"); print.format("\n {}{} While {} {:a} while in {} Ring", .{ what, reserved, when, putil.cr2(), user}); // TODO: Zig Compiler Assertion // print.format("\n {}{} While {} {:a} while in {} Ring", .{ // if ((ec & 1) > 0) // @as([]const u8, "Page Protection Violation") else // @as([]const u8, "Missing Page"), // if ((ec & 8) > 0) // @as([]const u8, " (Reserved bits set in directory entry)") else // @as([]const u8, ""), // if ((ec & 16) > 0) // @as([]const u8, "Fetching an Instruction From") // else // (if ((ec & 2) > 0) @as([]const u8, "Writing to") else // @as([]const u8, "Reading From")), // putil.cr2(), // if ((ec & 4) > 0) @as([]const u8, "User") else // @as([]const u8, "Non-User")}); } } print.format( \\ \\ \\--Registers------------------------------------------------------------------- \\ EIP: {:a} \\ EFLAGS: {:x} \\ EAX: {:x} \\ ECX: {:x} \\ EDX: {:x} \\ EBX: {:x} \\ ESP: {:a} \\ EBP: {:a} \\ ESI: {:x} \\ EDI: {:x} \\ CS: {:x} ({}) , .{ interrupt_stack.eip, interrupt_stack.eflags, interrupt_stack.eax, interrupt_stack.ecx, interrupt_stack.edx, interrupt_stack.ebx, interrupt_stack.esp, interrupt_stack.ebp, interrupt_stack.esi, interrupt_stack.edi, interrupt_stack.cs, segments.get_name(interrupt_stack.cs / 8), }); putil.done(); } }; } fn BaseInterruptHandler( comptime i: u32, comptime StackType: type, comptime irq: bool, impl: fn(u32, *const StackType) void) type { return struct { const index: u8 = i; const irq_number: u32 = if (irq) i - pic.irq_0_7_interrupt_offset else 0; fn inner_handler(interrupt_stack: *const StackType) void { const spurious = if (irq_number == 7 or irq_number == 15) pic.is_spurious_irq(irq_number) else false; if (irq) { if (!spurious) { impl(irq_number, interrupt_stack); } pic.end_of_interrupt(irq_number, spurious); } else if (!spurious) { impl(@as(u32, i), interrupt_stack); } } pub fn handler() callconv(.Naked) noreturn { asm volatile ("cli"); // Push EAX, ECX, EDX, EBX, original ESP, EBP, ESI, and EDI asm volatile ("pushal"); inner_handler(asm volatile ("mov %%esp, %[interrupt_stack]" : [interrupt_stack] "={eax}" (-> *const StackType))); asm volatile ("popal"); // Restore Registers if (StackType.has_error_code) { asm volatile ("addl $4, %%esp"); // Pop Error Code } asm volatile ("iret"); unreachable; } pub fn get() fn() void { return @ptrCast(fn() void, handler); } pub fn set(name: []const u8, selector: u16, flags: u8) void { set_entry(name, index, @ptrCast(fn() void, handler), selector, flags); } }; } fn HardwareErrorInterruptHandler( comptime i: u32, comptime error_code: bool) type { const StackType = StackTemplate(error_code); return BaseInterruptHandler( i, StackType, false, PanicMessage(StackType).show); } pub fn IrqInterruptHandler( comptime irq_number: u32, impl: fn(u32, *const Stack) void) type { return BaseInterruptHandler(irq_number + pic.irq_0_7_interrupt_offset, Stack, true, impl); } fn InterruptHandler(comptime i: u32, impl: fn(u32, *const Stack) void) type { return BaseInterruptHandler(i, Stack, false, impl); } // CPU Exception Interrupts ================================================== const Exception = struct { name: []const u8, index: u32, error_code: bool, }; const exceptions = [_]Exception { Exception{.name = "Divide by Zero Fault", .index = 0, .error_code = false}, Exception{.name = "Debug Trap", .index = 1, .error_code = false}, Exception{.name = "Nonmaskable Interrupt", .index = 2, .error_code = false}, Exception{.name = "Breakpoint Trap", .index = 3, .error_code = false}, Exception{.name = "Overflow Trap", .index = 4, .error_code = false}, Exception{.name = "Bounds Fault", .index = 5, .error_code = false}, Exception{.name = "Invalid Opcode", .index = 6, .error_code = false}, Exception{.name = "Device Not Available", .index = 7, .error_code = false}, Exception{.name = "Double Fault", .index = 8, .error_code = true}, Exception{.name = "Coprocessor Segment Overrun", .index = 9, .error_code = false}, Exception{.name = "Invalid TSS", .index = 10, .error_code = true}, Exception{.name = "Segment Not Present", .index = 11, .error_code = true}, Exception{.name = "Stack-Segment Fault", .index = 12, .error_code = true}, Exception{.name = "General Protection Fault", .index = 13, .error_code = true}, Exception{.name = "Page Fault", .index = 14, .error_code = true}, Exception{.name = "x87 Floating-Point Exception", .index = 16, .error_code = false}, Exception{.name = "Alignment Check", .index = 17, .error_code = true}, Exception{.name = "Machine Check", .index = 18, .error_code = false}, Exception{.name = "SIMD Floating-Point Exception", .index = 19, .error_code = false}, Exception{.name = "Virtualization Exception", .index = 20, .error_code = false}, Exception{.name = "Security Exception", .index = 30, .error_code = true}, }; // 8259 Programmable Interrupt Controller (PIC) ============================== pub const pic = struct { const irq_0_7_interrupt_offset: u8 = 32; const irq_8_15_interrupt_offset: u8 = irq_0_7_interrupt_offset + 8; const irq_0_7_command_port: u16 = 0x20; const irq_0_7_data_port: u16 = 0x21; const irq_8_15_command_port: u16 = 0xA0; const irq_8_15_data_port: u16 = 0xA1; const read_irr_command: u8 = 0x0a; const read_isr_command: u8 = 0x0b; const init_command: u8 = 0x11; const reset_command: u8 = 0x20; fn busywork() callconv(.Inline) void { asm volatile ( \\add %%ch, %%bl \\add %%ch, %%bl ); } fn irq_mask(irq: u8) callconv(.Inline) u8 { var offset = irq; if (irq >= 8) { offset -= 8; } return @as(u8, 1) << @intCast(u3, offset); } pub fn is_spurious_irq(irq: u8) bool { var port = irq_0_7_command_port; if (irq >= 8) { port = irq_8_15_command_port; } putil.out8(port, read_isr_command); const rv = putil.in8(port) & irq_mask(irq) == 0; return rv; } pub fn end_of_interrupt(irq: u8, spurious: bool) void { const chained = irq >= 8; if (chained and !spurious) { putil.out8(irq_8_15_command_port, reset_command); } if (!spurious or (chained and spurious)) { putil.out8(irq_0_7_command_port, reset_command); } busywork(); } pub fn allow_irq(irq: u8, enabled: bool) void { _ = enabled; // TODO var port = irq_0_7_data_port; if (irq >= 8) { port = irq_8_15_data_port; } putil.out8(port, putil.in8(port) & ~irq_mask(irq)); busywork(); } pub fn init() void { // Start Initialization of PICs putil.out8(irq_0_7_command_port, init_command); busywork(); putil.out8(irq_8_15_command_port, init_command); busywork(); // Set Interrupt Number Offsets for IRQs putil.out8(irq_0_7_data_port, irq_0_7_interrupt_offset); busywork(); putil.out8(irq_8_15_data_port, irq_8_15_interrupt_offset); busywork(); // Tell PICs About Each Other putil.out8(irq_0_7_data_port, 4); busywork(); putil.out8(irq_8_15_data_port, 2); busywork(); // Set Mode of PICs putil.out8(irq_0_7_data_port, 1); busywork(); putil.out8(irq_8_15_data_port, 1); busywork(); // Disable All IRQs for Now putil.out8(irq_0_7_data_port, 0xff); busywork(); putil.out8(irq_8_15_data_port, 0xff); busywork(); // Enable Interrupts putil.enable_interrupts(); } }; pub var in_tick = false; fn tick(irq_number: u32, interrupt_stack: *const Stack) void { _ = irq_number; _ = interrupt_stack; in_tick = true; if (kthreading.debug) print.char('!'); kernel.threading_mgr.yield(); in_tick = false; } pub fn init() void { table_pointer.limit = @sizeOf(Entry) * table.len; table_pointer.base = @ptrToInt(&table); // TODO: See top of file const kernel_code_selector = @import("segments.zig").kernel_code_selector; print.debug_string(" - Filling the Interrupt Descriptor Table (IDT)\n"); const debug_print_value = print.debug_print; print.debug_print = false; // Too many lines comptime var interrupt_number = 0; comptime var exceptions_index = 0; @setEvalBranchQuota(2000); inline while (interrupt_number < 150) { if (exceptions_index < exceptions.len and exceptions[exceptions_index].index == interrupt_number) { exceptions_index += 1; } else { HardwareErrorInterruptHandler(interrupt_number, false).set( "Unknown Interrupt", kernel_code_selector, kernel_flags); } interrupt_number += 1; } print.debug_print = debug_print_value; inline for (exceptions) |ex| { HardwareErrorInterruptHandler(ex.index, ex.error_code).set( ex.name, kernel_code_selector, kernel_flags); } InterruptHandler(50, PanicMessage(Stack).show).set( "Software Panic", kernel_code_selector, kernel_flags); InterruptHandler(system_calls.interrupt_number, system_calls.handle).set( "System Call", kernel_code_selector, user_flags); IrqInterruptHandler(0, tick).set( "IRQ0: Timer", kernel_code_selector, kernel_flags); load(); pic.init(); } pub fn get_name(index: u32) []const u8 { return if (index < names.len) names[index] else invalid_index ++ " and out of range"; } pub fn is_exception(index: u32) bool { return index <= exceptions.len; }
kernel/platform/interrupts.zig
const georgios = @import("georgios"); const kb = georgios.keyboard; pub const Entry = struct { key: ?kb.Key, shifted_key: ?kb.Key, kind: ?kb.Kind, }; pub const one_byte = [256]Entry { Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_Escape, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_1, .shifted_key = .Key_Exclamation, .kind = .Pressed}, Entry{.key = .Key_2, .shifted_key = .Key_At, .kind = .Pressed}, Entry{.key = .Key_3, .shifted_key = .Key_Pound, .kind = .Pressed}, Entry{.key = .Key_4, .shifted_key = .Key_Dollar, .kind = .Pressed}, Entry{.key = .Key_5, .shifted_key = .Key_Percent, .kind = .Pressed}, Entry{.key = .Key_6, .shifted_key = .Key_Caret, .kind = .Pressed}, Entry{.key = .Key_7, .shifted_key = .Key_Ampersand, .kind = .Pressed}, Entry{.key = .Key_8, .shifted_key = .Key_Asterisk, .kind = .Pressed}, Entry{.key = .Key_9, .shifted_key = .Key_LeftParentheses, .kind = .Pressed}, Entry{.key = .Key_0, .shifted_key = .Key_RightParentheses, .kind = .Pressed}, Entry{.key = .Key_Minus, .shifted_key = .Key_Underscore, .kind = .Pressed}, Entry{.key = .Key_Equals, .shifted_key = .Key_Plus, .kind = .Pressed}, Entry{.key = .Key_Backspace, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Tab, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_q, .shifted_key = .Key_Q, .kind = .Pressed}, Entry{.key = .Key_w, .shifted_key = .Key_W, .kind = .Pressed}, Entry{.key = .Key_e, .shifted_key = .Key_E, .kind = .Pressed}, Entry{.key = .Key_r, .shifted_key = .Key_R, .kind = .Pressed}, Entry{.key = .Key_t, .shifted_key = .Key_T, .kind = .Pressed}, Entry{.key = .Key_y, .shifted_key = .Key_Y, .kind = .Pressed}, Entry{.key = .Key_u, .shifted_key = .Key_U, .kind = .Pressed}, Entry{.key = .Key_i, .shifted_key = .Key_I, .kind = .Pressed}, Entry{.key = .Key_o, .shifted_key = .Key_O, .kind = .Pressed}, Entry{.key = .Key_p, .shifted_key = .Key_P, .kind = .Pressed}, Entry{.key = .Key_LeftSquareBracket, .shifted_key = .Key_LeftBrace, .kind = .Pressed}, Entry{.key = .Key_RightSquareBracket, .shifted_key = .Key_RightBrace, .kind = .Pressed}, Entry{.key = .Key_Enter, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_LeftControl, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_a, .shifted_key = .Key_A, .kind = .Pressed}, Entry{.key = .Key_s, .shifted_key = .Key_S, .kind = .Pressed}, Entry{.key = .Key_d, .shifted_key = .Key_D, .kind = .Pressed}, Entry{.key = .Key_f, .shifted_key = .Key_F, .kind = .Pressed}, Entry{.key = .Key_g, .shifted_key = .Key_G, .kind = .Pressed}, Entry{.key = .Key_h, .shifted_key = .Key_H, .kind = .Pressed}, Entry{.key = .Key_j, .shifted_key = .Key_J, .kind = .Pressed}, Entry{.key = .Key_k, .shifted_key = .Key_K, .kind = .Pressed}, Entry{.key = .Key_l, .shifted_key = .Key_L, .kind = .Pressed}, Entry{.key = .Key_SemiColon, .shifted_key = .Key_Colon, .kind = .Pressed}, Entry{.key = .Key_SingleQuote, .shifted_key = .Key_DoubleQuote, .kind = .Pressed}, Entry{.key = .Key_BackTick, .shifted_key = .Key_Tilde, .kind = .Pressed}, Entry{.key = .Key_LeftShift, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Backslash, .shifted_key = .Key_Pipe, .kind = .Pressed}, Entry{.key = .Key_z, .shifted_key = .Key_Z, .kind = .Pressed}, Entry{.key = .Key_x, .shifted_key = .Key_X, .kind = .Pressed}, Entry{.key = .Key_c, .shifted_key = .Key_C, .kind = .Pressed}, Entry{.key = .Key_v, .shifted_key = .Key_V, .kind = .Pressed}, Entry{.key = .Key_b, .shifted_key = .Key_B, .kind = .Pressed}, Entry{.key = .Key_n, .shifted_key = .Key_N, .kind = .Pressed}, Entry{.key = .Key_m, .shifted_key = .Key_M, .kind = .Pressed}, Entry{.key = .Key_Comma, .shifted_key = .Key_LessThan, .kind = .Pressed}, Entry{.key = .Key_Period, .shifted_key = .Key_GreaterThan, .kind = .Pressed}, Entry{.key = .Key_Slash, .shifted_key = .Key_Question, .kind = .Pressed}, Entry{.key = .Key_RightShift, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_KeypadAsterisk, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_LeftAlt, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Space, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_CapsLock, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F1, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F2, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F3, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F4, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F5, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F6, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F7, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F8, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F9, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F10, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_NumberLock, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_ScrollLock, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad7, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad8, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad9, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_KeypadMinus, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad4, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad5, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad6, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_KeypadPlus, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad1, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad2, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad3, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Keypad0, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_KeypadPeriod, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_F11, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_F12, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_Escape, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_1, .shifted_key = .Key_Exclamation, .kind = .Released}, Entry{.key = .Key_2, .shifted_key = .Key_At, .kind = .Released}, Entry{.key = .Key_3, .shifted_key = .Key_Pound, .kind = .Released}, Entry{.key = .Key_4, .shifted_key = .Key_Dollar, .kind = .Released}, Entry{.key = .Key_5, .shifted_key = .Key_Percent, .kind = .Released}, Entry{.key = .Key_6, .shifted_key = .Key_Caret, .kind = .Released}, Entry{.key = .Key_7, .shifted_key = .Key_Ampersand, .kind = .Released}, Entry{.key = .Key_8, .shifted_key = .Key_Asterisk, .kind = .Released}, Entry{.key = .Key_9, .shifted_key = .Key_LeftParentheses, .kind = .Released}, Entry{.key = .Key_0, .shifted_key = .Key_RightParentheses, .kind = .Released}, Entry{.key = .Key_Minus, .shifted_key = .Key_Underscore, .kind = .Released}, Entry{.key = .Key_Equals, .shifted_key = .Key_Plus, .kind = .Released}, Entry{.key = .Key_Backspace, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Tab, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_q, .shifted_key = .Key_Q, .kind = .Released}, Entry{.key = .Key_w, .shifted_key = .Key_W, .kind = .Released}, Entry{.key = .Key_e, .shifted_key = .Key_E, .kind = .Released}, Entry{.key = .Key_r, .shifted_key = .Key_R, .kind = .Released}, Entry{.key = .Key_t, .shifted_key = .Key_T, .kind = .Released}, Entry{.key = .Key_y, .shifted_key = .Key_Y, .kind = .Released}, Entry{.key = .Key_u, .shifted_key = .Key_U, .kind = .Released}, Entry{.key = .Key_i, .shifted_key = .Key_I, .kind = .Released}, Entry{.key = .Key_o, .shifted_key = .Key_O, .kind = .Released}, Entry{.key = .Key_p, .shifted_key = .Key_P, .kind = .Released}, Entry{.key = .Key_LeftSquareBracket, .shifted_key = .Key_LeftBrace, .kind = .Released}, Entry{.key = .Key_RightSquareBracket, .shifted_key = .Key_RightBrace, .kind = .Released}, Entry{.key = .Key_Enter, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_LeftControl, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_a, .shifted_key = .Key_A, .kind = .Released}, Entry{.key = .Key_s, .shifted_key = .Key_S, .kind = .Released}, Entry{.key = .Key_d, .shifted_key = .Key_D, .kind = .Released}, Entry{.key = .Key_f, .shifted_key = .Key_F, .kind = .Released}, Entry{.key = .Key_g, .shifted_key = .Key_G, .kind = .Released}, Entry{.key = .Key_h, .shifted_key = .Key_H, .kind = .Released}, Entry{.key = .Key_j, .shifted_key = .Key_J, .kind = .Released}, Entry{.key = .Key_k, .shifted_key = .Key_K, .kind = .Released}, Entry{.key = .Key_l, .shifted_key = .Key_L, .kind = .Released}, Entry{.key = .Key_SemiColon, .shifted_key = .Key_Colon, .kind = .Released}, Entry{.key = .Key_SingleQuote, .shifted_key = .Key_DoubleQuote, .kind = .Released}, Entry{.key = .Key_BackTick, .shifted_key = .Key_Tilde, .kind = .Released}, Entry{.key = .Key_LeftShift, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Backslash, .shifted_key = .Key_Pipe, .kind = .Released}, Entry{.key = .Key_z, .shifted_key = .Key_Z, .kind = .Released}, Entry{.key = .Key_x, .shifted_key = .Key_X, .kind = .Released}, Entry{.key = .Key_c, .shifted_key = .Key_C, .kind = .Released}, Entry{.key = .Key_v, .shifted_key = .Key_V, .kind = .Released}, Entry{.key = .Key_b, .shifted_key = .Key_B, .kind = .Released}, Entry{.key = .Key_n, .shifted_key = .Key_N, .kind = .Released}, Entry{.key = .Key_m, .shifted_key = .Key_M, .kind = .Released}, Entry{.key = .Key_Comma, .shifted_key = .Key_LessThan, .kind = .Released}, Entry{.key = .Key_Period, .shifted_key = .Key_GreaterThan, .kind = .Released}, Entry{.key = .Key_Slash, .shifted_key = .Key_Question, .kind = .Released}, Entry{.key = .Key_RightShift, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_KeypadAsterisk, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_LeftAlt, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Space, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_CapsLock, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F1, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F2, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F3, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F4, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F5, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F6, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F7, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F8, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F9, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F10, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_NumberLock, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_ScrollLock, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad7, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad8, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad9, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_KeypadMinus, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad4, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad5, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad6, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_KeypadPlus, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad1, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad2, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad3, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Keypad0, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_KeypadPeriod, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_F11, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_F12, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, }; pub const two_byte = [256]Entry { Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_KeypadEnter, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_RightControl, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_KeypadSlash, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_RightAlt, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_Home, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_CursorUp, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_PageUp, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_CursorLeft, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_CursorRight, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_End, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_CursorDown, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_PageDown, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Insert, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_Delete, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_AcpiPower, .shifted_key = null, .kind = .Pressed}, Entry{.key = .Key_AcpiSleep, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_AcpiWake, .shifted_key = null, .kind = .Pressed}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_KeypadEnter, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_RightControl, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_KeypadSlash, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_RightAlt, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_Home, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_CursorUp, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_PageUp, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_CursorLeft, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_CursorRight, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_End, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_CursorDown, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_PageDown, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Insert, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_Delete, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_AcpiPower, .shifted_key = null, .kind = .Released}, Entry{.key = .Key_AcpiSleep, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = .Key_AcpiWake, .shifted_key = null, .kind = .Released}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, Entry{.key = null, .shifted_key = null, .kind = null}, };
kernel/platform/ps2_scan_codes.zig
const std = @import("std.zig"); const StringHashMap = std.StringHashMap; const mem = @import("mem.zig"); const Allocator = mem.Allocator; const testing = std.testing; /// A BufSet is a set of strings. The BufSet duplicates /// strings internally, and never takes ownership of strings /// which are passed to it. pub const BufSet = struct { hash_map: BufSetHashMap, const BufSetHashMap = StringHashMap(void); pub const Iterator = BufSetHashMap.KeyIterator; /// Create a BufSet using an allocator. The allocator will /// be used internally for both backing allocations and /// string duplication. pub fn init(a: Allocator) BufSet { var self = BufSet{ .hash_map = BufSetHashMap.init(a) }; return self; } /// Free a BufSet along with all stored keys. pub fn deinit(self: *BufSet) void { var it = self.hash_map.keyIterator(); while (it.next()) |key_ptr| { self.free(key_ptr.*); } self.hash_map.deinit(); self.* = undefined; } /// Insert an item into the BufSet. The item will be /// copied, so the caller may delete or reuse the /// passed string immediately. pub fn insert(self: *BufSet, value: []const u8) !void { const gop = try self.hash_map.getOrPut(value); if (!gop.found_existing) { gop.key_ptr.* = self.copy(value) catch |err| { _ = self.hash_map.remove(value); return err; }; } } /// Check if the set contains an item matching the passed string pub fn contains(self: BufSet, value: []const u8) bool { return self.hash_map.contains(value); } /// Remove an item from the set. pub fn remove(self: *BufSet, value: []const u8) void { const kv = self.hash_map.fetchRemove(value) orelse return; self.free(kv.key); } /// Returns the number of items stored in the set pub fn count(self: *const BufSet) usize { return self.hash_map.count(); } /// Returns an iterator over the items stored in the set. /// Iteration order is arbitrary. pub fn iterator(self: *const BufSet) Iterator { return self.hash_map.keyIterator(); } /// Get the allocator used by this set pub fn allocator(self: *const BufSet) Allocator { return self.hash_map.allocator; } /// Creates a copy of this BufSet, using a specified allocator. pub fn cloneWithAllocator( self: *const BufSet, new_allocator: Allocator, ) Allocator.Error!BufSet { var cloned_hashmap = try self.hash_map.cloneWithAllocator(new_allocator); var cloned = BufSet{ .hash_map = cloned_hashmap }; var it = cloned.hash_map.keyIterator(); while (it.next()) |key_ptr| { key_ptr.* = try cloned.copy(key_ptr.*); } return cloned; } /// Creates a copy of this BufSet, using the same allocator. pub fn clone(self: *const BufSet) Allocator.Error!BufSet { return self.cloneWithAllocator(self.allocator()); } fn free(self: *const BufSet, value: []const u8) void { self.hash_map.allocator.free(value); } fn copy(self: *const BufSet, value: []const u8) ![]const u8 { const result = try self.hash_map.allocator.alloc(u8, value.len); mem.copy(u8, result, value); return result; } }; test "BufSet" { var bufset = BufSet.init(std.testing.allocator); defer bufset.deinit(); try bufset.insert("x"); try testing.expect(bufset.count() == 1); bufset.remove("x"); try testing.expect(bufset.count() == 0); try bufset.insert("x"); try bufset.insert("y"); try bufset.insert("z"); } test "BufSet clone" { var original = BufSet.init(testing.allocator); defer original.deinit(); try original.insert("x"); var cloned = try original.clone(); defer cloned.deinit(); cloned.remove("x"); try testing.expect(original.count() == 1); try testing.expect(cloned.count() == 0); try testing.expectError( error.OutOfMemory, original.cloneWithAllocator(testing.failing_allocator), ); } test "BufSet.clone with arena" { var allocator = std.testing.allocator; var arena = std.heap.ArenaAllocator.init(allocator); defer arena.deinit(); var buf = BufSet.init(allocator); defer buf.deinit(); try buf.insert("member1"); try buf.insert("member2"); _ = try buf.cloneWithAllocator(arena.allocator()); }
lib/std/buf_set.zig
const std = @import("std"); const eql = std.mem.eql; const Allocator = std.mem.Allocator; const OpCode = enum { nop, acc, jmp }; const Op = union(OpCode) { nop: isize, acc: isize, jmp: isize }; const Program = std.ArrayList(Op); const HashMap = std.AutoHashMap(isize, u8); fn parse(line: []u8, program: *Program) !void { const n = try std.fmt.parseInt(isize, line[4..], 10); if (eql(u8, line[0..3], "nop")) { try program.append(Op{ .nop = n }); } else if (eql(u8, line[0..3], "acc")) { try program.append(Op{ .acc = n }); } else if (eql(u8, line[0..3], "jmp")) { try program.append(Op{ .jmp = n }); } } fn run(allocator: *Allocator, program: *Program, fixed: *bool) !isize { var visited = HashMap.init(allocator); defer visited.deinit(); var ic: isize = 0; var acc: isize = 0; while (visited.get(ic) == null) { if (ic >= program.items.len) { break; } try visited.put(ic, 0); switch (program.items[@intCast(usize, ic)]) { .nop => |_| { ic += 1; }, .acc => |val| { acc += val; ic += 1; }, .jmp => |val| { ic += val; }, } if (ic == program.items.len - 1) { fixed.* = true; } } return acc; } fn swap(op: *Op) void { switch (op.*) { .nop => |val| { op.* = Op{ .jmp = val }; }, .jmp => |val| { op.* = Op{ .nop = val }; }, .acc => {}, } } pub fn main() anyerror!void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = &arena.allocator; var program = Program.init(allocator); var stdin = std.io.getStdIn().reader(); var in = std.io.bufferedReader(stdin).reader(); var buf: [32]u8 = undefined; while (try in.readUntilDelimiterOrEof(&buf, '\n')) |line| { try parse(line, &program); } // Part A var fixed = false; const na = try run(allocator, &program, &fixed); std.debug.print("A) the value of the accumulator is {d}\n", .{na}); // Part B var nb: isize = 0; var i: usize = 0; while (i < program.items.len) : (i += 1) { swap(&program.items[i]); nb = try run(allocator, &program, &fixed); if (fixed) { std.debug.print("B) the value of the accumulator is {d}\n", .{nb}); break; } else { swap(&program.items[i]); } } }
2020/zig/src/8.zig
const std = @import("std"); const os = @import("root").os; const kepler = os.kepler; const tries = 1_000_000; fn server_task(allocator: *std.mem.Allocator, server_noteq: *kepler.ipc.NoteQueue) !void { // Server note queue should get the .Request note server_noteq.wait(); const connect_note = server_noteq.try_recv() orelse unreachable; std.debug.assert(connect_note.typ == .RequestPending); const conn = connect_note.owner_ref.stream; os.log(".Request note recieved!\n", .{}); // Accept the requests try connect_note.owner_ref.stream.accept(); os.log("Request was accepted!\n", .{}); // Test 10000000 requests var i: usize = 0; var server_send_rdtsc: u64 = 0; var server_recv_rdtsc: u64 = 0; os.log("Server task enters stress test!\n", .{}); while (i < tries) : (i += 1) { // Server should get .Submit note server_noteq.wait(); const recv_starting_time = os.platform.clock(); const submit_note = server_noteq.try_recv() orelse unreachable; server_recv_rdtsc += os.platform.clock() - recv_starting_time; std.debug.assert(submit_note.typ == .TasksAvailable); std.debug.assert(submit_note.owner_ref.stream == conn); // Allow client to resent its note submit_note.drop(); conn.unblock(.Consumer); // Notify consumer about completed tasks const send_starting_time = os.platform.clock(); try conn.notify(.Consumer); server_send_rdtsc += os.platform.clock() - send_starting_time; } os.log("Server task exits stress test! Send: {} clk. Recieve: {} clk\n", .{ server_send_rdtsc / tries, server_recv_rdtsc / tries }); // Terminate connection from the server conn.abandon(.Producer); os.log("Connection terminated from the server side!\n", .{}); } fn client_task(allocator: *std.mem.Allocator, client_noteq: *kepler.ipc.NoteQueue, endpoint: *kepler.ipc.Endpoint) !void { // Stream connection object const conn_params = kepler.ipc.Stream.UserspaceInfo{ .consumer_rw_buf_size = 1024, .producer_rw_buf_size = 1024, .obj_mailbox_size = 16, }; const conn = try kepler.ipc.Stream.create(allocator, client_noteq, endpoint, conn_params); os.log("Created connection!\n", .{}); // Client note queue should get the .Accept note client_noteq.wait(); const accept_note = client_noteq.try_recv() orelse unreachable; std.debug.assert(accept_note.typ == .RequestAccepted); std.debug.assert(accept_note.owner_ref.stream == conn); accept_note.drop(); os.log(".Accept note recieved!\n", .{}); // Finalize accept/request sequence conn.finalize_connection(); os.log("Connection finalized!\n", .{}); // Test 10000000 requests var i: usize = 0; var client_send_rdtsc: usize = 0; var client_recv_rdtsc: usize = 0; os.log("Client task enters stress test!\n", .{}); while (i < tries) : (i += 1) { // Let's notify server about more tasks const send_starting_time = os.platform.clock(); try conn.notify(.Producer); client_send_rdtsc += os.platform.clock() - send_starting_time; // Client should get .Complete note client_noteq.wait(); const recv_starting_time = os.platform.clock(); const complete_note = client_noteq.try_recv() orelse unreachable; client_recv_rdtsc += os.platform.clock() - recv_starting_time; std.debug.assert(complete_note.typ == .ResultsAvailable); std.debug.assert(complete_note.owner_ref.stream == conn); complete_note.drop(); // Allow server to resend its note conn.unblock(.Producer); } os.log("Client task exits stress test! Send: {} clk. Recieve: {} clk\n", .{ client_send_rdtsc / tries, client_recv_rdtsc / tries }); // Client should get ping of death message client_noteq.wait(); const server_death_note = client_noteq.try_recv() orelse unreachable; std.debug.assert(server_death_note.owner_ref.stream == conn); std.debug.assert(server_death_note.typ == .ProducerLeft); os.log("Ping of death recieved!\n", .{}); server_death_note.drop(); // Close connection on the client's side as well conn.abandon(.Consumer); os.log("Connection terminated from the client side!\n", .{}); // Exit client task os.thread.scheduler.exit_task(); } fn notifications(allocator: *std.mem.Allocator) !void { os.log("\nNotifications test...\n", .{}); // Server notificaiton queue const server_noteq = try kepler.ipc.NoteQueue.create(allocator); os.log("Created server queue!\n", .{}); // Client notification queue const client_noteq = try kepler.ipc.NoteQueue.create(allocator); os.log("Created client queue!\n", .{}); // Server endpoint const endpoint = try kepler.ipc.Endpoint.create(allocator, server_noteq); os.log("Created server endpoint!\n", .{}); // Run client task separately try os.thread.scheduler.spawn_task(client_task, .{ allocator, client_noteq, endpoint }); // Launch server task inline try server_task(allocator, server_noteq); os.log("Server has terminated! Let's hope that client would finish as needed", .{}); } fn memory_objects(allocator: *std.mem.Allocator) !void { os.log("\nMemory objects test...\n", .{}); const test_obj = try kepler.memory.MemoryObject.create(allocator, 0x10000); os.log("Created memory object of size 0x10000!\n", .{}); const base = try kepler.memory.kernel_mapper.map(test_obj, os.memory.paging.rw(), .MemoryWriteBack); os.log("Mapped memory object!\n", .{}); const arr = @intToPtr([*]u8, base); arr[0] = 0x69; kepler.memory.kernel_mapper.unmap(test_obj, base); os.log("Unmapped memory object!\n", .{}); const base2 = try kepler.memory.kernel_mapper.map(test_obj, os.memory.paging.ro(), .MemoryWriteBack); os.log("Mapped memory object again!\n", .{}); const arr2 = @intToPtr([*]u8, base2); std.debug.assert(arr2[0] == 0x69); kepler.memory.kernel_mapper.unmap(test_obj, base2); os.log("Unmapped memory object again!\n", .{}); test_obj.drop(); os.log("Dropped memory object!\n", .{}); } fn object_passing(allocator: *std.mem.Allocator) !void { os.log("\nObject passing test...\n", .{}); var mailbox = try kepler.objects.ObjectRefMailbox.init(allocator, 2); os.log("Created object reference mailbox!\n", .{}); // Create a dummy object to pass around const dummy = try kepler.memory.MemoryObject.create(allocator, 0x1000); os.log("Created dummy object!\n", .{}); const dummy_ref = kepler.objects.ObjectRef{ .MemoryObject = .{ .ref = dummy.borrow(), .mapped_to = null } }; // Test send from consumer and recieve from producer if (mailbox.write_from_consumer(3, dummy_ref)) { unreachable; } else |err| { std.debug.assert(err == error.OutOfBounds); } os.log("Out of bounds write passed!\n", .{}); try mailbox.write_from_consumer(0, dummy_ref); os.log("Send passed!\n", .{}); if (mailbox.write_from_consumer(0, dummy_ref)) { unreachable; } else |err| { std.debug.assert(err == error.NotEnoughPermissions); } os.log("Wrong send to the same cell passed!\n", .{}); if (mailbox.read_from_producer(1)) |_| { unreachable; } else |err| { std.debug.assert(err == error.NotEnoughPermissions); } os.log("Read with wrong permissions passed!\n", .{}); const recieved_dummy_ref = try mailbox.read_from_producer(0); std.debug.assert(recieved_dummy_ref.MemoryObject.ref == dummy_ref.MemoryObject.ref); recieved_dummy_ref.drop(&kepler.memory.kernel_mapper); os.log("Read passed!\n", .{}); // Test grant from consumer, send from producer, and reciever from consumer try mailbox.grant_write(0); if (mailbox.write_from_producer(1, dummy_ref)) { unreachable; } else |err| { std.debug.assert(err == error.NotEnoughPermissions); } os.log("Write with wrong permissions passed!\n", .{}); try mailbox.write_from_producer(0, dummy_ref); const new_recieved_dummy_ref = try mailbox.read_from_consumer(0); std.debug.assert(new_recieved_dummy_ref.MemoryObject.ref == dummy_ref.MemoryObject.ref); new_recieved_dummy_ref.drop(&kepler.memory.kernel_mapper); os.log("Read passed!\n", .{}); dummy_ref.drop(&kepler.memory.kernel_mapper); mailbox.drop(); } fn locked_handles(allocator: *std.mem.Allocator) !void { os.log("\nLocked handles test...\n", .{}); const handle = try kepler.objects.LockedHandle.create(allocator, 69, 420); std.debug.assert((try handle.peek(420)) == 69); if (handle.peek(412)) |_| unreachable else |err| std.debug.assert(err == error.AuthenticationFailed); os.log("Locked handles test passed...\n", .{}); } fn locked_handle_table(allocator: *std.mem.Allocator) !void { os.log("\nLocked handle table test...\n", .{}); var instance: os.lib.handle_table.LockedHandleTable(u64) = .{}; instance.init(allocator); const result1 = try instance.new_cell(); result1.ref.* = 69; std.debug.assert(result1.id == 0); instance.unlock(); os.log("First alloc done!...\n", .{}); const result2 = try instance.new_cell(); result2.ref.* = 420; std.debug.assert(result2.id == 1); instance.unlock(); os.log("Second alloc done!...\n", .{}); const TestDisposer = struct { called: u64, pub fn init() @This() { return .{ .called = 0 }; } pub fn dispose(self: *@This(), loc: os.lib.handle_table.LockedHandleTable(u64).Location) void { self.called += 1; } }; var disposer = TestDisposer.init(); os.log("Disposing handle table...\n", .{}); instance.deinit(TestDisposer, &disposer); std.testing.expect(disposer.called == 2); } fn interrupt_test(allocator: *std.mem.Allocator) !void { os.log("\nInterrupt test...\n", .{}); // Create a notification queue const noteq = try kepler.ipc.NoteQueue.create(allocator); // Create interrupt object var object: kepler.interrupts.InterruptObject = undefined; const dummy_callback = struct {fn dummy(_: *kepler.interrupts.InterruptObject) void {}}.dummy; object.init(noteq, dummy_callback, dummy_callback); // Raise interrupt object.raise(); // Check that we got a notification const note = noteq.try_recv() orelse unreachable; std.debug.assert(note.typ == .InterruptRaised); note.drop(); object.shutdown(); } pub fn run_tests() !void { var buffer: [4096]u8 = undefined; var fixed_buffer = std.heap.FixedBufferAllocator.init(&buffer); const allocator = &fixed_buffer.allocator; try notifications(allocator); try memory_objects(allocator); try object_passing(allocator); try locked_handles(allocator); try locked_handle_table(allocator); try interrupt_test(allocator); os.log("\nAll tests passing!\n", .{}); }
src/kepler/tests.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; // Input values const p1_init = 7; const p2_init = 5; /// Possible total values from three dice, and /// number of universes where each total can happen. const rolls = [_]u32{ 3, 4, 5, 6, 7, 8, 9 }; const counts = [_]u64{ 1, 3, 6, 7, 6, 3, 1 }; const Table = struct { /// Playing to 21, the max number of turns is 10, plus 1 for turn 0 const max_turns = 11; /// Number of universes where the player has not won after this many turns alive: [max_turns]u64 = std.mem.zeroes([max_turns]u64), /// Number of universes where the player wins on this turn wins: [max_turns]u64 = std.mem.zeroes([max_turns]u64), fn countRecursive(self: *@This(), depth: u32, alive: u64, pos: u32, score: u32) void { for (rolls) |r, i| { const new_pos = (pos + r) % 10; const new_score = score + new_pos + 1; const new_alive = alive * counts[i]; if (new_score >= 21) { self.wins[depth] += new_alive; } else { self.alive[depth] += new_alive; self.countRecursive(depth + 1, new_alive, new_pos, new_score); } } } pub fn buildRecursive(self: *@This(), start_pos: u32) void { self.alive[0] = 1; self.wins[0] = 0; self.countRecursive(1, 1, start_pos - 1, 0); } const Buffer = [21][10]u64; pub fn buildIterative(self: *@This(), start_pos: u32) void { var pos = start_pos - 1; // [score][position-1] var buf_a: Buffer = undefined; var buf_b: Buffer = undefined; @memset(@ptrCast([*]u8, &buf_a), 0, @sizeOf(Buffer)); buf_a[0][pos] = 1; self.alive[0] = 1; self.wins[0] = 0; var turn: usize = 1; while (turn < max_turns-1) : (turn += 2) { self.countTurn(turn, &buf_a, &buf_b); self.countTurn(turn + 1, &buf_b, &buf_a); } if (turn < max_turns) { self.countTurn(turn, &buf_a, &buf_b); } } fn countTurn(noalias self: *@This(), turn: usize, noalias curr: *const Buffer, noalias next: *Buffer) void { @memset(@ptrCast([*]u8, next), 0, @sizeOf(Buffer)); var alive_this_turn: u64 = 0; var wins_this_turn: u64 = 0; var score: usize = 0; while (score < 21) : (score += 1) { var pos: usize = 0; while (pos < 10) : (pos += 1) { const universes = curr[score][pos]; for (rolls) |r, i| { const new_pos = (pos + r) % 10; const new_score = score + new_pos + 1; const new_universes = universes * counts[i]; if (new_score < 21) { next[new_score][new_pos] += new_universes; alive_this_turn += new_universes; } else { wins_this_turn += new_universes; } } } } self.alive[turn] = alive_this_turn; self.wins[turn] = wins_this_turn; } }; pub fn main() !void { var timer = try std.time.Timer.start(); const part1 = blk: { var p1: u32 = p1_init - 1; var p2: u32 = p2_init - 1; var p1_score: u32 = 0; var p2_score: u32 = 0; var turn: u32 = 0; var die: u32 = 0; const loser_score = while (true) { { turn += 1; const roll = 3*die + 6; die += 3; p1 = (p1 + roll) % 10; p1_score += (p1 + 1); if (p1_score >= 1000) break p2_score; } { turn += 1; const roll = 3*die + 6; die += 3; p2 = (p2 + roll) % 10; p2_score += (p2 + 1); if (p2_score >= 1000) break p1_score; } } else unreachable; break :blk @as(u64, loser_score) * die; }; const p1_time = timer.lap(); var p1_table = Table{}; //p1_table.buildRecursive(p1_init); p1_table.buildIterative(p1_init); var p2_table = Table{}; //p2_table.buildRecursive(p2_init); p2_table.buildIterative(p2_init); var p1_wins: u64 = 0; var p2_wins: u64 = 0; // Calculate wins by multiplying the number of universes where we win // by the number of unverses where the opponent had not already won. // Note the off by one for p1 because p1 plays first. for (p1_table.wins[1..]) |wins, turn| { p1_wins += wins * p2_table.alive[turn]; } for (p2_table.wins) |wins, turn| { p2_wins += wins * p1_table.alive[turn]; } const part2 = max(p1_wins, p2_wins); const p2_time = timer.lap(); print("part1={}, part2={}\n", .{part1, part2}); print("Times: part1={}, part2={}, total={}\n", .{p1_time, p2_time, p1_time + p2_time}); } // 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/day21.zig
usingnamespace @cImport({ @cInclude("sys/ptrace.h"); }); const arch = @import("std").builtin.arch; // Regular register type pub const regT = switch (arch) { .x86_64 => c_ulonglong, .i386 => c_long, else => @compileError("Unsupported CPU architecture"), }; // Signed register type pub const sregT = switch (arch) { .x86_64 => c_longlong, .i386 => c_long, else => @compileError("Unsupported CPU architecture"), }; pub const registers = switch (arch) { .x86_64 => x86_64_registers, // .i386 => _i386_registers, else => @compileError("Unsupported CPU architecture"), }; pub const x86_64_registers = extern struct { r15: c_ulonglong, r14: c_ulonglong, r13: c_ulonglong, r12: c_ulonglong, rbp: c_ulonglong, rbx: c_ulonglong, r11: c_ulonglong, arg4: c_ulonglong, // r10 arg6: c_ulonglong, // r9 arg5: c_ulonglong, // r8 result: c_ulonglong, // syscall result after execution rcx: c_ulonglong, arg3: c_ulonglong, // rdx arg2: c_ulonglong, // rsi arg1: c_ulonglong, // rdi syscall: c_ulonglong, // the syscall number rip: c_ulonglong, cs: c_ulonglong, eflags: c_ulonglong, rsp: c_ulonglong, ss: c_ulonglong, fs_base: c_ulonglong, gs_base: c_ulonglong, ds: c_ulonglong, es: c_ulonglong, fs: c_ulonglong, gs: c_ulonglong, }; const _i386_registers = extern struct { arg1: c_long, // ebx arg2: c_long, // ecx arg3: c_long, // edx arg4: c_long, // esi arg5: c_long, // edi arg6: c_long, // ebp result: c_long, // syscall result after execution xds: c_long, xes: c_long, xfs: c_long, xgs: c_long, syscall: c_long, // the syscall number eip: c_long, xcs: c_long, eflags: c_long, esp: c_long, xss: c_long, }; // . // BACKUPS // . // Taken from zig-cache/o/*/cimport.zig:'user_regs_struct' after building with @cInclude("sys/user.h") const x86_64_registers_original = extern struct { r15: c_ulonglong, r14: c_ulonglong, r13: c_ulonglong, r12: c_ulonglong, rbp: c_ulonglong, rbx: c_ulonglong, r11: c_ulonglong, r10: c_ulonglong, r9: c_ulonglong, r8: c_ulonglong, rax: c_ulonglong, rcx: c_ulonglong, rdx: c_ulonglong, rsi: c_ulonglong, rdi: c_ulonglong, orig_rax: c_ulonglong, rip: c_ulonglong, cs: c_ulonglong, eflags: c_ulonglong, rsp: c_ulonglong, ss: c_ulonglong, fs_base: c_ulonglong, gs_base: c_ulonglong, ds: c_ulonglong, es: c_ulonglong, fs: c_ulonglong, gs: c_ulonglong, }; // Taken from zig-cache/o/*/cimport.zig after building with @cInclude("sys/user.h") and referencing user_regs_struct const _i386_registers_original = extern struct { ebx: c_long, ecx: c_long, edx: c_long, esi: c_long, edi: c_long, ebp: c_long, eax: c_long, xds: c_long, xes: c_long, xfs: c_long, xgs: c_long, orig_eax: c_long, eip: c_long, xcs: c_long, eflags: c_long, esp: c_long, xss: c_long, };
src/c.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const Sha224 = std.crypto.hash.sha2.Sha224; const Sha384 = std.crypto.hash.sha2.Sha384; const Sha512 = std.crypto.hash.sha2.Sha512; const Sha256 = std.crypto.hash.sha2.Sha256; const x509 = @import("x509.zig"); const SignatureAlgorithm = x509.Certificate.SignatureAlgorithm; const asn1 = @import("asn1.zig"); fn rsa_perform( allocator: Allocator, modulus: std.math.big.int.Const, exponent: std.math.big.int.Const, base: []const u8, ) !?std.math.big.int.Managed { // @TODO Better algorithm, make it faster. const curr_base_limbs = try allocator.alloc( usize, std.math.divCeil(usize, base.len, @sizeOf(usize)) catch unreachable, ); const curr_base_limb_bytes = @ptrCast([*]u8, curr_base_limbs)[0..base.len]; mem.copy(u8, curr_base_limb_bytes, base); mem.reverse(u8, curr_base_limb_bytes); var curr_base = (std.math.big.int.Mutable{ .limbs = curr_base_limbs, .positive = true, .len = curr_base_limbs.len, }).toManaged(allocator); defer curr_base.deinit(); var curr_exponent = try exponent.toManaged(allocator); defer curr_exponent.deinit(); var result = try std.math.big.int.Managed.initSet(allocator, @as(usize, 1)); // encrypted = signature ^ key.exponent MOD key.modulus while (curr_exponent.toConst().orderAgainstScalar(0) == .gt) { if (curr_exponent.isOdd()) { try result.ensureMulCapacity(result.toConst(), curr_base.toConst()); try result.mul(result.toConst(), curr_base.toConst()); try llmod(&result, modulus); } try curr_base.sqr(curr_base.toConst()); try llmod(&curr_base, modulus); try curr_exponent.shiftRight(curr_exponent, 1); } if (result.limbs.len * @sizeOf(usize) < base.len) return null; return result; } // res = res mod N fn llmod(res: *std.math.big.int.Managed, n: std.math.big.int.Const) !void { var temp = try std.math.big.int.Managed.init(res.allocator); defer temp.deinit(); try temp.divTrunc(res, res.toConst(), n); } pub fn algorithm_prefix(signature_algorithm: SignatureAlgorithm) ?[]const u8 { return switch (signature_algorithm.hash) { .none, .md5, .sha1 => null, .sha224 => &[_]u8{ 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1c, }, .sha256 => &[_]u8{ 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20, }, .sha384 => &[_]u8{ 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30, }, .sha512 => &[_]u8{ 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40, }, }; } pub fn sign( allocator: Allocator, signature_algorithm: SignatureAlgorithm, hash: []const u8, private_key: x509.PrivateKey, ) !?[]const u8 { // @TODO ECDSA signatures if (signature_algorithm.signature != .rsa or private_key != .rsa) return null; const signature_length = private_key.rsa.modulus.len * @sizeOf(usize); var sig_buf = try allocator.alloc(u8, signature_length); defer allocator.free(sig_buf); const prefix = algorithm_prefix(signature_algorithm) orelse return null; const first_prefix_idx = sig_buf.len - hash.len - prefix.len; const first_hash_idx = sig_buf.len - hash.len; // EM = 0x00 || 0x01 || PS || 0x00 || T sig_buf[0] = 0; sig_buf[1] = 1; mem.set(u8, sig_buf[2 .. first_prefix_idx - 1], 0xff); sig_buf[first_prefix_idx - 1] = 0; mem.copy(u8, sig_buf[first_prefix_idx..first_hash_idx], prefix); mem.copy(u8, sig_buf[first_hash_idx..], hash); const modulus = std.math.big.int.Const{ .limbs = private_key.rsa.modulus, .positive = true }; const exponent = std.math.big.int.Const{ .limbs = private_key.rsa.exponent, .positive = true }; var rsa_result = (try rsa_perform(allocator, modulus, exponent, sig_buf)) orelse return null; if (rsa_result.limbs.len * @sizeOf(usize) < signature_length) { rsa_result.deinit(); return null; } const enc_buf = @ptrCast([*]u8, rsa_result.limbs.ptr)[0..signature_length]; mem.reverse(u8, enc_buf); return allocator.resize( enc_buf.ptr[0 .. rsa_result.limbs.len * @sizeOf(usize)], signature_length, ); } pub fn verify_signature( allocator: Allocator, signature_algorithm: SignatureAlgorithm, signature: asn1.BitString, hash: []const u8, public_key: x509.PublicKey, ) !bool { // @TODO ECDSA algorithms if (public_key != .rsa or signature_algorithm.signature != .rsa) return false; const prefix = algorithm_prefix(signature_algorithm) orelse return false; // RSA hash verification with PKCS 1 V1_5 padding const modulus = std.math.big.int.Const{ .limbs = public_key.rsa.modulus, .positive = true }; const exponent = std.math.big.int.Const{ .limbs = public_key.rsa.exponent, .positive = true }; if (modulus.bitCountAbs() != signature.bit_len) return false; var rsa_result = (try rsa_perform(allocator, modulus, exponent, signature.data)) orelse return false; defer rsa_result.deinit(); if (rsa_result.limbs.len * @sizeOf(usize) < signature.data.len) return false; const enc_buf = @ptrCast([*]u8, rsa_result.limbs.ptr)[0..signature.data.len]; mem.reverse(u8, enc_buf); if (enc_buf[0] != 0x00 or enc_buf[1] != 0x01) return false; if (!mem.endsWith(u8, enc_buf, hash)) return false; if (!mem.endsWith(u8, enc_buf[0 .. enc_buf.len - hash.len], prefix)) return false; if (enc_buf[enc_buf.len - hash.len - prefix.len - 1] != 0x00) return false; for (enc_buf[2 .. enc_buf.len - hash.len - prefix.len - 1]) |c| { if (c != 0xff) return false; } return true; } pub fn certificate_verify_signature( allocator: Allocator, signature_algorithm: x509.Certificate.SignatureAlgorithm, signature: asn1.BitString, bytes: []const u8, public_key: x509.PublicKey, ) !bool { // @TODO ECDSA algorithms if (public_key != .rsa or signature_algorithm.signature != .rsa) return false; var hash_buf: [64]u8 = undefined; var hash: []u8 = undefined; switch (signature_algorithm.hash) { // Deprecated hash algos .none, .md5, .sha1 => return false, .sha224 => { Sha224.hash(bytes, hash_buf[0..28], .{}); hash = hash_buf[0..28]; }, .sha256 => { Sha256.hash(bytes, hash_buf[0..32], .{}); hash = hash_buf[0..32]; }, .sha384 => { Sha384.hash(bytes, hash_buf[0..48], .{}); hash = hash_buf[0..48]; }, .sha512 => { Sha512.hash(bytes, hash_buf[0..64], .{}); hash = &hash_buf; }, } return try verify_signature(allocator, signature_algorithm, signature, hash, public_key); }
src/pcks1-1_5.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 foreign import" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const module = try codebase.createEntity(.{}); const code = "@import"; var tokens = try tokenize(module, code); { const token = tokens.next().?; try expectEqual(token.get(components.TokenKind), .attribute_import); try expectEqual(token.get(components.Span), .{ .begin = .{ .column = 0, .row = 0 }, .end = .{ .column = 7, .row = 0 }, }); } try expectEqual(tokens.next(), null); } test "parse foreign import" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const module = try codebase.createEntity(.{}); const code = \\@import("console", "log") \\log(value: i64) void ; var tokens = try tokenize(module, code); try parse(module, &tokens); const top_level = module.get(components.TopLevel); const log = top_level.findString("log"); const overloads = log.get(components.Overloads).slice(); try expectEqual(overloads.len, 1); const function = overloads[0]; try expectEqual(function.get(components.AstKind), .function); try expectEqualStrings(literalOf(function.get(components.ForeignModule).entity), "console"); try expectEqualStrings(literalOf(function.get(components.ForeignName).entity), "log"); const parameters = function.get(components.Parameters).slice(); try expectEqual(parameters.len, 1); const parameter = parameters[0]; try expectEqualStrings(literalOf(parameter), "value"); try expectEqualStrings(literalOf(parameter.get(components.TypeAst).entity), "i64"); try expectEqualStrings(literalOf(function.get(components.ReturnTypeAst).entity), "void"); } test "parse foreign import with module and name inferred" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const module = try codebase.createEntity(.{}); const code = \\@import \\log(value: i64) void ; var tokens = try tokenize(module, code); try parse(module, &tokens); const top_level = module.get(components.TopLevel); const log = top_level.findString("log"); const overloads = log.get(components.Overloads).slice(); try expectEqual(overloads.len, 1); const function = overloads[0]; try expectEqual(function.get(components.AstKind), .function); try expectEqualStrings(literalOf(function.get(components.ForeignModule).entity), "host"); try expectEqualStrings(literalOf(function.get(components.ForeignName).entity), "log"); const parameters = function.get(components.Parameters).slice(); try expectEqual(parameters.len, 1); const parameter = parameters[0]; try expectEqualStrings(literalOf(parameter), "value"); try expectEqualStrings(literalOf(parameter.get(components.TypeAst).entity), "i64"); try expectEqualStrings(literalOf(function.get(components.ReturnTypeAst).entity), "void"); } test "analyze semantics of foreign import" { 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", \\@import("console", "log") \\log(value: i64) void \\ \\start() void { \\ log(10) \\} ); _ = try analyzeSemantics(codebase, fs, "foo.yeti"); 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.Void); const body = start.get(components.Body).slice(); try expectEqual(body.len, 1); const log = body[0]; try expectEqual(log.get(components.AstKind), .call); const arguments = log.get(components.Arguments).slice(); try expectEqual(arguments.len, 1); const callable = log.get(components.Callable).entity; try expectEqualStrings(literalOf(callable.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(callable.get(components.Name).entity), "log"); const parameters = callable.get(components.Parameters).slice(); try expectEqual(parameters.len, 1); try expectEqual(callable.get(components.ReturnType).entity, builtins.Void); const parameter = parameters[0]; try expectEqual(typeOf(parameter), builtins.I64); try expectEqualStrings(literalOf(parameter.get(components.Name).entity), "value"); } test "print wasm foreign import" { 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", \\@import("console", "log") \\log(value: i64) void \\ \\start() void { \\ log(10) \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); try codegen(module); const wasm = try printWasm(module); try expectEqualStrings(wasm, \\(module \\ \\ (import "console" "log" (func $foo/log..value.i64 (param $value i64))) \\ \\ (func $foo/start \\ (i64.const 10) \\ (call $foo/log..value.i64)) \\ \\ (export "_start" (func $foo/start))) ); }
src/tests/test_foreign_import.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 a void container for composing elements in a regular grid. /// It is a box that arranges the elements it contains from top to bottom and /// from left to right, but can distribute the elements in lines or in columns. /// The child elements are added to the control just like a vbox and hbox, sequentially. /// Then they are distributed accordingly the attributes ORIENTATION and NUMDIV. /// When ORIENTATION=HORIZONTAL children are distributed from left to right on /// the first line until NUMDIV, then on the second line, and so on. /// When ORIENTATION=VERTICAL children are distributed from top to bottom on /// the first column until NUMDIV, then on the second column, and so on. /// The number of lines and the number of columns can be easily obtained from /// the combination of these attributes: if (orientation==IGBOX_HORIZONTAL) /// num_lin = child_count / num_div num_col = num_div else num_lin = num_div /// num_col = child_count / num_div Notice that the total number of spaces can /// be larger than the number of actual children, the last line or column can /// be incomplete. /// The column sizes will be based only on the width of the children of the /// reference line, usually line 0. /// The line sizes will be based only on the height of the children of the /// reference column, usually column 0. /// It does not have a native representation. pub const GridBox = opaque { pub const CLASS_NAME = "gridbox"; pub const NATIVE_TYPE = iup.NativeType.Void; const Self = @This(); pub const OnUpDateAttribfromFontFn = 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; /// /// 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; /// /// 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; pub const OnLDestroyFn = fn (self: *Self) anyerror!void; pub const OnPostMessageFn = fn (self: *Self, arg0: [:0]const u8, arg1: i32, arg2: f64, arg3: *iup.Unknow) anyerror!void; /// /// NORMALIZESIZE (non inheritable): normalizes all children natural size to be /// the biggest natural size among the reference line and/or the reference column. /// All natural width will be set to the biggest width, and all natural height /// will be set to the biggest height according to is value. /// Can be NO, HORIZONTAL (width only), VERTICAL (height only) or BOTH. /// Default: "NO". /// Same as using IupNormalizer. /// Notice that this is different from the HOMOGENEOUS* attributes in the sense /// that the children will have their sizes changed. pub const NormalizeSize = enum { Horizontal, Vertical, Both, None, }; /// /// EXPANDCHILDREN (non inheritable): forces all children to expand in the /// given direction and to fully occupy its space available inside the box. /// Can be YES (both directions), HORIZONTAL, VERTICAL or NO. /// Default: "NO". /// This has the same effect as setting EXPAND on each child. pub const ExpandChildren = enum { Yes, Horizontal, Vertical, None, }; /// /// EXPAND (non inheritable*): The default value is "YES". /// See the documentation of the attribute for EXPAND inheritance. pub const Expand = enum { Yes, Horizontal, Vertical, HorizontalFree, VerticalFree, No, }; /// /// ORIENTATION (non inheritable): controls the distribution of the children in /// lines or in columns. /// Can be: HORIZONTAL or VERTICAL. /// Default: HORIZONTAL. pub const Orientation = enum { Horizontal, Vertical, }; /// /// 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". 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.*; } pub fn setChildren(self: *Initializer, tuple: anytype) Initializer { if (self.last_error) |_| return self.*; Self.appendChildren(self.ref, tuple) catch |err| { self.last_error = err; }; 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.*; } /// /// NORMALIZESIZE (non inheritable): normalizes all children natural size to be /// the biggest natural size among the reference line and/or the reference column. /// All natural width will be set to the biggest width, and all natural height /// will be set to the biggest height according to is value. /// Can be NO, HORIZONTAL (width only), VERTICAL (height only) or BOTH. /// Default: "NO". /// Same as using IupNormalizer. /// Notice that this is different from the HOMOGENEOUS* attributes in the sense /// that the children will have their sizes changed. pub fn setNormalizeSize(self: *Initializer, arg: ?NormalizeSize) Initializer { if (self.last_error) |_| return self.*; if (arg) |value| switch (value) { .Horizontal => interop.setStrAttribute(self.ref, "NORMALIZESIZE", .{}, "HORIZONTAL"), .Vertical => interop.setStrAttribute(self.ref, "NORMALIZESIZE", .{}, "VERTICAL"), .Both => interop.setStrAttribute(self.ref, "NORMALIZESIZE", .{}, "BOTH"), .None => interop.setStrAttribute(self.ref, "NORMALIZESIZE", .{}, "NONE"), } else { interop.clearAttribute(self.ref, "NORMALIZESIZE", .{}); } return self.*; } /// /// GAPLIN, CGAPLIN: Defines a vertical space in pixels between lines, CGAPLIN /// is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn setGapLin(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "GAPLIN", .{}, arg); return self.*; } pub fn setMaxSize(self: *Initializer, width: ?i32, height: ?i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self.ref, "MAXSIZE", .{}, value); return self.*; } /// /// EXPANDCHILDREN (non inheritable): forces all children to expand in the /// given direction and to fully occupy its space available inside the box. /// Can be YES (both directions), HORIZONTAL, VERTICAL or NO. /// Default: "NO". /// This has the same effect as setting EXPAND on each child. pub fn setExpandChildren(self: *Initializer, arg: ?ExpandChildren) Initializer { if (self.last_error) |_| return self.*; if (arg) |value| switch (value) { .Yes => interop.setStrAttribute(self.ref, "EXPANDCHILDREN", .{}, "YES"), .Horizontal => interop.setStrAttribute(self.ref, "EXPANDCHILDREN", .{}, "HORIZONTAL"), .Vertical => interop.setStrAttribute(self.ref, "EXPANDCHILDREN", .{}, "VERTICAL"), .None => interop.setStrAttribute(self.ref, "EXPANDCHILDREN", .{}, "NONE"), } else { interop.clearAttribute(self.ref, "EXPANDCHILDREN", .{}); } return self.*; } pub fn setPosition(self: *Initializer, x: i32, y: i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = iup.XYPos.intIntToString(&buffer, x, y, ','); interop.setStrAttribute(self.ref, "POSITION", .{}, value); return self.*; } pub fn setCanFocus(self: *Initializer, arg: bool) Initializer { if (self.last_error) |_| return self.*; interop.setBoolAttribute(self.ref, "CANFOCUS", .{}, arg); return self.*; } pub fn setVisible(self: *Initializer, arg: bool) Initializer { if (self.last_error) |_| return self.*; interop.setBoolAttribute(self.ref, "VISIBLE", .{}, arg); return self.*; } /// /// GAPCOL, CGAPCOL: Defines a horizontal space in pixels between columns, /// CGAPCOL is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn setCGapCol(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "CGAPCOL", .{}, arg); return self.*; } pub fn setTheme(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "THEME", .{}, arg); return self.*; } /// /// MARGIN, CMARGIN: Defines a margin in pixels, CMARGIN is in the same units /// of the SIZE attribute. /// Its value has the format "widthxheight", where width and height are integer /// values corresponding to the horizontal and vertical margins, respectively. /// Default: "0x0" (no margin). pub fn setCMargin(self: *Initializer, horiz: i32, vert: i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Margin.intIntToString(&buffer, horiz, vert); interop.setStrAttribute(self.ref, "CMARGIN", .{}, value); return self.*; } /// /// EXPAND (non inheritable*): The default value is "YES". /// See the documentation of the attribute for EXPAND inheritance. pub fn setExpand(self: *Initializer, arg: ?Expand) Initializer { if (self.last_error) |_| return self.*; if (arg) |value| switch (value) { .Yes => interop.setStrAttribute(self.ref, "EXPAND", .{}, "YES"), .Horizontal => interop.setStrAttribute(self.ref, "EXPAND", .{}, "HORIZONTAL"), .Vertical => interop.setStrAttribute(self.ref, "EXPAND", .{}, "VERTICAL"), .HorizontalFree => interop.setStrAttribute(self.ref, "EXPAND", .{}, "HORIZONTALFREE"), .VerticalFree => interop.setStrAttribute(self.ref, "EXPAND", .{}, "VERTICALFREE"), .No => interop.setStrAttribute(self.ref, "EXPAND", .{}, "NO"), } else { interop.clearAttribute(self.ref, "EXPAND", .{}); } return self.*; } /// /// SIZE, RASTERSIZE, FONT, CLIENTSIZE, CLIENTOFFSET, POSITION, MINSIZE, /// MAXSIZE, THEME: also accepted. pub fn setSize(self: *Initializer, width: ?i32, height: ?i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self.ref, "SIZE", .{}, value); return self.*; } /// /// GAPLIN, CGAPLIN: Defines a vertical space in pixels between lines, CGAPLIN /// is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn setCGapLin(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "CGAPLIN", .{}, arg); return self.*; } /// /// ORIENTATION (non inheritable): controls the distribution of the children in /// lines or in columns. /// Can be: HORIZONTAL or VERTICAL. /// Default: HORIZONTAL. pub fn setOrientation(self: *Initializer, arg: ?Orientation) Initializer { if (self.last_error) |_| return self.*; if (arg) |value| switch (value) { .Horizontal => interop.setStrAttribute(self.ref, "ORIENTATION", .{}, "HORIZONTAL"), .Vertical => interop.setStrAttribute(self.ref, "ORIENTATION", .{}, "VERTICAL"), } else { interop.clearAttribute(self.ref, "ORIENTATION", .{}); } return self.*; } pub fn setFontSize(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "FONTSIZE", .{}, arg); return self.*; } pub fn setUserSize(self: *Initializer, width: ?i32, height: ?i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self.ref, "USERSIZE", .{}, value); return self.*; } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn setNGapCol(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "NGAPCOL", .{}, arg); return self.*; } pub fn setPropagateFocus(self: *Initializer, arg: bool) Initializer { if (self.last_error) |_| return self.*; interop.setBoolAttribute(self.ref, "PROPAGATEFOCUS", .{}, 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". 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.*; } /// /// NMARGIN, NCMARGIN (non inheritable): Same as MARGIN but are non inheritable. pub fn setNMargin(self: *Initializer, horiz: i32, vert: i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Margin.intIntToString(&buffer, horiz, vert); interop.setStrAttribute(self.ref, "NMARGIN", .{}, value); return self.*; } pub fn setNormalizerGroup(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "NORMALIZERGROUP", .{}, arg); return self.*; } pub fn setRasterSize(self: *Initializer, width: ?i32, height: ?i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self.ref, "RASTERSIZE", .{}, value); return self.*; } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn setNcGapCol(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "NCGAPCOL", .{}, arg); return self.*; } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn setNGapLin(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "NGAPLIN", .{}, arg); return self.*; } pub fn setFontFace(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "FONTFACE", .{}, arg); return self.*; } /// /// NUMDIV: controls the number of divisions along the distribution according /// to ORIENTATION. /// When ORIENTATION=HORIZONTAL, NUMDIV is the number of columns, when /// ORIENTATION=VERTICAL, NUMDIV is the number of lines. /// When value is AUTO, its actual value will be calculated to fit the maximum /// number of elements in the orientation direction. /// Default: AUTO. pub fn setNumDiv(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "NUMDIV", .{}, arg); return self.*; } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn setNcGapLin(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "NCGAPLIN", .{}, 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.*; } pub fn setActive(self: *Initializer, arg: bool) Initializer { if (self.last_error) |_| return self.*; interop.setBoolAttribute(self.ref, "ACTIVE", .{}, arg); return self.*; } pub fn setExpandWeight(self: *Initializer, arg: f64) Initializer { if (self.last_error) |_| return self.*; interop.setDoubleAttribute(self.ref, "EXPANDWEIGHT", .{}, arg); return self.*; } pub fn setMinSize(self: *Initializer, width: ?i32, height: ?i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self.ref, "MINSIZE", .{}, value); return self.*; } pub fn setNTheme(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "NTHEME", .{}, arg); return self.*; } pub fn setFontStyle(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "FONTSTYLE", .{}, arg); return self.*; } /// /// GAPCOL, CGAPCOL: Defines a horizontal space in pixels between columns, /// CGAPCOL is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn setGapCol(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "GAPCOL", .{}, arg); return self.*; } /// /// NMARGIN, NCMARGIN (non inheritable): Same as MARGIN but are non inheritable. pub fn setNcMargin(self: *Initializer, horiz: i32, vert: i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Margin.intIntToString(&buffer, horiz, vert); interop.setStrAttribute(self.ref, "NCMARGIN", .{}, value); return self.*; } /// /// MARGIN, CMARGIN: Defines a margin in pixels, CMARGIN is in the same units /// of the SIZE attribute. /// Its value has the format "widthxheight", where width and height are integer /// values corresponding to the horizontal and vertical margins, respectively. /// Default: "0x0" (no margin). pub fn setMargin(self: *Initializer, horiz: i32, vert: i32) Initializer { if (self.last_error) |_| return self.*; var buffer: [128]u8 = undefined; var value = Margin.intIntToString(&buffer, horiz, vert); interop.setStrAttribute(self.ref, "MARGIN", .{}, value); 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.*; } /// /// 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 setUpDateAttribfromFontCallback(self: *Initializer, callback: ?OnUpDateAttribfromFontFn) Initializer { const Handler = CallbackHandler(Self, OnUpDateAttribfromFontFn, "UPDATEATTRIBFROMFONT_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.*; } /// /// 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.*; } /// /// 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.*; } pub fn setLDestroyCallback(self: *Initializer, callback: ?OnLDestroyFn) Initializer { const Handler = CallbackHandler(Self, OnLDestroyFn, "LDESTROY_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.*; } }; 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); } /// /// Adds a tuple of children pub fn appendChildren(self: *Self, tuple: anytype) !void { try Impl(Self).appendChildren(self, tuple); } /// /// Appends a child on this container /// child must be an Element or pub fn appendChild(self: *Self, child: anytype) !void { try Impl(Self).appendChild(self, child); } /// /// Returns a iterator for children elements. pub fn children(self: *Self) ChildrenIterator { return ChildrenIterator.init(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); } 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); } /// /// NORMALIZESIZE (non inheritable): normalizes all children natural size to be /// the biggest natural size among the reference line and/or the reference column. /// All natural width will be set to the biggest width, and all natural height /// will be set to the biggest height according to is value. /// Can be NO, HORIZONTAL (width only), VERTICAL (height only) or BOTH. /// Default: "NO". /// Same as using IupNormalizer. /// Notice that this is different from the HOMOGENEOUS* attributes in the sense /// that the children will have their sizes changed. pub fn getNormalizeSize(self: *Self) ?NormalizeSize { var ret = interop.getStrAttribute(self, "NORMALIZESIZE", .{}); if (std.ascii.eqlIgnoreCase("HORIZONTAL", ret)) return .Horizontal; if (std.ascii.eqlIgnoreCase("VERTICAL", ret)) return .Vertical; if (std.ascii.eqlIgnoreCase("BOTH", ret)) return .Both; if (std.ascii.eqlIgnoreCase("NONE", ret)) return .None; return null; } /// /// NORMALIZESIZE (non inheritable): normalizes all children natural size to be /// the biggest natural size among the reference line and/or the reference column. /// All natural width will be set to the biggest width, and all natural height /// will be set to the biggest height according to is value. /// Can be NO, HORIZONTAL (width only), VERTICAL (height only) or BOTH. /// Default: "NO". /// Same as using IupNormalizer. /// Notice that this is different from the HOMOGENEOUS* attributes in the sense /// that the children will have their sizes changed. pub fn setNormalizeSize(self: *Self, arg: ?NormalizeSize) void { if (arg) |value| switch (value) { .Horizontal => interop.setStrAttribute(self, "NORMALIZESIZE", .{}, "HORIZONTAL"), .Vertical => interop.setStrAttribute(self, "NORMALIZESIZE", .{}, "VERTICAL"), .Both => interop.setStrAttribute(self, "NORMALIZESIZE", .{}, "BOTH"), .None => interop.setStrAttribute(self, "NORMALIZESIZE", .{}, "NONE"), } else { interop.clearAttribute(self, "NORMALIZESIZE", .{}); } } /// /// GAPLIN, CGAPLIN: Defines a vertical space in pixels between lines, CGAPLIN /// is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn getGapLin(self: *Self) i32 { return interop.getIntAttribute(self, "GAPLIN", .{}); } /// /// GAPLIN, CGAPLIN: Defines a vertical space in pixels between lines, CGAPLIN /// is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn setGapLin(self: *Self, arg: i32) void { interop.setIntAttribute(self, "GAPLIN", .{}, arg); } pub fn getMaxSize(self: *Self) Size { var str = interop.getStrAttribute(self, "MAXSIZE", .{}); return Size.parse(str); } pub fn setMaxSize(self: *Self, width: ?i32, height: ?i32) void { var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self, "MAXSIZE", .{}, value); } /// /// EXPANDCHILDREN (non inheritable): forces all children to expand in the /// given direction and to fully occupy its space available inside the box. /// Can be YES (both directions), HORIZONTAL, VERTICAL or NO. /// Default: "NO". /// This has the same effect as setting EXPAND on each child. pub fn getExpandChildren(self: *Self) ?ExpandChildren { var ret = interop.getStrAttribute(self, "EXPANDCHILDREN", .{}); if (std.ascii.eqlIgnoreCase("YES", ret)) return .Yes; if (std.ascii.eqlIgnoreCase("HORIZONTAL", ret)) return .Horizontal; if (std.ascii.eqlIgnoreCase("VERTICAL", ret)) return .Vertical; if (std.ascii.eqlIgnoreCase("NONE", ret)) return .None; return null; } /// /// EXPANDCHILDREN (non inheritable): forces all children to expand in the /// given direction and to fully occupy its space available inside the box. /// Can be YES (both directions), HORIZONTAL, VERTICAL or NO. /// Default: "NO". /// This has the same effect as setting EXPAND on each child. pub fn setExpandChildren(self: *Self, arg: ?ExpandChildren) void { if (arg) |value| switch (value) { .Yes => interop.setStrAttribute(self, "EXPANDCHILDREN", .{}, "YES"), .Horizontal => interop.setStrAttribute(self, "EXPANDCHILDREN", .{}, "HORIZONTAL"), .Vertical => interop.setStrAttribute(self, "EXPANDCHILDREN", .{}, "VERTICAL"), .None => interop.setStrAttribute(self, "EXPANDCHILDREN", .{}, "NONE"), } else { interop.clearAttribute(self, "EXPANDCHILDREN", .{}); } } pub fn getPosition(self: *Self) iup.XYPos { var str = interop.getStrAttribute(self, "POSITION", .{}); return iup.XYPos.parse(str, ','); } pub fn setPosition(self: *Self, x: i32, y: i32) void { var buffer: [128]u8 = undefined; var value = iup.XYPos.intIntToString(&buffer, x, y, ','); interop.setStrAttribute(self, "POSITION", .{}, value); } pub fn getCanFocus(self: *Self) bool { return interop.getBoolAttribute(self, "CANFOCUS", .{}); } pub fn setCanFocus(self: *Self, arg: bool) void { interop.setBoolAttribute(self, "CANFOCUS", .{}, arg); } pub fn getVisible(self: *Self) bool { return interop.getBoolAttribute(self, "VISIBLE", .{}); } pub fn setVisible(self: *Self, arg: bool) void { interop.setBoolAttribute(self, "VISIBLE", .{}, arg); } /// /// GAPCOL, CGAPCOL: Defines a horizontal space in pixels between columns, /// CGAPCOL is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn getCGapCol(self: *Self) i32 { return interop.getIntAttribute(self, "CGAPCOL", .{}); } /// /// GAPCOL, CGAPCOL: Defines a horizontal space in pixels between columns, /// CGAPCOL is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn setCGapCol(self: *Self, arg: i32) void { interop.setIntAttribute(self, "CGAPCOL", .{}, arg); } pub fn getTheme(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "THEME", .{}); } pub fn setTheme(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "THEME", .{}, arg); } /// /// MARGIN, CMARGIN: Defines a margin in pixels, CMARGIN is in the same units /// of the SIZE attribute. /// Its value has the format "widthxheight", where width and height are integer /// values corresponding to the horizontal and vertical margins, respectively. /// Default: "0x0" (no margin). pub fn getCMargin(self: *Self) Margin { var str = interop.getStrAttribute(self, "CMARGIN", .{}); return Margin.parse(str); } /// /// MARGIN, CMARGIN: Defines a margin in pixels, CMARGIN is in the same units /// of the SIZE attribute. /// Its value has the format "widthxheight", where width and height are integer /// values corresponding to the horizontal and vertical margins, respectively. /// Default: "0x0" (no margin). pub fn setCMargin(self: *Self, horiz: i32, vert: i32) void { var buffer: [128]u8 = undefined; var value = Margin.intIntToString(&buffer, horiz, vert); interop.setStrAttribute(self, "CMARGIN", .{}, value); } /// /// EXPAND (non inheritable*): The default value is "YES". /// See the documentation of the attribute for EXPAND inheritance. pub fn getExpand(self: *Self) ?Expand { var ret = interop.getStrAttribute(self, "EXPAND", .{}); if (std.ascii.eqlIgnoreCase("YES", ret)) return .Yes; if (std.ascii.eqlIgnoreCase("HORIZONTAL", ret)) return .Horizontal; if (std.ascii.eqlIgnoreCase("VERTICAL", ret)) return .Vertical; if (std.ascii.eqlIgnoreCase("HORIZONTALFREE", ret)) return .HorizontalFree; if (std.ascii.eqlIgnoreCase("VERTICALFREE", ret)) return .VerticalFree; if (std.ascii.eqlIgnoreCase("NO", ret)) return .No; return null; } /// /// EXPAND (non inheritable*): The default value is "YES". /// See the documentation of the attribute for EXPAND inheritance. pub fn setExpand(self: *Self, arg: ?Expand) void { if (arg) |value| switch (value) { .Yes => interop.setStrAttribute(self, "EXPAND", .{}, "YES"), .Horizontal => interop.setStrAttribute(self, "EXPAND", .{}, "HORIZONTAL"), .Vertical => interop.setStrAttribute(self, "EXPAND", .{}, "VERTICAL"), .HorizontalFree => interop.setStrAttribute(self, "EXPAND", .{}, "HORIZONTALFREE"), .VerticalFree => interop.setStrAttribute(self, "EXPAND", .{}, "VERTICALFREE"), .No => interop.setStrAttribute(self, "EXPAND", .{}, "NO"), } else { interop.clearAttribute(self, "EXPAND", .{}); } } /// /// SIZE, RASTERSIZE, FONT, CLIENTSIZE, CLIENTOFFSET, POSITION, MINSIZE, /// MAXSIZE, THEME: also accepted. pub fn getSize(self: *Self) Size { var str = interop.getStrAttribute(self, "SIZE", .{}); return Size.parse(str); } /// /// SIZE, RASTERSIZE, FONT, CLIENTSIZE, CLIENTOFFSET, POSITION, MINSIZE, /// MAXSIZE, THEME: also accepted. pub fn setSize(self: *Self, width: ?i32, height: ?i32) void { var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self, "SIZE", .{}, value); } /// /// WID (read-only): returns -1 if mapped. pub fn getWId(self: *Self) i32 { return interop.getIntAttribute(self, "WID", .{}); } /// /// GAPLIN, CGAPLIN: Defines a vertical space in pixels between lines, CGAPLIN /// is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn getCGapLin(self: *Self) i32 { return interop.getIntAttribute(self, "CGAPLIN", .{}); } /// /// GAPLIN, CGAPLIN: Defines a vertical space in pixels between lines, CGAPLIN /// is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn setCGapLin(self: *Self, arg: i32) void { interop.setIntAttribute(self, "CGAPLIN", .{}, arg); } /// /// ORIENTATION (non inheritable): controls the distribution of the children in /// lines or in columns. /// Can be: HORIZONTAL or VERTICAL. /// Default: HORIZONTAL. pub fn getOrientation(self: *Self) ?Orientation { var ret = interop.getStrAttribute(self, "ORIENTATION", .{}); if (std.ascii.eqlIgnoreCase("HORIZONTAL", ret)) return .Horizontal; if (std.ascii.eqlIgnoreCase("VERTICAL", ret)) return .Vertical; return null; } /// /// ORIENTATION (non inheritable): controls the distribution of the children in /// lines or in columns. /// Can be: HORIZONTAL or VERTICAL. /// Default: HORIZONTAL. pub fn setOrientation(self: *Self, arg: ?Orientation) void { if (arg) |value| switch (value) { .Horizontal => interop.setStrAttribute(self, "ORIENTATION", .{}, "HORIZONTAL"), .Vertical => interop.setStrAttribute(self, "ORIENTATION", .{}, "VERTICAL"), } else { interop.clearAttribute(self, "ORIENTATION", .{}); } } pub fn getFontSize(self: *Self) i32 { return interop.getIntAttribute(self, "FONTSIZE", .{}); } pub fn setFontSize(self: *Self, arg: i32) void { interop.setIntAttribute(self, "FONTSIZE", .{}, arg); } pub fn getNaturalSize(self: *Self) Size { var str = interop.getStrAttribute(self, "NATURALSIZE", .{}); return Size.parse(str); } pub fn getUserSize(self: *Self) Size { var str = interop.getStrAttribute(self, "USERSIZE", .{}); return Size.parse(str); } pub fn setUserSize(self: *Self, width: ?i32, height: ?i32) void { var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self, "USERSIZE", .{}, value); } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn getNGapCol(self: *Self) i32 { return interop.getIntAttribute(self, "NGAPCOL", .{}); } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn setNGapCol(self: *Self, arg: i32) void { interop.setIntAttribute(self, "NGAPCOL", .{}, arg); } pub fn getPropagateFocus(self: *Self) bool { return interop.getBoolAttribute(self, "PROPAGATEFOCUS", .{}); } pub fn setPropagateFocus(self: *Self, arg: bool) void { interop.setBoolAttribute(self, "PROPAGATEFOCUS", .{}, 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". 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". 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", .{}); } } /// /// NMARGIN, NCMARGIN (non inheritable): Same as MARGIN but are non inheritable. pub fn getNMargin(self: *Self) Margin { var str = interop.getStrAttribute(self, "NMARGIN", .{}); return Margin.parse(str); } /// /// NMARGIN, NCMARGIN (non inheritable): Same as MARGIN but are non inheritable. pub fn setNMargin(self: *Self, horiz: i32, vert: i32) void { var buffer: [128]u8 = undefined; var value = Margin.intIntToString(&buffer, horiz, vert); interop.setStrAttribute(self, "NMARGIN", .{}, value); } pub fn getNormalizerGroup(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "NORMALIZERGROUP", .{}); } pub fn setNormalizerGroup(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "NORMALIZERGROUP", .{}, arg); } pub fn getRasterSize(self: *Self) Size { var str = interop.getStrAttribute(self, "RASTERSIZE", .{}); return Size.parse(str); } pub fn setRasterSize(self: *Self, width: ?i32, height: ?i32) void { var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self, "RASTERSIZE", .{}, value); } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn getNcGapCol(self: *Self) i32 { return interop.getIntAttribute(self, "NCGAPCOL", .{}); } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn setNcGapCol(self: *Self, arg: i32) void { interop.setIntAttribute(self, "NCGAPCOL", .{}, arg); } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn getNGapLin(self: *Self) i32 { return interop.getIntAttribute(self, "NGAPLIN", .{}); } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn setNGapLin(self: *Self, arg: i32) void { interop.setIntAttribute(self, "NGAPLIN", .{}, arg); } pub fn getFontFace(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "FONTFACE", .{}); } pub fn setFontFace(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "FONTFACE", .{}, arg); } /// /// NUMDIV: controls the number of divisions along the distribution according /// to ORIENTATION. /// When ORIENTATION=HORIZONTAL, NUMDIV is the number of columns, when /// ORIENTATION=VERTICAL, NUMDIV is the number of lines. /// When value is AUTO, its actual value will be calculated to fit the maximum /// number of elements in the orientation direction. /// Default: AUTO. pub fn getNumDiv(self: *Self) i32 { return interop.getIntAttribute(self, "NUMDIV", .{}); } /// /// NUMDIV: controls the number of divisions along the distribution according /// to ORIENTATION. /// When ORIENTATION=HORIZONTAL, NUMDIV is the number of columns, when /// ORIENTATION=VERTICAL, NUMDIV is the number of lines. /// When value is AUTO, its actual value will be calculated to fit the maximum /// number of elements in the orientation direction. /// Default: AUTO. pub fn setNumDiv(self: *Self, arg: i32) void { interop.setIntAttribute(self, "NUMDIV", .{}, arg); } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn getNcGapLin(self: *Self) i32 { return interop.getIntAttribute(self, "NCGAPLIN", .{}); } /// /// NGAPLIN, NCGAPLIN, NGAPCOL, NCGAPCOL (non inheritable): Same as *GAP* but /// are non inheritable. pub fn setNcGapLin(self: *Self, arg: i32) void { interop.setIntAttribute(self, "NCGAPLIN", .{}, 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); } /// /// NUMCOL (read-only): returns the number of columns. pub fn getNumCol(self: *Self) i32 { return interop.getIntAttribute(self, "NUMCOL", .{}); } pub fn getActive(self: *Self) bool { return interop.getBoolAttribute(self, "ACTIVE", .{}); } pub fn setActive(self: *Self, arg: bool) void { interop.setBoolAttribute(self, "ACTIVE", .{}, arg); } pub fn getExpandWeight(self: *Self) f64 { return interop.getDoubleAttribute(self, "EXPANDWEIGHT", .{}); } pub fn setExpandWeight(self: *Self, arg: f64) void { interop.setDoubleAttribute(self, "EXPANDWEIGHT", .{}, arg); } pub fn getMinSize(self: *Self) Size { var str = interop.getStrAttribute(self, "MINSIZE", .{}); return Size.parse(str); } pub fn setMinSize(self: *Self, width: ?i32, height: ?i32) void { var buffer: [128]u8 = undefined; var value = Size.intIntToString(&buffer, width, height); interop.setStrAttribute(self, "MINSIZE", .{}, value); } /// /// NUMLIN (read-only): returns the number of lines. pub fn getNumLin(self: *Self) i32 { return interop.getIntAttribute(self, "NUMLIN", .{}); } pub fn getNTheme(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "NTHEME", .{}); } pub fn setNTheme(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "NTHEME", .{}, arg); } pub fn getCharSize(self: *Self) Size { var str = interop.getStrAttribute(self, "CHARSIZE", .{}); return Size.parse(str); } pub fn getClientSize(self: *Self) Size { var str = interop.getStrAttribute(self, "CLIENTSIZE", .{}); return Size.parse(str); } pub fn getClientOffset(self: *Self) Size { var str = interop.getStrAttribute(self, "CLIENTOFFSET", .{}); return Size.parse(str); } pub fn getFontStyle(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "FONTSTYLE", .{}); } pub fn setFontStyle(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "FONTSTYLE", .{}, arg); } /// /// GAPCOL, CGAPCOL: Defines a horizontal space in pixels between columns, /// CGAPCOL is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn getGapCol(self: *Self) i32 { return interop.getIntAttribute(self, "GAPCOL", .{}); } /// /// GAPCOL, CGAPCOL: Defines a horizontal space in pixels between columns, /// CGAPCOL is in the same units of the SIZE attribute for the height. /// Default: "0". pub fn setGapCol(self: *Self, arg: i32) void { interop.setIntAttribute(self, "GAPCOL", .{}, arg); } /// /// NMARGIN, NCMARGIN (non inheritable): Same as MARGIN but are non inheritable. pub fn getNcMargin(self: *Self) Margin { var str = interop.getStrAttribute(self, "NCMARGIN", .{}); return Margin.parse(str); } /// /// NMARGIN, NCMARGIN (non inheritable): Same as MARGIN but are non inheritable. pub fn setNcMargin(self: *Self, horiz: i32, vert: i32) void { var buffer: [128]u8 = undefined; var value = Margin.intIntToString(&buffer, horiz, vert); interop.setStrAttribute(self, "NCMARGIN", .{}, value); } /// /// MARGIN, CMARGIN: Defines a margin in pixels, CMARGIN is in the same units /// of the SIZE attribute. /// Its value has the format "widthxheight", where width and height are integer /// values corresponding to the horizontal and vertical margins, respectively. /// Default: "0x0" (no margin). pub fn getMargin(self: *Self) Margin { var str = interop.getStrAttribute(self, "MARGIN", .{}); return Margin.parse(str); } /// /// MARGIN, CMARGIN: Defines a margin in pixels, CMARGIN is in the same units /// of the SIZE attribute. /// Its value has the format "widthxheight", where width and height are integer /// values corresponding to the horizontal and vertical margins, respectively. /// Default: "0x0" (no margin). pub fn setMargin(self: *Self, horiz: i32, vert: i32) void { var buffer: [128]u8 = undefined; var value = Margin.intIntToString(&buffer, horiz, vert); interop.setStrAttribute(self, "MARGIN", .{}, value); } 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); } /// /// 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 setUpDateAttribfromFontCallback(self: *Self, callback: ?OnUpDateAttribfromFontFn) void { const Handler = CallbackHandler(Self, OnUpDateAttribfromFontFn, "UPDATEATTRIBFROMFONT_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); } /// /// 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); } /// /// 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); } pub fn setLDestroyCallback(self: *Self, callback: ?OnLDestroyFn) void { const Handler = CallbackHandler(Self, OnLDestroyFn, "LDESTROY_CB"); Handler.setCallback(self, callback); } pub fn setPostMessageCallback(self: *Self, callback: ?OnPostMessageFn) void { const Handler = CallbackHandler(Self, OnPostMessageFn, "POSTMESSAGE_CB"); Handler.setCallback(self, callback); } }; test "GridBox HandleName" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setHandleName("Hello").unwrap()); defer item.deinit(); var ret = item.getHandleName(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "GridBox NormalizeSize" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNormalizeSize(.Horizontal).unwrap()); defer item.deinit(); var ret = item.getNormalizeSize(); try std.testing.expect(ret != null and ret.? == .Horizontal); } test "GridBox GapLin" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setGapLin(42).unwrap()); defer item.deinit(); var ret = item.getGapLin(); try std.testing.expect(ret == 42); } test "GridBox MaxSize" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setMaxSize(9, 10).unwrap()); defer item.deinit(); var ret = item.getMaxSize(); try std.testing.expect(ret.width != null and ret.width.? == 9 and ret.height != null and ret.height.? == 10); } test "GridBox ExpandChildren" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setExpandChildren(.Yes).unwrap()); defer item.deinit(); var ret = item.getExpandChildren(); try std.testing.expect(ret != null and ret.? == .Yes); } test "GridBox Position" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setPosition(9, 10).unwrap()); defer item.deinit(); var ret = item.getPosition(); try std.testing.expect(ret.x == 9 and ret.y == 10); } test "GridBox CanFocus" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setCanFocus(true).unwrap()); defer item.deinit(); var ret = item.getCanFocus(); try std.testing.expect(ret == true); } test "GridBox Visible" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setVisible(true).unwrap()); defer item.deinit(); var ret = item.getVisible(); try std.testing.expect(ret == true); } test "GridBox CGapCol" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setCGapCol(42).unwrap()); defer item.deinit(); var ret = item.getCGapCol(); try std.testing.expect(ret == 42); } test "GridBox Theme" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setTheme("Hello").unwrap()); defer item.deinit(); var ret = item.getTheme(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "GridBox CMargin" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setCMargin(9, 10).unwrap()); defer item.deinit(); var ret = item.getCMargin(); try std.testing.expect(ret.horiz == 9 and ret.vert == 10); } test "GridBox Expand" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setExpand(.Yes).unwrap()); defer item.deinit(); var ret = item.getExpand(); try std.testing.expect(ret != null and ret.? == .Yes); } test "GridBox Size" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setSize(9, 10).unwrap()); defer item.deinit(); var ret = item.getSize(); try std.testing.expect(ret.width != null and ret.width.? == 9 and ret.height != null and ret.height.? == 10); } test "GridBox CGapLin" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setCGapLin(42).unwrap()); defer item.deinit(); var ret = item.getCGapLin(); try std.testing.expect(ret == 42); } test "GridBox Orientation" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setOrientation(.Horizontal).unwrap()); defer item.deinit(); var ret = item.getOrientation(); try std.testing.expect(ret != null and ret.? == .Horizontal); } test "GridBox FontSize" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setFontSize(42).unwrap()); defer item.deinit(); var ret = item.getFontSize(); try std.testing.expect(ret == 42); } test "GridBox UserSize" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setUserSize(9, 10).unwrap()); defer item.deinit(); var ret = item.getUserSize(); try std.testing.expect(ret.width != null and ret.width.? == 9 and ret.height != null and ret.height.? == 10); } test "GridBox NGapCol" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNGapCol(42).unwrap()); defer item.deinit(); var ret = item.getNGapCol(); try std.testing.expect(ret == 42); } test "GridBox PropagateFocus" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setPropagateFocus(true).unwrap()); defer item.deinit(); var ret = item.getPropagateFocus(); try std.testing.expect(ret == true); } test "GridBox Floating" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setFloating(.Yes).unwrap()); defer item.deinit(); var ret = item.getFloating(); try std.testing.expect(ret != null and ret.? == .Yes); } test "GridBox NMargin" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNMargin(9, 10).unwrap()); defer item.deinit(); var ret = item.getNMargin(); try std.testing.expect(ret.horiz == 9 and ret.vert == 10); } test "GridBox NormalizerGroup" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNormalizerGroup("Hello").unwrap()); defer item.deinit(); var ret = item.getNormalizerGroup(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "GridBox RasterSize" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setRasterSize(9, 10).unwrap()); defer item.deinit(); var ret = item.getRasterSize(); try std.testing.expect(ret.width != null and ret.width.? == 9 and ret.height != null and ret.height.? == 10); } test "GridBox NcGapCol" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNcGapCol(42).unwrap()); defer item.deinit(); var ret = item.getNcGapCol(); try std.testing.expect(ret == 42); } test "GridBox NGapLin" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNGapLin(42).unwrap()); defer item.deinit(); var ret = item.getNGapLin(); try std.testing.expect(ret == 42); } test "GridBox FontFace" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setFontFace("Hello").unwrap()); defer item.deinit(); var ret = item.getFontFace(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "GridBox NumDiv" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNumDiv(42).unwrap()); defer item.deinit(); var ret = item.getNumDiv(); try std.testing.expect(ret == 42); } test "GridBox NcGapLin" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNcGapLin(42).unwrap()); defer item.deinit(); var ret = item.getNcGapLin(); try std.testing.expect(ret == 42); } test "GridBox Name" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setName("Hello").unwrap()); defer item.deinit(); var ret = item.getName(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "GridBox Active" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setActive(true).unwrap()); defer item.deinit(); var ret = item.getActive(); try std.testing.expect(ret == true); } test "GridBox ExpandWeight" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setExpandWeight(3.14).unwrap()); defer item.deinit(); var ret = item.getExpandWeight(); try std.testing.expect(ret == @as(f64, 3.14)); } test "GridBox MinSize" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setMinSize(9, 10).unwrap()); defer item.deinit(); var ret = item.getMinSize(); try std.testing.expect(ret.width != null and ret.width.? == 9 and ret.height != null and ret.height.? == 10); } test "GridBox NTheme" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNTheme("Hello").unwrap()); defer item.deinit(); var ret = item.getNTheme(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "GridBox FontStyle" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setFontStyle("Hello").unwrap()); defer item.deinit(); var ret = item.getFontStyle(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "GridBox GapCol" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setGapCol(42).unwrap()); defer item.deinit(); var ret = item.getGapCol(); try std.testing.expect(ret == 42); } test "GridBox NcMargin" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setNcMargin(9, 10).unwrap()); defer item.deinit(); var ret = item.getNcMargin(); try std.testing.expect(ret.horiz == 9 and ret.vert == 10); } test "GridBox Margin" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setMargin(9, 10).unwrap()); defer item.deinit(); var ret = item.getMargin(); try std.testing.expect(ret.horiz == 9 and ret.vert == 10); } test "GridBox Font" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.GridBox.init().setFont("Hello").unwrap()); defer item.deinit(); var ret = item.getFont(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); }
src/elements/grid_box.zig
const std = @import("std"); const panic = std.debug.panic; const builtin = @import("builtin"); const warn = std.debug.warn; const join = std.fs.path.join; const pi = std.math.pi; usingnamespace @import("c.zig"); const Shader = @import("shader.zig").Shader; const glm = @import("glm.zig"); const Mat4 = glm.Mat4; const Vec3 = glm.Vec3; const vec3 = glm.vec3; const translation = glm.translation; const rotation = glm.rotation; const perspective = glm.perspective; // settings const SCR_WIDTH: u32 = 1920; const SCR_HEIGHT: u32 = 1080; pub fn main() !void { const allocator = std.heap.page_allocator; const vertPath = try join(allocator, &[_][]const u8{ "shaders", "1_6_coordinate_systems.vert" }); const fragPath = try join(allocator, &[_][]const u8{ "shaders", "1_6_coordinate_systems.frag" }); const ok = glfwInit(); if (ok == 0) { panic("Failed to initialise GLFW\n", .{}); } defer glfwTerminate(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // glfw: initialize and configure var window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Learn OpenGL", null, null); if (window == null) { panic("Failed to create GLFW window\n", .{}); } glfwMakeContextCurrent(window); const resizeCallback = glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); // glad: load all OpenGL function pointers if (gladLoadGLLoader(@ptrCast(GLADloadproc, glfwGetProcAddress)) == 0) { panic("Failed to initialise GLAD\n", .{}); } glEnable(GL_DEPTH_TEST); // build and compile our shader program const ourShader = try Shader.init(allocator, vertPath, fragPath); // set up vertex data (and buffer(s)) and configure vertex attributes const vertices = [_]f32{ -0.5, -0.5, -0.5, 0.0, 0.0, 0.5, -0.5, -0.5, 1.0, 0.0, 0.5, 0.5, -0.5, 1.0, 1.0, 0.5, 0.5, -0.5, 1.0, 1.0, -0.5, 0.5, -0.5, 0.0, 1.0, -0.5, -0.5, -0.5, 0.0, 0.0, -0.5, -0.5, 0.5, 0.0, 0.0, 0.5, -0.5, 0.5, 1.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0, 0.5, 0.5, 0.5, 1.0, 1.0, -0.5, 0.5, 0.5, 0.0, 1.0, -0.5, -0.5, 0.5, 0.0, 0.0, -0.5, 0.5, 0.5, 1.0, 0.0, -0.5, 0.5, -0.5, 1.0, 1.0, -0.5, -0.5, -0.5, 0.0, 1.0, -0.5, -0.5, -0.5, 0.0, 1.0, -0.5, -0.5, 0.5, 0.0, 0.0, -0.5, 0.5, 0.5, 1.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, 0.5, 0.5, -0.5, 1.0, 1.0, 0.5, -0.5, -0.5, 0.0, 1.0, 0.5, -0.5, -0.5, 0.0, 1.0, 0.5, -0.5, 0.5, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, -0.5, -0.5, -0.5, 0.0, 1.0, 0.5, -0.5, -0.5, 1.0, 1.0, 0.5, -0.5, 0.5, 1.0, 0.0, 0.5, -0.5, 0.5, 1.0, 0.0, -0.5, -0.5, 0.5, 0.0, 0.0, -0.5, -0.5, -0.5, 0.0, 1.0, -0.5, 0.5, -0.5, 0.0, 1.0, 0.5, 0.5, -0.5, 1.0, 1.0, 0.5, 0.5, 0.5, 1.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, -0.5, 0.5, 0.5, 0.0, 0.0, -0.5, 0.5, -0.5, 0.0, 1.0, }; // world space positions of our cubes const cubePositions = [_]Vec3{ vec3(0.0, 0.0, 0.0), vec3(2.0, 5.0, -15.0), vec3(-1.5, -2.2, -2.5), vec3(-3.8, -2.0, -12.3), vec3(2.4, -0.4, -3.5), vec3(-1.7, 3.0, -7.5), vec3(1.3, -2.0, -2.5), vec3(1.5, 2.0, -2.5), vec3(1.5, 0.2, -1.5), vec3(-1.3, 1.0, -1.5), }; var VAO: c_uint = undefined; var VBO: c_uint = undefined; glGenVertexArrays(1, &VAO); defer glDeleteVertexArrays(1, &VAO); glGenBuffers(1, &VBO); defer glDeleteBuffers(1, &VBO); // bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s). glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, vertices.len * @sizeOf(f32), &vertices, GL_STATIC_DRAW); // position attribute glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * @sizeOf(f32), null); glEnableVertexAttribArray(0); // texture coord attribute glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * @sizeOf(f32), @intToPtr(*c_void, 3 * @sizeOf(f32))); glEnableVertexAttribArray(1); // load and create a texture var texture1: c_uint = undefined; var texture2: c_uint = undefined; // texture 1 glGenTextures(1, &texture1); glBindTexture(GL_TEXTURE_2D, texture1); // set the texture wrapping parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // set texture wrapping to GL_REPEAT (default wrapping method) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // set texture filtering parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // load image, create texture and generate mipmaps var width: c_int = undefined; var height: c_int = undefined; var nrChannels: c_int = undefined; stbi_set_flip_vertically_on_load(1); // tell stb_image.h to flip loaded texture's on the y-axis. // The FileSystem::getPath(...) is part of the GitHub repository so we can find files on any IDE/platform; replace it with your own image path. var data = stbi_load("textures/container.jpg", &width, &height, &nrChannels, 0); if (data != null) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); } else { warn("Failed to load texture\n", .{}); } stbi_image_free(data); // texture 2 glGenTextures(1, &texture2); glBindTexture(GL_TEXTURE_2D, texture2); // set the texture wrapping parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // set texture wrapping to GL_REPEAT (default wrapping method) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // set texture filtering parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // load image, create texture and generate mipmaps data = stbi_load("textures/awesomeface.png", &width, &height, &nrChannels, 0); if (data != null) { // note that the awesomeface.png has transparency and thus an alpha channel, so make sure to tell OpenGL the data type is of GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); } else { warn("Failed to load texture\n", .{}); } stbi_image_free(data); // tell opengl for each sampler to which texture unit it belongs to (only has to be done once) ourShader.use(); // don't forget to activate/use the shader before setting uniforms! // either set it manually like so: glUniform1i(glGetUniformLocation(ourShader.id, "texture1"), 0); // or set it via the texture class ourShader.setInt("texture2", 1); // render loop while (glfwWindowShouldClose(window) == 0) { // input processInput(window); // render glClearColor(0.2, 0.3, 0.3, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // also clear the depth buffer now! // bind textures on corresponding texture units glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture1); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture2); // activate shader ourShader.use(); // create transformations const view = translation(vec3(0.0, 0.0, -3.0)); const projection = perspective(45.0 / 180.0 * pi, @intToFloat(f32, SCR_WIDTH) / @intToFloat(f32, SCR_HEIGHT), 0.1, 100.0); // pass transformation matrices to the shader ourShader.setMat4("projection", projection); // note: currently we set the projection matrix each frame, but since the projection matrix rarely changes it's often best practice to set it outside the main loop only once. ourShader.setMat4("view", view); // render boxes glBindVertexArray(VAO); var i: usize = 0; while (i < 10) : (i += 1) { // calculate the model matrix for each object and pass it to shader before drawing var model = translation(cubePositions[i]); const angle = 20.0 * @intToFloat(f32, i); model = model.matmul(rotation(angle / 180.0 * pi, vec3(1.0, 0.3, 0.5))); ourShader.setMat4("model", model); glDrawArrays(GL_TRIANGLES, 0, 36); } // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.) glfwSwapBuffers(window); glfwPollEvents(); } } // process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly pub fn processInput(window: ?*GLFWwindow) callconv(.C) void { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, 1); } // glfw: whenever the window size changed (by OS or user resize) this callback function executes pub fn framebuffer_size_callback(window: ?*GLFWwindow, width: c_int, height: c_int) callconv(.C) void { // make sure the viewport matches the new window dimensions; note that width and // height will be significantly larger than specified on retina displays. glViewport(0, 0, width, height); }
src/1_6_coordinate_systems.zig
const std = @import("std"); const mem = std.mem; const testing = std.testing; const unicode = std.unicode; const cats = @import("ziglyph.zig").derived_general_category; const eaw = @import("ziglyph.zig").derived_east_asian_width; const emoji = @import("ziglyph.zig").emoji_data; const gbp = @import("ziglyph.zig").grapheme_break_property; const GraphemeIterator = @import("ziglyph.zig").GraphemeIterator; const isAsciiStr = @import("ascii.zig").isAsciiStr; const Word = @import("ziglyph.zig").Word; const WordIterator = Word.WordIterator; /// AmbiguousWidth determines the width of ambiguous characters according to the context. In an /// East Asian context, the width of ambiguous code points should be 2 (full), and 1 (half) /// in non-East Asian contexts. The most common use case is `half`. pub const AmbiguousWidth = enum(u2) { half = 1, full = 2, }; /// codePointWidth returns how many cells (or columns) wide `cp` should be when rendered in a /// fixed-width font. pub fn codePointWidth(cp: u21, am_width: AmbiguousWidth) i3 { if (cp == 0x000 or cp == 0x0005 or cp == 0x0007 or (cp >= 0x000A and cp <= 0x000F)) { // Control. return 0; } else if (cp == 0x0008 or cp == 0x007F) { // backspace and DEL return -1; } else if (cp == 0x00AD) { // soft-hyphen return 1; } else if (cp == 0x2E3A) { // two-em dash return 2; } else if (cp == 0x2E3B) { // three-em dash return 3; } else if (cats.isEnclosingMark(cp) or cats.isNonspacingMark(cp)) { // Combining Marks. return 0; } else if (cats.isFormat(cp) and (!(cp >= 0x0600 and cp <= 0x0605) and cp != 0x061C and cp != 0x06DD and cp != 0x08E2)) { // Format except Arabic. return 0; } else if ((cp >= 0x1160 and cp <= 0x11FF) or (cp >= 0x2060 and cp <= 0x206F) or (cp >= 0xFFF0 and cp <= 0xFFF8) or (cp >= 0xE0000 and cp <= 0xE0FFF)) { // Hangul syllable and ignorable. return 0; } else if ((cp >= 0x3400 and cp <= 0x4DBF) or (cp >= 0x4E00 and cp <= 0x9FFF) or (cp >= 0xF900 and cp <= 0xFAFF) or (cp >= 0x20000 and cp <= 0x2FFFD) or (cp >= 0x30000 and cp <= 0x3FFFD)) { return 2; } else if (eaw.isWide(cp) or eaw.isFullwidth(cp)) { return 2; } else if (gbp.isRegionalIndicator(cp)) { return 2; } else if (eaw.isAmbiguous(cp)) { return @enumToInt(am_width); } else { return 1; } } /// strWidth returns how many cells (or columns) wide `str` should be when rendered in a /// fixed-width font. pub fn strWidth(allocator: mem.Allocator, str: []const u8, am_width: AmbiguousWidth) !usize { var total: isize = 0; // ASCII bytes are all width == 1. if (try isAsciiStr(str)) { for (str) |b| { // Backspace and DEL if (b == 8 or b == 127) { total -= 1; continue; } // Control if (b < 32) continue; // All other ASCII. total += 1; } return if (total > 0) @intCast(usize, total) else 0; } var giter = try GraphemeIterator.init(allocator, str); defer giter.deinit(); while (giter.next()) |gc| { var cp_iter = (try unicode.Utf8View.init(gc.bytes)).iterator(); while (cp_iter.nextCodepoint()) |cp| { var w = codePointWidth(cp, am_width); if (w != 0) { // Only adding width of first non-zero-width code point. if (emoji.isExtendedPictographic(cp)) { if (cp_iter.nextCodepoint()) |ncp| { // emoji text sequence. if (ncp == 0xFE0E) w = 1; } } total += w; break; } } } return if (total > 0) @intCast(usize, total) else 0; } /// centers `str` in a new string of width `total_width` (in display cells) using `pad` as padding. /// Caller must free returned bytes. pub fn center(allocator: *mem.Allocator, str: []const u8, total_width: usize, pad: []const u8) ![]u8 { var str_width = try strWidth(allocator, str, .half); if (str_width > total_width) return error.StrTooLong; var pad_width = try strWidth(allocator, pad, .half); if (pad_width > total_width or str_width + pad_width > total_width) return error.PadTooLong; const margin_width = @divFloor((total_width - str_width), 2); if (pad_width > margin_width) return error.PadTooLong; const pads = @divFloor(margin_width, pad_width) * 2; var result = try allocator.alloc(u8, pads * pad.len + str.len); var bytes_index: usize = 0; var pads_index: usize = 0; while (pads_index < pads / 2) : (pads_index += 1) { mem.copy(u8, result[bytes_index..], pad); bytes_index += pad.len; } mem.copy(u8, result[bytes_index..], str); bytes_index += str.len; pads_index = 0; while (pads_index < pads / 2) : (pads_index += 1) { mem.copy(u8, result[bytes_index..], pad); bytes_index += pad.len; } return result; } /// padLeft returns a new string of width `total_width` (in display cells) using `pad` as padding /// on the left side. Caller must free returned bytes. pub fn padLeft(allocator: *mem.Allocator, str: []const u8, total_width: usize, pad: []const u8) ![]u8 { var str_width = try strWidth(allocator, str, .half); if (str_width > total_width) return error.StrTooLong; var pad_width = try strWidth(allocator, pad, .half); if (pad_width > total_width or str_width + pad_width > total_width) return error.PadTooLong; const margin_width = total_width - str_width; if (pad_width > margin_width) return error.PadTooLong; const pads = @divFloor(margin_width, pad_width); var result = try allocator.alloc(u8, pads * pad.len + str.len); var bytes_index: usize = 0; var pads_index: usize = 0; while (pads_index < pads) : (pads_index += 1) { mem.copy(u8, result[bytes_index..], pad); bytes_index += pad.len; } mem.copy(u8, result[bytes_index..], str); return result; } /// padRight returns a new string of width `total_width` (in display cells) using `pad` as padding /// on the right side. Caller must free returned bytes. pub fn padRight(allocator: *mem.Allocator, str: []const u8, total_width: usize, pad: []const u8) ![]u8 { var str_width = try strWidth(allocator, str, .half); if (str_width > total_width) return error.StrTooLong; var pad_width = try strWidth(allocator, pad, .half); if (pad_width > total_width or str_width + pad_width > total_width) return error.PadTooLong; const margin_width = total_width - str_width; if (pad_width > margin_width) return error.PadTooLong; const pads = @divFloor(margin_width, pad_width); var result = try allocator.alloc(u8, pads * pad.len + str.len); var bytes_index: usize = 0; var pads_index: usize = 0; mem.copy(u8, result[bytes_index..], str); bytes_index += str.len; while (pads_index < pads) : (pads_index += 1) { mem.copy(u8, result[bytes_index..], pad); bytes_index += pad.len; } return result; } /// Wraps a string approximately at the given number of colums per line. Threshold defines how far the last column of /// the last word can be from the edge. Caller must free returned bytes. pub fn wrap(allocator: *std.mem.Allocator, str: []const u8, columns: usize, threshold: usize) ![]u8 { var iter = try WordIterator.init(allocator, str); defer iter.deinit(); var result = std.ArrayList(u8).init(allocator); defer result.deinit(); var line_width: usize = 0; while (iter.next()) |word| { if (isLineBreak(word.bytes)) { try result.append(' '); continue; } try result.appendSlice(word.bytes); line_width += try strWidth(allocator, word.bytes, .half); if (line_width > columns or columns - line_width <= threshold) { try result.append('\n'); line_width = 0; } } return result.toOwnedSlice(); } fn isLineBreak(str: []const u8) bool { if (std.mem.eql(u8, str, "\r\n")) { return true; } else if (std.mem.eql(u8, str, "\r")) { return true; } else if (std.mem.eql(u8, str, "\n")) { return true; } else { return false; } } test "display_width Width" { var allocator = std.testing.allocator; try testing.expectEqual(@as(i8, -1), codePointWidth(0x0008, .half)); // \b try testing.expectEqual(@as(i8, 0), codePointWidth(0x0000, .half)); // null try testing.expectEqual(@as(i8, 0), codePointWidth(0x0005, .half)); // Cf try testing.expectEqual(@as(i8, 0), codePointWidth(0x0007, .half)); // \a BEL try testing.expectEqual(@as(i8, 0), codePointWidth(0x000A, .half)); // \n LF try testing.expectEqual(@as(i8, 0), codePointWidth(0x000B, .half)); // \v VT try testing.expectEqual(@as(i8, 0), codePointWidth(0x000C, .half)); // \f FF try testing.expectEqual(@as(i8, 0), codePointWidth(0x000D, .half)); // \r CR try testing.expectEqual(@as(i8, 0), codePointWidth(0x000E, .half)); // SQ try testing.expectEqual(@as(i8, 0), codePointWidth(0x000F, .half)); // SI try testing.expectEqual(@as(i8, 0), codePointWidth(0x070F, .half)); // Cf try testing.expectEqual(@as(i8, 1), codePointWidth(0x0603, .half)); // Cf Arabic try testing.expectEqual(@as(i8, 1), codePointWidth(0x00AD, .half)); // soft-hyphen try testing.expectEqual(@as(i8, 2), codePointWidth(0x2E3A, .half)); // two-em dash try testing.expectEqual(@as(i8, 3), codePointWidth(0x2E3B, .half)); // three-em dash try testing.expectEqual(@as(i8, 1), codePointWidth(0x00BD, .half)); // ambiguous halfwidth try testing.expectEqual(@as(i8, 2), codePointWidth(0x00BD, .full)); // ambiguous fullwidth try testing.expectEqual(@as(i8, 1), codePointWidth('é', .half)); try testing.expectEqual(@as(i8, 2), codePointWidth('😊', .half)); try testing.expectEqual(@as(i8, 2), codePointWidth('统', .half)); try testing.expectEqual(@as(usize, 5), try strWidth(allocator, "Hello\r\n", .half)); try testing.expectEqual(@as(usize, 1), try strWidth(allocator, "\u{0065}\u{0301}", .half)); try testing.expectEqual(@as(usize, 2), try strWidth(allocator, "\u{1F476}\u{1F3FF}\u{0308}\u{200D}\u{1F476}\u{1F3FF}", .half)); try testing.expectEqual(@as(usize, 8), try strWidth(allocator, "Hello 😊", .half)); try testing.expectEqual(@as(usize, 8), try strWidth(allocator, "Héllo 😊", .half)); try testing.expectEqual(@as(usize, 8), try strWidth(allocator, "Héllo :)", .half)); try testing.expectEqual(@as(usize, 8), try strWidth(allocator, "Héllo 🇪🇸", .half)); try testing.expectEqual(@as(usize, 2), try strWidth(allocator, "\u{26A1}", .half)); // Lone emoji try testing.expectEqual(@as(usize, 1), try strWidth(allocator, "\u{26A1}\u{FE0E}", .half)); // Text sequence try testing.expectEqual(@as(usize, 2), try strWidth(allocator, "\u{26A1}\u{FE0F}", .half)); // Presentation sequence try testing.expectEqual(@as(usize, 0), try strWidth(allocator, "A\x08", .half)); // Backspace try testing.expectEqual(@as(usize, 0), try strWidth(allocator, "\x7FA", .half)); // DEL try testing.expectEqual(@as(usize, 0), try strWidth(allocator, "\x7FA\x08\x08", .half)); // never less than o } test "display_width center" { var allocator = std.testing.allocator; var centered = try center(allocator, "abc", 9, "*"); defer allocator.free(centered); try testing.expectEqualSlices(u8, "***abc***", centered); allocator.free(centered); centered = try center(allocator, "w😊w", 10, "-"); try testing.expectEqualSlices(u8, "---w😊w---", centered); } test "display_width padLeft" { var allocator = std.testing.allocator; var right_aligned = try padLeft(allocator, "abc", 9, "*"); defer allocator.free(right_aligned); try testing.expectEqualSlices(u8, "******abc", right_aligned); allocator.free(right_aligned); right_aligned = try padLeft(allocator, "w😊w", 10, "-"); try testing.expectEqualSlices(u8, "------w😊w", right_aligned); } test "display_width padRight" { var allocator = std.testing.allocator; var left_aligned = try padRight(allocator, "abc", 9, "*"); defer allocator.free(left_aligned); try testing.expectEqualSlices(u8, "abc******", left_aligned); allocator.free(left_aligned); left_aligned = try padRight(allocator, "w😊w", 10, "-"); try testing.expectEqualSlices(u8, "w😊w------", left_aligned); } test "display_width wrap" { var allocator = std.testing.allocator; var input = "The quick brown fox\r\njumped over the lazy dog!"; var got = try wrap(allocator, input, 10, 3); defer allocator.free(got); var want = "The quick\n brown \nfox jumped\n over the\n lazy dog\n!"; try testing.expectEqualStrings(want, got); }
.gyro/ziglyph-jecolon-github.com-c37d93b6/pkg/src/display_width.zig
const stdx = @import("../stdx.zig"); const t = stdx.testing; const math = @import("math.zig"); const log = stdx.log.scoped(.matrix); const Vec4 = [4]f32; // Row-major order. pub const Mat4 = [16]f32; // Because we're using row major order, we prefer to do mat * vec where vec is on the right side. // In theory it should be faster since more contiguous memory is accessed in order from the bigger matrix on the left. pub fn mul4x4_4x1(a: Mat4, b: Vec4) Vec4 { const stride = 4; const r0 = 0 * stride; const r1 = 1 * stride; const r2 = 2 * stride; const r3 = 3 * stride; const a00 = a[r0 + 0]; const a01 = a[r0 + 1]; const a02 = a[r0 + 2]; const a03 = a[r0 + 3]; const a10 = a[r1 + 0]; const a11 = a[r1 + 1]; const a12 = a[r1 + 2]; const a13 = a[r1 + 3]; const a20 = a[r2 + 0]; const a21 = a[r2 + 1]; const a22 = a[r2 + 2]; const a23 = a[r2 + 3]; const a30 = a[r3 + 0]; const a31 = a[r3 + 1]; const a32 = a[r3 + 2]; const a33 = a[r3 + 3]; const b00 = b[0]; const b10 = b[1]; const b20 = b[2]; const b30 = b[3]; return .{ a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30, a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30, a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30, a30 * b00 + a31 * b10 + a32 * b20 + a33 * b30, }; } pub fn mul4x4_4x4(a: Mat4, b: Mat4) Mat4 { const stride = 4; const r0 = 0 * stride; const r1 = 1 * stride; const r2 = 2 * stride; const r3 = 3 * stride; const a00 = a[r0 + 0]; const a01 = a[r0 + 1]; const a02 = a[r0 + 2]; const a03 = a[r0 + 3]; const a10 = a[r1 + 0]; const a11 = a[r1 + 1]; const a12 = a[r1 + 2]; const a13 = a[r1 + 3]; const a20 = a[r2 + 0]; const a21 = a[r2 + 1]; const a22 = a[r2 + 2]; const a23 = a[r2 + 3]; const a30 = a[r3 + 0]; const a31 = a[r3 + 1]; const a32 = a[r3 + 2]; const a33 = a[r3 + 3]; const b00 = b[r0 + 0]; const b01 = b[r0 + 1]; const b02 = b[r0 + 2]; const b03 = b[r0 + 3]; const b10 = b[r1 + 0]; const b11 = b[r1 + 1]; const b12 = b[r1 + 2]; const b13 = b[r1 + 3]; const b20 = b[r2 + 0]; const b21 = b[r2 + 1]; const b22 = b[r2 + 2]; const b23 = b[r2 + 3]; const b30 = b[r3 + 0]; const b31 = b[r3 + 1]; const b32 = b[r3 + 2]; const b33 = b[r3 + 3]; return .{ // First row. a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30, a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31, a00 * b02 + a01 * b12 + a02 * b22 + a03 * b32, a00 * b03 + a01 * b13 + a02 * b23 + a03 * b33, a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30, a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31, a10 * b02 + a11 * b12 + a12 * b22 + a13 * b32, a10 * b03 + a11 * b13 + a12 * b23 + a13 * b33, a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30, a20 * b01 + a21 * b11 + a22 * b21 + a23 * b31, a20 * b02 + a21 * b12 + a22 * b22 + a23 * b32, a20 * b03 + a21 * b13 + a22 * b23 + a23 * b33, a30 * b00 + a31 * b10 + a32 * b20 + a33 * b30, a30 * b01 + a31 * b11 + a32 * b21 + a33 * b31, a30 * b02 + a31 * b12 + a32 * b22 + a33 * b32, a30 * b03 + a31 * b13 + a32 * b23 + a33 * b33, }; } pub fn transpose4x4(m: Mat4) Mat4 { return .{ m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15], }; } test "transpose4x4" { const m = Mat4{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, }; const mt = transpose4x4(m); try t.eq(mt, .{ 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, }); const mtt = transpose4x4(mt); try t.eq(mtt, m); } /// From Mesa's implementation of GLU. /// https://stackoverflow.com/questions/1148309/inverting-a-4x4-matrix pub fn invert4x4(m: Mat4, out: *Mat4) bool { var inv: [16]f32 = undefined; inv[0] = m[5] * m[10] * m[15] - m[5] * m[11] * m[14] - m[9] * m[6] * m[15] + m[9] * m[7] * m[14] + m[13] * m[6] * m[11] - m[13] * m[7] * m[10]; inv[4] = -m[4] * m[10] * m[15] + m[4] * m[11] * m[14] + m[8] * m[6] * m[15] - m[8] * m[7] * m[14] - m[12] * m[6] * m[11] + m[12] * m[7] * m[10]; inv[8] = m[4] * m[9] * m[15] - m[4] * m[11] * m[13] - m[8] * m[5] * m[15] + m[8] * m[7] * m[13] + m[12] * m[5] * m[11] - m[12] * m[7] * m[9]; inv[12] = -m[4] * m[9] * m[14] + m[4] * m[10] * m[13] + m[8] * m[5] * m[14] - m[8] * m[6] * m[13] - m[12] * m[5] * m[10] + m[12] * m[6] * m[9]; inv[1] = -m[1] * m[10] * m[15] + m[1] * m[11] * m[14] + m[9] * m[2] * m[15] - m[9] * m[3] * m[14] - m[13] * m[2] * m[11] + m[13] * m[3] * m[10]; inv[5] = m[0] * m[10] * m[15] - m[0] * m[11] * m[14] - m[8] * m[2] * m[15] + m[8] * m[3] * m[14] + m[12] * m[2] * m[11] - m[12] * m[3] * m[10]; inv[9] = -m[0] * m[9] * m[15] + m[0] * m[11] * m[13] + m[8] * m[1] * m[15] - m[8] * m[3] * m[13] - m[12] * m[1] * m[11] + m[12] * m[3] * m[9]; inv[13] = m[0] * m[9] * m[14] - m[0] * m[10] * m[13] - m[8] * m[1] * m[14] + m[8] * m[2] * m[13] + m[12] * m[1] * m[10] - m[12] * m[2] * m[9]; inv[2] = m[1] * m[6] * m[15] - m[1] * m[7] * m[14] - m[5] * m[2] * m[15] + m[5] * m[3] * m[14] + m[13] * m[2] * m[7] - m[13] * m[3] * m[6]; inv[6] = -m[0] * m[6] * m[15] + m[0] * m[7] * m[14] + m[4] * m[2] * m[15] - m[4] * m[3] * m[14] - m[12] * m[2] * m[7] + m[12] * m[3] * m[6]; inv[10] = m[0] * m[5] * m[15] - m[0] * m[7] * m[13] - m[4] * m[1] * m[15] + m[4] * m[3] * m[13] + m[12] * m[1] * m[7] - m[12] * m[3] * m[5]; inv[14] = -m[0] * m[5] * m[14] + m[0] * m[6] * m[13] + m[4] * m[1] * m[14] - m[4] * m[2] * m[13] - m[12] * m[1] * m[6] + m[12] * m[2] * m[5]; inv[3] = -m[1] * m[6] * m[11] + m[1] * m[7] * m[10] + m[5] * m[2] * m[11] - m[5] * m[3] * m[10] - m[9] * m[2] * m[7] + m[9] * m[3] * m[6]; inv[7] = m[0] * m[6] * m[11] - m[0] * m[7] * m[10] - m[4] * m[2] * m[11] + m[4] * m[3] * m[10] + m[8] * m[2] * m[7] - m[8] * m[3] * m[6]; inv[11] = -m[0] * m[5] * m[11] + m[0] * m[7] * m[9] + m[4] * m[1] * m[11] - m[4] * m[3] * m[9] - m[8] * m[1] * m[7] + m[8] * m[3] * m[5]; inv[15] = m[0] * m[5] * m[10] - m[0] * m[6] * m[9] - m[4] * m[1] * m[10] + m[4] * m[2] * m[9] + m[8] * m[1] * m[6] - m[8] * m[2] * m[5]; var det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12]; if (det == 0) { return false; } det = 1.0 / det; var i: u32 = 0; while (i < 16) : (i += 1) { out.*[i] = inv[i] * det; } return true; } test "invert4x4" { const a = Mat4{ 5, 2, 6, 2, 6, 2, 6, 3, 6, 2, 2, 6, 8, 8, 8, 7, }; var inv: Mat4 = undefined; t.setLogLevel(.debug); try t.eq(invert4x4(a, &inv), true); const exp = Mat4{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, }; const act = mul4x4_4x4(inv, a); for (act) |it, i| { try t.eqApproxEps(it, exp[i]); } }
stdx/math/matrix.zig
const module = @import("module.zig"); pub const Module = module.Module; pub const Layout = module.Layout; pub const TextMeasureId = module.TextMeasureId; pub const BuildContext = module.BuildContext; pub const RenderContext = module.RenderContext; pub const LayoutContext = module.LayoutContext; pub const EventContext = module.EventContext; pub const InitContext = module.InitContext; pub const ModuleContext = module.ModuleContext; pub const CommonContext = module.CommonContext; pub const IntervalId = module.IntervalId; pub const Event = module.Event; pub const IntervalEvent = module.IntervalEvent; pub const KeyDownEvent = module.KeyDownEvent; pub const KeyUpEvent = module.KeyUpEvent; pub const MouseDownEvent = module.MouseDownEvent; pub const MouseUpEvent = module.MouseUpEvent; pub const MouseMoveEvent = module.MouseMoveEvent; pub const MouseScrollEvent = module.MouseScrollEvent; const config = @import("config.zig"); pub const Config = config.Config; pub const Import = config.Import; const frame = @import("frame.zig"); pub const Frame = frame.Frame; pub const FrameId = frame.FrameId; pub const NullId = @import("std").math.maxInt(u32); pub const NullFrameId = frame.NullFrameId; pub const FrameListPtr = frame.FrameListPtr; pub const FramePropsPtr = frame.FramePropsPtr; const widget = @import("widget.zig"); pub const Node = widget.Node; pub const WidgetTypeId = widget.WidgetTypeId; pub const WidgetUserId = widget.WidgetUserId; pub const WidgetKey = widget.WidgetKey; pub const WidgetRef = widget.WidgetRef; pub const NodeRef = widget.NodeRef; pub const WidgetVTable = widget.WidgetVTable; pub const LayoutSize = widget.LayoutSize; pub const widgets = @import("widgets.zig"); const text = @import("text.zig"); pub const TextMeasure = text.TextMeasure; const tween = @import("tween.zig"); pub const Tween = tween.Tween; pub const SimpleTween = tween.SimpleTween; pub const VAlign = enum(u2) { Top = 0, Center = 1, Bottom = 2, }; pub const HAlign = enum(u2) { Left = 0, Center = 1, Right = 2, }; pub const FlexFit = enum(u2) { /// Prefers to fit exactly the available space. Exact = 0, /// Prefers to wrap the child. If the available space is less than the child's dimension, prefers to fit the available space. Shrink = 1, /// Like Shrink but in the case that the child size is less than the available space; instead of skipping the missing space to the next flex widget, /// that missing space is given to the next flex widget, which can make the next flex widget bigger than it's calculated flex size. ShrinkAndGive = 2, }; pub const FlexInfo = struct { val: u32, fit: FlexFit, }; /// Create a declaration function for a Widget. pub fn createDeclFn(comptime Widget: type) fn (*BuildContext, anytype) callconv(.Inline) FrameId { const S = struct { inline fn decl(c: *BuildContext, props: anytype) FrameId { return c.decl(Widget, props); } }; return S.decl; } pub const EventResult = enum(u1) { /// Allow event to propagate down to children. Continue = 0, /// Stop the event from propagating to children. Stop = 1, };
ui/src/ui.zig
const std = @import("std"); ////////////////////////////////////////////////////////////////////////////// // Transforms /// Transform is a 2D affine transformation matrix. /// It is the low level interface for positioning, scaling and rotating things. pub const Transform = extern struct { m: [3][2]f32, /// identity returns the identity matrix. pub fn identity() Transform { return Transform{.m = .{.{1, 0}, .{0, 1}, .{0, 0}}}; } /// translate adds translation to the given matrix according to the given x /// and y values. pub fn translate(t: Transform, dx: f32, dy: f32) Transform { return Transform{.m = .{ t.m[0], t.m[1], .{ t.m[0][0]*dx + t.m[1][0]*dy + t.m[2][0], t.m[0][1]*dx + t.m[1][1]*dy + t.m[2][1] } }}; } /// rotate adds counter-clockwise rotation by the given angle (in radians) // to the matrix. pub fn rotate(t: Transform, angle: f32) Transform { var sin = std.math.sin(angle); var cos = std.math.cos(angle); return Transform{.m = .{ .{cos*t.m[0][0] + sin*t.m[1][0], cos*t.m[0][1] + sin*t.m[1][1]}, .{cos*t.m[1][0] - sin*t.m[0][0], cos*t.m[1][1] - sin*t.m[0][1]}, t.m[2] }}; } /// scale adds scaling to the given matrix, with the scaling factors for x and /// y direction given separately. pub fn scale(t: Transform, x: f32, y: f32) Transform { return Transform{.m = .{ .{t.m[0][0] * x, t.m[0][1] * x}, .{t.m[1][0] * y, t.m[1][1] * y}, t.m[2] }}; } /// compose multiplies the two given matrixes. pub fn compose(t1: Transform, t2: Transform) Transform { return Transform{.m = .{ .{t2.m[0][0] * t1.m[0][0] + t2.m[0][1] * t1.m[1][0], t2.m[0][0] * t1.m[0][1] + t2.m[0][1] * t1.m[1][1]}, .{t2.m[1][0] * t1.m[0][0] + t2.m[1][1] * t1.m[1][0], t2.m[1][0] * t1.m[0][1] + t2.m[1][1] * t1.m[1][1]}, .{t2.m[2][0] * t1.m[0][0] + t2.m[2][1] * t1.m[1][0] + t1.m[2][0], t2.m[2][0] * t1.m[0][1] + t2.m[2][1] * t1.m[1][1] + t1.m[2][1]}, }}; } }; ////////////////////////////////////////////////////////////////////////////// // Rectangles fn RectangleImpl(comptime Self: type) type { return struct { /// translation returns a translation matrix that will translate the point /// (0,0) to the current center of the rectangle. pub fn translation(r: Self) Transform { return Transform.identity().translate(@intToFloat(f32, r.x) + @intToFloat(f32, r.width) / 2.0, @intToFloat(f32, r.y) + @intToFloat(f32, r.height) / 2.0); } /// transformation returns a transformation matrix that will transform a unit /// square at ((-0.5,-0.5), (0.5,-0.5), (0.5, 0.5), (-0.5, 0.5)) into the /// given rectangle. pub fn transformation(r: Self) Transform { return r.translation().scale(@intToFloat(f32, r.width), @intToFloat(f32, r.height)); } /// move modifies the rectangle's position by the given dx and dy values. pub fn move(r: Self, dx: i32, dy: i32) Self { return Self{.x = r.x + dx, .y = r.y + dy, .width = r.width, .height = r.height}; } /// grows the rectangle by the given dw and dh values, /// keeping its center point (i.e. dw and dh will be evenly distributed to /// the four edges). /// use negative values to shrink. pub fn grow(r: Self, dw: i32, dh: i32) Self { return Self{.x = r.x + @divTrunc(dw, 2), .y = r.y + @divTrunc(dh, 2), .width = @intCast(u31, @intCast(u31, r.width) - dw), .height = @intCast(u31, @intCast(u31, r.height) - dh)}; } /// scale will scale the rectangle by the given factors. pub fn scale(r: Self, factorX: f32, factorY: f32) Self { var ret = Self{.x = undefined, .y = undefined, .width = @floatToInt(u31, @intToFloat(f32, r.width) * factorX), .height = @floatToInt(u31, @intToFloat(f32, r.height) * factorY)}; ret.x = r.x + @intCast(i32, @divTrunc(r.width - ret.width, 2)); ret.y = r.y + @intCast(i32, @divTrunc(r.height - ret.height, 2)); return ret; } /// HAlign describse horizontal alignment. pub const HAlign = enum(c_int) { left, center, right }; /// VAlign describes vertical alignment. pub const VAlign = enum(c_int) { top, middle, bottom }; /// position takes a width and a height, and positions a rectangle with these /// dimensions inside the given rectangle. /// Horizontal and vertical alignment can be given with horiz and vert. pub fn position(r: Self, width: u31, height: u31, horiz: HAlign, vert: VAlign) Self { return Self{ .x = switch (horiz) { .left => r.x, .center => r.x + @rem(@intCast(u31, r.width) - width, 2), .right => r.x + @intCast(u31, r.width) - width }, .y = switch (vert) { .top => r.y + @intCast(u31, r.height) - height, .middle => r.y + @rem(@intCast(u31, r.height) - height, 2), .bottom => r.y }, .width = width, .height = height }; } }; } /// A Rectangle represents a rectangular area with given size and offset. /// This is the high-level API for positioning. pub const Rectangle = struct { x: i32, y: i32, width: u31, height: u31, usingnamespace RectangleImpl(@This()); pub fn from(r: CRectangle) Rectangle { var ret: Rectangle = undefined; inline for(std.meta.fields(Rectangle)) |fld| { @field(ret, fld.name) = @intCast(fld.field_type, @field(r, fld.name)); } return ret; } }; pub const CRectangle = extern struct { x: i32, y: i32, width: u32, height: u32, usingnamespace RectangleImpl(@This()); pub fn from(r: Rectangle) CRectangle { var ret: CRectangle = undefined; inline for(std.meta.fields(CRectangle)) |fld| { @field(ret, fld.name) = @field(r, fld.name); } return ret; } }; ////////////////////////////////////////////////////////////////////////////// // Images fn ImageImpl(comptime Self: type, comptime RectImpl: type) type { return struct { /// empty returns an empty image, which is not linked to a GPU texture. pub fn empty() Self { return Self{ .id = .invalid, .width = 0, .height = 0, .flipped = false, .has_alpha = false }; } /// isEmpty returns true iff the given image is linked to a GPU texture. pub fn isEmpty(i: Self) bool { return i.width == 0; } /// area returns a rectangle with lower left corner at (0,0) that has the /// image's width and height. pub fn area(i: Self) RectImpl { return RectImpl{.x = 0, .y = 0, .width = @intCast(u31, i.width), .height = @intCast(u31, i.height)}; } pub fn free(i: *Self) void { i.id.delete(); i.* = empty(); } }; } /// Image is an image in GPU memory, i.e. a texture. /// Images must be explicitly free'd using free(). /// Images can be created via the engine, you cannot load an image into GPU /// memory before initializing the engine. pub const Image = struct { id: gl.Texture, width: u31, height: u31, flipped: bool, has_alpha: bool, usingnamespace ImageImpl(@This(), Rectangle); /// draw draws the given image with the given engine. /// dst_area is the rectangle to draw into. /// src_area is the rectangle to draw from – give i.area() to draw the whole /// image. /// alpha defines the opacity of the image, with 255 being fully opaque and /// 0 being fully transparent (i.e. invisible). /// alpha is applied on top of the image's alpha channel, if it has one. pub fn draw(i: Image, e: *Engine, dst_area: Rectangle, src_area: Rectangle, alpha: u8) void { e.drawImage(i, dst_area.transformation(), src_area.transformation(), alpha); } /// drawAll is a convenience function that calls draw with i.area() as the /// src_area. pub fn drawAll(i: Image, e: *Engine, dst_area: Rectangle, alpha: u8) void { i.draw(e, dst_area, i.area(), alpha); } }; pub const CImage = extern struct { id: gl.Texture, width: u32, height: u32, flipped: bool, has_alpha: bool, usingnamespace ImageImpl(@This(), CRectangle); /// draw draws the given image with the given engine. /// dst_area is the rectangle to draw into. /// src_area is the rectangle to draw from – give i.area() to draw the whole /// image. /// alpha defines the opacity of the image, with 255 being fully opaque and /// 0 being fully transparent (i.e. invisible). /// alpha is applied on top of the image's alpha channel, if it has one. pub fn draw(i: CImage, e: *Engine, dst_area: CRectangle, src_area: CRectangle, alpha: u8) void { CEngineInterface.drawImage(e, i, dst_area.transformation(), src_area.transformation(), alpha); } /// drawAll is a convenience function that calls draw with i.area() as the /// src_area. pub fn drawAll(i: CImage, e: *Engine, dst_area: CRectangle, alpha: u8) void { draw(i, e, dst_area, i.area(), alpha); } }; ////////////////////////////////////////////////////////////////////////////// // Canvas pub const CanvasError = error { AlreadyClosed }; fn CanvasImpl(comptime Self: type, comptime ImgImpl: type, comptime RectImpl: type, comptime EngImpl: type) type { const len_type = std.meta.fieldInfo(ImgImpl, .width).field_type; return struct { fn reinstatePreviousFb(canvas: *Self) void { canvas.e.canvas_count -= 1; canvas.previous_framebuffer.bind(.buffer); canvas.framebuffer.delete(); canvas.framebuffer = .invalid; if (canvas.e.canvas_count == 0) { canvas.e.target_framebuffer = .{.width = canvas.e.window.width, .height = canvas.e.window.height}; } else { canvas.e.target_framebuffer = .{.width = canvas.prev_width, .height = canvas.prev_height}; } gl.viewport(0, 0, canvas.e.target_framebuffer.width, canvas.e.target_framebuffer.height); } pub fn create(e: *Engine, width: len_type, height: len_type, with_alpha: bool) !Self { var ret = Self{ .e = e, .previous_framebuffer = @intToEnum(gl.Framebuffer, @intCast(std.meta.Tag(gl.Framebuffer), gl.getInteger(.draw_framebuffer_binding))), .framebuffer = gl.Framebuffer.gen(), .target_image = EngImpl.genTexture(e, width, height, if (with_alpha) 3 else 4, true, null), .alpha = with_alpha, .prev_width = e.target_framebuffer.width, .prev_height = e.target_framebuffer.height, }; ret.framebuffer.texture2D(.buffer, .color0, .@"2d", ret.target_image.id, 0); if (e.backend == .ogl_32 or e.backend == .ogl_43) { gl.drawBuffers(&[_]gl.FramebufferAttachment{.color0}); } if (gl.Framebuffer.checkStatus(.buffer) != .complete) unreachable; gl.clearColor(0, 0, 0, 0); gl.clear(.{.color = true}); e.canvas_count += 1; return ret; } pub fn rectangle(canvas: *Self) RectImpl { return canvas.target_image.area(); } /// closes the canvas and returns the resulting Image. /// returns CanvasError.AlreadyClosed if either finish() or close() have /// already been called on this canvas. pub fn finish(canvas: *Self) !ImgImpl { if (canvas.framebuffer == .invalid) { return CanvasError.AlreadyClosed; } reinstatePreviousFb(canvas); return canvas.target_image; } /// closes the canvas, dropping the drawn image. /// does nothing if either close() or finish() has been called previously on /// this Canvas. /// Should be used with `defer` after creating a Canvas. pub fn close(canvas: *Self) void { if (canvas.framebuffer != .invalid) { reinstatePreviousFb(canvas); canvas.target_image.free(); } } }; } /// A Canvas is a surface you can draw onto. /// Creating a canvas will direct all OpenGL drawing commands onto the canvas. /// You can frame the canvas to create an Image of what you've drawn onto the /// canvas. /// Taking down the canvas will discard what you've drawn if you haven't already /// framed it. /// Canvases do stack, so it is safe to create a Canvas while another Canvas is /// active. If you take down or frame the new Canvas, the previous canvas will /// be active again. pub const Canvas = struct { e: *Engine, previous_framebuffer: gl.Framebuffer, framebuffer: gl.Framebuffer, target_image: Image, alpha: bool, prev_width: u32, prev_height: u32, usingnamespace CanvasImpl(@This(), Image, Rectangle, Engine.Impl); }; pub const CCanvas = extern struct { e: *Engine, previous_framebuffer: gl.Framebuffer, framebuffer: gl.Framebuffer, target_image: CImage, alpha: bool, prev_width: u32, prev_height: u32, usingnamespace CanvasImpl(@This(), CImage, CRectangle, CEngineInterface); }; ////////////////////////////////////////////////////////////////////////////// // Text rendering const ft = @cImport({ @cInclude("ft2build.h"); @cInclude("freetype/freetype.h"); @cInclude("freetype/ftmodapi.h"); @cInclude("freetype/fterrors.h"); }); const FreeTypeMemImpl = struct { fn userAllocator(memory: ft.FT_Memory) *std.mem.Allocator { return @ptrCast(*std.mem.Allocator, @alignCast(@alignOf(*std.mem.Allocator), memory.*.user)); } fn allocFunc(memory: ft.FT_Memory, size: c_long) callconv(.C) ?*c_void { const slice = userAllocator(memory).allocAdvanced(u8, @alignOf(usize), @intCast(usize, size) + @sizeOf(usize), .at_least) catch return null; const p = @ptrCast([*]usize, slice.ptr); p.* = @intCast(usize, size); return @ptrCast(*c_void, p+1); } fn freeFunc(memory: ft.FT_Memory, block: ?*c_void) callconv(.C) void { const p = @ptrCast([*]usize, @alignCast(@alignOf(usize), block orelse return)) - 1; const slice: []u8 = @ptrCast([*]u8, p)[0..p[0] + @sizeOf(usize)]; userAllocator(memory).free(slice); } fn reallocFunc(memory: ft.FT_Memory, cur_size: c_long, new_size: c_long, block: ?*c_void) callconv(.C) ?*c_void { const p = @ptrCast([*]usize, @alignCast(@alignOf(usize), block orelse return null)) - 1; const slice = @ptrCast([*]u8, p)[0..p[0] + @sizeOf(usize)]; const ret_slice = userAllocator(memory).realloc(slice, @intCast(usize, new_size) + @sizeOf(usize)) catch return null; const rp = @ptrCast([*]usize, ret_slice.ptr); rp.* = @intCast(usize, new_size); return @ptrCast(*c_void, rp+1); } }; pub const Font = extern struct { }; ////////////////////////////////////////////////////////////////////////////// // Engine const gl = @import("zgl"); const c = @cImport({ @cInclude("stb_image.h"); }); const ShaderError = error { CompilationFailed, LinkingFailed, AttributeProblem }; const EngineError = error { NoDebugAvailable, FreeTypeError, }; fn loadShader(src: []const u8, t: gl.ShaderType) !gl.Shader { var shader = gl.createShader(t); gl.shaderSource(shader, 1, &[_][]const u8{src}); errdefer gl.deleteShader(shader); gl.compileShader(shader); var compiled = gl.getShader(shader, gl.ShaderParameter.compile_status); if (compiled == 1) { return shader; } var log = try gl.getShaderInfoLog(shader, std.heap.c_allocator); defer std.heap.c_allocator.free(log); std.log.scoped(.zargo).err("error compiling shader: {s} –– shader source:\n{s}\n-- end shader source", .{log, src}); return ShaderError.CompilationFailed; } fn linkProgram(vs_src: []const u8, fs_src: []const u8) !gl.Program { var vertex_shader = try loadShader(vs_src, gl.ShaderType.vertex); errdefer gl.deleteShader(vertex_shader); var fragment_shader = try loadShader(fs_src, gl.ShaderType.fragment); errdefer gl.deleteShader(fragment_shader); var program = gl.createProgram(); errdefer gl.deleteProgram(program); gl.attachShader(program, vertex_shader); gl.attachShader(program, fragment_shader); gl.linkProgram(program); var linked = gl.getProgram(program, gl.ProgramParameter.link_status); if (linked == 1) { return program; } var log = try gl.getProgramInfoLog(program, std.heap.c_allocator); defer std.heap.c_allocator.free(log); std.log.scoped(.zargo).err("error compiling shader: {s}", .{log}); return ShaderError.LinkingFailed; } fn getUniformLocation(p: gl.Program, name: [:0]const u8) !u32 { if (gl.getUniformLocation(p, name)) |value| { return value; } std.log.scoped(.zargo).err("unable to get attribute '{s}' location\n", .{name}); return ShaderError.AttributeProblem; } fn getAttribLocation(p: gl.Program, name: [:0]const u8) !u32 { if (gl.getAttribLocation(p, name)) |value| { return value; } std.log.scoped(.zargo).err("unable to get attribute '{s}' location\n", .{name}); return ShaderError.AttributeProblem; } fn setUniformColor(id: u32, color: [4]u8) void { gl.uniform4f(id, @intToFloat(f32, color[0]) / 255.0, @intToFloat(f32, color[1]) / 255.0, @intToFloat(f32, color[2]) / 255.0, @intToFloat(f32, color[3]) / 255.0); } /// Backend defines the possible backends the engine can use. These are /// currently OpenGL 3.2, OpenGL 4.3, OpenGL ES 2.0, and OpenGL ES 3.1. /// The differences relevant to the engine are: /// /// * OpenGL 4.3 will enable you to turn on debug output and is the only /// backend with this capability. /// * OpenGL 3.2 is the only backend available on macOS. /// * OpenGL ES 2.0 is widely supported on mobile devices but does not let you /// use MSAA when drawing to a canvas. /// * OpenGL ES 3.1 is supported on a small number on recent devices and does /// let you use MSAA when drawing to a canvas. /// /// Other OpenGL versions are not supported as backends because they don't bring /// any relevant functionality. pub const Backend = enum(c_int) { ogl_32, ogl_43, ogles_20, ogles_31 }; const ShaderKind = enum { vertex, fragment }; const Shaders = struct { rect_vertex: []const u8, rect_fragment: []const u8, img_vertex: []const u8, img_fragment: []const u8, blend_vertex: []const u8, blend_fragment: []const u8, }; fn genShaders(comptime backend: Backend) Shaders { const builder = struct { fn versionDef() []const u8 { return switch (backend) { .ogl_32, .ogl_43 => "#version 150\n", .ogles_20, .ogles_31 => "#version 100\n", }; } fn attr(comptime def: []const u8) []const u8 { return switch (backend) { .ogl_32, .ogl_43 => "in ", .ogles_20, .ogles_31 => "attribute ", } ++ def ++ ";\n"; } fn uniform(comptime def: []const u8) []const u8 { return "uniform " ++ def ++ ";\n"; } fn varyOut(comptime def: []const u8) []const u8 { return switch (backend) { .ogl_32, .ogl_43 => "out ", .ogles_20, .ogles_31 => "varying ", } ++ def ++ ";\n"; } fn varyIn(comptime def: []const u8) []const u8 { return switch (backend) { .ogl_32, .ogl_43 => "in ", .ogles_20, .ogles_31 => "varying " } ++ def ++ ";\n"; } fn fragColorDef() []const u8 { return switch (backend) { .ogl_32, .ogl_43 => "out vec4 fragColor;\n", .ogles_20, .ogles_31 => "", }; } fn fragColor() []const u8 { return switch (backend) { .ogl_32, .ogl_43 => "fragColor", .ogles_20, .ogles_31 => "gl_FragColor", }; } fn texture(comptime args: []const u8) []const u8 { return switch (backend) { .ogl_32, .ogl_43 => "texture(", .ogles_20, .ogles_31 => "texture2D(", } ++ args ++ ")"; } fn precision(comptime def: []const u8) []const u8 { return "precision " ++ def ++ ";\n"; } fn matMult(comptime m: []const u8, comptime v: []const u8) []const u8 { return "vec2(" ++ m ++ "[0].x * " ++ v ++ ".x + " ++ m ++ "[1].x * " ++ v ++ ".y + " ++ m ++ "[2].x, " ++ m ++ "[0].y * " ++ v ++ ".x + " ++ m ++ "[1].y * " ++ v ++ ".y + " ++ m ++ "[2].y)"; } fn rect(comptime kind: ShaderKind) []const u8 { return switch(kind) { .vertex => versionDef() ++ uniform("vec2 u_transform[3]") ++ attr("vec2 a_position") ++ \\ void main() { \\ gl_Position = vec4( ++ matMult("u_transform", "a_position") ++ \\ , 0, 1 \\ ); \\ } , .fragment => versionDef() ++ precision("mediump float") ++ uniform("vec4 u_color") ++ fragColorDef() ++ "void main() {\n " ++ fragColor() ++ " = u_color;\n}", }; } fn img(comptime kind: ShaderKind) []const u8 { return switch(kind) { .vertex => versionDef() ++ uniform("vec2 u_src_transform[3]") ++ uniform("vec2 u_dst_transform[3]") ++ attr("vec2 a_position") ++ varyOut("vec2 v_texCoord") ++ \\ void main() { \\ gl_Position = vec4( ++ matMult("u_dst_transform", "a_position") ++ \\ , 0, 1); \\ v_texCoord = vec2( \\ u_src_transform[0].x * a_position.x + u_src_transform[1].x * a_position.y + u_src_transform[2].x, \\ u_src_transform[0].y * a_position.x + u_src_transform[1].y * a_position.y + u_src_transform[2].y \\ ); \\ } , .fragment => versionDef() ++ precision("mediump float") ++ varyIn("vec2 v_texCoord") ++ fragColorDef() ++ uniform("sampler2D s_texture") ++ uniform("float u_alpha") ++ \\ void main() { \\ vec4 c = ++ texture("s_texture, v_texCoord") ++ ";\n " ++ fragColor() ++ " = vec4(c.rgb, u_alpha * c.a);\n}", }; } fn blend(comptime kind: ShaderKind) []const u8 { return switch(kind) { .vertex => versionDef() ++ uniform("vec2 u_posTrans[3]") ++ uniform("vec2 u_texTrans[3]") ++ attr("vec2 a_position") ++ varyOut("vec2 v_texCoord") ++ \\ void main() { \\ gl_Position = vec4( ++ matMult("u_posTrans", "a_position") ++ \\ , 0, 1); \\ vec2 flipped = vec2(a_position.x, 1.0-a_position.y); \\ v_texCoord = ++ matMult("u_texTrans", "flipped") ++ \\ ; \\ } , .fragment => versionDef() ++ precision("mediump float") ++ varyIn("vec2 v_texCoord") ++ fragColorDef() ++ uniform("sampler2D s_texture") ++ uniform("vec4 u_primary") ++ uniform("vec4 u_secondary") ++ \\ void main() { \\ float a = ++ texture("s_texture, v_texCoord") ++ ".r;" ++ fragColor() ++ " = a * u_primary + (1.0-a) * u_secondary;" ++ \\ } }; } }; return .{ .rect_vertex = builder.rect(.vertex), .rect_fragment = builder.rect(.fragment), .img_vertex = builder.img(.vertex), .img_fragment = builder.img(.fragment), .blend_vertex = builder.blend(.vertex), .blend_fragment = builder.blend(.fragment), }; } fn EngineImpl(comptime Self: type, comptime RectImpl: type, comptime ImgImpl: type) type { const len_type = std.meta.fieldInfo(ImgImpl, .width).field_type; return struct { fn debugCallback(e: *const Self, source: gl.DebugSource, msg_type: gl.DebugMessageType, id: usize, severity: gl.DebugSeverity, message: []const u8) void { if (msg_type == .@"error") { std.log.scoped(.OpenGL).err("[{s}] {s}: {s}", .{@tagName(severity), @tagName(source), message}); } else if (severity != .notification) { std.log.scoped(.OpenGL).warn("[{s}|{s}] {s}: {s}", .{@tagName(msg_type), @tagName(severity), @tagName(source), message}); } else { std.log.scoped(.OpenGL).notice("[{s}|{s}] {s}: {s}", .{@tagName(msg_type), @tagName(severity), @tagName(source), message}); } } /// init initializes the engine and must be called once before using the /// engine. Before initializing the engine, you must create an OpenGL context. /// This is platform dependent and therefore not implemented by the engine. /// You can use libraries like GLFW or SDL to create a context. /// /// The backend you give must match the OpenGL context you created. /// If it doesn't, you will likely get errors from shader compilation. /// /// windows_width and window_height ought to be the size of your OpenGL /// context in pixels. Mind that this must be the *real* pixel size, not the /// virtual pixel size you may get if you have an HiDPI monitor. /// If your window is resizeable, you can change the window size later with /// setWindowSize. /// /// Only set debug to true if backend is ogl_43. No other backend supports /// debug output and will return an error. pub fn init(e: *Self, allocator: *std.mem.Allocator, backend: Backend, window_width: u32, window_height: u32, debug: bool) !void { e.backend = backend; if (debug) { if (backend != .ogl_43) { return EngineError.NoDebugAvailable; } gl.enable(gl.Capabilities.debug_output); gl.debugMessageCallback(e, debugCallback); //gl.debugMessageInsert(.application, .other, .notification, "initialized debug output"); } const vertices = [_]f32{0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0}; e.vbo = gl.genBuffer(); gl.bindBuffer(e.vbo, gl.BufferTarget.array_buffer); gl.bufferData(gl.BufferTarget.array_buffer, f32, &vertices, gl.BufferUsage.static_draw); switch (backend) { .ogl_32, .ogl_43 => { e.vao = gl.genVertexArray(); gl.bindVertexArray(e.vao); e.single_value_color = gl.PixelFormat.red; }, else => { e.vao = .invalid; e.single_value_color = gl.PixelFormat.luminance; }, } e.canvas_count = 0; const shaders = switch (backend) { .ogl_32 => genShaders(.ogl_32), .ogl_43 => genShaders(.ogl_43), .ogles_20 => genShaders(.ogles_20), .ogles_31 => genShaders(.ogles_31) }; var rect_proc = try linkProgram(shaders.rect_vertex, shaders.rect_fragment); errdefer gl.deleteProgram(rect_proc); e.rect_proc = .{ .p = rect_proc, .transform = try getUniformLocation(rect_proc, "u_transform"), .position = try getAttribLocation(rect_proc, "a_position"), .color = try getUniformLocation(rect_proc, "u_color"), }; var img_proc = try linkProgram(shaders.img_vertex, shaders.img_fragment); errdefer gl.deleteProgram(img_proc); e.img_proc = .{ .p = img_proc, .src_transform = try getUniformLocation(img_proc, "u_src_transform"), .dst_transform = try getUniformLocation(img_proc, "u_dst_transform"), .position = try getAttribLocation(img_proc, "a_position"), .texture = try getUniformLocation(img_proc, "s_texture"), .alpha = try getUniformLocation(img_proc, "u_alpha"), }; var blend_proc = try linkProgram(shaders.blend_vertex, shaders.blend_fragment); errdefer gl.deleteProgram(blend_proc); e.blend_proc = .{ .p = blend_proc, .posTrans = try getUniformLocation(blend_proc, "u_posTrans"), .texTrans = try getUniformLocation(blend_proc, "u_texTrans"), .position = try getAttribLocation(blend_proc, "a_position"), .texture = try getUniformLocation(blend_proc, "s_texture"), .primary = try getUniformLocation(blend_proc, "u_primary"), .secondary = try getUniformLocation(blend_proc, "u_secondary"), }; gl.disable(gl.Capabilities.depth_test); gl.depthMask(false); e.max_tex_size = gl.getInteger(gl.Parameter.max_texture_size); e.setWindowSize(window_width, window_height); e.freetype_memory = .{ .user = @ptrCast(*c_void, allocator), .alloc = FreeTypeMemImpl.allocFunc, .free = FreeTypeMemImpl.freeFunc, .realloc = FreeTypeMemImpl.reallocFunc, }; const ft_res = ft.FT_New_Library(&e.freetype_memory, &e.freetype_lib); if (ft_res != 0) { gl.deleteBuffer(e.vbo); if (e.vao != .invalid) { gl.deleteVertexArray(e.vao); } if (@hasField(ft, "FT_Error_String")) { const msg = std.mem.span(ft.FT_Error_String(ft_res)); std.log.scoped(.zargo).err("FreeType init error: {s}", .{msg}); } else { // FT_Error_String not supported in Raspberry Pi FreeType version. std.log.scoped(.zargo).err("FreeType init error", .{}); } return EngineError.FreeTypeError; } } /// setWindowSize updates the window size. /// The window size is the coordinate system for Rectangles and Transforms. pub fn setWindowSize(e: *Self, width: u32, height: u32) void { e.window = .{.width = width, .height = height}; if (e.canvas_count == 0) { e.target_framebuffer = .{.width = e.window.width, .height = e.window.height}; gl.viewport(0, 0, width, height); } e.view_transform = Transform.identity().translate(-1.0, -1.0).scale( 2.0 / @intToFloat(f32, width), 2.0 / @intToFloat(f32, height)); } pub fn area(e: *Self) RectImpl { return RectImpl{.x = 0, .y = 0, .width = @intCast(u31, e.window.width), .height = @intCast(u31, e.window.height)}; } /// clear clears the current framebuffer to be of the given color. pub fn clear(e: *Self, color: [4]u8) void { gl.clearColor(@intToFloat(f32, color[0])/255.0, @intToFloat(f32, color[1])/255.0, @intToFloat(f32, color[2])/255.0, @intToFloat(f32, color[3])/255.0); gl.clear(.{.color = true}); } /// close closes the engine. It must not be used after that. pub fn close(e: *Self) void { gl.deleteBuffer(e.vbo); if (e.vao != .invalid) { gl.deleteVertexArray(e.vao); } _ = ft.FT_Done_Library(e.freetype_lib); } /// fillUnit fills the unit square around (0,0) with the given color. /// The square is transformed by t before it is being filled. /// If copy_alpha is true, the alpha value of the color is copied into the /// framebuffer; if it is false, it will cause the rectangle to blend with the /// existing content according to the given alpha value. /// /// The target area spans from (0,0) to (window_width, window_height) if /// rendering to the primary framebuffer, or from (0,0) to (c.width, c.height) /// if rendering to the canvas c. pub fn fillUnit(e: *Self, t: Transform, color: [4]u8, copy_alpha: bool) void { if (!copy_alpha and color[3] != 255) { gl.enable(gl.Capabilities.blend); gl.blendFuncSeparate(gl.BlendFactor.src_alpha, gl.BlendFactor.one_minus_src_alpha, gl.BlendFactor.one_minus_dst_alpha, gl.BlendFactor.one); defer gl.disable(gl.Capabilities.blend); } gl.bindBuffer(e.vbo, gl.BufferTarget.array_buffer); if (e.vao != .invalid) { gl.bindVertexArray(e.vao); } gl.useProgram(e.rect_proc.p); gl.vertexAttribPointer(e.rect_proc.position, 2, gl.Type.float, false, 2*@sizeOf(f32), null); gl.enableVertexAttribArray(e.rect_proc.position); const it = toInternalCoords(e, t, false); setUniformColor(e.rect_proc.color, color); gl.uniform2fv(e.rect_proc.transform, &it.m); gl.drawArrays(gl.PrimitiveType.triangle_fan, 0, 4); } /// fillRect fills the given rectangle with the given color according to the /// semantic of fillUnit. pub fn fillRect(e: *Self, r: RectImpl, color: [4]u8, copy_alpha: bool) void { e.fillUnit(r.transformation(), color, copy_alpha); } /// blendUnit fills the unit square around (0,0) with two colors. /// The square is transformed by dst_transform before it is being filled. /// The two colors are mixed via the red channel of mask by mapping /// 0 to color1 and 255 to color2, the values in between doing linear blending. /// /// The area of the mask used for blending is the unit square around (0,0), /// transformed by src_transform. The result can be larger than the mask if /// the mask should be repeated. pub fn blendUnit(e: *Self, mask: ImgImpl, dst_transform: Transform, src_transform: Transform, color1: [4]u8, color2: [4]u8) void { gl.bindBuffer(e.vbo, gl.BufferTarget.array_buffer); if (e.vao != .invalid) { gl.bindVertexArray(e.vao); } gl.useProgram(e.blend_proc.p); gl.vertexAttribPointer(e.blend_proc.position, 2, gl.Type.float, false, 2*@sizeOf(f32), null); gl.enableVertexAttribArray(e.blend_proc.position); gl.activeTexture(gl.TextureUnit.texture_0); gl.bindTexture(mask.id, gl.TextureTarget.@"2d"); gl.uniform1i(e.blend_proc.texture, 0); const ist = Transform.identity().scale( 1.0 / @intToFloat(f32, mask.width), -1.0 / @intToFloat(f32, mask.height) ).compose(src_transform).translate(-0.5, -0.5); gl.uniform2fv(e.blend_proc.texTrans, &ist.m); const idt = toInternalCoords(e, dst_transform, false); gl.uniform2fv(e.blend_proc.posTrans, &idt.m); setUniformColor(e.blend_proc.primary, color1); setUniformColor(e.blend_proc.secondary, color2); gl.drawArrays(gl.PrimitiveType.triangle_fan, 0, 4); } /// blendRect fills the given rectangle a blend of the given colors according /// to the semantics of blendUnit, with src_rect being source area of the mask, /// which may be larger than the mask and will then cause to repeat it. pub fn blendRect(e: *Self, mask: ImgImpl, dst_rect: RectImpl, src_rect: RectImpl, color1: [4]u8, color2: [4]u8) void { blendUnit(e, mask, dst_rect.transformation(), src_rect.transformation(), color1, color2); } /// loadImage loads the image file at the given path into a texture. /// on failure, the returned image will be empty. pub fn loadImage(e: *Self, path: [:0]const u8) ImgImpl { var x: c_int = undefined; var y: c_int = undefined; var n: c_int = undefined; const pixels = c.stbi_load(path, &x, &y, &n, 0); defer c.stbi_image_free(pixels); return genTexture(e, @intCast(usize, x), @intCast(usize, y), @intCast(u8, n), false, pixels); } /// drawImage is the low-level version of Image.draw. The src_transform /// transforms the unit square around (0,0) into the rectangle you want /// to draw from (give i.area() to draw the whole image). /// The dst_transform transforms the unit square around (0,0) into the /// rectangle you want to draw into. /// The given alpha value will applied on top of an existing alpha value if /// the image has an alpha channel. pub fn drawImage(e: *Self, i: ImgImpl, dst_transform: Transform, src_transform: Transform, alpha: u8) void { if (alpha != 255 or i.has_alpha) { gl.enable(gl.Capabilities.blend); gl.blendFuncSeparate(gl.BlendFactor.src_alpha, gl.BlendFactor.one_minus_src_alpha, gl.BlendFactor.one_minus_dst_alpha, gl.BlendFactor.one); } gl.bindBuffer(e.vbo, .array_buffer); if (e.vao != .invalid) { gl.bindVertexArray(e.vao); } gl.useProgram(e.img_proc.p); gl.vertexAttribPointer(e.rect_proc.position, 2, gl.Type.float, false, 2*@sizeOf(f32), null); gl.enableVertexAttribArray(e.rect_proc.position); gl.activeTexture(gl.TextureUnit.texture_0); gl.bindTexture(i.id, gl.TextureTarget.@"2d"); gl.uniform1i(e.img_proc.texture, 0); gl.uniform1f(e.img_proc.alpha, @intToFloat(f32, alpha)/255.0); const ist = Transform.identity().scale( 1.0 / @intToFloat(f32, i.width), -1.0 / @intToFloat(f32, i.height) ).compose(src_transform).translate(-0.5, -0.5); gl.uniform2fv(e.img_proc.src_transform, &ist.m); const idt = toInternalCoords(e, dst_transform, false); gl.uniform2fv(e.img_proc.dst_transform, &idt.m); gl.drawArrays(gl.PrimitiveType.triangle_fan, 0, 4); if (alpha != 255 or i.has_alpha) { gl.disable(gl.Capabilities.blend); } } fn toInternalCoords(e: *Self, t: Transform, flip: bool) Transform { var r = e.view_transform.compose(t); if (flip) { r = r.scale(1.0, -1.0); } return r.translate(-0.5, -0.5); } fn genTexture(e: *Self, width: usize, height: usize, num_colors: u8, flipped: bool, pixels: ?[*]const u8) ImgImpl { const ret = gl.genTexture(); gl.bindTexture(ret, .@"2d"); gl.texParameter(.@"2d", .mag_filter, .linear); gl.texParameter(.@"2d", .min_filter, .linear); gl.texParameter(.@"2d", .wrap_s, .repeat); gl.texParameter(.@"2d", .wrap_t, .repeat); gl.pixelStore(.unpack_alignment, @intCast(usize, num_colors)); const gl_format = switch (num_colors) { 1 => e.single_value_color, 2, 3 => .rgb, 4 => .rgba, else => unreachable }; gl.textureImage2D(.@"2d", 0, gl_format, width, height, gl_format, gl.PixelType.unsigned_byte, pixels); return ImgImpl{ .id = ret, .width = @intCast(len_type, width), .height = @intCast(len_type, height), .flipped = flipped, .has_alpha = num_colors == 4, }; } }; } /// The Engine is the core of the API. /// You need to initialize an Engine with init() before doing any drawing. /// /// Giving debug=true will enable debug output, you should have created a /// debugging context for that. Non-debugging contexts are allowed not to /// provide any debugging output. pub const Engine = struct { backend: Backend, rect_proc: struct { p: gl.Program, transform: u32, position: u32, color: u32, }, img_proc: struct { p: gl.Program, src_transform: u32, dst_transform: u32, position: u32, texture: u32, alpha: u32, }, blend_proc: struct { p: gl.Program, posTrans: u32, texTrans: u32, position: u32, texture: u32, primary: u32, secondary: u32, }, window: struct { width: u32, height: u32, }, target_framebuffer: struct { width: u32, height: u32, }, view_transform: Transform, vao: gl.VertexArray, vbo: gl.Buffer, canvas_count: u8, max_tex_size: i32, single_value_color: gl.PixelFormat, freetype_memory: ft.FT_MemoryRec_, freetype_lib: ft.FT_Library, const Impl = EngineImpl(@This(), Rectangle, Image); usingnamespace Impl; pub const createCanvas = Canvas.create; }; pub const CEngineInterface = EngineImpl(Engine, CRectangle, CImage);
src/zargo.zig
const std = @import("std"); const cstr = std.cstr; pub const Flag = struct { name: [*:0]const u8, kind: enum { boolean, arg }, }; pub fn ParseResult(comptime flags: []const Flag) type { return struct { const Self = @This(); const FlagData = struct { name: [*:0]const u8, value: union { boolean: bool, arg: ?[*:0]const u8, }, }; /// Remaining args after the recognized flags args: [][*:0]const u8, /// Data obtained from parsed flags flag_data: [flags.len]FlagData = blk: { // Init all flags to false/null var flag_data: [flags.len]FlagData = undefined; inline for (flags) |flag, i| { flag_data[i] = switch (flag.kind) { .boolean => .{ .name = flag.name, .value = .{ .boolean = false }, }, .arg => .{ .name = flag.name, .value = .{ .arg = null }, }, }; } break :blk flag_data; }, pub fn boolFlag(self: Self, flag_name: [*:0]const u8) bool { for (self.flag_data) |flag_data| { if (cstr.cmp(flag_data.name, flag_name) == 0) return flag_data.value.boolean; } unreachable; // Invalid flag_name } pub fn argFlag(self: Self, flag_name: [*:0]const u8) ?[:0]const u8 { for (self.flag_data) |flag_data| { if (cstr.cmp(flag_data.name, flag_name) == 0) { return std.mem.span(flag_data.value.arg); } } unreachable; // Invalid flag_name } }; } pub fn parse(args: [][*:0]const u8, comptime flags: []const Flag) !ParseResult(flags) { var ret: ParseResult(flags) = .{ .args = undefined }; var arg_idx: usize = 0; while (arg_idx < args.len) : (arg_idx += 1) { var parsed_flag = false; inline for (flags) |flag, flag_idx| { if (cstr.cmp(flag.name, args[arg_idx]) == 0) { switch (flag.kind) { .boolean => ret.flag_data[flag_idx].value.boolean = true, .arg => { arg_idx += 1; if (arg_idx == args.len) { std.log.err("option '" ++ flag.name ++ "' requires an argument but none was provided!", .{}); return error.MissingFlagArgument; } ret.flag_data[flag_idx].value.arg = args[arg_idx]; }, } parsed_flag = true; } } if (!parsed_flag) break; } ret.args = args[arg_idx..]; return ret; }
src/flags.zig
const std = @import("std"); const io = @import("io.zig"); const Terminal = @import("tty.zig"); pub const InterruptHandler = fn (*CpuState) *CpuState; var irqHandlers = [_]?InterruptHandler{null} ** 32; pub fn setIRQHandler(irq: u4, handler: ?InterruptHandler) void { irqHandlers[irq] = handler; } export fn handle_interrupt(_cpu: *CpuState) *CpuState { const Kernel = @import("kernel"); var cpu = _cpu; switch (cpu.interrupt) { 0x00...0x1F => { // Exception // Terminal.setColors(.white, .magenta); var exception: []const u8 = switch (cpu.interrupt) { 0x00 => "Divide By Zero", 0x01 => "Debug", 0x02 => "Non Maskable Interrupt", 0x03 => "Breakpoint", 0x04 => "Overflow", 0x05 => "Bound Range", 0x06 => "Invalid Opcode", 0x07 => "Device Not Available", 0x08 => "Double Fault", 0x09 => "Coprocessor Segment Overrun", 0x0A => "Invalid TSS", 0x0B => "Segment not Present", 0x0C => "Stack Fault", 0x0D => "General Protection Fault", 0x0E => "Page Fault", 0x0F => "Reserved", 0x10 => "x87 Floating Point", 0x11 => "Alignment Check", 0x12 => "Machine Check", 0x13 => "SIMD Floating Point", 0x14...0x1D => "Reserved", 0x1E => "Security-sensitive event in Host", 0x1F => "Reserved", else => "Unknown", }; Terminal.println("Unhandled exception: {}", .{exception}); Terminal.println("{}", .{cpu}); if (cpu.interrupt == 0x0E) { const cr2 = asm volatile ("mov %%cr2, %[cr]" : [cr] "=r" (-> usize) ); const cr3 = asm volatile ("mov %%cr3, %[cr]" : [cr] "=r" (-> usize) ); Terminal.println("Page Fault when {1} address 0x{0X} from {3}: {2}", .{ cr2, if ((cpu.errorcode & 2) != 0) "writing" else "reading", if ((cpu.errorcode & 1) != 0) "access denied" else "page unmapped", if ((cpu.errorcode & 4) != 0) "userspace"[0..] else "kernelspace", }); } // Terminal.resetColors(); while (true) { asm volatile ( \\ cli \\ hlt ); } }, 0x20...0x2F => { // IRQ if (irqHandlers[cpu.interrupt - 0x20]) |handler| { cpu = handler(cpu); } else { Terminal.print("Unhandled IRQ{}:\r\n{}", .{ cpu.interrupt - 0x20, cpu }); } if (cpu.interrupt >= 0x28) { io.out(u8, 0xA0, 0x20); // ACK slave PIC } io.out(u8, 0x20, 0x20); // ACK master PIC }, 0x30 => { // assembler debug call // Kernel.debugCall(cpu); }, 0x40 => { while (true) { asm volatile ( \\ cli \\ hlt ); } }, // 0x41 => return Kernel.switchTask(.codeEditor), // 0x42 => return Kernel.switchTask(.spriteEditor), // 0x43 => return Kernel.switchTask(.tilemapEditor), // 0x44 => return Kernel.switchTask(.codeRunner), // 0x45 => return Kernel.switchTask(.splash), else => { Terminal.println("Unhandled interrupt: {}", .{cpu}); while (true) { asm volatile ( \\ cli \\ hlt ); } }, } return cpu; } export var idt: [256]Descriptor align(16) = undefined; pub fn init() void { comptime var i: usize = 0; inline while (i < idt.len) : (i += 1) { idt[i] = Descriptor.init(getInterruptStub(i), 0x08, .interruptGate, .bits32, 0, true); } asm volatile ("lidt idtp"); // Master-PIC initialisieren io.out(u8, 0x20, 0x11); // Initialisierungsbefehl fuer den PIC io.out(u8, 0x21, 0x20); // Interruptnummer fuer IRQ 0 io.out(u8, 0x21, 0x04); // An IRQ 2 haengt der Slave io.out(u8, 0x21, 0x01); // ICW 4 // Slave-PIC initialisieren io.out(u8, 0xa0, 0x11); // Initialisierungsbefehl fuer den PIC io.out(u8, 0xa1, 0x28); // Interruptnummer fuer IRQ 8 io.out(u8, 0xa1, 0x02); // An IRQ 2 haengt der Slave io.out(u8, 0xa1, 0x01); // ICW 4 } pub fn fireInterrupt(comptime intr: u32) void { asm volatile ("int %[i]" : : [i] "n" (intr) ); } pub fn enableIRQ(irqNum: u4) void { switch (irqNum) { 0...7 => { io.out(u8, 0x21, io.in(u8, 0x21) & ~(@as(u8, 1) << @intCast(u3, irqNum))); }, 8...15 => { io.out(u8, 0x21, io.in(u8, 0x21) & ~(@as(u8, 1) << @intCast(u3, irqNum - 8))); }, } } pub fn disableIRQ(irqNum: u4) void { switch (irqNum) { 0...7 => { io.out(u8, 0x21, io.in(u8, 0x21) | (@as(u8, 1) << @intCast(u3, irqNum))); }, 8...15 => { io.out(u8, 0x21, io.in(u8, 0x21) | (@as(u8, 1) << @intCast(u3, irqNum - 8))); }, } } pub fn enableAllIRQs() void { // Alle IRQs aktivieren (demaskieren) io.out(u8, 0x21, 0x0); io.out(u8, 0xa1, 0x0); } pub fn disableAllIRQs() void { // Alle IRQs aktivieren (demaskieren) io.out(u8, 0x21, 0xFF); io.out(u8, 0xa1, 0xFF); } pub fn enableExternalInterrupts() void { asm volatile ("sti"); } pub fn disableExternalInterrupts() void { asm volatile ("cli"); } pub const CpuState = packed struct { // Von Hand gesicherte Register eax: u32, ebx: u32, ecx: u32, edx: u32, esi: u32, edi: u32, ebp: u32, interrupt: u32, errorcode: u32, // Von der CPU gesichert eip: u32, cs: u32, eflags: u32, esp: u32, ss: u32, pub fn format( self: CpuState, comptime fmt: []const u8, options: std.fmt.FormatOptions, context: var, comptime Errors: type, comptime output: fn (@TypeOf(context), []const u8) Errors!void, ) Errors!void { Terminal.println("Format called", .{}); try std.fmt.format(context, Errors, output, " EAX={X:0>8} EBX={X:0>8} ECX={X:0>8} EDX={X:0>8}\r\n", .{ self.eax, self.ebx, self.ecx, self.edx }); try std.fmt.format(context, Errors, output, " ESI={X:0>8} EDI={X:0>8} EBP={X:0>8} EIP={X:0>8}\r\n", .{ self.esi, self.edi, self.ebp, self.eip }); try std.fmt.format(context, Errors, output, " INT={X:0>2} ERR={X:0>8} CS={X:0>8} FLG={X:0>8}\r\n", .{ self.interrupt, self.errorcode, self.cs, self.eflags }); try std.fmt.format(context, Errors, output, " ESP={X:0>8} SS={X:0>8}\r\n", .{ self.esp, self.ss }); } }; const InterruptType = enum(u3) { interruptGate = 0b110, trapGate = 0b111, taskGate = 0b101, }; const InterruptBits = enum(u1) { bits32 = 1, bits16 = 0, }; const Descriptor = packed struct { offset0: u16, // 0-15 Offset 0-15 Gibt das Offset des ISR innerhalb des Segments an. Wenn der entsprechende Interrupt auftritt, wird eip auf diesen Wert gesetzt. selector: u16, // 16-31 Selector Gibt den Selector des Codesegments an, in das beim Auftreten des Interrupts gewechselt werden soll. Im Allgemeinen ist dies das Kernel-Codesegment (Ring 0). ist: u3 = 0, // 32-34 000 / IST Gibt im LM den Index in die IST an, ansonsten 0! _0: u5 = 0, // 35-39 Reserviert Wird ignoriert type: InterruptType, // 40-42 Typ Gibt die Art des Interrupts an bits: InterruptBits, // 43 D Gibt an, ob es sich um ein 32bit- (1) oder um ein 16bit-Segment (0) handelt. // Im LM: Für 64-Bit LDT 0, ansonsten 1 _1: u1 = 0, // 44 0 privilege: u2, // 45-46 DPL Gibt das Descriptor Privilege Level an, das man braucht um diesen Interrupt aufrufen zu dürfen. enabled: bool, // 47 P Gibt an, ob dieser Eintrag benutzt wird. offset1: u16, // 48-63 Offset 16-31 pub fn init(offset: ?fn () callconv(.Naked) void, selector: u16, _type: InterruptType, bits: InterruptBits, privilege: u2, enabled: bool) Descriptor { const offset_val = @ptrToInt(offset); return Descriptor{ .offset0 = @truncate(u16, offset_val & 0xFFFF), .offset1 = @truncate(u16, (offset_val >> 16) & 0xFFFF), .selector = selector, .type = _type, .bits = bits, .privilege = privilege, .enabled = enabled, }; } }; comptime { std.debug.assert(@sizeOf(Descriptor) == 8); } const InterruptTable = packed struct { limit: u16, table: [*]Descriptor, }; export const idtp = InterruptTable{ .table = &idt, .limit = @sizeOf(@TypeOf(idt)) - 1, }; export fn common_isr_handler() callconv(.Naked) void { asm volatile ( \\ push %%ebp \\ push %%edi \\ push %%esi \\ push %%edx \\ push %%ecx \\ push %%ebx \\ push %%eax \\ \\ // Handler aufrufen \\ push %%esp \\ call handle_interrupt \\ mov %%eax, %%esp \\ \\ // CPU-Zustand wiederherstellen \\ pop %%eax \\ pop %%ebx \\ pop %%ecx \\ pop %%edx \\ pop %%esi \\ pop %%edi \\ pop %%ebp \\ \\ // Fehlercode und Interruptnummer vom Stack nehmen \\ add $8, %%esp \\ \\ // Ruecksprung zum unterbrochenen Code \\ iret ); } fn getInterruptStub(comptime i: u32) fn () callconv(.Naked) void { const Wrapper = struct { fn stub_with_zero() callconv(.Naked) void { asm volatile ( \\ pushl $0 \\ pushl %[nr] \\ jmp common_isr_handler : : [nr] "n" (i) ); } fn stub_with_errorcode() callconv(.Naked) void { asm volatile ( \\ pushl %[nr] \\ jmp common_isr_handler : : [nr] "n" (i) ); } }; return switch (i) { 8, 10...14, 17 => Wrapper.stub_with_errorcode, else => Wrapper.stub_with_zero, }; }
src/kernel/arch/x86/boot/idt.zig
const std = @import("std"); const Span = @import("basics.zig").Span; const ConstantOrBuffer = @import("trigger.zig").ConstantOrBuffer; const fc32bit: f32 = 1 << 32; inline fn sqr(v: f32) f32 { return v * v; } inline fn clamp01(v: f32) f32 { return if (v < 0.0) 0.0 else if (v > 1.0) 1.0 else v; } // 32-bit value into float with 23 bits precision inline fn utof23(x: u32) f32 { return @bitCast(f32, (x >> 9) | 0x3f800000) - 1; } // float from [0,1) into 0.32 unsigned fixed-point inline fn ftou32(v: f32) u32 { return @floatToInt(u32, v * fc32bit * 0.99995); } pub const TriSawOsc = struct { pub const num_outputs = 1; pub const num_temps = 0; pub const Params = struct { sample_rate: f32, freq: ConstantOrBuffer, color: f32, }; cnt: u32, t: f32, // TODO - remove (see below) pub fn init() TriSawOsc { return .{ .cnt = 0, .t = 0.0, }; } pub fn paint( self: *TriSawOsc, span: Span, outputs: [num_outputs][]f32, temps: [num_temps][]f32, note_id_changed: bool, params: Params, ) void { switch (params.freq) { .constant => |freq| { self.paintConstantFrequency( outputs[0][span.start..span.end], params.sample_rate, freq, params.color, ); }, .buffer => |freq| { self.paintControlledFrequency( outputs[0][span.start..span.end], params.sample_rate, freq[span.start..span.end], params.color, ); } } } fn paintConstantFrequency( self: *TriSawOsc, output: []f32, sample_rate: f32, freq: f32, color: f32, ) void { if (freq < 0 or freq > sample_rate / 8.0) { return; } // note: farbrausch code includes some explanatory comments. i've // preserved the variable names they used, but condensed the code var cnt = self.cnt; const SRfcobasefrq = fc32bit / sample_rate; const ifreq = @floatToInt(u32, SRfcobasefrq * freq); const brpt = ftou32(clamp01(color)); const gain = 0.7; const f = utof23(ifreq); const omf = 1.0 - f; const rcpf = 1.0 / f; const col = utof23(brpt); const c1 = gain / col; const c2 = -gain / (1.0 - col); var state = if ((cnt -% ifreq) < brpt) @as(u32, 3) else @as(u32, 0); var i: usize = 0; while (i < output.len) : (i += 1) { const p = utof23(cnt) - col; state = ((state << 1) | @boolToInt(cnt < brpt)) & 3; const s = state | (@as(u32, @boolToInt(cnt < ifreq)) << 2); output[i] += gain + switch (s) { 0b011 => c1 * (p + p - f), // up 0b000 => c2 * (p + p - f), // down 0b010 => rcpf * (c2 * sqr(p) - c1 * sqr(p - f)), // up down 0b101 => -rcpf * (gain + c2 * sqr(p + omf) - c1 * sqr(p)), // down up 0b111 => -rcpf * (gain + c1 * omf * (p + p + omf)), // up down up 0b100 => -rcpf * (gain + c2 * omf * (p + p + omf)), // down up down else => unreachable, }; cnt +%= ifreq; } self.cnt = cnt; } fn paintControlledFrequency( self: *TriSawOsc, output: []f32, sample_rate: f32, freq: []const f32, color: f32, ) void { // TODO - implement color properly // TODO - rewrite using self.cnt and get rid of self.t // TODO - antialiasing // TODO - add equivalent of the bad frequency check at the top of // paintConstantFrequency var t = self.t; const gain = 0.7; var i: usize = 0; while (i < output.len) : (i += 1) { var frac: f32 = undefined; if (color < 0.25 or color > 0.75) { // sawtooth frac = (t - std.math.floor(t)) * 2.0 - 1.0; } else { // triangle frac = t - std.math.floor(t); if (frac < 0.25) { frac = frac * 4.0; } else if (frac < 0.75) { frac = 1.0 - (frac - 0.25) * 4.0; } else { frac = (frac - 0.75) * 4.0 - 1.0; } } output[i] += gain * frac; t += freq[i] / sample_rate; } // it actually goes out of tune without this!... self.t = t - std.math.trunc(t); } };
src/zang/mod_trisawosc.zig
const wlr = @import("../wlroots.zig"); const pixman = @import("pixman"); const std = @import("std"); const wayland = @import("wayland"); const wl = wayland.server.wl; const zwp = wayland.server.zwp; pub const PointerConstraintV1 = extern struct { pub const State = extern struct { pub const Field = packed struct { region: bool align(@alignOf(u32)) = false, cursor_hint: bool = false, _: u30 = 0, comptime { std.debug.assert(@sizeOf(@This()) == @sizeOf(u32)); std.debug.assert(@alignOf(@This()) == @alignOf(u32)); } }; committed: Field, region: pixman.Region32, cursor_hint: extern struct { x: f64, y: f64, }, }; pub const Type = enum(c_int) { locked, confined, }; pointer_constraints: *PointerConstraintsV1, resource: *wl.Resource, surface: *wlr.Surface, seat: *wlr.Seat, lifetime: zwp.PointerConstraintsV1.Lifetime, type: Type, region: pixman.Region32, current: State, pending: State, surface_commit: wl.Listener(*wlr.Surface), surface_destroy: wl.Listener(*wlr.Surface), seat_destroy: wl.Listener(*wl.Seat), link: wl.list.Link, events: extern struct { set_region: wl.Signal(void), destroy: wl.Signal(*PointerConstraintV1), }, data: usize, extern fn wlr_pointer_constraint_v1_send_activated(constraint: *PointerConstraintV1) void; pub const sendActivated = wlr_pointer_constraint_v1_send_activated; extern fn wlr_pointer_constraint_v1_send_deactivated(constraint: *PointerConstraintV1) void; pub const sendDeactivated = wlr_pointer_constraint_v1_send_deactivated; }; pub const PointerConstraintsV1 = extern struct { global: *wl.Global, constraints: wl.list.Head(PointerConstraintV1, "link"), events: extern struct { new_constraint: wl.Signal(*PointerConstraintV1), }, server_destroy: wl.Listener(*wl.Server), data: usize, extern fn wlr_pointer_constraints_v1_create(server: *wl.Server) ?*PointerConstraintsV1; pub fn create(server: *wl.Server) !*PointerConstraintsV1 { return wlr_pointer_constraints_v1_create(server) orelse error.OutOfMemory; } extern fn wlr_pointer_constraints_v1_constraint_for_surface(pointer_constraints: *PointerConstraintsV1, surface: *wlr.Surface, seat: *wlr.Seat) ?*PointerConstraintV1; pub const constraintForSurface = wlr_pointer_constraints_v1_constraint_for_surface; };
src/types/pointer_constraints_v1.zig
const std = @import("std"); // dross-zig const Vector3 = @import("vector3.zig").Vector3; // ----------------------------------------- // - Color - // ----------------------------------------- /// Color in rgba pub const Color = struct { r: f32 = 0.0, g: f32 = 0.0, b: f32 = 0.0, a: f32 = 1.0, const Self = @This(); /// Returns a color struct with the provided rgb values and a alpha of 1.0 /// Comment: Uses 0.0-1.0 formatting pub fn rgb(r: f32, g: f32, b: f32) Self { var new_color: Color = Color{ .r = r, .g = g, .b = b, .a = 1.0, }; return new_color; } /// Returns a color struct with the provided rgba values /// Comment: Uses 0.0-1.0 formatting pub fn rgba(r: f32, g: f32, b: f32, a: f32) Self { var new_color: Color = Color{ .r = r, .g = g, .b = b, .a = a, }; return new_color; } /// Returns a Vector3 filled with the Color's r, g, and b values respectively. pub fn toVector3(self: Self) Vector3 { return Vector3.new(self.r, self.g, self.b); } /// Returns a random color pub fn random() !Self { var prng = std.rand.DefaultPrng.init(blk: { var seed: u64 = undefined; try std.os.getrandom(std.mem.asBytes(&seed)); break :blk seed; }); const rand = &prng.random; return Self{ .r = rand.float(f32), .g = rand.float(f32), .b = rand.float(f32), .a = 1.0, }; } /// Returns a Color struct with the values (1.0, 1.0, 1.0, 1.0). pub fn white() Self { return .{ .r = 1.0, .g = 1.0, .b = 1.0, .a = 1.0, }; } /// Returns a Color struct with the values (0.0, 0.0, 0.0, 1.0). pub fn black() Self { return .{ .r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0, }; } /// Returns a Color struct with the values (1.0, 0.0, 0.0, 1.0). pub fn red() Self { return .{ .r = 1.0, .g = 0.0, .b = 0.0, .a = 1.0, }; } /// Returns a Color struct with the values (0.0, 0.0, 1.0, 1.0). pub fn blue() Self { return .{ .r = 0.0, .g = 0.0, .b = 1.0, .a = 1.0, }; } /// Returns a Color struct with the values (0.0, 1.0, 0.0, 1.0). pub fn green() Self { return .{ .r = 0.0, .g = 1.0, .b = 0.0, .a = 1.0, }; } /// Returns a Color struct with the values (0.28, 0.28, 0.28, 1.0). pub fn gray() Self { return .{ .r = 0.28, .g = 0.28, .b = 0.28, .a = 1.0, }; } /// Returns a Color struct with the values (0.12, 0.12, 0.12, 1.0). pub fn darkGray() Self { return .{ .r = 0.12, .g = 0.12, .b = 0.12, .a = 1.0, }; } };
src/core/color.zig
const std = @import("std"); const panic = std.debug.panic; const print = std.debug.print; const fmt = std.fmt; const ascii = std.ascii; const math = std.math; const alloc = std.heap.page_allocator; const ArrayList = std.ArrayList; const HashMap = std.AutoHashMap; var orders = ArrayList(i32).init(alloc); var device_joltage: i32 = math.minInt(i32); var nb_of_1_diff: i32 = 0; var nb_of_3_diff: i32 = 0; var nb_of_uniq_way: i128 = 0; pub fn main() !void { var adapters = HashMap(i32, bool).init(alloc); defer adapters.deinit(); try orders.append(0); defer orders.deinit(); var it = std.mem.tokenize(@embedFile("../inputs/day_10"), "\n"); while (it.next()) |line| { const adapter = try fmt.parseInt(i32, line, 0); device_joltage = math.max(device_joltage, adapter); try adapters.put(adapter, false); } device_joltage += 3; _ = find_chain(&adapters, 0); var pairs = HashMap(i32, i128).init(alloc); defer pairs.deinit(); for (orders.items) |n, i| { const diff = n - 3; var acc: i128 = 0; if (i == 0 or i == 1) { try pairs.put(n, 1); continue; } if (i != 2) { var key = orders.items[i - 3]; if (key >= diff) { if (pairs.get(key)) |v| { acc += v; } } } { var key = orders.items[i - 2]; if (key >= diff) { if (pairs.get(key)) |v| { acc += v; } } } { var key = orders.items[i - 1]; if (key >= diff) { if (pairs.get(key)) |v| { acc += v; } } } try pairs.put(n, acc); if (i == orders.items.len - 1) { nb_of_uniq_way = acc; } } print("ANSWER PART 1: {}\n", .{nb_of_1_diff * nb_of_3_diff}); print("ANSWER PART 2: {}\n", .{nb_of_uniq_way}); } fn find_chain(adapters: *HashMap(i32, bool), current: i32) bool { var iter = adapters.iterator(); if (current >= device_joltage - 3) { nb_of_3_diff += 1; return true; } var min_key: ?i32 = null; while (iter.next()) |n| { if (n.key > current and n.key <= current + 3 and !n.value) { if (min_key) |min| { min_key = math.min(min, n.key); } else { min_key = n.key; } } } if (min_key == null) { return false; } if (adapters.getEntry(min_key.?)) |entry| { if (entry.*.key == current + 1) { nb_of_1_diff += 1; } if (entry.*.key == current + 3) { nb_of_3_diff += 1; } orders.append(entry.*.key) catch unreachable; entry.*.value = true; } return find_chain(adapters, min_key.?); }
src/10.zig
pub const CLFS_FLAG_REENTRANT_FILE_SYSTEM = @as(u32, 8); pub const CLFS_FLAG_NON_REENTRANT_FILTER = @as(u32, 16); pub const CLFS_FLAG_REENTRANT_FILTER = @as(u32, 32); pub const CLFS_FLAG_IGNORE_SHARE_ACCESS = @as(u32, 64); pub const CLFS_FLAG_READ_IN_PROGRESS = @as(u32, 128); pub const CLFS_FLAG_MINIFILTER_LEVEL = @as(u32, 256); pub const CLFS_FLAG_HIDDEN_SYSTEM_LOG = @as(u32, 512); pub const CLFS_MARSHALLING_FLAG_NONE = @as(u32, 0); pub const CLFS_MARSHALLING_FLAG_DISABLE_BUFF_INIT = @as(u32, 1); pub const CLFS_FLAG_FILTER_INTERMEDIATE_LEVEL = @as(u32, 16); pub const CLFS_FLAG_FILTER_TOP_LEVEL = @as(u32, 32); pub const TRANSACTION_MANAGER_VOLATILE = @as(u32, 1); pub const TRANSACTION_MANAGER_COMMIT_DEFAULT = @as(u32, 0); pub const TRANSACTION_MANAGER_COMMIT_SYSTEM_VOLUME = @as(u32, 2); pub const TRANSACTION_MANAGER_COMMIT_SYSTEM_HIVES = @as(u32, 4); pub const TRANSACTION_MANAGER_COMMIT_LOWEST = @as(u32, 8); pub const TRANSACTION_MANAGER_CORRUPT_FOR_RECOVERY = @as(u32, 16); pub const TRANSACTION_MANAGER_CORRUPT_FOR_PROGRESS = @as(u32, 32); pub const TRANSACTION_MANAGER_MAXIMUM_OPTION = @as(u32, 63); pub const TRANSACTION_DO_NOT_PROMOTE = @as(u32, 1); pub const TRANSACTION_MAXIMUM_OPTION = @as(u32, 1); pub const RESOURCE_MANAGER_VOLATILE = @as(u32, 1); pub const RESOURCE_MANAGER_COMMUNICATION = @as(u32, 2); pub const RESOURCE_MANAGER_MAXIMUM_OPTION = @as(u32, 3); pub const CRM_PROTOCOL_EXPLICIT_MARSHAL_ONLY = @as(u32, 1); pub const CRM_PROTOCOL_DYNAMIC_MARSHAL_INFO = @as(u32, 2); pub const CRM_PROTOCOL_MAXIMUM_OPTION = @as(u32, 3); pub const ENLISTMENT_SUPERIOR = @as(u32, 1); pub const ENLISTMENT_MAXIMUM_OPTION = @as(u32, 1); pub const TRANSACTION_NOTIFY_MASK = @as(u32, 1073741823); pub const TRANSACTION_NOTIFY_PREPREPARE = @as(u32, 1); pub const TRANSACTION_NOTIFY_PREPARE = @as(u32, 2); pub const TRANSACTION_NOTIFY_COMMIT = @as(u32, 4); pub const TRANSACTION_NOTIFY_ROLLBACK = @as(u32, 8); pub const TRANSACTION_NOTIFY_PREPREPARE_COMPLETE = @as(u32, 16); pub const TRANSACTION_NOTIFY_PREPARE_COMPLETE = @as(u32, 32); pub const TRANSACTION_NOTIFY_COMMIT_COMPLETE = @as(u32, 64); pub const TRANSACTION_NOTIFY_ROLLBACK_COMPLETE = @as(u32, 128); pub const TRANSACTION_NOTIFY_RECOVER = @as(u32, 256); pub const TRANSACTION_NOTIFY_SINGLE_PHASE_COMMIT = @as(u32, 512); pub const TRANSACTION_NOTIFY_DELEGATE_COMMIT = @as(u32, 1024); pub const TRANSACTION_NOTIFY_RECOVER_QUERY = @as(u32, 2048); pub const TRANSACTION_NOTIFY_ENLIST_PREPREPARE = @as(u32, 4096); pub const TRANSACTION_NOTIFY_LAST_RECOVER = @as(u32, 8192); pub const TRANSACTION_NOTIFY_INDOUBT = @as(u32, 16384); pub const TRANSACTION_NOTIFY_PROPAGATE_PULL = @as(u32, 32768); pub const TRANSACTION_NOTIFY_PROPAGATE_PUSH = @as(u32, 65536); pub const TRANSACTION_NOTIFY_MARSHAL = @as(u32, 131072); pub const TRANSACTION_NOTIFY_ENLIST_MASK = @as(u32, 262144); pub const TRANSACTION_NOTIFY_RM_DISCONNECTED = @as(u32, 16777216); pub const TRANSACTION_NOTIFY_TM_ONLINE = @as(u32, 33554432); pub const TRANSACTION_NOTIFY_COMMIT_REQUEST = @as(u32, 67108864); pub const TRANSACTION_NOTIFY_PROMOTE = @as(u32, 134217728); pub const TRANSACTION_NOTIFY_PROMOTE_NEW = @as(u32, 268435456); pub const TRANSACTION_NOTIFY_REQUEST_OUTCOME = @as(u32, 536870912); pub const TRANSACTION_NOTIFY_COMMIT_FINALIZE = @as(u32, 1073741824); pub const TRANSACTION_NOTIFICATION_TM_ONLINE_FLAG_IS_CLUSTERED = @as(u32, 1); pub const KTM_MARSHAL_BLOB_VERSION_MAJOR = @as(u32, 1); pub const KTM_MARSHAL_BLOB_VERSION_MINOR = @as(u32, 1); pub const MAX_TRANSACTION_DESCRIPTION_LENGTH = @as(u32, 64); pub const MAX_RESOURCEMANAGER_DESCRIPTION_LENGTH = @as(u32, 64); pub const IOCTL_VOLUME_BASE = @as(u32, 86); pub const IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS = @as(u32, 5636096); pub const IOCTL_VOLUME_ONLINE = @as(u32, 5685256); pub const IOCTL_VOLUME_OFFLINE = @as(u32, 5685260); pub const IOCTL_VOLUME_IS_CLUSTERED = @as(u32, 5636144); pub const IOCTL_VOLUME_GET_GPT_ATTRIBUTES = @as(u32, 5636152); pub const IOCTL_VOLUME_SUPPORTS_ONLINE_OFFLINE = @as(u32, 5636100); pub const IOCTL_VOLUME_IS_OFFLINE = @as(u32, 5636112); pub const IOCTL_VOLUME_IS_IO_CAPABLE = @as(u32, 5636116); pub const IOCTL_VOLUME_QUERY_FAILOVER_SET = @as(u32, 5636120); pub const IOCTL_VOLUME_QUERY_VOLUME_NUMBER = @as(u32, 5636124); pub const IOCTL_VOLUME_LOGICAL_TO_PHYSICAL = @as(u32, 5636128); pub const IOCTL_VOLUME_PHYSICAL_TO_LOGICAL = @as(u32, 5636132); pub const IOCTL_VOLUME_IS_PARTITION = @as(u32, 5636136); pub const IOCTL_VOLUME_READ_PLEX = @as(u32, 5652526); pub const IOCTL_VOLUME_SET_GPT_ATTRIBUTES = @as(u32, 5636148); pub const IOCTL_VOLUME_GET_BC_PROPERTIES = @as(u32, 5652540); pub const IOCTL_VOLUME_ALLOCATE_BC_STREAM = @as(u32, 5685312); pub const IOCTL_VOLUME_FREE_BC_STREAM = @as(u32, 5685316); pub const IOCTL_VOLUME_BC_VERSION = @as(u32, 1); pub const IOCTL_VOLUME_IS_DYNAMIC = @as(u32, 5636168); pub const IOCTL_VOLUME_PREPARE_FOR_CRITICAL_IO = @as(u32, 5685324); pub const IOCTL_VOLUME_QUERY_ALLOCATION_HINT = @as(u32, 5652562); pub const IOCTL_VOLUME_UPDATE_PROPERTIES = @as(u32, 5636180); pub const IOCTL_VOLUME_QUERY_MINIMUM_SHRINK_SIZE = @as(u32, 5652568); pub const IOCTL_VOLUME_PREPARE_FOR_SHRINK = @as(u32, 5685340); pub const IOCTL_VOLUME_IS_CSV = @as(u32, 5636192); pub const IOCTL_VOLUME_POST_ONLINE = @as(u32, 5685348); pub const IOCTL_VOLUME_GET_CSVBLOCKCACHE_CALLBACK = @as(u32, 5685352); pub const CSV_BLOCK_CACHE_CALLBACK_VERSION = @as(u32, 1); pub const CSV_BLOCK_AND_FILE_CACHE_CALLBACK_VERSION = @as(u32, 2); pub const PARTITION_BASIC_DATA_GUID = Guid.initString("ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"); pub const PARTITION_BSP_GUID = Guid.initString("57434f53-4df9-45b9-8e9e-2370f006457c"); pub const PARTITION_CLUSTER_GUID = Guid.initString("db97dba9-0840-4bae-97f0-ffb9a327c7e1"); pub const PARTITION_DPP_GUID = Guid.initString("57434f53-94cb-43f0-a533-d73c10cfa57d"); pub const PARTITION_ENTRY_UNUSED_GUID = Guid.initString("00000000-0000-0000-0000-000000000000"); pub const PARTITION_LDM_DATA_GUID = Guid.initString("af9b60a0-1431-4f62-bc68-3311714a69ad"); pub const PARTITION_LDM_METADATA_GUID = Guid.initString("5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"); pub const PARTITION_LEGACY_BL_GUID = Guid.initString("424ca0e2-7cb2-4fb9-8143-c52a99398bc6"); pub const PARTITION_LEGACY_BL_GUID_BACKUP = Guid.initString("424c3e6c-d79f-49cb-935d-36d71467a288"); pub const PARTITION_MAIN_OS_GUID = Guid.initString("57434f53-8f45-405e-8a23-186d8a4330d3"); pub const PARTITION_MSFT_RECOVERY_GUID = Guid.initString("de94bba4-06d1-4d40-a16a-bfd50179d6ac"); pub const PARTITION_MSFT_RESERVED_GUID = Guid.initString("e3c9e316-0b5c-4db8-817d-f92df00215ae"); pub const PARTITION_MSFT_SNAPSHOT_GUID = Guid.initString("caddebf1-4400-4de8-b103-12117dcf3ccf"); pub const PARTITION_OS_DATA_GUID = Guid.initString("57434f53-23f2-44d5-a830-67bbdaa609f9"); pub const PARTITION_PATCH_GUID = Guid.initString("8967a686-96aa-6aa8-9589-a84256541090"); pub const PARTITION_PRE_INSTALLED_GUID = Guid.initString("57434f53-7fe0-4196-9b42-427b51643484"); pub const PARTITION_SERVICING_FILES_GUID = Guid.initString("57434f53-432e-4014-ae4c-8deaa9c0006a"); pub const PARTITION_SERVICING_METADATA_GUID = Guid.initString("57434f53-c691-4a05-bb4e-703dafd229ce"); pub const PARTITION_SERVICING_RESERVE_GUID = Guid.initString("57434f53-4b81-460b-a319-ffb6fe136d14"); pub const PARTITION_SERVICING_STAGING_ROOT_GUID = Guid.initString("57434f53-e84d-4e84-aaf3-ecbbbd04b9df"); pub const PARTITION_SPACES_GUID = Guid.initString("e75caf8f-f680-4cee-afa3-b001e56efc2d"); pub const PARTITION_SPACES_DATA_GUID = Guid.initString("e7addcb4-dc34-4539-9a76-ebbd07be6f7e"); pub const PARTITION_SYSTEM_GUID = Guid.initString("c12a7328-f81f-11d2-ba4b-00a0c93ec93b"); pub const PARTITION_WINDOWS_SYSTEM_GUID = Guid.initString("57434f53-e3e3-4631-a5c5-26d2243873aa"); pub const _FT_TYPES_DEFINITION_ = @as(u32, 1); pub const CLFS_MGMT_POLICY_VERSION = @as(u32, 1); pub const LOG_POLICY_OVERWRITE = @as(u32, 1); pub const LOG_POLICY_PERSIST = @as(u32, 2); pub const CLFS_MGMT_CLIENT_REGISTRATION_VERSION = @as(u32, 1); pub const CLSID_DiskQuotaControl = Guid.initString("7988b571-ec89-11cf-9c00-00aa00a14f56"); pub const DISKQUOTA_STATE_DISABLED = @as(u32, 0); pub const DISKQUOTA_STATE_TRACK = @as(u32, 1); pub const DISKQUOTA_STATE_ENFORCE = @as(u32, 2); pub const DISKQUOTA_STATE_MASK = @as(u32, 3); pub const DISKQUOTA_FILESTATE_INCOMPLETE = @as(u32, 256); pub const DISKQUOTA_FILESTATE_REBUILDING = @as(u32, 512); pub const DISKQUOTA_FILESTATE_MASK = @as(u32, 768); pub const DISKQUOTA_LOGFLAG_USER_THRESHOLD = @as(u32, 1); pub const DISKQUOTA_LOGFLAG_USER_LIMIT = @as(u32, 2); pub const DISKQUOTA_USER_ACCOUNT_RESOLVED = @as(u32, 0); pub const DISKQUOTA_USER_ACCOUNT_UNAVAILABLE = @as(u32, 1); pub const DISKQUOTA_USER_ACCOUNT_DELETED = @as(u32, 2); pub const DISKQUOTA_USER_ACCOUNT_INVALID = @as(u32, 3); pub const DISKQUOTA_USER_ACCOUNT_UNKNOWN = @as(u32, 4); pub const DISKQUOTA_USER_ACCOUNT_UNRESOLVED = @as(u32, 5); pub const INVALID_SET_FILE_POINTER = @as(u32, 4294967295); pub const INVALID_FILE_ATTRIBUTES = @as(u32, 4294967295); pub const SHARE_NETNAME_PARMNUM = @as(u32, 1); pub const SHARE_TYPE_PARMNUM = @as(u32, 3); pub const SHARE_REMARK_PARMNUM = @as(u32, 4); pub const SHARE_PERMISSIONS_PARMNUM = @as(u32, 5); pub const SHARE_MAX_USES_PARMNUM = @as(u32, 6); pub const SHARE_CURRENT_USES_PARMNUM = @as(u32, 7); pub const SHARE_PATH_PARMNUM = @as(u32, 8); pub const SHARE_PASSWD_PARMNUM = @as(u32, 9); pub const SHARE_FILE_SD_PARMNUM = @as(u32, 501); pub const SHARE_SERVER_PARMNUM = @as(u32, 503); pub const SHI1_NUM_ELEMENTS = @as(u32, 4); pub const SHI2_NUM_ELEMENTS = @as(u32, 10); pub const STYPE_RESERVED1 = @as(u32, 16777216); pub const STYPE_RESERVED2 = @as(u32, 33554432); pub const STYPE_RESERVED3 = @as(u32, 67108864); pub const STYPE_RESERVED4 = @as(u32, 134217728); pub const STYPE_RESERVED5 = @as(u32, 1048576); pub const STYPE_RESERVED_ALL = @as(u32, 1073741568); pub const SHI_USES_UNLIMITED = @as(u32, 4294967295); pub const SHI1005_FLAGS_DFS = @as(u32, 1); pub const SHI1005_FLAGS_DFS_ROOT = @as(u32, 2); pub const CSC_MASK_EXT = @as(u32, 8240); pub const CSC_MASK = @as(u32, 48); pub const CSC_CACHE_MANUAL_REINT = @as(u32, 0); pub const CSC_CACHE_AUTO_REINT = @as(u32, 16); pub const CSC_CACHE_VDO = @as(u32, 32); pub const CSC_CACHE_NONE = @as(u32, 48); pub const SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS = @as(u32, 256); pub const SHI1005_FLAGS_FORCE_SHARED_DELETE = @as(u32, 512); pub const SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING = @as(u32, 1024); pub const SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM = @as(u32, 2048); pub const SHI1005_FLAGS_FORCE_LEVELII_OPLOCK = @as(u32, 4096); pub const SHI1005_FLAGS_ENABLE_HASH = @as(u32, 8192); pub const SHI1005_FLAGS_ENABLE_CA = @as(u32, 16384); pub const SHI1005_FLAGS_ENCRYPT_DATA = @as(u32, 32768); pub const SHI1005_FLAGS_RESERVED = @as(u32, 65536); pub const SHI1005_FLAGS_DISABLE_CLIENT_BUFFERING = @as(u32, 131072); pub const SHI1005_FLAGS_IDENTITY_REMOTING = @as(u32, 262144); pub const SHI1005_FLAGS_CLUSTER_MANAGED = @as(u32, 524288); pub const SHI1005_FLAGS_COMPRESS_DATA = @as(u32, 1048576); pub const SESI1_NUM_ELEMENTS = @as(u32, 8); pub const SESI2_NUM_ELEMENTS = @as(u32, 9); pub const STATSOPT_CLR = @as(u32, 1); pub const LZERROR_BADINHANDLE = @as(i32, -1); pub const LZERROR_BADOUTHANDLE = @as(i32, -2); pub const LZERROR_READ = @as(i32, -3); pub const LZERROR_WRITE = @as(i32, -4); pub const LZERROR_GLOBALLOC = @as(i32, -5); pub const LZERROR_GLOBLOCK = @as(i32, -6); pub const LZERROR_BADVALUE = @as(i32, -7); pub const LZERROR_UNKNOWNALG = @as(i32, -8); pub const NTMS_OBJECTNAME_LENGTH = @as(u32, 64); pub const NTMS_DESCRIPTION_LENGTH = @as(u32, 127); pub const NTMS_DEVICENAME_LENGTH = @as(u32, 64); pub const NTMS_SERIALNUMBER_LENGTH = @as(u32, 32); pub const NTMS_REVISION_LENGTH = @as(u32, 32); pub const NTMS_BARCODE_LENGTH = @as(u32, 64); pub const NTMS_SEQUENCE_LENGTH = @as(u32, 32); pub const NTMS_VENDORNAME_LENGTH = @as(u32, 128); pub const NTMS_PRODUCTNAME_LENGTH = @as(u32, 128); pub const NTMS_USERNAME_LENGTH = @as(u32, 64); pub const NTMS_APPLICATIONNAME_LENGTH = @as(u32, 64); pub const NTMS_COMPUTERNAME_LENGTH = @as(u32, 64); pub const NTMS_I1_MESSAGE_LENGTH = @as(u32, 127); pub const NTMS_MESSAGE_LENGTH = @as(u32, 256); pub const NTMS_POOLHIERARCHY_LENGTH = @as(u32, 512); pub const NTMS_OMIDLABELID_LENGTH = @as(u32, 255); pub const NTMS_OMIDLABELTYPE_LENGTH = @as(u32, 64); pub const NTMS_OMIDLABELINFO_LENGTH = @as(u32, 256); pub const NTMS_MAXATTR_LENGTH = @as(u32, 65536); pub const NTMS_MAXATTR_NAMELEN = @as(u32, 32); pub const NTMSMLI_MAXTYPE = @as(u32, 64); pub const NTMSMLI_MAXIDSIZE = @as(u32, 256); pub const NTMSMLI_MAXAPPDESCR = @as(u32, 256); pub const TXF_LOG_RECORD_GENERIC_TYPE_COMMIT = @as(u32, 1); pub const TXF_LOG_RECORD_GENERIC_TYPE_ABORT = @as(u32, 2); pub const TXF_LOG_RECORD_GENERIC_TYPE_PREPARE = @as(u32, 4); pub const TXF_LOG_RECORD_GENERIC_TYPE_DATA = @as(u32, 8); pub const VS_VERSION_INFO = @as(u32, 1); pub const VS_USER_DEFINED = @as(u32, 100); pub const VS_FFI_SIGNATURE = @as(i32, -17890115); pub const VS_FFI_STRUCVERSION = @as(i32, 65536); pub const VS_FFI_FILEFLAGSMASK = @as(i32, 63); pub const WINEFS_SETUSERKEY_SET_CAPABILITIES = @as(u32, 1); pub const EFS_COMPATIBILITY_VERSION_NCRYPT_PROTECTOR = @as(u32, 5); pub const EFS_COMPATIBILITY_VERSION_PFILE_PROTECTOR = @as(u32, 6); pub const EFS_SUBVER_UNKNOWN = @as(u32, 0); pub const EFS_EFS_SUBVER_EFS_CERT = @as(u32, 1); pub const EFS_PFILE_SUBVER_RMS = @as(u32, 2); pub const EFS_PFILE_SUBVER_APPX = @as(u32, 3); pub const MAX_SID_SIZE = @as(u32, 256); pub const EFS_METADATA_ADD_USER = @as(u32, 1); pub const EFS_METADATA_REMOVE_USER = @as(u32, 2); pub const EFS_METADATA_REPLACE_USER = @as(u32, 4); pub const EFS_METADATA_GENERAL_OP = @as(u32, 8); pub const WOF_PROVIDER_WIM = @as(u32, 1); pub const WOF_PROVIDER_FILE = @as(u32, 2); pub const WIM_PROVIDER_HASH_SIZE = @as(u32, 20); pub const WIM_BOOT_OS_WIM = @as(u32, 1); pub const WIM_BOOT_NOT_OS_WIM = @as(u32, 0); pub const WIM_ENTRY_FLAG_NOT_ACTIVE = @as(u32, 1); pub const WIM_ENTRY_FLAG_SUSPENDED = @as(u32, 2); pub const WIM_EXTERNAL_FILE_INFO_FLAG_NOT_ACTIVE = @as(u32, 1); pub const WIM_EXTERNAL_FILE_INFO_FLAG_SUSPENDED = @as(u32, 2); pub const FILE_PROVIDER_COMPRESSION_XPRESS4K = @as(u32, 0); pub const FILE_PROVIDER_COMPRESSION_LZX = @as(u32, 1); pub const FILE_PROVIDER_COMPRESSION_XPRESS8K = @as(u32, 2); pub const FILE_PROVIDER_COMPRESSION_XPRESS16K = @as(u32, 3); pub const ClfsNullRecord = @as(u8, 0); pub const ClfsDataRecord = @as(u8, 1); pub const ClfsRestartRecord = @as(u8, 2); pub const ClfsClientRecord = @as(u8, 3); pub const ClsContainerInitializing = @as(u32, 1); pub const ClsContainerInactive = @as(u32, 2); pub const ClsContainerActive = @as(u32, 4); pub const ClsContainerActivePendingDelete = @as(u32, 8); pub const ClsContainerPendingArchive = @as(u32, 16); pub const ClsContainerPendingArchiveAndDelete = @as(u32, 32); pub const ClfsContainerInitializing = @as(u32, 1); pub const ClfsContainerInactive = @as(u32, 2); pub const ClfsContainerActive = @as(u32, 4); pub const ClfsContainerActivePendingDelete = @as(u32, 8); pub const ClfsContainerPendingArchive = @as(u32, 16); pub const ClfsContainerPendingArchiveAndDelete = @as(u32, 32); pub const CLFS_MAX_CONTAINER_INFO = @as(u32, 256); pub const CLFS_SCAN_INIT = @as(u8, 1); pub const CLFS_SCAN_FORWARD = @as(u8, 2); pub const CLFS_SCAN_BACKWARD = @as(u8, 4); pub const CLFS_SCAN_CLOSE = @as(u8, 8); pub const CLFS_SCAN_INITIALIZED = @as(u8, 16); pub const CLFS_SCAN_BUFFERED = @as(u8, 32); //-------------------------------------------------------------------------------- // Section: Types (336) //-------------------------------------------------------------------------------- pub const FIND_FIRST_EX_FLAGS = enum(u32) { CASE_SENSITIVE = 1, LARGE_FETCH = 2, ON_DISK_ENTRIES_ONLY = 4, _, pub fn initFlags(o: struct { CASE_SENSITIVE: u1 = 0, LARGE_FETCH: u1 = 0, ON_DISK_ENTRIES_ONLY: u1 = 0, }) FIND_FIRST_EX_FLAGS { return @intToEnum(FIND_FIRST_EX_FLAGS, (if (o.CASE_SENSITIVE == 1) @enumToInt(FIND_FIRST_EX_FLAGS.CASE_SENSITIVE) else 0) | (if (o.LARGE_FETCH == 1) @enumToInt(FIND_FIRST_EX_FLAGS.LARGE_FETCH) else 0) | (if (o.ON_DISK_ENTRIES_ONLY == 1) @enumToInt(FIND_FIRST_EX_FLAGS.ON_DISK_ENTRIES_ONLY) else 0) ); } }; pub const FIND_FIRST_EX_CASE_SENSITIVE = FIND_FIRST_EX_FLAGS.CASE_SENSITIVE; pub const FIND_FIRST_EX_LARGE_FETCH = FIND_FIRST_EX_FLAGS.LARGE_FETCH; pub const FIND_FIRST_EX_ON_DISK_ENTRIES_ONLY = FIND_FIRST_EX_FLAGS.ON_DISK_ENTRIES_ONLY; pub const DEFINE_DOS_DEVICE_FLAGS = enum(u32) { RAW_TARGET_PATH = 1, REMOVE_DEFINITION = 2, EXACT_MATCH_ON_REMOVE = 4, NO_BROADCAST_SYSTEM = 8, LUID_BROADCAST_DRIVE = 16, _, pub fn initFlags(o: struct { RAW_TARGET_PATH: u1 = 0, REMOVE_DEFINITION: u1 = 0, EXACT_MATCH_ON_REMOVE: u1 = 0, NO_BROADCAST_SYSTEM: u1 = 0, LUID_BROADCAST_DRIVE: u1 = 0, }) DEFINE_DOS_DEVICE_FLAGS { return @intToEnum(DEFINE_DOS_DEVICE_FLAGS, (if (o.RAW_TARGET_PATH == 1) @enumToInt(DEFINE_DOS_DEVICE_FLAGS.RAW_TARGET_PATH) else 0) | (if (o.REMOVE_DEFINITION == 1) @enumToInt(DEFINE_DOS_DEVICE_FLAGS.REMOVE_DEFINITION) else 0) | (if (o.EXACT_MATCH_ON_REMOVE == 1) @enumToInt(DEFINE_DOS_DEVICE_FLAGS.EXACT_MATCH_ON_REMOVE) else 0) | (if (o.NO_BROADCAST_SYSTEM == 1) @enumToInt(DEFINE_DOS_DEVICE_FLAGS.NO_BROADCAST_SYSTEM) else 0) | (if (o.LUID_BROADCAST_DRIVE == 1) @enumToInt(DEFINE_DOS_DEVICE_FLAGS.LUID_BROADCAST_DRIVE) else 0) ); } }; pub const DDD_RAW_TARGET_PATH = DEFINE_DOS_DEVICE_FLAGS.RAW_TARGET_PATH; pub const DDD_REMOVE_DEFINITION = DEFINE_DOS_DEVICE_FLAGS.REMOVE_DEFINITION; pub const DDD_EXACT_MATCH_ON_REMOVE = DEFINE_DOS_DEVICE_FLAGS.EXACT_MATCH_ON_REMOVE; pub const DDD_NO_BROADCAST_SYSTEM = DEFINE_DOS_DEVICE_FLAGS.NO_BROADCAST_SYSTEM; pub const DDD_LUID_BROADCAST_DRIVE = DEFINE_DOS_DEVICE_FLAGS.LUID_BROADCAST_DRIVE; pub const FILE_FLAGS_AND_ATTRIBUTES = enum(u32) { FILE_ATTRIBUTE_READONLY = 1, FILE_ATTRIBUTE_HIDDEN = 2, FILE_ATTRIBUTE_SYSTEM = 4, FILE_ATTRIBUTE_DIRECTORY = 16, FILE_ATTRIBUTE_ARCHIVE = 32, FILE_ATTRIBUTE_DEVICE = 64, FILE_ATTRIBUTE_NORMAL = 128, FILE_ATTRIBUTE_TEMPORARY = 256, FILE_ATTRIBUTE_SPARSE_FILE = 512, FILE_ATTRIBUTE_REPARSE_POINT = 1024, FILE_ATTRIBUTE_COMPRESSED = 2048, FILE_ATTRIBUTE_OFFLINE = 4096, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192, FILE_ATTRIBUTE_ENCRYPTED = 16384, FILE_ATTRIBUTE_INTEGRITY_STREAM = 32768, FILE_ATTRIBUTE_VIRTUAL = 65536, FILE_ATTRIBUTE_NO_SCRUB_DATA = 131072, FILE_ATTRIBUTE_EA = 262144, FILE_ATTRIBUTE_PINNED = 524288, FILE_ATTRIBUTE_UNPINNED = 1048576, // FILE_ATTRIBUTE_RECALL_ON_OPEN = 262144, this enum value conflicts with FILE_ATTRIBUTE_EA FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 4194304, FILE_FLAG_WRITE_THROUGH = 2147483648, FILE_FLAG_OVERLAPPED = 1073741824, FILE_FLAG_NO_BUFFERING = 536870912, FILE_FLAG_RANDOM_ACCESS = 268435456, FILE_FLAG_SEQUENTIAL_SCAN = 134217728, FILE_FLAG_DELETE_ON_CLOSE = 67108864, FILE_FLAG_BACKUP_SEMANTICS = 33554432, FILE_FLAG_POSIX_SEMANTICS = 16777216, FILE_FLAG_SESSION_AWARE = 8388608, FILE_FLAG_OPEN_REPARSE_POINT = 2097152, // FILE_FLAG_OPEN_NO_RECALL = 1048576, this enum value conflicts with FILE_ATTRIBUTE_UNPINNED // FILE_FLAG_FIRST_PIPE_INSTANCE = 524288, this enum value conflicts with FILE_ATTRIBUTE_PINNED PIPE_ACCESS_DUPLEX = 3, // PIPE_ACCESS_INBOUND = 1, this enum value conflicts with FILE_ATTRIBUTE_READONLY // PIPE_ACCESS_OUTBOUND = 2, this enum value conflicts with FILE_ATTRIBUTE_HIDDEN SECURITY_ANONYMOUS = 0, // SECURITY_IDENTIFICATION = 65536, this enum value conflicts with FILE_ATTRIBUTE_VIRTUAL // SECURITY_IMPERSONATION = 131072, this enum value conflicts with FILE_ATTRIBUTE_NO_SCRUB_DATA SECURITY_DELEGATION = 196608, // SECURITY_CONTEXT_TRACKING = 262144, this enum value conflicts with FILE_ATTRIBUTE_EA // SECURITY_EFFECTIVE_ONLY = 524288, this enum value conflicts with FILE_ATTRIBUTE_PINNED // SECURITY_SQOS_PRESENT = 1048576, this enum value conflicts with FILE_ATTRIBUTE_UNPINNED SECURITY_VALID_SQOS_FLAGS = 2031616, _, pub fn initFlags(o: struct { FILE_ATTRIBUTE_READONLY: u1 = 0, FILE_ATTRIBUTE_HIDDEN: u1 = 0, FILE_ATTRIBUTE_SYSTEM: u1 = 0, FILE_ATTRIBUTE_DIRECTORY: u1 = 0, FILE_ATTRIBUTE_ARCHIVE: u1 = 0, FILE_ATTRIBUTE_DEVICE: u1 = 0, FILE_ATTRIBUTE_NORMAL: u1 = 0, FILE_ATTRIBUTE_TEMPORARY: u1 = 0, FILE_ATTRIBUTE_SPARSE_FILE: u1 = 0, FILE_ATTRIBUTE_REPARSE_POINT: u1 = 0, FILE_ATTRIBUTE_COMPRESSED: u1 = 0, FILE_ATTRIBUTE_OFFLINE: u1 = 0, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: u1 = 0, FILE_ATTRIBUTE_ENCRYPTED: u1 = 0, FILE_ATTRIBUTE_INTEGRITY_STREAM: u1 = 0, FILE_ATTRIBUTE_VIRTUAL: u1 = 0, FILE_ATTRIBUTE_NO_SCRUB_DATA: u1 = 0, FILE_ATTRIBUTE_EA: u1 = 0, FILE_ATTRIBUTE_PINNED: u1 = 0, FILE_ATTRIBUTE_UNPINNED: u1 = 0, FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS: u1 = 0, FILE_FLAG_WRITE_THROUGH: u1 = 0, FILE_FLAG_OVERLAPPED: u1 = 0, FILE_FLAG_NO_BUFFERING: u1 = 0, FILE_FLAG_RANDOM_ACCESS: u1 = 0, FILE_FLAG_SEQUENTIAL_SCAN: u1 = 0, FILE_FLAG_DELETE_ON_CLOSE: u1 = 0, FILE_FLAG_BACKUP_SEMANTICS: u1 = 0, FILE_FLAG_POSIX_SEMANTICS: u1 = 0, FILE_FLAG_SESSION_AWARE: u1 = 0, FILE_FLAG_OPEN_REPARSE_POINT: u1 = 0, PIPE_ACCESS_DUPLEX: u1 = 0, SECURITY_ANONYMOUS: u1 = 0, SECURITY_DELEGATION: u1 = 0, SECURITY_VALID_SQOS_FLAGS: u1 = 0, }) FILE_FLAGS_AND_ATTRIBUTES { return @intToEnum(FILE_FLAGS_AND_ATTRIBUTES, (if (o.FILE_ATTRIBUTE_READONLY == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_READONLY) else 0) | (if (o.FILE_ATTRIBUTE_HIDDEN == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_HIDDEN) else 0) | (if (o.FILE_ATTRIBUTE_SYSTEM == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_SYSTEM) else 0) | (if (o.FILE_ATTRIBUTE_DIRECTORY == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_DIRECTORY) else 0) | (if (o.FILE_ATTRIBUTE_ARCHIVE == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_ARCHIVE) else 0) | (if (o.FILE_ATTRIBUTE_DEVICE == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_DEVICE) else 0) | (if (o.FILE_ATTRIBUTE_NORMAL == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_NORMAL) else 0) | (if (o.FILE_ATTRIBUTE_TEMPORARY == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_TEMPORARY) else 0) | (if (o.FILE_ATTRIBUTE_SPARSE_FILE == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_SPARSE_FILE) else 0) | (if (o.FILE_ATTRIBUTE_REPARSE_POINT == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_REPARSE_POINT) else 0) | (if (o.FILE_ATTRIBUTE_COMPRESSED == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_COMPRESSED) else 0) | (if (o.FILE_ATTRIBUTE_OFFLINE == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_OFFLINE) else 0) | (if (o.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) else 0) | (if (o.FILE_ATTRIBUTE_ENCRYPTED == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_ENCRYPTED) else 0) | (if (o.FILE_ATTRIBUTE_INTEGRITY_STREAM == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_INTEGRITY_STREAM) else 0) | (if (o.FILE_ATTRIBUTE_VIRTUAL == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_VIRTUAL) else 0) | (if (o.FILE_ATTRIBUTE_NO_SCRUB_DATA == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_NO_SCRUB_DATA) else 0) | (if (o.FILE_ATTRIBUTE_EA == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_EA) else 0) | (if (o.FILE_ATTRIBUTE_PINNED == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_PINNED) else 0) | (if (o.FILE_ATTRIBUTE_UNPINNED == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_UNPINNED) else 0) | (if (o.FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS) else 0) | (if (o.FILE_FLAG_WRITE_THROUGH == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_WRITE_THROUGH) else 0) | (if (o.FILE_FLAG_OVERLAPPED == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_OVERLAPPED) else 0) | (if (o.FILE_FLAG_NO_BUFFERING == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_NO_BUFFERING) else 0) | (if (o.FILE_FLAG_RANDOM_ACCESS == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_RANDOM_ACCESS) else 0) | (if (o.FILE_FLAG_SEQUENTIAL_SCAN == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_SEQUENTIAL_SCAN) else 0) | (if (o.FILE_FLAG_DELETE_ON_CLOSE == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_DELETE_ON_CLOSE) else 0) | (if (o.FILE_FLAG_BACKUP_SEMANTICS == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_BACKUP_SEMANTICS) else 0) | (if (o.FILE_FLAG_POSIX_SEMANTICS == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_POSIX_SEMANTICS) else 0) | (if (o.FILE_FLAG_SESSION_AWARE == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_SESSION_AWARE) else 0) | (if (o.FILE_FLAG_OPEN_REPARSE_POINT == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_OPEN_REPARSE_POINT) else 0) | (if (o.PIPE_ACCESS_DUPLEX == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.PIPE_ACCESS_DUPLEX) else 0) | (if (o.SECURITY_ANONYMOUS == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.SECURITY_ANONYMOUS) else 0) | (if (o.SECURITY_DELEGATION == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.SECURITY_DELEGATION) else 0) | (if (o.SECURITY_VALID_SQOS_FLAGS == 1) @enumToInt(FILE_FLAGS_AND_ATTRIBUTES.SECURITY_VALID_SQOS_FLAGS) else 0) ); } }; pub const FILE_ATTRIBUTE_READONLY = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_READONLY; pub const FILE_ATTRIBUTE_HIDDEN = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_HIDDEN; pub const FILE_ATTRIBUTE_SYSTEM = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_SYSTEM; pub const FILE_ATTRIBUTE_DIRECTORY = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_DIRECTORY; pub const FILE_ATTRIBUTE_ARCHIVE = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_ARCHIVE; pub const FILE_ATTRIBUTE_DEVICE = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_DEVICE; pub const FILE_ATTRIBUTE_NORMAL = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_NORMAL; pub const FILE_ATTRIBUTE_TEMPORARY = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_TEMPORARY; pub const FILE_ATTRIBUTE_SPARSE_FILE = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_SPARSE_FILE; pub const FILE_ATTRIBUTE_REPARSE_POINT = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_REPARSE_POINT; pub const FILE_ATTRIBUTE_COMPRESSED = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_COMPRESSED; pub const FILE_ATTRIBUTE_OFFLINE = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_OFFLINE; pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED; pub const FILE_ATTRIBUTE_ENCRYPTED = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_ENCRYPTED; pub const FILE_ATTRIBUTE_INTEGRITY_STREAM = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_INTEGRITY_STREAM; pub const FILE_ATTRIBUTE_VIRTUAL = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_VIRTUAL; pub const FILE_ATTRIBUTE_NO_SCRUB_DATA = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_NO_SCRUB_DATA; pub const FILE_ATTRIBUTE_EA = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_EA; pub const FILE_ATTRIBUTE_PINNED = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_PINNED; pub const FILE_ATTRIBUTE_UNPINNED = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_UNPINNED; pub const FILE_ATTRIBUTE_RECALL_ON_OPEN = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_EA; pub const FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS; pub const FILE_FLAG_WRITE_THROUGH = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_WRITE_THROUGH; pub const FILE_FLAG_OVERLAPPED = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_OVERLAPPED; pub const FILE_FLAG_NO_BUFFERING = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_NO_BUFFERING; pub const FILE_FLAG_RANDOM_ACCESS = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_RANDOM_ACCESS; pub const FILE_FLAG_SEQUENTIAL_SCAN = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_SEQUENTIAL_SCAN; pub const FILE_FLAG_DELETE_ON_CLOSE = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_DELETE_ON_CLOSE; pub const FILE_FLAG_BACKUP_SEMANTICS = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_BACKUP_SEMANTICS; pub const FILE_FLAG_POSIX_SEMANTICS = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_POSIX_SEMANTICS; pub const FILE_FLAG_SESSION_AWARE = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_SESSION_AWARE; pub const FILE_FLAG_OPEN_REPARSE_POINT = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_OPEN_REPARSE_POINT; pub const FILE_FLAG_OPEN_NO_RECALL = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_UNPINNED; pub const FILE_FLAG_FIRST_PIPE_INSTANCE = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_PINNED; pub const PIPE_ACCESS_DUPLEX = FILE_FLAGS_AND_ATTRIBUTES.PIPE_ACCESS_DUPLEX; pub const PIPE_ACCESS_INBOUND = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_READONLY; pub const PIPE_ACCESS_OUTBOUND = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_HIDDEN; pub const SECURITY_ANONYMOUS = FILE_FLAGS_AND_ATTRIBUTES.SECURITY_ANONYMOUS; pub const SECURITY_IDENTIFICATION = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_VIRTUAL; pub const SECURITY_IMPERSONATION = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_NO_SCRUB_DATA; pub const SECURITY_DELEGATION = FILE_FLAGS_AND_ATTRIBUTES.SECURITY_DELEGATION; pub const SECURITY_CONTEXT_TRACKING = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_EA; pub const SECURITY_EFFECTIVE_ONLY = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_PINNED; pub const SECURITY_SQOS_PRESENT = FILE_FLAGS_AND_ATTRIBUTES.FILE_ATTRIBUTE_UNPINNED; pub const SECURITY_VALID_SQOS_FLAGS = FILE_FLAGS_AND_ATTRIBUTES.SECURITY_VALID_SQOS_FLAGS; pub const FILE_ACCESS_FLAGS = enum(u32) { FILE_READ_DATA = 1, // FILE_LIST_DIRECTORY = 1, this enum value conflicts with FILE_READ_DATA FILE_WRITE_DATA = 2, // FILE_ADD_FILE = 2, this enum value conflicts with FILE_WRITE_DATA FILE_APPEND_DATA = 4, // FILE_ADD_SUBDIRECTORY = 4, this enum value conflicts with FILE_APPEND_DATA // FILE_CREATE_PIPE_INSTANCE = 4, this enum value conflicts with FILE_APPEND_DATA FILE_READ_EA = 8, FILE_WRITE_EA = 16, FILE_EXECUTE = 32, // FILE_TRAVERSE = 32, this enum value conflicts with FILE_EXECUTE FILE_DELETE_CHILD = 64, FILE_READ_ATTRIBUTES = 128, FILE_WRITE_ATTRIBUTES = 256, READ_CONTROL = 131072, SYNCHRONIZE = 1048576, STANDARD_RIGHTS_REQUIRED = 983040, // STANDARD_RIGHTS_READ = 131072, this enum value conflicts with READ_CONTROL // STANDARD_RIGHTS_WRITE = 131072, this enum value conflicts with READ_CONTROL // STANDARD_RIGHTS_EXECUTE = 131072, this enum value conflicts with READ_CONTROL STANDARD_RIGHTS_ALL = 2031616, SPECIFIC_RIGHTS_ALL = 65535, FILE_ALL_ACCESS = 2032127, FILE_GENERIC_READ = 1179785, FILE_GENERIC_WRITE = 1179926, FILE_GENERIC_EXECUTE = 1179808, _, pub fn initFlags(o: struct { FILE_READ_DATA: u1 = 0, FILE_WRITE_DATA: u1 = 0, FILE_APPEND_DATA: u1 = 0, FILE_READ_EA: u1 = 0, FILE_WRITE_EA: u1 = 0, FILE_EXECUTE: u1 = 0, FILE_DELETE_CHILD: u1 = 0, FILE_READ_ATTRIBUTES: u1 = 0, FILE_WRITE_ATTRIBUTES: u1 = 0, READ_CONTROL: u1 = 0, SYNCHRONIZE: u1 = 0, STANDARD_RIGHTS_REQUIRED: u1 = 0, STANDARD_RIGHTS_ALL: u1 = 0, SPECIFIC_RIGHTS_ALL: u1 = 0, FILE_ALL_ACCESS: u1 = 0, FILE_GENERIC_READ: u1 = 0, FILE_GENERIC_WRITE: u1 = 0, FILE_GENERIC_EXECUTE: u1 = 0, }) FILE_ACCESS_FLAGS { return @intToEnum(FILE_ACCESS_FLAGS, (if (o.FILE_READ_DATA == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_READ_DATA) else 0) | (if (o.FILE_WRITE_DATA == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_WRITE_DATA) else 0) | (if (o.FILE_APPEND_DATA == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_APPEND_DATA) else 0) | (if (o.FILE_READ_EA == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_READ_EA) else 0) | (if (o.FILE_WRITE_EA == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_WRITE_EA) else 0) | (if (o.FILE_EXECUTE == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_EXECUTE) else 0) | (if (o.FILE_DELETE_CHILD == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_DELETE_CHILD) else 0) | (if (o.FILE_READ_ATTRIBUTES == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_READ_ATTRIBUTES) else 0) | (if (o.FILE_WRITE_ATTRIBUTES == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_WRITE_ATTRIBUTES) else 0) | (if (o.READ_CONTROL == 1) @enumToInt(FILE_ACCESS_FLAGS.READ_CONTROL) else 0) | (if (o.SYNCHRONIZE == 1) @enumToInt(FILE_ACCESS_FLAGS.SYNCHRONIZE) else 0) | (if (o.STANDARD_RIGHTS_REQUIRED == 1) @enumToInt(FILE_ACCESS_FLAGS.STANDARD_RIGHTS_REQUIRED) else 0) | (if (o.STANDARD_RIGHTS_ALL == 1) @enumToInt(FILE_ACCESS_FLAGS.STANDARD_RIGHTS_ALL) else 0) | (if (o.SPECIFIC_RIGHTS_ALL == 1) @enumToInt(FILE_ACCESS_FLAGS.SPECIFIC_RIGHTS_ALL) else 0) | (if (o.FILE_ALL_ACCESS == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_ALL_ACCESS) else 0) | (if (o.FILE_GENERIC_READ == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_GENERIC_READ) else 0) | (if (o.FILE_GENERIC_WRITE == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_GENERIC_WRITE) else 0) | (if (o.FILE_GENERIC_EXECUTE == 1) @enumToInt(FILE_ACCESS_FLAGS.FILE_GENERIC_EXECUTE) else 0) ); } }; pub const FILE_READ_DATA = FILE_ACCESS_FLAGS.FILE_READ_DATA; pub const FILE_LIST_DIRECTORY = FILE_ACCESS_FLAGS.FILE_READ_DATA; pub const FILE_WRITE_DATA = FILE_ACCESS_FLAGS.FILE_WRITE_DATA; pub const FILE_ADD_FILE = FILE_ACCESS_FLAGS.FILE_WRITE_DATA; pub const FILE_APPEND_DATA = FILE_ACCESS_FLAGS.FILE_APPEND_DATA; pub const FILE_ADD_SUBDIRECTORY = FILE_ACCESS_FLAGS.FILE_APPEND_DATA; pub const FILE_CREATE_PIPE_INSTANCE = FILE_ACCESS_FLAGS.FILE_APPEND_DATA; pub const FILE_READ_EA = FILE_ACCESS_FLAGS.FILE_READ_EA; pub const FILE_WRITE_EA = FILE_ACCESS_FLAGS.FILE_WRITE_EA; pub const FILE_EXECUTE = FILE_ACCESS_FLAGS.FILE_EXECUTE; pub const FILE_TRAVERSE = FILE_ACCESS_FLAGS.FILE_EXECUTE; pub const FILE_DELETE_CHILD = FILE_ACCESS_FLAGS.FILE_DELETE_CHILD; pub const FILE_READ_ATTRIBUTES = FILE_ACCESS_FLAGS.FILE_READ_ATTRIBUTES; pub const FILE_WRITE_ATTRIBUTES = FILE_ACCESS_FLAGS.FILE_WRITE_ATTRIBUTES; pub const READ_CONTROL = FILE_ACCESS_FLAGS.READ_CONTROL; pub const SYNCHRONIZE = FILE_ACCESS_FLAGS.SYNCHRONIZE; pub const STANDARD_RIGHTS_REQUIRED = FILE_ACCESS_FLAGS.STANDARD_RIGHTS_REQUIRED; pub const STANDARD_RIGHTS_READ = FILE_ACCESS_FLAGS.READ_CONTROL; pub const STANDARD_RIGHTS_WRITE = FILE_ACCESS_FLAGS.READ_CONTROL; pub const STANDARD_RIGHTS_EXECUTE = FILE_ACCESS_FLAGS.READ_CONTROL; pub const STANDARD_RIGHTS_ALL = FILE_ACCESS_FLAGS.STANDARD_RIGHTS_ALL; pub const SPECIFIC_RIGHTS_ALL = FILE_ACCESS_FLAGS.SPECIFIC_RIGHTS_ALL; pub const FILE_ALL_ACCESS = FILE_ACCESS_FLAGS.FILE_ALL_ACCESS; pub const FILE_GENERIC_READ = FILE_ACCESS_FLAGS.FILE_GENERIC_READ; pub const FILE_GENERIC_WRITE = FILE_ACCESS_FLAGS.FILE_GENERIC_WRITE; pub const FILE_GENERIC_EXECUTE = FILE_ACCESS_FLAGS.FILE_GENERIC_EXECUTE; pub const GET_FILE_VERSION_INFO_FLAGS = enum(u32) { LOCALISED = 1, NEUTRAL = 2, PREFETCHED = 4, _, pub fn initFlags(o: struct { LOCALISED: u1 = 0, NEUTRAL: u1 = 0, PREFETCHED: u1 = 0, }) GET_FILE_VERSION_INFO_FLAGS { return @intToEnum(GET_FILE_VERSION_INFO_FLAGS, (if (o.LOCALISED == 1) @enumToInt(GET_FILE_VERSION_INFO_FLAGS.LOCALISED) else 0) | (if (o.NEUTRAL == 1) @enumToInt(GET_FILE_VERSION_INFO_FLAGS.NEUTRAL) else 0) | (if (o.PREFETCHED == 1) @enumToInt(GET_FILE_VERSION_INFO_FLAGS.PREFETCHED) else 0) ); } }; pub const FILE_VER_GET_LOCALISED = GET_FILE_VERSION_INFO_FLAGS.LOCALISED; pub const FILE_VER_GET_NEUTRAL = GET_FILE_VERSION_INFO_FLAGS.NEUTRAL; pub const FILE_VER_GET_PREFETCHED = GET_FILE_VERSION_INFO_FLAGS.PREFETCHED; pub const VER_FIND_FILE_FLAGS = enum(u32) { E = 1, }; pub const VFFF_ISSHAREDFILE = VER_FIND_FILE_FLAGS.E; pub const VER_FIND_FILE_STATUS = enum(u32) { CURNEDEST = 1, FILEINUSE = 2, BUFFTOOSMALL = 4, _, pub fn initFlags(o: struct { CURNEDEST: u1 = 0, FILEINUSE: u1 = 0, BUFFTOOSMALL: u1 = 0, }) VER_FIND_FILE_STATUS { return @intToEnum(VER_FIND_FILE_STATUS, (if (o.CURNEDEST == 1) @enumToInt(VER_FIND_FILE_STATUS.CURNEDEST) else 0) | (if (o.FILEINUSE == 1) @enumToInt(VER_FIND_FILE_STATUS.FILEINUSE) else 0) | (if (o.BUFFTOOSMALL == 1) @enumToInt(VER_FIND_FILE_STATUS.BUFFTOOSMALL) else 0) ); } }; pub const VFF_CURNEDEST = VER_FIND_FILE_STATUS.CURNEDEST; pub const VFF_FILEINUSE = VER_FIND_FILE_STATUS.FILEINUSE; pub const VFF_BUFFTOOSMALL = VER_FIND_FILE_STATUS.BUFFTOOSMALL; pub const VER_INSTALL_FILE_FLAGS = enum(u32) { FORCEINSTALL = 1, DONTDELETEOLD = 2, }; pub const VIFF_FORCEINSTALL = VER_INSTALL_FILE_FLAGS.FORCEINSTALL; pub const VIFF_DONTDELETEOLD = VER_INSTALL_FILE_FLAGS.DONTDELETEOLD; pub const VER_INSTALL_FILE_STATUS = enum(u32) { TEMPFILE = 1, MISMATCH = 2, SRCOLD = 4, DIFFLANG = 8, DIFFCODEPG = 16, DIFFTYPE = 32, WRITEPROT = 64, FILEINUSE = 128, OUTOFSPACE = 256, ACCESSVIOLATION = 512, SHARINGVIOLATION = 1024, CANNOTCREATE = 2048, CANNOTDELETE = 4096, CANNOTRENAME = 8192, CANNOTDELETECUR = 16384, OUTOFMEMORY = 32768, CANNOTREADSRC = 65536, CANNOTREADDST = 131072, BUFFTOOSMALL = 262144, CANNOTLOADLZ32 = 524288, CANNOTLOADCABINET = 1048576, _, pub fn initFlags(o: struct { TEMPFILE: u1 = 0, MISMATCH: u1 = 0, SRCOLD: u1 = 0, DIFFLANG: u1 = 0, DIFFCODEPG: u1 = 0, DIFFTYPE: u1 = 0, WRITEPROT: u1 = 0, FILEINUSE: u1 = 0, OUTOFSPACE: u1 = 0, ACCESSVIOLATION: u1 = 0, SHARINGVIOLATION: u1 = 0, CANNOTCREATE: u1 = 0, CANNOTDELETE: u1 = 0, CANNOTRENAME: u1 = 0, CANNOTDELETECUR: u1 = 0, OUTOFMEMORY: u1 = 0, CANNOTREADSRC: u1 = 0, CANNOTREADDST: u1 = 0, BUFFTOOSMALL: u1 = 0, CANNOTLOADLZ32: u1 = 0, CANNOTLOADCABINET: u1 = 0, }) VER_INSTALL_FILE_STATUS { return @intToEnum(VER_INSTALL_FILE_STATUS, (if (o.TEMPFILE == 1) @enumToInt(VER_INSTALL_FILE_STATUS.TEMPFILE) else 0) | (if (o.MISMATCH == 1) @enumToInt(VER_INSTALL_FILE_STATUS.MISMATCH) else 0) | (if (o.SRCOLD == 1) @enumToInt(VER_INSTALL_FILE_STATUS.SRCOLD) else 0) | (if (o.DIFFLANG == 1) @enumToInt(VER_INSTALL_FILE_STATUS.DIFFLANG) else 0) | (if (o.DIFFCODEPG == 1) @enumToInt(VER_INSTALL_FILE_STATUS.DIFFCODEPG) else 0) | (if (o.DIFFTYPE == 1) @enumToInt(VER_INSTALL_FILE_STATUS.DIFFTYPE) else 0) | (if (o.WRITEPROT == 1) @enumToInt(VER_INSTALL_FILE_STATUS.WRITEPROT) else 0) | (if (o.FILEINUSE == 1) @enumToInt(VER_INSTALL_FILE_STATUS.FILEINUSE) else 0) | (if (o.OUTOFSPACE == 1) @enumToInt(VER_INSTALL_FILE_STATUS.OUTOFSPACE) else 0) | (if (o.ACCESSVIOLATION == 1) @enumToInt(VER_INSTALL_FILE_STATUS.ACCESSVIOLATION) else 0) | (if (o.SHARINGVIOLATION == 1) @enumToInt(VER_INSTALL_FILE_STATUS.SHARINGVIOLATION) else 0) | (if (o.CANNOTCREATE == 1) @enumToInt(VER_INSTALL_FILE_STATUS.CANNOTCREATE) else 0) | (if (o.CANNOTDELETE == 1) @enumToInt(VER_INSTALL_FILE_STATUS.CANNOTDELETE) else 0) | (if (o.CANNOTRENAME == 1) @enumToInt(VER_INSTALL_FILE_STATUS.CANNOTRENAME) else 0) | (if (o.CANNOTDELETECUR == 1) @enumToInt(VER_INSTALL_FILE_STATUS.CANNOTDELETECUR) else 0) | (if (o.OUTOFMEMORY == 1) @enumToInt(VER_INSTALL_FILE_STATUS.OUTOFMEMORY) else 0) | (if (o.CANNOTREADSRC == 1) @enumToInt(VER_INSTALL_FILE_STATUS.CANNOTREADSRC) else 0) | (if (o.CANNOTREADDST == 1) @enumToInt(VER_INSTALL_FILE_STATUS.CANNOTREADDST) else 0) | (if (o.BUFFTOOSMALL == 1) @enumToInt(VER_INSTALL_FILE_STATUS.BUFFTOOSMALL) else 0) | (if (o.CANNOTLOADLZ32 == 1) @enumToInt(VER_INSTALL_FILE_STATUS.CANNOTLOADLZ32) else 0) | (if (o.CANNOTLOADCABINET == 1) @enumToInt(VER_INSTALL_FILE_STATUS.CANNOTLOADCABINET) else 0) ); } }; pub const VIF_TEMPFILE = VER_INSTALL_FILE_STATUS.TEMPFILE; pub const VIF_MISMATCH = VER_INSTALL_FILE_STATUS.MISMATCH; pub const VIF_SRCOLD = VER_INSTALL_FILE_STATUS.SRCOLD; pub const VIF_DIFFLANG = VER_INSTALL_FILE_STATUS.DIFFLANG; pub const VIF_DIFFCODEPG = VER_INSTALL_FILE_STATUS.DIFFCODEPG; pub const VIF_DIFFTYPE = VER_INSTALL_FILE_STATUS.DIFFTYPE; pub const VIF_WRITEPROT = VER_INSTALL_FILE_STATUS.WRITEPROT; pub const VIF_FILEINUSE = VER_INSTALL_FILE_STATUS.FILEINUSE; pub const VIF_OUTOFSPACE = VER_INSTALL_FILE_STATUS.OUTOFSPACE; pub const VIF_ACCESSVIOLATION = VER_INSTALL_FILE_STATUS.ACCESSVIOLATION; pub const VIF_SHARINGVIOLATION = VER_INSTALL_FILE_STATUS.SHARINGVIOLATION; pub const VIF_CANNOTCREATE = VER_INSTALL_FILE_STATUS.CANNOTCREATE; pub const VIF_CANNOTDELETE = VER_INSTALL_FILE_STATUS.CANNOTDELETE; pub const VIF_CANNOTRENAME = VER_INSTALL_FILE_STATUS.CANNOTRENAME; pub const VIF_CANNOTDELETECUR = VER_INSTALL_FILE_STATUS.CANNOTDELETECUR; pub const VIF_OUTOFMEMORY = VER_INSTALL_FILE_STATUS.OUTOFMEMORY; pub const VIF_CANNOTREADSRC = VER_INSTALL_FILE_STATUS.CANNOTREADSRC; pub const VIF_CANNOTREADDST = VER_INSTALL_FILE_STATUS.CANNOTREADDST; pub const VIF_BUFFTOOSMALL = VER_INSTALL_FILE_STATUS.BUFFTOOSMALL; pub const VIF_CANNOTLOADLZ32 = VER_INSTALL_FILE_STATUS.CANNOTLOADLZ32; pub const VIF_CANNOTLOADCABINET = VER_INSTALL_FILE_STATUS.CANNOTLOADCABINET; pub const VS_FIXEDFILEINFO_FILE_FLAGS = enum(u32) { DEBUG = 1, PRERELEASE = 2, PATCHED = 4, PRIVATEBUILD = 8, INFOINFERRED = 16, SPECIALBUILD = 32, _, pub fn initFlags(o: struct { DEBUG: u1 = 0, PRERELEASE: u1 = 0, PATCHED: u1 = 0, PRIVATEBUILD: u1 = 0, INFOINFERRED: u1 = 0, SPECIALBUILD: u1 = 0, }) VS_FIXEDFILEINFO_FILE_FLAGS { return @intToEnum(VS_FIXEDFILEINFO_FILE_FLAGS, (if (o.DEBUG == 1) @enumToInt(VS_FIXEDFILEINFO_FILE_FLAGS.DEBUG) else 0) | (if (o.PRERELEASE == 1) @enumToInt(VS_FIXEDFILEINFO_FILE_FLAGS.PRERELEASE) else 0) | (if (o.PATCHED == 1) @enumToInt(VS_FIXEDFILEINFO_FILE_FLAGS.PATCHED) else 0) | (if (o.PRIVATEBUILD == 1) @enumToInt(VS_FIXEDFILEINFO_FILE_FLAGS.PRIVATEBUILD) else 0) | (if (o.INFOINFERRED == 1) @enumToInt(VS_FIXEDFILEINFO_FILE_FLAGS.INFOINFERRED) else 0) | (if (o.SPECIALBUILD == 1) @enumToInt(VS_FIXEDFILEINFO_FILE_FLAGS.SPECIALBUILD) else 0) ); } }; pub const VS_FF_DEBUG = VS_FIXEDFILEINFO_FILE_FLAGS.DEBUG; pub const VS_FF_PRERELEASE = VS_FIXEDFILEINFO_FILE_FLAGS.PRERELEASE; pub const VS_FF_PATCHED = VS_FIXEDFILEINFO_FILE_FLAGS.PATCHED; pub const VS_FF_PRIVATEBUILD = VS_FIXEDFILEINFO_FILE_FLAGS.PRIVATEBUILD; pub const VS_FF_INFOINFERRED = VS_FIXEDFILEINFO_FILE_FLAGS.INFOINFERRED; pub const VS_FF_SPECIALBUILD = VS_FIXEDFILEINFO_FILE_FLAGS.SPECIALBUILD; pub const VS_FIXEDFILEINFO_FILE_OS = enum(i32) { UNKNOWN = 0, DOS = 65536, OS216 = 131072, OS232 = 196608, NT = 262144, WINCE = 327680, // _BASE = 0, this enum value conflicts with UNKNOWN _WINDOWS16 = 1, _PM16 = 2, _PM32 = 3, _WINDOWS32 = 4, DOS_WINDOWS16 = 65537, DOS_WINDOWS32 = 65540, OS216_PM16 = 131074, OS232_PM32 = 196611, NT_WINDOWS32 = 262148, }; pub const VOS_UNKNOWN = VS_FIXEDFILEINFO_FILE_OS.UNKNOWN; pub const VOS_DOS = VS_FIXEDFILEINFO_FILE_OS.DOS; pub const VOS_OS216 = VS_FIXEDFILEINFO_FILE_OS.OS216; pub const VOS_OS232 = VS_FIXEDFILEINFO_FILE_OS.OS232; pub const VOS_NT = VS_FIXEDFILEINFO_FILE_OS.NT; pub const VOS_WINCE = VS_FIXEDFILEINFO_FILE_OS.WINCE; pub const VOS__BASE = VS_FIXEDFILEINFO_FILE_OS.UNKNOWN; pub const VOS__WINDOWS16 = VS_FIXEDFILEINFO_FILE_OS._WINDOWS16; pub const VOS__PM16 = VS_FIXEDFILEINFO_FILE_OS._PM16; pub const VOS__PM32 = VS_FIXEDFILEINFO_FILE_OS._PM32; pub const VOS__WINDOWS32 = VS_FIXEDFILEINFO_FILE_OS._WINDOWS32; pub const VOS_DOS_WINDOWS16 = VS_FIXEDFILEINFO_FILE_OS.DOS_WINDOWS16; pub const VOS_DOS_WINDOWS32 = VS_FIXEDFILEINFO_FILE_OS.DOS_WINDOWS32; pub const VOS_OS216_PM16 = VS_FIXEDFILEINFO_FILE_OS.OS216_PM16; pub const VOS_OS232_PM32 = VS_FIXEDFILEINFO_FILE_OS.OS232_PM32; pub const VOS_NT_WINDOWS32 = VS_FIXEDFILEINFO_FILE_OS.NT_WINDOWS32; pub const VS_FIXEDFILEINFO_FILE_TYPE = enum(i32) { UNKNOWN = 0, APP = 1, DLL = 2, DRV = 3, FONT = 4, VXD = 5, STATIC_LIB = 7, }; pub const VFT_UNKNOWN = VS_FIXEDFILEINFO_FILE_TYPE.UNKNOWN; pub const VFT_APP = VS_FIXEDFILEINFO_FILE_TYPE.APP; pub const VFT_DLL = VS_FIXEDFILEINFO_FILE_TYPE.DLL; pub const VFT_DRV = VS_FIXEDFILEINFO_FILE_TYPE.DRV; pub const VFT_FONT = VS_FIXEDFILEINFO_FILE_TYPE.FONT; pub const VFT_VXD = VS_FIXEDFILEINFO_FILE_TYPE.VXD; pub const VFT_STATIC_LIB = VS_FIXEDFILEINFO_FILE_TYPE.STATIC_LIB; pub const VS_FIXEDFILEINFO_FILE_SUBTYPE = enum(i32) { UNKNOWN = 0, DRV_PRINTER = 1, DRV_KEYBOARD = 2, DRV_LANGUAGE = 3, DRV_DISPLAY = 4, DRV_MOUSE = 5, DRV_NETWORK = 6, DRV_SYSTEM = 7, DRV_INSTALLABLE = 8, DRV_SOUND = 9, DRV_COMM = 10, DRV_INPUTMETHOD = 11, DRV_VERSIONED_PRINTER = 12, // FONT_RASTER = 1, this enum value conflicts with DRV_PRINTER // FONT_VECTOR = 2, this enum value conflicts with DRV_KEYBOARD // FONT_TRUETYPE = 3, this enum value conflicts with DRV_LANGUAGE }; pub const VFT2_UNKNOWN = VS_FIXEDFILEINFO_FILE_SUBTYPE.UNKNOWN; pub const VFT2_DRV_PRINTER = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_PRINTER; pub const VFT2_DRV_KEYBOARD = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_KEYBOARD; pub const VFT2_DRV_LANGUAGE = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_LANGUAGE; pub const VFT2_DRV_DISPLAY = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_DISPLAY; pub const VFT2_DRV_MOUSE = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_MOUSE; pub const VFT2_DRV_NETWORK = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_NETWORK; pub const VFT2_DRV_SYSTEM = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_SYSTEM; pub const VFT2_DRV_INSTALLABLE = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_INSTALLABLE; pub const VFT2_DRV_SOUND = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_SOUND; pub const VFT2_DRV_COMM = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_COMM; pub const VFT2_DRV_INPUTMETHOD = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_INPUTMETHOD; pub const VFT2_DRV_VERSIONED_PRINTER = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_VERSIONED_PRINTER; pub const VFT2_FONT_RASTER = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_PRINTER; pub const VFT2_FONT_VECTOR = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_KEYBOARD; pub const VFT2_FONT_TRUETYPE = VS_FIXEDFILEINFO_FILE_SUBTYPE.DRV_LANGUAGE; pub const FILE_CREATION_DISPOSITION = enum(u32) { CREATE_NEW = 1, CREATE_ALWAYS = 2, OPEN_EXISTING = 3, OPEN_ALWAYS = 4, TRUNCATE_EXISTING = 5, }; pub const CREATE_NEW = FILE_CREATION_DISPOSITION.CREATE_NEW; pub const CREATE_ALWAYS = FILE_CREATION_DISPOSITION.CREATE_ALWAYS; pub const OPEN_EXISTING = FILE_CREATION_DISPOSITION.OPEN_EXISTING; pub const OPEN_ALWAYS = FILE_CREATION_DISPOSITION.OPEN_ALWAYS; pub const TRUNCATE_EXISTING = FILE_CREATION_DISPOSITION.TRUNCATE_EXISTING; pub const FILE_SHARE_MODE = enum(u32) { NONE = 0, DELETE = 4, READ = 1, WRITE = 2, _, pub fn initFlags(o: struct { NONE: u1 = 0, DELETE: u1 = 0, READ: u1 = 0, WRITE: u1 = 0, }) FILE_SHARE_MODE { return @intToEnum(FILE_SHARE_MODE, (if (o.NONE == 1) @enumToInt(FILE_SHARE_MODE.NONE) else 0) | (if (o.DELETE == 1) @enumToInt(FILE_SHARE_MODE.DELETE) else 0) | (if (o.READ == 1) @enumToInt(FILE_SHARE_MODE.READ) else 0) | (if (o.WRITE == 1) @enumToInt(FILE_SHARE_MODE.WRITE) else 0) ); } }; pub const FILE_SHARE_NONE = FILE_SHARE_MODE.NONE; pub const FILE_SHARE_DELETE = FILE_SHARE_MODE.DELETE; pub const FILE_SHARE_READ = FILE_SHARE_MODE.READ; pub const FILE_SHARE_WRITE = FILE_SHARE_MODE.WRITE; pub const SHARE_TYPE = enum(u32) { DISKTREE = 0, PRINTQ = 1, DEVICE = 2, IPC = 3, SPECIAL = 2147483648, TEMPORARY = 1073741824, MASK = 255, _, pub fn initFlags(o: struct { DISKTREE: u1 = 0, PRINTQ: u1 = 0, DEVICE: u1 = 0, IPC: u1 = 0, SPECIAL: u1 = 0, TEMPORARY: u1 = 0, MASK: u1 = 0, }) SHARE_TYPE { return @intToEnum(SHARE_TYPE, (if (o.DISKTREE == 1) @enumToInt(SHARE_TYPE.DISKTREE) else 0) | (if (o.PRINTQ == 1) @enumToInt(SHARE_TYPE.PRINTQ) else 0) | (if (o.DEVICE == 1) @enumToInt(SHARE_TYPE.DEVICE) else 0) | (if (o.IPC == 1) @enumToInt(SHARE_TYPE.IPC) else 0) | (if (o.SPECIAL == 1) @enumToInt(SHARE_TYPE.SPECIAL) else 0) | (if (o.TEMPORARY == 1) @enumToInt(SHARE_TYPE.TEMPORARY) else 0) | (if (o.MASK == 1) @enumToInt(SHARE_TYPE.MASK) else 0) ); } }; pub const STYPE_DISKTREE = SHARE_TYPE.DISKTREE; pub const STYPE_PRINTQ = SHARE_TYPE.PRINTQ; pub const STYPE_DEVICE = SHARE_TYPE.DEVICE; pub const STYPE_IPC = SHARE_TYPE.IPC; pub const STYPE_SPECIAL = SHARE_TYPE.SPECIAL; pub const STYPE_TEMPORARY = SHARE_TYPE.TEMPORARY; pub const STYPE_MASK = SHARE_TYPE.MASK; pub const CLFS_FLAG = enum(u32) { FORCE_APPEND = 1, FORCE_FLUSH = 2, NO_FLAGS = 0, USE_RESERVATION = 4, _, pub fn initFlags(o: struct { FORCE_APPEND: u1 = 0, FORCE_FLUSH: u1 = 0, NO_FLAGS: u1 = 0, USE_RESERVATION: u1 = 0, }) CLFS_FLAG { return @intToEnum(CLFS_FLAG, (if (o.FORCE_APPEND == 1) @enumToInt(CLFS_FLAG.FORCE_APPEND) else 0) | (if (o.FORCE_FLUSH == 1) @enumToInt(CLFS_FLAG.FORCE_FLUSH) else 0) | (if (o.NO_FLAGS == 1) @enumToInt(CLFS_FLAG.NO_FLAGS) else 0) | (if (o.USE_RESERVATION == 1) @enumToInt(CLFS_FLAG.USE_RESERVATION) else 0) ); } }; pub const CLFS_FLAG_FORCE_APPEND = CLFS_FLAG.FORCE_APPEND; pub const CLFS_FLAG_FORCE_FLUSH = CLFS_FLAG.FORCE_FLUSH; pub const CLFS_FLAG_NO_FLAGS = CLFS_FLAG.NO_FLAGS; pub const CLFS_FLAG_USE_RESERVATION = CLFS_FLAG.USE_RESERVATION; pub const SET_FILE_POINTER_MOVE_METHOD = enum(u32) { BEGIN = 0, CURRENT = 1, END = 2, }; pub const FILE_BEGIN = SET_FILE_POINTER_MOVE_METHOD.BEGIN; pub const FILE_CURRENT = SET_FILE_POINTER_MOVE_METHOD.CURRENT; pub const FILE_END = SET_FILE_POINTER_MOVE_METHOD.END; pub const MOVE_FILE_FLAGS = enum(u32) { COPY_ALLOWED = 2, CREATE_HARDLINK = 16, DELAY_UNTIL_REBOOT = 4, REPLACE_EXISTING = 1, WRITE_THROUGH = 8, FAIL_IF_NOT_TRACKABLE = 32, _, pub fn initFlags(o: struct { COPY_ALLOWED: u1 = 0, CREATE_HARDLINK: u1 = 0, DELAY_UNTIL_REBOOT: u1 = 0, REPLACE_EXISTING: u1 = 0, WRITE_THROUGH: u1 = 0, FAIL_IF_NOT_TRACKABLE: u1 = 0, }) MOVE_FILE_FLAGS { return @intToEnum(MOVE_FILE_FLAGS, (if (o.COPY_ALLOWED == 1) @enumToInt(MOVE_FILE_FLAGS.COPY_ALLOWED) else 0) | (if (o.CREATE_HARDLINK == 1) @enumToInt(MOVE_FILE_FLAGS.CREATE_HARDLINK) else 0) | (if (o.DELAY_UNTIL_REBOOT == 1) @enumToInt(MOVE_FILE_FLAGS.DELAY_UNTIL_REBOOT) else 0) | (if (o.REPLACE_EXISTING == 1) @enumToInt(MOVE_FILE_FLAGS.REPLACE_EXISTING) else 0) | (if (o.WRITE_THROUGH == 1) @enumToInt(MOVE_FILE_FLAGS.WRITE_THROUGH) else 0) | (if (o.FAIL_IF_NOT_TRACKABLE == 1) @enumToInt(MOVE_FILE_FLAGS.FAIL_IF_NOT_TRACKABLE) else 0) ); } }; pub const MOVEFILE_COPY_ALLOWED = MOVE_FILE_FLAGS.COPY_ALLOWED; pub const MOVEFILE_CREATE_HARDLINK = MOVE_FILE_FLAGS.CREATE_HARDLINK; pub const MOVEFILE_DELAY_UNTIL_REBOOT = MOVE_FILE_FLAGS.DELAY_UNTIL_REBOOT; pub const MOVEFILE_REPLACE_EXISTING = MOVE_FILE_FLAGS.REPLACE_EXISTING; pub const MOVEFILE_WRITE_THROUGH = MOVE_FILE_FLAGS.WRITE_THROUGH; pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE = MOVE_FILE_FLAGS.FAIL_IF_NOT_TRACKABLE; pub const FILE_NAME = enum(u32) { NORMALIZED = 0, OPENED = 8, }; pub const FILE_NAME_NORMALIZED = FILE_NAME.NORMALIZED; pub const FILE_NAME_OPENED = FILE_NAME.OPENED; pub const LZOPENFILE_STYLE = enum(u32) { CANCEL = 2048, CREATE = 4096, DELETE = 512, EXIST = 16384, PARSE = 256, PROMPT = 8192, READ = 0, READWRITE = 2, REOPEN = 32768, SHARE_DENY_NONE = 64, SHARE_DENY_READ = 48, SHARE_DENY_WRITE = 32, SHARE_EXCLUSIVE = 16, WRITE = 1, // SHARE_COMPAT = 0, this enum value conflicts with READ VERIFY = 1024, _, pub fn initFlags(o: struct { CANCEL: u1 = 0, CREATE: u1 = 0, DELETE: u1 = 0, EXIST: u1 = 0, PARSE: u1 = 0, PROMPT: u1 = 0, READ: u1 = 0, READWRITE: u1 = 0, REOPEN: u1 = 0, SHARE_DENY_NONE: u1 = 0, SHARE_DENY_READ: u1 = 0, SHARE_DENY_WRITE: u1 = 0, SHARE_EXCLUSIVE: u1 = 0, WRITE: u1 = 0, VERIFY: u1 = 0, }) LZOPENFILE_STYLE { return @intToEnum(LZOPENFILE_STYLE, (if (o.CANCEL == 1) @enumToInt(LZOPENFILE_STYLE.CANCEL) else 0) | (if (o.CREATE == 1) @enumToInt(LZOPENFILE_STYLE.CREATE) else 0) | (if (o.DELETE == 1) @enumToInt(LZOPENFILE_STYLE.DELETE) else 0) | (if (o.EXIST == 1) @enumToInt(LZOPENFILE_STYLE.EXIST) else 0) | (if (o.PARSE == 1) @enumToInt(LZOPENFILE_STYLE.PARSE) else 0) | (if (o.PROMPT == 1) @enumToInt(LZOPENFILE_STYLE.PROMPT) else 0) | (if (o.READ == 1) @enumToInt(LZOPENFILE_STYLE.READ) else 0) | (if (o.READWRITE == 1) @enumToInt(LZOPENFILE_STYLE.READWRITE) else 0) | (if (o.REOPEN == 1) @enumToInt(LZOPENFILE_STYLE.REOPEN) else 0) | (if (o.SHARE_DENY_NONE == 1) @enumToInt(LZOPENFILE_STYLE.SHARE_DENY_NONE) else 0) | (if (o.SHARE_DENY_READ == 1) @enumToInt(LZOPENFILE_STYLE.SHARE_DENY_READ) else 0) | (if (o.SHARE_DENY_WRITE == 1) @enumToInt(LZOPENFILE_STYLE.SHARE_DENY_WRITE) else 0) | (if (o.SHARE_EXCLUSIVE == 1) @enumToInt(LZOPENFILE_STYLE.SHARE_EXCLUSIVE) else 0) | (if (o.WRITE == 1) @enumToInt(LZOPENFILE_STYLE.WRITE) else 0) | (if (o.VERIFY == 1) @enumToInt(LZOPENFILE_STYLE.VERIFY) else 0) ); } }; pub const OF_CANCEL = LZOPENFILE_STYLE.CANCEL; pub const OF_CREATE = LZOPENFILE_STYLE.CREATE; pub const OF_DELETE = LZOPENFILE_STYLE.DELETE; pub const OF_EXIST = LZOPENFILE_STYLE.EXIST; pub const OF_PARSE = LZOPENFILE_STYLE.PARSE; pub const OF_PROMPT = LZOPENFILE_STYLE.PROMPT; pub const OF_READ = LZOPENFILE_STYLE.READ; pub const OF_READWRITE = LZOPENFILE_STYLE.READWRITE; pub const OF_REOPEN = LZOPENFILE_STYLE.REOPEN; pub const OF_SHARE_DENY_NONE = LZOPENFILE_STYLE.SHARE_DENY_NONE; pub const OF_SHARE_DENY_READ = LZOPENFILE_STYLE.SHARE_DENY_READ; pub const OF_SHARE_DENY_WRITE = LZOPENFILE_STYLE.SHARE_DENY_WRITE; pub const OF_SHARE_EXCLUSIVE = LZOPENFILE_STYLE.SHARE_EXCLUSIVE; pub const OF_WRITE = LZOPENFILE_STYLE.WRITE; pub const OF_SHARE_COMPAT = LZOPENFILE_STYLE.READ; pub const OF_VERIFY = LZOPENFILE_STYLE.VERIFY; pub const FILE_NOTIFY_CHANGE = enum(u32) { FILE_NAME = 1, DIR_NAME = 2, ATTRIBUTES = 4, SIZE = 8, LAST_WRITE = 16, LAST_ACCESS = 32, CREATION = 64, SECURITY = 256, _, pub fn initFlags(o: struct { FILE_NAME: u1 = 0, DIR_NAME: u1 = 0, ATTRIBUTES: u1 = 0, SIZE: u1 = 0, LAST_WRITE: u1 = 0, LAST_ACCESS: u1 = 0, CREATION: u1 = 0, SECURITY: u1 = 0, }) FILE_NOTIFY_CHANGE { return @intToEnum(FILE_NOTIFY_CHANGE, (if (o.FILE_NAME == 1) @enumToInt(FILE_NOTIFY_CHANGE.FILE_NAME) else 0) | (if (o.DIR_NAME == 1) @enumToInt(FILE_NOTIFY_CHANGE.DIR_NAME) else 0) | (if (o.ATTRIBUTES == 1) @enumToInt(FILE_NOTIFY_CHANGE.ATTRIBUTES) else 0) | (if (o.SIZE == 1) @enumToInt(FILE_NOTIFY_CHANGE.SIZE) else 0) | (if (o.LAST_WRITE == 1) @enumToInt(FILE_NOTIFY_CHANGE.LAST_WRITE) else 0) | (if (o.LAST_ACCESS == 1) @enumToInt(FILE_NOTIFY_CHANGE.LAST_ACCESS) else 0) | (if (o.CREATION == 1) @enumToInt(FILE_NOTIFY_CHANGE.CREATION) else 0) | (if (o.SECURITY == 1) @enumToInt(FILE_NOTIFY_CHANGE.SECURITY) else 0) ); } }; pub const FILE_NOTIFY_CHANGE_FILE_NAME = FILE_NOTIFY_CHANGE.FILE_NAME; pub const FILE_NOTIFY_CHANGE_DIR_NAME = FILE_NOTIFY_CHANGE.DIR_NAME; pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = FILE_NOTIFY_CHANGE.ATTRIBUTES; pub const FILE_NOTIFY_CHANGE_SIZE = FILE_NOTIFY_CHANGE.SIZE; pub const FILE_NOTIFY_CHANGE_LAST_WRITE = FILE_NOTIFY_CHANGE.LAST_WRITE; pub const FILE_NOTIFY_CHANGE_LAST_ACCESS = FILE_NOTIFY_CHANGE.LAST_ACCESS; pub const FILE_NOTIFY_CHANGE_CREATION = FILE_NOTIFY_CHANGE.CREATION; pub const FILE_NOTIFY_CHANGE_SECURITY = FILE_NOTIFY_CHANGE.SECURITY; pub const TXFS_MINIVERSION = enum(u32) { COMMITTED_VIEW = 0, DIRTY_VIEW = 65535, DEFAULT_VIEW = 65534, }; pub const TXFS_MINIVERSION_COMMITTED_VIEW = TXFS_MINIVERSION.COMMITTED_VIEW; pub const TXFS_MINIVERSION_DIRTY_VIEW = TXFS_MINIVERSION.DIRTY_VIEW; pub const TXFS_MINIVERSION_DEFAULT_VIEW = TXFS_MINIVERSION.DEFAULT_VIEW; pub const TAPE_POSITION_TYPE = enum(i32) { ABSOLUTE_POSITION = 0, LOGICAL_POSITION = 1, }; pub const TAPE_ABSOLUTE_POSITION = TAPE_POSITION_TYPE.ABSOLUTE_POSITION; pub const TAPE_LOGICAL_POSITION = TAPE_POSITION_TYPE.LOGICAL_POSITION; pub const CREATE_TAPE_PARTITION_METHOD = enum(i32) { FIXED_PARTITIONS = 0, INITIATOR_PARTITIONS = 2, SELECT_PARTITIONS = 1, }; pub const TAPE_FIXED_PARTITIONS = CREATE_TAPE_PARTITION_METHOD.FIXED_PARTITIONS; pub const TAPE_INITIATOR_PARTITIONS = CREATE_TAPE_PARTITION_METHOD.INITIATOR_PARTITIONS; pub const TAPE_SELECT_PARTITIONS = CREATE_TAPE_PARTITION_METHOD.SELECT_PARTITIONS; pub const REPLACE_FILE_FLAGS = enum(u32) { WRITE_THROUGH = 1, IGNORE_MERGE_ERRORS = 2, IGNORE_ACL_ERRORS = 4, _, pub fn initFlags(o: struct { WRITE_THROUGH: u1 = 0, IGNORE_MERGE_ERRORS: u1 = 0, IGNORE_ACL_ERRORS: u1 = 0, }) REPLACE_FILE_FLAGS { return @intToEnum(REPLACE_FILE_FLAGS, (if (o.WRITE_THROUGH == 1) @enumToInt(REPLACE_FILE_FLAGS.WRITE_THROUGH) else 0) | (if (o.IGNORE_MERGE_ERRORS == 1) @enumToInt(REPLACE_FILE_FLAGS.IGNORE_MERGE_ERRORS) else 0) | (if (o.IGNORE_ACL_ERRORS == 1) @enumToInt(REPLACE_FILE_FLAGS.IGNORE_ACL_ERRORS) else 0) ); } }; pub const REPLACEFILE_WRITE_THROUGH = REPLACE_FILE_FLAGS.WRITE_THROUGH; pub const REPLACEFILE_IGNORE_MERGE_ERRORS = REPLACE_FILE_FLAGS.IGNORE_MERGE_ERRORS; pub const REPLACEFILE_IGNORE_ACL_ERRORS = REPLACE_FILE_FLAGS.IGNORE_ACL_ERRORS; pub const TAPEMARK_TYPE = enum(i32) { FILEMARKS = 1, LONG_FILEMARKS = 3, SETMARKS = 0, SHORT_FILEMARKS = 2, }; pub const TAPE_FILEMARKS = TAPEMARK_TYPE.FILEMARKS; pub const TAPE_LONG_FILEMARKS = TAPEMARK_TYPE.LONG_FILEMARKS; pub const TAPE_SETMARKS = TAPEMARK_TYPE.SETMARKS; pub const TAPE_SHORT_FILEMARKS = TAPEMARK_TYPE.SHORT_FILEMARKS; pub const DISKQUOTA_USERNAME_RESOLVE = enum(u32) { ASYNC = 2, NONE = 0, SYNC = 1, }; pub const DISKQUOTA_USERNAME_RESOLVE_ASYNC = DISKQUOTA_USERNAME_RESOLVE.ASYNC; pub const DISKQUOTA_USERNAME_RESOLVE_NONE = DISKQUOTA_USERNAME_RESOLVE.NONE; pub const DISKQUOTA_USERNAME_RESOLVE_SYNC = DISKQUOTA_USERNAME_RESOLVE.SYNC; pub const TAPE_POSITION_METHOD = enum(i32) { ABSOLUTE_BLOCK = 1, LOGICAL_BLOCK = 2, REWIND = 0, SPACE_END_OF_DATA = 4, SPACE_FILEMARKS = 6, SPACE_RELATIVE_BLOCKS = 5, SPACE_SEQUENTIAL_FMKS = 7, SPACE_SEQUENTIAL_SMKS = 9, SPACE_SETMARKS = 8, }; pub const TAPE_ABSOLUTE_BLOCK = TAPE_POSITION_METHOD.ABSOLUTE_BLOCK; pub const TAPE_LOGICAL_BLOCK = TAPE_POSITION_METHOD.LOGICAL_BLOCK; pub const TAPE_REWIND = TAPE_POSITION_METHOD.REWIND; pub const TAPE_SPACE_END_OF_DATA = TAPE_POSITION_METHOD.SPACE_END_OF_DATA; pub const TAPE_SPACE_FILEMARKS = TAPE_POSITION_METHOD.SPACE_FILEMARKS; pub const TAPE_SPACE_RELATIVE_BLOCKS = TAPE_POSITION_METHOD.SPACE_RELATIVE_BLOCKS; pub const TAPE_SPACE_SEQUENTIAL_FMKS = TAPE_POSITION_METHOD.SPACE_SEQUENTIAL_FMKS; pub const TAPE_SPACE_SEQUENTIAL_SMKS = TAPE_POSITION_METHOD.SPACE_SEQUENTIAL_SMKS; pub const TAPE_SPACE_SETMARKS = TAPE_POSITION_METHOD.SPACE_SETMARKS; pub const NT_CREATE_FILE_DISPOSITION = enum(u32) { SUPERSEDE = 0, CREATE = 2, OPEN = 1, OPEN_IF = 3, OVERWRITE = 4, OVERWRITE_IF = 5, }; pub const FILE_SUPERSEDE = NT_CREATE_FILE_DISPOSITION.SUPERSEDE; pub const FILE_CREATE = NT_CREATE_FILE_DISPOSITION.CREATE; pub const FILE_OPEN = NT_CREATE_FILE_DISPOSITION.OPEN; pub const FILE_OPEN_IF = NT_CREATE_FILE_DISPOSITION.OPEN_IF; pub const FILE_OVERWRITE = NT_CREATE_FILE_DISPOSITION.OVERWRITE; pub const FILE_OVERWRITE_IF = NT_CREATE_FILE_DISPOSITION.OVERWRITE_IF; pub const TAPE_INFORMATION_TYPE = enum(u32) { DRIVE_INFORMATION = 1, MEDIA_INFORMATION = 0, }; pub const SET_TAPE_DRIVE_INFORMATION = TAPE_INFORMATION_TYPE.DRIVE_INFORMATION; pub const SET_TAPE_MEDIA_INFORMATION = TAPE_INFORMATION_TYPE.MEDIA_INFORMATION; pub const NTMS_OMID_TYPE = enum(u32) { FILESYSTEM_INFO = 2, RAW_LABEL = 1, }; pub const NTMS_OMID_TYPE_FILESYSTEM_INFO = NTMS_OMID_TYPE.FILESYSTEM_INFO; pub const NTMS_OMID_TYPE_RAW_LABEL = NTMS_OMID_TYPE.RAW_LABEL; pub const LOCK_FILE_FLAGS = enum(u32) { EXCLUSIVE_LOCK = 2, FAIL_IMMEDIATELY = 1, _, pub fn initFlags(o: struct { EXCLUSIVE_LOCK: u1 = 0, FAIL_IMMEDIATELY: u1 = 0, }) LOCK_FILE_FLAGS { return @intToEnum(LOCK_FILE_FLAGS, (if (o.EXCLUSIVE_LOCK == 1) @enumToInt(LOCK_FILE_FLAGS.EXCLUSIVE_LOCK) else 0) | (if (o.FAIL_IMMEDIATELY == 1) @enumToInt(LOCK_FILE_FLAGS.FAIL_IMMEDIATELY) else 0) ); } }; pub const LOCKFILE_EXCLUSIVE_LOCK = LOCK_FILE_FLAGS.EXCLUSIVE_LOCK; pub const LOCKFILE_FAIL_IMMEDIATELY = LOCK_FILE_FLAGS.FAIL_IMMEDIATELY; pub const LPPROGRESS_ROUTINE_CALLBACK_REASON = enum(u32) { CHUNK_FINISHED = 0, STREAM_SWITCH = 1, }; pub const CALLBACK_CHUNK_FINISHED = LPPROGRESS_ROUTINE_CALLBACK_REASON.CHUNK_FINISHED; pub const CALLBACK_STREAM_SWITCH = LPPROGRESS_ROUTINE_CALLBACK_REASON.STREAM_SWITCH; pub const PREPARE_TAPE_OPERATION = enum(i32) { FORMAT = 5, LOAD = 0, LOCK = 3, TENSION = 2, UNLOAD = 1, UNLOCK = 4, }; pub const TAPE_FORMAT = PREPARE_TAPE_OPERATION.FORMAT; pub const TAPE_LOAD = PREPARE_TAPE_OPERATION.LOAD; pub const TAPE_LOCK = PREPARE_TAPE_OPERATION.LOCK; pub const TAPE_TENSION = PREPARE_TAPE_OPERATION.TENSION; pub const TAPE_UNLOAD = PREPARE_TAPE_OPERATION.UNLOAD; pub const TAPE_UNLOCK = PREPARE_TAPE_OPERATION.UNLOCK; pub const GET_TAPE_DRIVE_PARAMETERS_OPERATION = enum(u32) { DRIVE_INFORMATION = 1, MEDIA_INFORMATION = 0, }; pub const GET_TAPE_DRIVE_INFORMATION = GET_TAPE_DRIVE_PARAMETERS_OPERATION.DRIVE_INFORMATION; pub const GET_TAPE_MEDIA_INFORMATION = GET_TAPE_DRIVE_PARAMETERS_OPERATION.MEDIA_INFORMATION; pub const ERASE_TAPE_TYPE = enum(i32) { LONG = 1, SHORT = 0, }; pub const TAPE_ERASE_LONG = ERASE_TAPE_TYPE.LONG; pub const TAPE_ERASE_SHORT = ERASE_TAPE_TYPE.SHORT; pub const FILE_ACTION = enum(u32) { ADDED = 1, REMOVED = 2, MODIFIED = 3, RENAMED_OLD_NAME = 4, RENAMED_NEW_NAME = 5, }; pub const FILE_ACTION_ADDED = FILE_ACTION.ADDED; pub const FILE_ACTION_REMOVED = FILE_ACTION.REMOVED; pub const FILE_ACTION_MODIFIED = FILE_ACTION.MODIFIED; pub const FILE_ACTION_RENAMED_OLD_NAME = FILE_ACTION.RENAMED_OLD_NAME; pub const FILE_ACTION_RENAMED_NEW_NAME = FILE_ACTION.RENAMED_NEW_NAME; pub const SHARE_INFO_PERMISSIONS = enum(u32) { READ = 1, WRITE = 2, CREATE = 4, EXEC = 8, DELETE = 16, ATRIB = 32, PERM = 64, ALL = 32768, }; pub const ACCESS_READ = SHARE_INFO_PERMISSIONS.READ; pub const ACCESS_WRITE = SHARE_INFO_PERMISSIONS.WRITE; pub const ACCESS_CREATE = SHARE_INFO_PERMISSIONS.CREATE; pub const ACCESS_EXEC = SHARE_INFO_PERMISSIONS.EXEC; pub const ACCESS_DELETE = SHARE_INFO_PERMISSIONS.DELETE; pub const ACCESS_ATRIB = SHARE_INFO_PERMISSIONS.ATRIB; pub const ACCESS_PERM = SHARE_INFO_PERMISSIONS.PERM; pub const ACCESS_ALL = SHARE_INFO_PERMISSIONS.ALL; pub const FILE_DEVICE_TYPE = enum(u32) { CD_ROM = 2, DISK = 7, TAPE = 31, DVD = 51, }; pub const FILE_DEVICE_CD_ROM = FILE_DEVICE_TYPE.CD_ROM; pub const FILE_DEVICE_DISK = FILE_DEVICE_TYPE.DISK; pub const FILE_DEVICE_TAPE = FILE_DEVICE_TYPE.TAPE; pub const FILE_DEVICE_DVD = FILE_DEVICE_TYPE.DVD; pub const SESSION_INFO_USER_FLAGS = enum(u32) { GUEST = 1, NOENCRYPTION = 2, }; pub const SESS_GUEST = SESSION_INFO_USER_FLAGS.GUEST; pub const SESS_NOENCRYPTION = SESSION_INFO_USER_FLAGS.NOENCRYPTION; pub const WIN_STREAM_ID = enum(u32) { ALTERNATE_DATA = 4, DATA = 1, EA_DATA = 2, LINK = 5, OBJECT_ID = 7, PROPERTY_DATA = 6, REPARSE_DATA = 8, SECURITY_DATA = 3, SPARSE_BLOCK = 9, TXFS_DATA = 10, }; pub const BACKUP_ALTERNATE_DATA = WIN_STREAM_ID.ALTERNATE_DATA; pub const BACKUP_DATA = WIN_STREAM_ID.DATA; pub const BACKUP_EA_DATA = WIN_STREAM_ID.EA_DATA; pub const BACKUP_LINK = WIN_STREAM_ID.LINK; pub const BACKUP_OBJECT_ID = WIN_STREAM_ID.OBJECT_ID; pub const BACKUP_PROPERTY_DATA = WIN_STREAM_ID.PROPERTY_DATA; pub const BACKUP_REPARSE_DATA = WIN_STREAM_ID.REPARSE_DATA; pub const BACKUP_SECURITY_DATA = WIN_STREAM_ID.SECURITY_DATA; pub const BACKUP_SPARSE_BLOCK = WIN_STREAM_ID.SPARSE_BLOCK; pub const BACKUP_TXFS_DATA = WIN_STREAM_ID.TXFS_DATA; pub const TXF_LOG_RECORD_TYPE = enum(u16) { AFFECTED_FILE = 4, TRUNCATE = 2, WRITE = 1, }; pub const TXF_LOG_RECORD_TYPE_AFFECTED_FILE = TXF_LOG_RECORD_TYPE.AFFECTED_FILE; pub const TXF_LOG_RECORD_TYPE_TRUNCATE = TXF_LOG_RECORD_TYPE.TRUNCATE; pub const TXF_LOG_RECORD_TYPE_WRITE = TXF_LOG_RECORD_TYPE.WRITE; pub const FILE_INFO_FLAGS_PERMISSIONS = enum(u32) { READ = 1, WRITE = 2, CREATE = 4, _, pub fn initFlags(o: struct { READ: u1 = 0, WRITE: u1 = 0, CREATE: u1 = 0, }) FILE_INFO_FLAGS_PERMISSIONS { return @intToEnum(FILE_INFO_FLAGS_PERMISSIONS, (if (o.READ == 1) @enumToInt(FILE_INFO_FLAGS_PERMISSIONS.READ) else 0) | (if (o.WRITE == 1) @enumToInt(FILE_INFO_FLAGS_PERMISSIONS.WRITE) else 0) | (if (o.CREATE == 1) @enumToInt(FILE_INFO_FLAGS_PERMISSIONS.CREATE) else 0) ); } }; pub const PERM_FILE_READ = FILE_INFO_FLAGS_PERMISSIONS.READ; pub const PERM_FILE_WRITE = FILE_INFO_FLAGS_PERMISSIONS.WRITE; pub const PERM_FILE_CREATE = FILE_INFO_FLAGS_PERMISSIONS.CREATE; pub const SYMBOLIC_LINK_FLAGS = enum(u32) { DIRECTORY = 1, ALLOW_UNPRIVILEGED_CREATE = 2, _, pub fn initFlags(o: struct { DIRECTORY: u1 = 0, ALLOW_UNPRIVILEGED_CREATE: u1 = 0, }) SYMBOLIC_LINK_FLAGS { return @intToEnum(SYMBOLIC_LINK_FLAGS, (if (o.DIRECTORY == 1) @enumToInt(SYMBOLIC_LINK_FLAGS.DIRECTORY) else 0) | (if (o.ALLOW_UNPRIVILEGED_CREATE == 1) @enumToInt(SYMBOLIC_LINK_FLAGS.ALLOW_UNPRIVILEGED_CREATE) else 0) ); } }; pub const SYMBOLIC_LINK_FLAG_DIRECTORY = SYMBOLIC_LINK_FLAGS.DIRECTORY; pub const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = SYMBOLIC_LINK_FLAGS.ALLOW_UNPRIVILEGED_CREATE; // TODO: this type has a FreeFunc 'FindClose', what can Zig do with this information? pub const FindFileHandle = isize; // TODO: this type has a FreeFunc 'FindClose', what can Zig do with this information? pub const FindFileNameHandle = isize; // TODO: this type has a FreeFunc 'FindClose', what can Zig do with this information? pub const FindStreamHandle = isize; // TODO: this type has a FreeFunc 'FindCloseChangeNotification', what can Zig do with this information? pub const FindChangeNotificationHandle = isize; // TODO: this type has a FreeFunc 'FindVolumeClose', what can Zig do with this information? pub const FindVolumeHandle = isize; // TODO: this type has a FreeFunc 'FindVolumeMountPointClose', what can Zig do with this information? pub const FindVolumeMointPointHandle = isize; pub const WIN32_FIND_DATAA = extern struct { dwFileAttributes: u32, ftCreationTime: FILETIME, ftLastAccessTime: FILETIME, ftLastWriteTime: FILETIME, nFileSizeHigh: u32, nFileSizeLow: u32, dwReserved0: u32, dwReserved1: u32, cFileName: [260]CHAR, cAlternateFileName: [14]CHAR, }; pub const WIN32_FIND_DATAW = extern struct { dwFileAttributes: u32, ftCreationTime: FILETIME, ftLastAccessTime: FILETIME, ftLastWriteTime: FILETIME, nFileSizeHigh: u32, nFileSizeLow: u32, dwReserved0: u32, dwReserved1: u32, cFileName: [260]u16, cAlternateFileName: [14]u16, }; pub const FINDEX_INFO_LEVELS = enum(i32) { Standard = 0, Basic = 1, MaxInfoLevel = 2, }; pub const FindExInfoStandard = FINDEX_INFO_LEVELS.Standard; pub const FindExInfoBasic = FINDEX_INFO_LEVELS.Basic; pub const FindExInfoMaxInfoLevel = FINDEX_INFO_LEVELS.MaxInfoLevel; pub const FINDEX_SEARCH_OPS = enum(i32) { NameMatch = 0, LimitToDirectories = 1, LimitToDevices = 2, MaxSearchOp = 3, }; pub const FindExSearchNameMatch = FINDEX_SEARCH_OPS.NameMatch; pub const FindExSearchLimitToDirectories = FINDEX_SEARCH_OPS.LimitToDirectories; pub const FindExSearchLimitToDevices = FINDEX_SEARCH_OPS.LimitToDevices; pub const FindExSearchMaxSearchOp = FINDEX_SEARCH_OPS.MaxSearchOp; pub const READ_DIRECTORY_NOTIFY_INFORMATION_CLASS = enum(i32) { Information = 1, ExtendedInformation = 2, }; pub const ReadDirectoryNotifyInformation = READ_DIRECTORY_NOTIFY_INFORMATION_CLASS.Information; pub const ReadDirectoryNotifyExtendedInformation = READ_DIRECTORY_NOTIFY_INFORMATION_CLASS.ExtendedInformation; pub const GET_FILEEX_INFO_LEVELS = enum(i32) { InfoStandard = 0, MaxInfoLevel = 1, }; pub const GetFileExInfoStandard = GET_FILEEX_INFO_LEVELS.InfoStandard; pub const GetFileExMaxInfoLevel = GET_FILEEX_INFO_LEVELS.MaxInfoLevel; pub const FILE_INFO_BY_HANDLE_CLASS = enum(i32) { FileBasicInfo = 0, FileStandardInfo = 1, FileNameInfo = 2, FileRenameInfo = 3, FileDispositionInfo = 4, FileAllocationInfo = 5, FileEndOfFileInfo = 6, FileStreamInfo = 7, FileCompressionInfo = 8, FileAttributeTagInfo = 9, FileIdBothDirectoryInfo = 10, FileIdBothDirectoryRestartInfo = 11, FileIoPriorityHintInfo = 12, FileRemoteProtocolInfo = 13, FileFullDirectoryInfo = 14, FileFullDirectoryRestartInfo = 15, FileStorageInfo = 16, FileAlignmentInfo = 17, FileIdInfo = 18, FileIdExtdDirectoryInfo = 19, FileIdExtdDirectoryRestartInfo = 20, FileDispositionInfoEx = 21, FileRenameInfoEx = 22, FileCaseSensitiveInfo = 23, FileNormalizedNameInfo = 24, MaximumFileInfoByHandleClass = 25, }; pub const FileBasicInfo = FILE_INFO_BY_HANDLE_CLASS.FileBasicInfo; pub const FileStandardInfo = FILE_INFO_BY_HANDLE_CLASS.FileStandardInfo; pub const FileNameInfo = FILE_INFO_BY_HANDLE_CLASS.FileNameInfo; pub const FileRenameInfo = FILE_INFO_BY_HANDLE_CLASS.FileRenameInfo; pub const FileDispositionInfo = FILE_INFO_BY_HANDLE_CLASS.FileDispositionInfo; pub const FileAllocationInfo = FILE_INFO_BY_HANDLE_CLASS.FileAllocationInfo; pub const FileEndOfFileInfo = FILE_INFO_BY_HANDLE_CLASS.FileEndOfFileInfo; pub const FileStreamInfo = FILE_INFO_BY_HANDLE_CLASS.FileStreamInfo; pub const FileCompressionInfo = FILE_INFO_BY_HANDLE_CLASS.FileCompressionInfo; pub const FileAttributeTagInfo = FILE_INFO_BY_HANDLE_CLASS.FileAttributeTagInfo; pub const FileIdBothDirectoryInfo = FILE_INFO_BY_HANDLE_CLASS.FileIdBothDirectoryInfo; pub const FileIdBothDirectoryRestartInfo = FILE_INFO_BY_HANDLE_CLASS.FileIdBothDirectoryRestartInfo; pub const FileIoPriorityHintInfo = FILE_INFO_BY_HANDLE_CLASS.FileIoPriorityHintInfo; pub const FileRemoteProtocolInfo = FILE_INFO_BY_HANDLE_CLASS.FileRemoteProtocolInfo; pub const FileFullDirectoryInfo = FILE_INFO_BY_HANDLE_CLASS.FileFullDirectoryInfo; pub const FileFullDirectoryRestartInfo = FILE_INFO_BY_HANDLE_CLASS.FileFullDirectoryRestartInfo; pub const FileStorageInfo = FILE_INFO_BY_HANDLE_CLASS.FileStorageInfo; pub const FileAlignmentInfo = FILE_INFO_BY_HANDLE_CLASS.FileAlignmentInfo; pub const FileIdInfo = FILE_INFO_BY_HANDLE_CLASS.FileIdInfo; pub const FileIdExtdDirectoryInfo = FILE_INFO_BY_HANDLE_CLASS.FileIdExtdDirectoryInfo; pub const FileIdExtdDirectoryRestartInfo = FILE_INFO_BY_HANDLE_CLASS.FileIdExtdDirectoryRestartInfo; pub const FileDispositionInfoEx = FILE_INFO_BY_HANDLE_CLASS.FileDispositionInfoEx; pub const FileRenameInfoEx = FILE_INFO_BY_HANDLE_CLASS.FileRenameInfoEx; pub const FileCaseSensitiveInfo = FILE_INFO_BY_HANDLE_CLASS.FileCaseSensitiveInfo; pub const FileNormalizedNameInfo = FILE_INFO_BY_HANDLE_CLASS.FileNormalizedNameInfo; pub const MaximumFileInfoByHandleClass = FILE_INFO_BY_HANDLE_CLASS.MaximumFileInfoByHandleClass; pub const TRANSACTION_NOTIFICATION = extern struct { TransactionKey: ?*anyopaque, TransactionNotification: u32, TmVirtualClock: LARGE_INTEGER, ArgumentLength: u32, }; pub const TRANSACTION_NOTIFICATION_RECOVERY_ARGUMENT = extern struct { EnlistmentId: Guid, UOW: Guid, }; pub const TRANSACTION_NOTIFICATION_TM_ONLINE_ARGUMENT = extern struct { TmIdentity: Guid, Flags: u32, }; pub const TRANSACTION_NOTIFICATION_SAVEPOINT_ARGUMENT = extern struct { SavepointId: u32, }; pub const TRANSACTION_NOTIFICATION_PROPAGATE_ARGUMENT = extern struct { PropagationCookie: u32, UOW: Guid, TmIdentity: Guid, BufferLength: u32, }; pub const TRANSACTION_NOTIFICATION_MARSHAL_ARGUMENT = extern struct { MarshalCookie: u32, UOW: Guid, }; pub const KCRM_MARSHAL_HEADER = extern struct { VersionMajor: u32, VersionMinor: u32, NumProtocols: u32, Unused: u32, }; pub const KCRM_TRANSACTION_BLOB = extern struct { UOW: Guid, TmIdentity: Guid, IsolationLevel: u32, IsolationFlags: u32, Timeout: u32, Description: [64]u16, }; pub const KCRM_PROTOCOL_BLOB = extern struct { ProtocolId: Guid, StaticInfoLength: u32, TransactionIdInfoLength: u32, Unused1: u32, Unused2: u32, }; pub const DISK_SPACE_INFORMATION = extern struct { ActualTotalAllocationUnits: u64, ActualAvailableAllocationUnits: u64, ActualPoolUnavailableAllocationUnits: u64, CallerTotalAllocationUnits: u64, CallerAvailableAllocationUnits: u64, CallerPoolUnavailableAllocationUnits: u64, UsedAllocationUnits: u64, TotalReservedAllocationUnits: u64, VolumeStorageReserveAllocationUnits: u64, AvailableCommittedAllocationUnits: u64, PoolAvailableAllocationUnits: u64, SectorsPerAllocationUnit: u32, BytesPerSector: u32, }; pub const WIN32_FILE_ATTRIBUTE_DATA = extern struct { dwFileAttributes: u32, ftCreationTime: FILETIME, ftLastAccessTime: FILETIME, ftLastWriteTime: FILETIME, nFileSizeHigh: u32, nFileSizeLow: u32, }; pub const BY_HANDLE_FILE_INFORMATION = extern struct { dwFileAttributes: u32, ftCreationTime: FILETIME, ftLastAccessTime: FILETIME, ftLastWriteTime: FILETIME, dwVolumeSerialNumber: u32, nFileSizeHigh: u32, nFileSizeLow: u32, nNumberOfLinks: u32, nFileIndexHigh: u32, nFileIndexLow: u32, }; pub const CREATEFILE2_EXTENDED_PARAMETERS = extern struct { dwSize: u32, dwFileAttributes: u32, dwFileFlags: u32, dwSecurityQosFlags: u32, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, hTemplateFile: ?HANDLE, }; pub const STREAM_INFO_LEVELS = enum(i32) { Standard = 0, MaxInfoLevel = 1, }; pub const FindStreamInfoStandard = STREAM_INFO_LEVELS.Standard; pub const FindStreamInfoMaxInfoLevel = STREAM_INFO_LEVELS.MaxInfoLevel; pub const WIN32_FIND_STREAM_DATA = extern struct { StreamSize: LARGE_INTEGER, cStreamName: [296]u16, }; pub const VS_FIXEDFILEINFO = extern struct { dwSignature: u32, dwStrucVersion: u32, dwFileVersionMS: u32, dwFileVersionLS: u32, dwProductVersionMS: u32, dwProductVersionLS: u32, dwFileFlagsMask: u32, dwFileFlags: VS_FIXEDFILEINFO_FILE_FLAGS, dwFileOS: VS_FIXEDFILEINFO_FILE_OS, dwFileType: VS_FIXEDFILEINFO_FILE_TYPE, dwFileSubtype: VS_FIXEDFILEINFO_FILE_SUBTYPE, dwFileDateMS: u32, dwFileDateLS: u32, }; pub const NtmsObjectsTypes = enum(i32) { UNKNOWN = 0, OBJECT = 1, CHANGER = 2, CHANGER_TYPE = 3, COMPUTER = 4, DRIVE = 5, DRIVE_TYPE = 6, IEDOOR = 7, IEPORT = 8, LIBRARY = 9, LIBREQUEST = 10, LOGICAL_MEDIA = 11, MEDIA_POOL = 12, MEDIA_TYPE = 13, PARTITION = 14, PHYSICAL_MEDIA = 15, STORAGESLOT = 16, OPREQUEST = 17, UI_DESTINATION = 18, NUMBER_OF_OBJECT_TYPES = 19, }; pub const NTMS_UNKNOWN = NtmsObjectsTypes.UNKNOWN; pub const NTMS_OBJECT = NtmsObjectsTypes.OBJECT; pub const NTMS_CHANGER = NtmsObjectsTypes.CHANGER; pub const NTMS_CHANGER_TYPE = NtmsObjectsTypes.CHANGER_TYPE; pub const NTMS_COMPUTER = NtmsObjectsTypes.COMPUTER; pub const NTMS_DRIVE = NtmsObjectsTypes.DRIVE; pub const NTMS_DRIVE_TYPE = NtmsObjectsTypes.DRIVE_TYPE; pub const NTMS_IEDOOR = NtmsObjectsTypes.IEDOOR; pub const NTMS_IEPORT = NtmsObjectsTypes.IEPORT; pub const NTMS_LIBRARY = NtmsObjectsTypes.LIBRARY; pub const NTMS_LIBREQUEST = NtmsObjectsTypes.LIBREQUEST; pub const NTMS_LOGICAL_MEDIA = NtmsObjectsTypes.LOGICAL_MEDIA; pub const NTMS_MEDIA_POOL = NtmsObjectsTypes.MEDIA_POOL; pub const NTMS_MEDIA_TYPE = NtmsObjectsTypes.MEDIA_TYPE; pub const NTMS_PARTITION = NtmsObjectsTypes.PARTITION; pub const NTMS_PHYSICAL_MEDIA = NtmsObjectsTypes.PHYSICAL_MEDIA; pub const NTMS_STORAGESLOT = NtmsObjectsTypes.STORAGESLOT; pub const NTMS_OPREQUEST = NtmsObjectsTypes.OPREQUEST; pub const NTMS_UI_DESTINATION = NtmsObjectsTypes.UI_DESTINATION; pub const NTMS_NUMBER_OF_OBJECT_TYPES = NtmsObjectsTypes.NUMBER_OF_OBJECT_TYPES; pub const NTMS_ASYNC_IO = extern struct { OperationId: Guid, EventId: Guid, dwOperationType: u32, dwResult: u32, dwAsyncState: u32, hEvent: ?HANDLE, bOnStateChange: BOOL, }; pub const NtmsAsyncStatus = enum(i32) { QUEUED = 0, WAIT_RESOURCE = 1, WAIT_OPERATOR = 2, INPROCESS = 3, COMPLETE = 4, }; pub const NTMS_ASYNCSTATE_QUEUED = NtmsAsyncStatus.QUEUED; pub const NTMS_ASYNCSTATE_WAIT_RESOURCE = NtmsAsyncStatus.WAIT_RESOURCE; pub const NTMS_ASYNCSTATE_WAIT_OPERATOR = NtmsAsyncStatus.WAIT_OPERATOR; pub const NTMS_ASYNCSTATE_INPROCESS = NtmsAsyncStatus.INPROCESS; pub const NTMS_ASYNCSTATE_COMPLETE = NtmsAsyncStatus.COMPLETE; pub const NtmsAsyncOperations = enum(i32) { T = 1, }; pub const NTMS_ASYNCOP_MOUNT = NtmsAsyncOperations.T; pub const NtmsSessionOptions = enum(i32) { E = 1, }; pub const NTMS_SESSION_QUERYEXPEDITE = NtmsSessionOptions.E; pub const NtmsMountOptions = enum(i32) { READ = 1, WRITE = 2, ERROR_NOT_AVAILABLE = 4, // ERROR_IF_UNAVAILABLE = 4, this enum value conflicts with ERROR_NOT_AVAILABLE ERROR_OFFLINE = 8, // ERROR_IF_OFFLINE = 8, this enum value conflicts with ERROR_OFFLINE SPECIFIC_DRIVE = 16, NOWAIT = 32, }; pub const NTMS_MOUNT_READ = NtmsMountOptions.READ; pub const NTMS_MOUNT_WRITE = NtmsMountOptions.WRITE; pub const NTMS_MOUNT_ERROR_NOT_AVAILABLE = NtmsMountOptions.ERROR_NOT_AVAILABLE; pub const NTMS_MOUNT_ERROR_IF_UNAVAILABLE = NtmsMountOptions.ERROR_NOT_AVAILABLE; pub const NTMS_MOUNT_ERROR_OFFLINE = NtmsMountOptions.ERROR_OFFLINE; pub const NTMS_MOUNT_ERROR_IF_OFFLINE = NtmsMountOptions.ERROR_OFFLINE; pub const NTMS_MOUNT_SPECIFIC_DRIVE = NtmsMountOptions.SPECIFIC_DRIVE; pub const NTMS_MOUNT_NOWAIT = NtmsMountOptions.NOWAIT; pub const NtmsDismountOptions = enum(i32) { DEFERRED = 1, IMMEDIATE = 2, }; pub const NTMS_DISMOUNT_DEFERRED = NtmsDismountOptions.DEFERRED; pub const NTMS_DISMOUNT_IMMEDIATE = NtmsDismountOptions.IMMEDIATE; pub const NtmsMountPriority = enum(i32) { DEFAULT = 0, HIGHEST = 15, HIGH = 7, // NORMAL = 0, this enum value conflicts with DEFAULT LOW = -7, LOWEST = -15, }; pub const NTMS_PRIORITY_DEFAULT = NtmsMountPriority.DEFAULT; pub const NTMS_PRIORITY_HIGHEST = NtmsMountPriority.HIGHEST; pub const NTMS_PRIORITY_HIGH = NtmsMountPriority.HIGH; pub const NTMS_PRIORITY_NORMAL = NtmsMountPriority.DEFAULT; pub const NTMS_PRIORITY_LOW = NtmsMountPriority.LOW; pub const NTMS_PRIORITY_LOWEST = NtmsMountPriority.LOWEST; pub const NTMS_MOUNT_INFORMATION = extern struct { dwSize: u32, lpReserved: ?*anyopaque, }; pub const NtmsAllocateOptions = enum(i32) { NEW = 1, NEXT = 2, ERROR_IF_UNAVAILABLE = 4, }; pub const NTMS_ALLOCATE_NEW = NtmsAllocateOptions.NEW; pub const NTMS_ALLOCATE_NEXT = NtmsAllocateOptions.NEXT; pub const NTMS_ALLOCATE_ERROR_IF_UNAVAILABLE = NtmsAllocateOptions.ERROR_IF_UNAVAILABLE; pub const NTMS_ALLOCATION_INFORMATION = extern struct { dwSize: u32, lpReserved: ?*anyopaque, AllocatedFrom: Guid, }; pub const NtmsCreateOptions = enum(i32) { OPEN_EXISTING = 1, CREATE_NEW = 2, OPEN_ALWAYS = 3, }; pub const NTMS_OPEN_EXISTING = NtmsCreateOptions.OPEN_EXISTING; pub const NTMS_CREATE_NEW = NtmsCreateOptions.CREATE_NEW; pub const NTMS_OPEN_ALWAYS = NtmsCreateOptions.OPEN_ALWAYS; pub const NtmsDriveState = enum(i32) { DISMOUNTED = 0, MOUNTED = 1, LOADED = 2, UNLOADED = 5, BEING_CLEANED = 6, DISMOUNTABLE = 7, }; pub const NTMS_DRIVESTATE_DISMOUNTED = NtmsDriveState.DISMOUNTED; pub const NTMS_DRIVESTATE_MOUNTED = NtmsDriveState.MOUNTED; pub const NTMS_DRIVESTATE_LOADED = NtmsDriveState.LOADED; pub const NTMS_DRIVESTATE_UNLOADED = NtmsDriveState.UNLOADED; pub const NTMS_DRIVESTATE_BEING_CLEANED = NtmsDriveState.BEING_CLEANED; pub const NTMS_DRIVESTATE_DISMOUNTABLE = NtmsDriveState.DISMOUNTABLE; pub const NTMS_DRIVEINFORMATIONA = extern struct { Number: u32, State: NtmsDriveState, DriveType: Guid, szDeviceName: [64]CHAR, szSerialNumber: [32]CHAR, szRevision: [32]CHAR, ScsiPort: u16, ScsiBus: u16, ScsiTarget: u16, ScsiLun: u16, dwMountCount: u32, LastCleanedTs: SYSTEMTIME, SavedPartitionId: Guid, Library: Guid, Reserved: Guid, dwDeferDismountDelay: u32, }; pub const NTMS_DRIVEINFORMATIONW = extern struct { Number: u32, State: NtmsDriveState, DriveType: Guid, szDeviceName: [64]u16, szSerialNumber: [32]u16, szRevision: [32]u16, ScsiPort: u16, ScsiBus: u16, ScsiTarget: u16, ScsiLun: u16, dwMountCount: u32, LastCleanedTs: SYSTEMTIME, SavedPartitionId: Guid, Library: Guid, Reserved: Guid, dwDeferDismountDelay: u32, }; pub const NtmsLibraryType = enum(i32) { UNKNOWN = 0, OFFLINE = 1, ONLINE = 2, STANDALONE = 3, }; pub const NTMS_LIBRARYTYPE_UNKNOWN = NtmsLibraryType.UNKNOWN; pub const NTMS_LIBRARYTYPE_OFFLINE = NtmsLibraryType.OFFLINE; pub const NTMS_LIBRARYTYPE_ONLINE = NtmsLibraryType.ONLINE; pub const NTMS_LIBRARYTYPE_STANDALONE = NtmsLibraryType.STANDALONE; pub const NtmsLibraryFlags = enum(i32) { FIXEDOFFLINE = 1, CLEANERPRESENT = 2, AUTODETECTCHANGE = 4, IGNORECLEANERUSESREMAINING = 8, RECOGNIZECLEANERBARCODE = 16, }; pub const NTMS_LIBRARYFLAG_FIXEDOFFLINE = NtmsLibraryFlags.FIXEDOFFLINE; pub const NTMS_LIBRARYFLAG_CLEANERPRESENT = NtmsLibraryFlags.CLEANERPRESENT; pub const NTMS_LIBRARYFLAG_AUTODETECTCHANGE = NtmsLibraryFlags.AUTODETECTCHANGE; pub const NTMS_LIBRARYFLAG_IGNORECLEANERUSESREMAINING = NtmsLibraryFlags.IGNORECLEANERUSESREMAINING; pub const NTMS_LIBRARYFLAG_RECOGNIZECLEANERBARCODE = NtmsLibraryFlags.RECOGNIZECLEANERBARCODE; pub const NtmsInventoryMethod = enum(i32) { NONE = 0, FAST = 1, OMID = 2, DEFAULT = 3, SLOT = 4, STOP = 5, MAX = 6, }; pub const NTMS_INVENTORY_NONE = NtmsInventoryMethod.NONE; pub const NTMS_INVENTORY_FAST = NtmsInventoryMethod.FAST; pub const NTMS_INVENTORY_OMID = NtmsInventoryMethod.OMID; pub const NTMS_INVENTORY_DEFAULT = NtmsInventoryMethod.DEFAULT; pub const NTMS_INVENTORY_SLOT = NtmsInventoryMethod.SLOT; pub const NTMS_INVENTORY_STOP = NtmsInventoryMethod.STOP; pub const NTMS_INVENTORY_MAX = NtmsInventoryMethod.MAX; pub const NTMS_LIBRARYINFORMATION = extern struct { LibraryType: NtmsLibraryType, CleanerSlot: Guid, CleanerSlotDefault: Guid, LibrarySupportsDriveCleaning: BOOL, BarCodeReaderInstalled: BOOL, InventoryMethod: NtmsInventoryMethod, dwCleanerUsesRemaining: u32, FirstDriveNumber: u32, dwNumberOfDrives: u32, FirstSlotNumber: u32, dwNumberOfSlots: u32, FirstDoorNumber: u32, dwNumberOfDoors: u32, FirstPortNumber: u32, dwNumberOfPorts: u32, FirstChangerNumber: u32, dwNumberOfChangers: u32, dwNumberOfMedia: u32, dwNumberOfMediaTypes: u32, dwNumberOfLibRequests: u32, Reserved: Guid, AutoRecovery: BOOL, dwFlags: NtmsLibraryFlags, }; pub const NTMS_CHANGERINFORMATIONA = extern struct { Number: u32, ChangerType: Guid, szSerialNumber: [32]CHAR, szRevision: [32]CHAR, szDeviceName: [64]CHAR, ScsiPort: u16, ScsiBus: u16, ScsiTarget: u16, ScsiLun: u16, Library: Guid, }; pub const NTMS_CHANGERINFORMATIONW = extern struct { Number: u32, ChangerType: Guid, szSerialNumber: [32]u16, szRevision: [32]u16, szDeviceName: [64]u16, ScsiPort: u16, ScsiBus: u16, ScsiTarget: u16, ScsiLun: u16, Library: Guid, }; pub const NtmsSlotState = enum(i32) { UNKNOWN = 0, FULL = 1, EMPTY = 2, NOTPRESENT = 3, NEEDSINVENTORY = 4, }; pub const NTMS_SLOTSTATE_UNKNOWN = NtmsSlotState.UNKNOWN; pub const NTMS_SLOTSTATE_FULL = NtmsSlotState.FULL; pub const NTMS_SLOTSTATE_EMPTY = NtmsSlotState.EMPTY; pub const NTMS_SLOTSTATE_NOTPRESENT = NtmsSlotState.NOTPRESENT; pub const NTMS_SLOTSTATE_NEEDSINVENTORY = NtmsSlotState.NEEDSINVENTORY; pub const NTMS_STORAGESLOTINFORMATION = extern struct { Number: u32, State: u32, Library: Guid, }; pub const NtmsDoorState = enum(i32) { UNKNOWN = 0, CLOSED = 1, OPEN = 2, }; pub const NTMS_DOORSTATE_UNKNOWN = NtmsDoorState.UNKNOWN; pub const NTMS_DOORSTATE_CLOSED = NtmsDoorState.CLOSED; pub const NTMS_DOORSTATE_OPEN = NtmsDoorState.OPEN; pub const NTMS_IEDOORINFORMATION = extern struct { Number: u32, State: NtmsDoorState, MaxOpenSecs: u16, Library: Guid, }; pub const NtmsPortPosition = enum(i32) { UNKNOWN = 0, EXTENDED = 1, RETRACTED = 2, }; pub const NTMS_PORTPOSITION_UNKNOWN = NtmsPortPosition.UNKNOWN; pub const NTMS_PORTPOSITION_EXTENDED = NtmsPortPosition.EXTENDED; pub const NTMS_PORTPOSITION_RETRACTED = NtmsPortPosition.RETRACTED; pub const NtmsPortContent = enum(i32) { UNKNOWN = 0, FULL = 1, EMPTY = 2, }; pub const NTMS_PORTCONTENT_UNKNOWN = NtmsPortContent.UNKNOWN; pub const NTMS_PORTCONTENT_FULL = NtmsPortContent.FULL; pub const NTMS_PORTCONTENT_EMPTY = NtmsPortContent.EMPTY; pub const NTMS_IEPORTINFORMATION = extern struct { Number: u32, Content: NtmsPortContent, Position: NtmsPortPosition, MaxExtendSecs: u16, Library: Guid, }; pub const NtmsBarCodeState = enum(i32) { OK = 1, UNREADABLE = 2, }; pub const NTMS_BARCODESTATE_OK = NtmsBarCodeState.OK; pub const NTMS_BARCODESTATE_UNREADABLE = NtmsBarCodeState.UNREADABLE; pub const NtmsMediaState = enum(i32) { IDLE = 0, INUSE = 1, MOUNTED = 2, LOADED = 3, UNLOADED = 4, OPERROR = 5, OPREQ = 6, }; pub const NTMS_MEDIASTATE_IDLE = NtmsMediaState.IDLE; pub const NTMS_MEDIASTATE_INUSE = NtmsMediaState.INUSE; pub const NTMS_MEDIASTATE_MOUNTED = NtmsMediaState.MOUNTED; pub const NTMS_MEDIASTATE_LOADED = NtmsMediaState.LOADED; pub const NTMS_MEDIASTATE_UNLOADED = NtmsMediaState.UNLOADED; pub const NTMS_MEDIASTATE_OPERROR = NtmsMediaState.OPERROR; pub const NTMS_MEDIASTATE_OPREQ = NtmsMediaState.OPREQ; pub const NTMS_PMIDINFORMATIONA = extern struct { CurrentLibrary: Guid, MediaPool: Guid, Location: Guid, LocationType: u32, MediaType: Guid, HomeSlot: Guid, szBarCode: [64]CHAR, BarCodeState: NtmsBarCodeState, szSequenceNumber: [32]CHAR, MediaState: NtmsMediaState, dwNumberOfPartitions: u32, dwMediaTypeCode: u32, dwDensityCode: u32, MountedPartition: Guid, }; pub const NTMS_PMIDINFORMATIONW = extern struct { CurrentLibrary: Guid, MediaPool: Guid, Location: Guid, LocationType: u32, MediaType: Guid, HomeSlot: Guid, szBarCode: [64]u16, BarCodeState: NtmsBarCodeState, szSequenceNumber: [32]u16, MediaState: NtmsMediaState, dwNumberOfPartitions: u32, dwMediaTypeCode: u32, dwDensityCode: u32, MountedPartition: Guid, }; pub const NTMS_LMIDINFORMATION = extern struct { MediaPool: Guid, dwNumberOfPartitions: u32, }; pub const NtmsPartitionState = enum(i32) { UNKNOWN = 0, UNPREPARED = 1, INCOMPATIBLE = 2, DECOMMISSIONED = 3, AVAILABLE = 4, ALLOCATED = 5, COMPLETE = 6, FOREIGN = 7, IMPORT = 8, RESERVED = 9, }; pub const NTMS_PARTSTATE_UNKNOWN = NtmsPartitionState.UNKNOWN; pub const NTMS_PARTSTATE_UNPREPARED = NtmsPartitionState.UNPREPARED; pub const NTMS_PARTSTATE_INCOMPATIBLE = NtmsPartitionState.INCOMPATIBLE; pub const NTMS_PARTSTATE_DECOMMISSIONED = NtmsPartitionState.DECOMMISSIONED; pub const NTMS_PARTSTATE_AVAILABLE = NtmsPartitionState.AVAILABLE; pub const NTMS_PARTSTATE_ALLOCATED = NtmsPartitionState.ALLOCATED; pub const NTMS_PARTSTATE_COMPLETE = NtmsPartitionState.COMPLETE; pub const NTMS_PARTSTATE_FOREIGN = NtmsPartitionState.FOREIGN; pub const NTMS_PARTSTATE_IMPORT = NtmsPartitionState.IMPORT; pub const NTMS_PARTSTATE_RESERVED = NtmsPartitionState.RESERVED; pub const NTMS_PARTITIONINFORMATIONA = extern struct { PhysicalMedia: Guid, LogicalMedia: Guid, State: NtmsPartitionState, Side: u16, dwOmidLabelIdLength: u32, OmidLabelId: [255]u8, szOmidLabelType: [64]CHAR, szOmidLabelInfo: [256]CHAR, dwMountCount: u32, dwAllocateCount: u32, Capacity: LARGE_INTEGER, }; pub const NTMS_PARTITIONINFORMATIONW = extern struct { PhysicalMedia: Guid, LogicalMedia: Guid, State: NtmsPartitionState, Side: u16, dwOmidLabelIdLength: u32, OmidLabelId: [255]u8, szOmidLabelType: [64]u16, szOmidLabelInfo: [256]u16, dwMountCount: u32, dwAllocateCount: u32, Capacity: LARGE_INTEGER, }; pub const NtmsPoolType = enum(i32) { UNKNOWN = 0, SCRATCH = 1, FOREIGN = 2, IMPORT = 3, APPLICATION = 1000, }; pub const NTMS_POOLTYPE_UNKNOWN = NtmsPoolType.UNKNOWN; pub const NTMS_POOLTYPE_SCRATCH = NtmsPoolType.SCRATCH; pub const NTMS_POOLTYPE_FOREIGN = NtmsPoolType.FOREIGN; pub const NTMS_POOLTYPE_IMPORT = NtmsPoolType.IMPORT; pub const NTMS_POOLTYPE_APPLICATION = NtmsPoolType.APPLICATION; pub const NtmsAllocationPolicy = enum(i32) { H = 1, }; pub const NTMS_ALLOCATE_FROMSCRATCH = NtmsAllocationPolicy.H; pub const NtmsDeallocationPolicy = enum(i32) { H = 1, }; pub const NTMS_DEALLOCATE_TOSCRATCH = NtmsDeallocationPolicy.H; pub const NTMS_MEDIAPOOLINFORMATION = extern struct { PoolType: u32, MediaType: Guid, Parent: Guid, AllocationPolicy: u32, DeallocationPolicy: u32, dwMaxAllocates: u32, dwNumberOfPhysicalMedia: u32, dwNumberOfLogicalMedia: u32, dwNumberOfMediaPools: u32, }; pub const NtmsReadWriteCharacteristics = enum(i32) { UNKNOWN = 0, REWRITABLE = 1, WRITEONCE = 2, READONLY = 3, }; pub const NTMS_MEDIARW_UNKNOWN = NtmsReadWriteCharacteristics.UNKNOWN; pub const NTMS_MEDIARW_REWRITABLE = NtmsReadWriteCharacteristics.REWRITABLE; pub const NTMS_MEDIARW_WRITEONCE = NtmsReadWriteCharacteristics.WRITEONCE; pub const NTMS_MEDIARW_READONLY = NtmsReadWriteCharacteristics.READONLY; pub const NTMS_MEDIATYPEINFORMATION = extern struct { MediaType: u32, NumberOfSides: u32, ReadWriteCharacteristics: NtmsReadWriteCharacteristics, DeviceType: FILE_DEVICE_TYPE, }; pub const NTMS_DRIVETYPEINFORMATIONA = extern struct { szVendor: [128]CHAR, szProduct: [128]CHAR, NumberOfHeads: u32, DeviceType: FILE_DEVICE_TYPE, }; pub const NTMS_DRIVETYPEINFORMATIONW = extern struct { szVendor: [128]u16, szProduct: [128]u16, NumberOfHeads: u32, DeviceType: FILE_DEVICE_TYPE, }; pub const NTMS_CHANGERTYPEINFORMATIONA = extern struct { szVendor: [128]CHAR, szProduct: [128]CHAR, DeviceType: u32, }; pub const NTMS_CHANGERTYPEINFORMATIONW = extern struct { szVendor: [128]u16, szProduct: [128]u16, DeviceType: u32, }; pub const NtmsLmOperation = enum(i32) { REMOVE = 0, DISABLECHANGER = 1, // DISABLELIBRARY = 1, this enum value conflicts with DISABLECHANGER ENABLECHANGER = 2, // ENABLELIBRARY = 2, this enum value conflicts with ENABLECHANGER DISABLEDRIVE = 3, ENABLEDRIVE = 4, DISABLEMEDIA = 5, ENABLEMEDIA = 6, UPDATEOMID = 7, INVENTORY = 8, DOORACCESS = 9, EJECT = 10, EJECTCLEANER = 11, INJECT = 12, INJECTCLEANER = 13, PROCESSOMID = 14, CLEANDRIVE = 15, DISMOUNT = 16, MOUNT = 17, WRITESCRATCH = 18, CLASSIFY = 19, RESERVECLEANER = 20, RELEASECLEANER = 21, MAXWORKITEM = 22, }; pub const NTMS_LM_REMOVE = NtmsLmOperation.REMOVE; pub const NTMS_LM_DISABLECHANGER = NtmsLmOperation.DISABLECHANGER; pub const NTMS_LM_DISABLELIBRARY = NtmsLmOperation.DISABLECHANGER; pub const NTMS_LM_ENABLECHANGER = NtmsLmOperation.ENABLECHANGER; pub const NTMS_LM_ENABLELIBRARY = NtmsLmOperation.ENABLECHANGER; pub const NTMS_LM_DISABLEDRIVE = NtmsLmOperation.DISABLEDRIVE; pub const NTMS_LM_ENABLEDRIVE = NtmsLmOperation.ENABLEDRIVE; pub const NTMS_LM_DISABLEMEDIA = NtmsLmOperation.DISABLEMEDIA; pub const NTMS_LM_ENABLEMEDIA = NtmsLmOperation.ENABLEMEDIA; pub const NTMS_LM_UPDATEOMID = NtmsLmOperation.UPDATEOMID; pub const NTMS_LM_INVENTORY = NtmsLmOperation.INVENTORY; pub const NTMS_LM_DOORACCESS = NtmsLmOperation.DOORACCESS; pub const NTMS_LM_EJECT = NtmsLmOperation.EJECT; pub const NTMS_LM_EJECTCLEANER = NtmsLmOperation.EJECTCLEANER; pub const NTMS_LM_INJECT = NtmsLmOperation.INJECT; pub const NTMS_LM_INJECTCLEANER = NtmsLmOperation.INJECTCLEANER; pub const NTMS_LM_PROCESSOMID = NtmsLmOperation.PROCESSOMID; pub const NTMS_LM_CLEANDRIVE = NtmsLmOperation.CLEANDRIVE; pub const NTMS_LM_DISMOUNT = NtmsLmOperation.DISMOUNT; pub const NTMS_LM_MOUNT = NtmsLmOperation.MOUNT; pub const NTMS_LM_WRITESCRATCH = NtmsLmOperation.WRITESCRATCH; pub const NTMS_LM_CLASSIFY = NtmsLmOperation.CLASSIFY; pub const NTMS_LM_RESERVECLEANER = NtmsLmOperation.RESERVECLEANER; pub const NTMS_LM_RELEASECLEANER = NtmsLmOperation.RELEASECLEANER; pub const NTMS_LM_MAXWORKITEM = NtmsLmOperation.MAXWORKITEM; pub const NtmsLmState = enum(i32) { QUEUED = 0, INPROCESS = 1, PASSED = 2, FAILED = 3, INVALID = 4, WAITING = 5, DEFERRED = 6, // DEFFERED = 6, this enum value conflicts with DEFERRED CANCELLED = 7, STOPPED = 8, }; pub const NTMS_LM_QUEUED = NtmsLmState.QUEUED; pub const NTMS_LM_INPROCESS = NtmsLmState.INPROCESS; pub const NTMS_LM_PASSED = NtmsLmState.PASSED; pub const NTMS_LM_FAILED = NtmsLmState.FAILED; pub const NTMS_LM_INVALID = NtmsLmState.INVALID; pub const NTMS_LM_WAITING = NtmsLmState.WAITING; pub const NTMS_LM_DEFERRED = NtmsLmState.DEFERRED; pub const NTMS_LM_DEFFERED = NtmsLmState.DEFERRED; pub const NTMS_LM_CANCELLED = NtmsLmState.CANCELLED; pub const NTMS_LM_STOPPED = NtmsLmState.STOPPED; pub const NTMS_LIBREQUESTINFORMATIONA = extern struct { OperationCode: NtmsLmOperation, OperationOption: u32, State: NtmsLmState, PartitionId: Guid, DriveId: Guid, PhysMediaId: Guid, Library: Guid, SlotId: Guid, TimeQueued: SYSTEMTIME, TimeCompleted: SYSTEMTIME, szApplication: [64]CHAR, szUser: [64]CHAR, szComputer: [64]CHAR, dwErrorCode: u32, WorkItemId: Guid, dwPriority: u32, }; pub const NTMS_LIBREQUESTINFORMATIONW = extern struct { OperationCode: NtmsLmOperation, OperationOption: u32, State: NtmsLmState, PartitionId: Guid, DriveId: Guid, PhysMediaId: Guid, Library: Guid, SlotId: Guid, TimeQueued: SYSTEMTIME, TimeCompleted: SYSTEMTIME, szApplication: [64]u16, szUser: [64]u16, szComputer: [64]u16, dwErrorCode: u32, WorkItemId: Guid, dwPriority: u32, }; pub const NtmsOpreqCommand = enum(i32) { UNKNOWN = 0, NEWMEDIA = 1, CLEANER = 2, DEVICESERVICE = 3, MOVEMEDIA = 4, MESSAGE = 5, }; pub const NTMS_OPREQ_UNKNOWN = NtmsOpreqCommand.UNKNOWN; pub const NTMS_OPREQ_NEWMEDIA = NtmsOpreqCommand.NEWMEDIA; pub const NTMS_OPREQ_CLEANER = NtmsOpreqCommand.CLEANER; pub const NTMS_OPREQ_DEVICESERVICE = NtmsOpreqCommand.DEVICESERVICE; pub const NTMS_OPREQ_MOVEMEDIA = NtmsOpreqCommand.MOVEMEDIA; pub const NTMS_OPREQ_MESSAGE = NtmsOpreqCommand.MESSAGE; pub const NtmsOpreqState = enum(i32) { UNKNOWN = 0, SUBMITTED = 1, ACTIVE = 2, INPROGRESS = 3, REFUSED = 4, COMPLETE = 5, }; pub const NTMS_OPSTATE_UNKNOWN = NtmsOpreqState.UNKNOWN; pub const NTMS_OPSTATE_SUBMITTED = NtmsOpreqState.SUBMITTED; pub const NTMS_OPSTATE_ACTIVE = NtmsOpreqState.ACTIVE; pub const NTMS_OPSTATE_INPROGRESS = NtmsOpreqState.INPROGRESS; pub const NTMS_OPSTATE_REFUSED = NtmsOpreqState.REFUSED; pub const NTMS_OPSTATE_COMPLETE = NtmsOpreqState.COMPLETE; pub const NTMS_OPREQUESTINFORMATIONA = extern struct { Request: NtmsOpreqCommand, Submitted: SYSTEMTIME, State: NtmsOpreqState, szMessage: [256]CHAR, Arg1Type: NtmsObjectsTypes, Arg1: Guid, Arg2Type: NtmsObjectsTypes, Arg2: Guid, szApplication: [64]CHAR, szUser: [64]CHAR, szComputer: [64]CHAR, }; pub const NTMS_OPREQUESTINFORMATIONW = extern struct { Request: NtmsOpreqCommand, Submitted: SYSTEMTIME, State: NtmsOpreqState, szMessage: [256]u16, Arg1Type: NtmsObjectsTypes, Arg1: Guid, Arg2Type: NtmsObjectsTypes, Arg2: Guid, szApplication: [64]u16, szUser: [64]u16, szComputer: [64]u16, }; pub const NTMS_COMPUTERINFORMATION = extern struct { dwLibRequestPurgeTime: u32, dwOpRequestPurgeTime: u32, dwLibRequestFlags: u32, dwOpRequestFlags: u32, dwMediaPoolPolicy: u32, }; pub const NtmsLibRequestFlags = enum(i32) { AUTOPURGE = 1, FAILEDPURGE = 2, }; pub const NTMS_LIBREQFLAGS_NOAUTOPURGE = NtmsLibRequestFlags.AUTOPURGE; pub const NTMS_LIBREQFLAGS_NOFAILEDPURGE = NtmsLibRequestFlags.FAILEDPURGE; pub const NtmsOpRequestFlags = enum(i32) { AUTOPURGE = 1, FAILEDPURGE = 2, ALERTS = 16, TRAYICON = 32, }; pub const NTMS_OPREQFLAGS_NOAUTOPURGE = NtmsOpRequestFlags.AUTOPURGE; pub const NTMS_OPREQFLAGS_NOFAILEDPURGE = NtmsOpRequestFlags.FAILEDPURGE; pub const NTMS_OPREQFLAGS_NOALERTS = NtmsOpRequestFlags.ALERTS; pub const NTMS_OPREQFLAGS_NOTRAYICON = NtmsOpRequestFlags.TRAYICON; pub const NtmsMediaPoolPolicy = enum(i32) { PURGEOFFLINESCRATCH = 1, KEEPOFFLINEIMPORT = 2, }; pub const NTMS_POOLPOLICY_PURGEOFFLINESCRATCH = NtmsMediaPoolPolicy.PURGEOFFLINESCRATCH; pub const NTMS_POOLPOLICY_KEEPOFFLINEIMPORT = NtmsMediaPoolPolicy.KEEPOFFLINEIMPORT; pub const NtmsOperationalState = enum(i32) { READY = 0, INITIALIZING = 10, NEEDS_SERVICE = 20, NOT_PRESENT = 21, }; pub const NTMS_READY = NtmsOperationalState.READY; pub const NTMS_INITIALIZING = NtmsOperationalState.INITIALIZING; pub const NTMS_NEEDS_SERVICE = NtmsOperationalState.NEEDS_SERVICE; pub const NTMS_NOT_PRESENT = NtmsOperationalState.NOT_PRESENT; pub const NTMS_OBJECTINFORMATIONA = extern struct { dwSize: u32, dwType: NtmsObjectsTypes, Created: SYSTEMTIME, Modified: SYSTEMTIME, ObjectGuid: Guid, Enabled: BOOL, dwOperationalState: NtmsOperationalState, szName: [64]CHAR, szDescription: [127]CHAR, Info: extern union { Drive: NTMS_DRIVEINFORMATIONA, DriveType: NTMS_DRIVETYPEINFORMATIONA, Library: NTMS_LIBRARYINFORMATION, Changer: NTMS_CHANGERINFORMATIONA, ChangerType: NTMS_CHANGERTYPEINFORMATIONA, StorageSlot: NTMS_STORAGESLOTINFORMATION, IEDoor: NTMS_IEDOORINFORMATION, IEPort: NTMS_IEPORTINFORMATION, PhysicalMedia: NTMS_PMIDINFORMATIONA, LogicalMedia: NTMS_LMIDINFORMATION, Partition: NTMS_PARTITIONINFORMATIONA, MediaPool: NTMS_MEDIAPOOLINFORMATION, MediaType: NTMS_MEDIATYPEINFORMATION, LibRequest: NTMS_LIBREQUESTINFORMATIONA, OpRequest: NTMS_OPREQUESTINFORMATIONA, Computer: NTMS_COMPUTERINFORMATION, }, }; pub const NTMS_OBJECTINFORMATIONW = extern struct { dwSize: u32, dwType: NtmsObjectsTypes, Created: SYSTEMTIME, Modified: SYSTEMTIME, ObjectGuid: Guid, Enabled: BOOL, dwOperationalState: NtmsOperationalState, szName: [64]u16, szDescription: [127]u16, Info: extern union { Drive: NTMS_DRIVEINFORMATIONW, DriveType: NTMS_DRIVETYPEINFORMATIONW, Library: NTMS_LIBRARYINFORMATION, Changer: NTMS_CHANGERINFORMATIONW, ChangerType: NTMS_CHANGERTYPEINFORMATIONW, StorageSlot: NTMS_STORAGESLOTINFORMATION, IEDoor: NTMS_IEDOORINFORMATION, IEPort: NTMS_IEPORTINFORMATION, PhysicalMedia: NTMS_PMIDINFORMATIONW, LogicalMedia: NTMS_LMIDINFORMATION, Partition: NTMS_PARTITIONINFORMATIONW, MediaPool: NTMS_MEDIAPOOLINFORMATION, MediaType: NTMS_MEDIATYPEINFORMATION, LibRequest: NTMS_LIBREQUESTINFORMATIONW, OpRequest: NTMS_OPREQUESTINFORMATIONW, Computer: NTMS_COMPUTERINFORMATION, }, }; pub const NTMS_I1_LIBRARYINFORMATION = extern struct { LibraryType: u32, CleanerSlot: Guid, CleanerSlotDefault: Guid, LibrarySupportsDriveCleaning: BOOL, BarCodeReaderInstalled: BOOL, InventoryMethod: u32, dwCleanerUsesRemaining: u32, FirstDriveNumber: u32, dwNumberOfDrives: u32, FirstSlotNumber: u32, dwNumberOfSlots: u32, FirstDoorNumber: u32, dwNumberOfDoors: u32, FirstPortNumber: u32, dwNumberOfPorts: u32, FirstChangerNumber: u32, dwNumberOfChangers: u32, dwNumberOfMedia: u32, dwNumberOfMediaTypes: u32, dwNumberOfLibRequests: u32, Reserved: Guid, }; pub const NTMS_I1_LIBREQUESTINFORMATIONA = extern struct { OperationCode: u32, OperationOption: u32, State: u32, PartitionId: Guid, DriveId: Guid, PhysMediaId: Guid, Library: Guid, SlotId: Guid, TimeQueued: SYSTEMTIME, TimeCompleted: SYSTEMTIME, szApplication: [64]CHAR, szUser: [64]CHAR, szComputer: [64]CHAR, }; pub const NTMS_I1_LIBREQUESTINFORMATIONW = extern struct { OperationCode: u32, OperationOption: u32, State: u32, PartitionId: Guid, DriveId: Guid, PhysMediaId: Guid, Library: Guid, SlotId: Guid, TimeQueued: SYSTEMTIME, TimeCompleted: SYSTEMTIME, szApplication: [64]u16, szUser: [64]u16, szComputer: [64]u16, }; pub const NTMS_I1_PMIDINFORMATIONA = extern struct { CurrentLibrary: Guid, MediaPool: Guid, Location: Guid, LocationType: u32, MediaType: Guid, HomeSlot: Guid, szBarCode: [64]CHAR, BarCodeState: u32, szSequenceNumber: [32]CHAR, MediaState: u32, dwNumberOfPartitions: u32, }; pub const NTMS_I1_PMIDINFORMATIONW = extern struct { CurrentLibrary: Guid, MediaPool: Guid, Location: Guid, LocationType: u32, MediaType: Guid, HomeSlot: Guid, szBarCode: [64]u16, BarCodeState: u32, szSequenceNumber: [32]u16, MediaState: u32, dwNumberOfPartitions: u32, }; pub const NTMS_I1_PARTITIONINFORMATIONA = extern struct { PhysicalMedia: Guid, LogicalMedia: Guid, State: u32, Side: u16, dwOmidLabelIdLength: u32, OmidLabelId: [255]u8, szOmidLabelType: [64]CHAR, szOmidLabelInfo: [256]CHAR, dwMountCount: u32, dwAllocateCount: u32, }; pub const NTMS_I1_PARTITIONINFORMATIONW = extern struct { PhysicalMedia: Guid, LogicalMedia: Guid, State: u32, Side: u16, dwOmidLabelIdLength: u32, OmidLabelId: [255]u8, szOmidLabelType: [64]u16, szOmidLabelInfo: [256]u16, dwMountCount: u32, dwAllocateCount: u32, }; pub const NTMS_I1_OPREQUESTINFORMATIONA = extern struct { Request: u32, Submitted: SYSTEMTIME, State: u32, szMessage: [127]CHAR, Arg1Type: u32, Arg1: Guid, Arg2Type: u32, Arg2: Guid, szApplication: [64]CHAR, szUser: [64]CHAR, szComputer: [64]CHAR, }; pub const NTMS_I1_OPREQUESTINFORMATIONW = extern struct { Request: u32, Submitted: SYSTEMTIME, State: u32, szMessage: [127]u16, Arg1Type: u32, Arg1: Guid, Arg2Type: u32, Arg2: Guid, szApplication: [64]u16, szUser: [64]u16, szComputer: [64]u16, }; pub const NTMS_I1_OBJECTINFORMATIONA = extern struct { dwSize: u32, dwType: u32, Created: SYSTEMTIME, Modified: SYSTEMTIME, ObjectGuid: Guid, Enabled: BOOL, dwOperationalState: u32, szName: [64]CHAR, szDescription: [127]CHAR, Info: extern union { Drive: NTMS_DRIVEINFORMATIONA, DriveType: NTMS_DRIVETYPEINFORMATIONA, Library: NTMS_I1_LIBRARYINFORMATION, Changer: NTMS_CHANGERINFORMATIONA, ChangerType: NTMS_CHANGERTYPEINFORMATIONA, StorageSlot: NTMS_STORAGESLOTINFORMATION, IEDoor: NTMS_IEDOORINFORMATION, IEPort: NTMS_IEPORTINFORMATION, PhysicalMedia: NTMS_I1_PMIDINFORMATIONA, LogicalMedia: NTMS_LMIDINFORMATION, Partition: NTMS_I1_PARTITIONINFORMATIONA, MediaPool: NTMS_MEDIAPOOLINFORMATION, MediaType: NTMS_MEDIATYPEINFORMATION, LibRequest: NTMS_I1_LIBREQUESTINFORMATIONA, OpRequest: NTMS_I1_OPREQUESTINFORMATIONA, }, }; pub const NTMS_I1_OBJECTINFORMATIONW = extern struct { dwSize: u32, dwType: u32, Created: SYSTEMTIME, Modified: SYSTEMTIME, ObjectGuid: Guid, Enabled: BOOL, dwOperationalState: u32, szName: [64]u16, szDescription: [127]u16, Info: extern union { Drive: NTMS_DRIVEINFORMATIONW, DriveType: NTMS_DRIVETYPEINFORMATIONW, Library: NTMS_I1_LIBRARYINFORMATION, Changer: NTMS_CHANGERINFORMATIONW, ChangerType: NTMS_CHANGERTYPEINFORMATIONW, StorageSlot: NTMS_STORAGESLOTINFORMATION, IEDoor: NTMS_IEDOORINFORMATION, IEPort: NTMS_IEPORTINFORMATION, PhysicalMedia: NTMS_I1_PMIDINFORMATIONW, LogicalMedia: NTMS_LMIDINFORMATION, Partition: NTMS_I1_PARTITIONINFORMATIONW, MediaPool: NTMS_MEDIAPOOLINFORMATION, MediaType: NTMS_MEDIATYPEINFORMATION, LibRequest: NTMS_I1_LIBREQUESTINFORMATIONW, OpRequest: NTMS_I1_OPREQUESTINFORMATIONW, }, }; pub const NtmsCreateNtmsMediaOptions = enum(i32) { E = 1, }; pub const NTMS_ERROR_ON_DUPLICATE = NtmsCreateNtmsMediaOptions.E; pub const NtmsEnumerateOption = enum(i32) { DEFAULT = 0, ROOTPOOL = 1, }; pub const NTMS_ENUM_DEFAULT = NtmsEnumerateOption.DEFAULT; pub const NTMS_ENUM_ROOTPOOL = NtmsEnumerateOption.ROOTPOOL; pub const NtmsEjectOperation = enum(i32) { START = 0, STOP = 1, QUEUE = 2, FORCE = 3, IMMEDIATE = 4, ASK_USER = 5, }; pub const NTMS_EJECT_START = NtmsEjectOperation.START; pub const NTMS_EJECT_STOP = NtmsEjectOperation.STOP; pub const NTMS_EJECT_QUEUE = NtmsEjectOperation.QUEUE; pub const NTMS_EJECT_FORCE = NtmsEjectOperation.FORCE; pub const NTMS_EJECT_IMMEDIATE = NtmsEjectOperation.IMMEDIATE; pub const NTMS_EJECT_ASK_USER = NtmsEjectOperation.ASK_USER; pub const NtmsInjectOperation = enum(i32) { START = 0, STOP = 1, RETRACT = 2, STARTMANY = 3, }; pub const NTMS_INJECT_START = NtmsInjectOperation.START; pub const NTMS_INJECT_STOP = NtmsInjectOperation.STOP; pub const NTMS_INJECT_RETRACT = NtmsInjectOperation.RETRACT; pub const NTMS_INJECT_STARTMANY = NtmsInjectOperation.STARTMANY; pub const NTMS_FILESYSTEM_INFO = extern struct { FileSystemType: [64]u16, VolumeName: [256]u16, SerialNumber: u32, }; pub const NtmsDriveType = enum(i32) { E = 0, }; pub const NTMS_UNKNOWN_DRIVE = NtmsDriveType.E; pub const NtmsAccessMask = enum(i32) { USE_ACCESS = 1, MODIFY_ACCESS = 2, CONTROL_ACCESS = 4, }; pub const NTMS_USE_ACCESS = NtmsAccessMask.USE_ACCESS; pub const NTMS_MODIFY_ACCESS = NtmsAccessMask.MODIFY_ACCESS; pub const NTMS_CONTROL_ACCESS = NtmsAccessMask.CONTROL_ACCESS; pub const NtmsUITypes = enum(i32) { INVALID = 0, INFO = 1, REQ = 2, ERR = 3, MAX = 4, }; pub const NTMS_UITYPE_INVALID = NtmsUITypes.INVALID; pub const NTMS_UITYPE_INFO = NtmsUITypes.INFO; pub const NTMS_UITYPE_REQ = NtmsUITypes.REQ; pub const NTMS_UITYPE_ERR = NtmsUITypes.ERR; pub const NTMS_UITYPE_MAX = NtmsUITypes.MAX; pub const NtmsUIOperations = enum(i32) { DEST_ADD = 1, DEST_DELETE = 2, DEST_DELETEALL = 3, OPERATION_MAX = 4, }; pub const NTMS_UIDEST_ADD = NtmsUIOperations.DEST_ADD; pub const NTMS_UIDEST_DELETE = NtmsUIOperations.DEST_DELETE; pub const NTMS_UIDEST_DELETEALL = NtmsUIOperations.DEST_DELETEALL; pub const NTMS_UIOPERATION_MAX = NtmsUIOperations.OPERATION_MAX; pub const NtmsNotificationOperations = enum(i32) { OBJ_UPDATE = 1, OBJ_INSERT = 2, OBJ_DELETE = 3, EVENT_SIGNAL = 4, EVENT_COMPLETE = 5, }; pub const NTMS_OBJ_UPDATE = NtmsNotificationOperations.OBJ_UPDATE; pub const NTMS_OBJ_INSERT = NtmsNotificationOperations.OBJ_INSERT; pub const NTMS_OBJ_DELETE = NtmsNotificationOperations.OBJ_DELETE; pub const NTMS_EVENT_SIGNAL = NtmsNotificationOperations.EVENT_SIGNAL; pub const NTMS_EVENT_COMPLETE = NtmsNotificationOperations.EVENT_COMPLETE; pub const NTMS_NOTIFICATIONINFORMATION = extern struct { dwOperation: NtmsNotificationOperations, ObjectId: Guid, }; pub const MediaLabelInfo = extern struct { LabelType: [64]u16, LabelIDSize: u32, LabelID: [256]u8, LabelAppDescr: [256]u16, }; pub const MAXMEDIALABEL = fn( pMaxSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub const CLAIMMEDIALABEL = fn( pBuffer: ?*const u8, nBufferSize: u32, pLabelInfo: ?*MediaLabelInfo, ) callconv(@import("std").os.windows.WINAPI) u32; pub const CLAIMMEDIALABELEX = fn( pBuffer: ?*const u8, nBufferSize: u32, pLabelInfo: ?*MediaLabelInfo, LabelGuid: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) u32; pub const CLS_LSN = extern struct { Internal: u64, }; pub const CLS_CONTEXT_MODE = enum(i32) { None = 0, UndoNext = 1, Previous = 2, Forward = 3, }; pub const ClsContextNone = CLS_CONTEXT_MODE.None; pub const ClsContextUndoNext = CLS_CONTEXT_MODE.UndoNext; pub const ClsContextPrevious = CLS_CONTEXT_MODE.Previous; pub const ClsContextForward = CLS_CONTEXT_MODE.Forward; pub const CLFS_CONTEXT_MODE = enum(i32) { None = 0, UndoNext = 1, Previous = 2, Forward = 3, }; pub const ClfsContextNone = CLFS_CONTEXT_MODE.None; pub const ClfsContextUndoNext = CLFS_CONTEXT_MODE.UndoNext; pub const ClfsContextPrevious = CLFS_CONTEXT_MODE.Previous; pub const ClfsContextForward = CLFS_CONTEXT_MODE.Forward; pub const CLFS_NODE_ID = extern struct { cType: u32, cbNode: u32, }; pub const CLS_WRITE_ENTRY = extern struct { Buffer: ?*anyopaque, ByteLength: u32, }; pub const CLS_INFORMATION = extern struct { TotalAvailable: i64, CurrentAvailable: i64, TotalReservation: i64, BaseFileSize: u64, ContainerSize: u64, TotalContainers: u32, FreeContainers: u32, TotalClients: u32, Attributes: u32, FlushThreshold: u32, SectorSize: u32, MinArchiveTailLsn: CLS_LSN, BaseLsn: CLS_LSN, LastFlushedLsn: CLS_LSN, LastLsn: CLS_LSN, RestartLsn: CLS_LSN, Identity: Guid, }; pub const CLFS_LOG_NAME_INFORMATION = extern struct { NameLengthInBytes: u16, Name: [1]u16, }; pub const CLFS_STREAM_ID_INFORMATION = extern struct { StreamIdentifier: u8, }; pub const CLFS_PHYSICAL_LSN_INFORMATION = extern struct { StreamIdentifier: u8, VirtualLsn: CLS_LSN, PhysicalLsn: CLS_LSN, }; pub const CLS_CONTAINER_INFORMATION = extern struct { FileAttributes: u32, CreationTime: u64, LastAccessTime: u64, LastWriteTime: u64, ContainerSize: i64, FileNameActualLength: u32, FileNameLength: u32, FileName: [256]u16, State: u32, PhysicalContainerId: u32, LogicalContainerId: u32, }; pub const CLS_LOG_INFORMATION_CLASS = enum(i32) { BasicInformation = 0, BasicInformationPhysical = 1, PhysicalNameInformation = 2, StreamIdentifierInformation = 3, SystemMarkingInformation = 4, PhysicalLsnInformation = 5, }; pub const ClfsLogBasicInformation = CLS_LOG_INFORMATION_CLASS.BasicInformation; pub const ClfsLogBasicInformationPhysical = CLS_LOG_INFORMATION_CLASS.BasicInformationPhysical; pub const ClfsLogPhysicalNameInformation = CLS_LOG_INFORMATION_CLASS.PhysicalNameInformation; pub const ClfsLogStreamIdentifierInformation = CLS_LOG_INFORMATION_CLASS.StreamIdentifierInformation; pub const ClfsLogSystemMarkingInformation = CLS_LOG_INFORMATION_CLASS.SystemMarkingInformation; pub const ClfsLogPhysicalLsnInformation = CLS_LOG_INFORMATION_CLASS.PhysicalLsnInformation; pub const CLS_IOSTATS_CLASS = enum(i32) { Default = 0, Max = 65535, }; pub const ClsIoStatsDefault = CLS_IOSTATS_CLASS.Default; pub const ClsIoStatsMax = CLS_IOSTATS_CLASS.Max; pub const CLFS_IOSTATS_CLASS = enum(i32) { Default = 0, Max = 65535, }; pub const ClfsIoStatsDefault = CLFS_IOSTATS_CLASS.Default; pub const ClfsIoStatsMax = CLFS_IOSTATS_CLASS.Max; pub const CLS_IO_STATISTICS_HEADER = extern struct { ubMajorVersion: u8, ubMinorVersion: u8, eStatsClass: CLFS_IOSTATS_CLASS, cbLength: u16, coffData: u32, }; pub const CLS_IO_STATISTICS = extern struct { hdrIoStats: CLS_IO_STATISTICS_HEADER, cFlush: u64, cbFlush: u64, cMetaFlush: u64, cbMetaFlush: u64, }; pub const CLS_SCAN_CONTEXT = extern struct { cidNode: CLFS_NODE_ID, hLog: ?HANDLE, cIndex: u32, cContainers: u32, cContainersReturned: u32, eScanMode: u8, pinfoContainer: ?*CLS_CONTAINER_INFORMATION, }; pub const CLS_ARCHIVE_DESCRIPTOR = extern struct { coffLow: u64, coffHigh: u64, infoContainer: CLS_CONTAINER_INFORMATION, }; pub const CLFS_BLOCK_ALLOCATION = fn( cbBufferLength: u32, pvUserContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) ?*anyopaque; pub const CLFS_BLOCK_DEALLOCATION = fn( pvBuffer: ?*anyopaque, pvUserContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const CLFS_LOG_ARCHIVE_MODE = enum(i32) { Enabled = 1, Disabled = 2, }; pub const ClfsLogArchiveEnabled = CLFS_LOG_ARCHIVE_MODE.Enabled; pub const ClfsLogArchiveDisabled = CLFS_LOG_ARCHIVE_MODE.Disabled; pub const PCLFS_COMPLETION_ROUTINE = fn( pvOverlapped: ?*anyopaque, ulReserved: u32, ) callconv(@import("std").os.windows.WINAPI) void; pub const CLFS_MGMT_POLICY_TYPE = enum(i32) { MaximumSize = 0, MinimumSize = 1, NewContainerSize = 2, GrowthRate = 3, LogTail = 4, AutoShrink = 5, AutoGrow = 6, NewContainerPrefix = 7, NewContainerSuffix = 8, NewContainerExtension = 9, Invalid = 10, }; pub const ClfsMgmtPolicyMaximumSize = CLFS_MGMT_POLICY_TYPE.MaximumSize; pub const ClfsMgmtPolicyMinimumSize = CLFS_MGMT_POLICY_TYPE.MinimumSize; pub const ClfsMgmtPolicyNewContainerSize = CLFS_MGMT_POLICY_TYPE.NewContainerSize; pub const ClfsMgmtPolicyGrowthRate = CLFS_MGMT_POLICY_TYPE.GrowthRate; pub const ClfsMgmtPolicyLogTail = CLFS_MGMT_POLICY_TYPE.LogTail; pub const ClfsMgmtPolicyAutoShrink = CLFS_MGMT_POLICY_TYPE.AutoShrink; pub const ClfsMgmtPolicyAutoGrow = CLFS_MGMT_POLICY_TYPE.AutoGrow; pub const ClfsMgmtPolicyNewContainerPrefix = CLFS_MGMT_POLICY_TYPE.NewContainerPrefix; pub const ClfsMgmtPolicyNewContainerSuffix = CLFS_MGMT_POLICY_TYPE.NewContainerSuffix; pub const ClfsMgmtPolicyNewContainerExtension = CLFS_MGMT_POLICY_TYPE.NewContainerExtension; pub const ClfsMgmtPolicyInvalid = CLFS_MGMT_POLICY_TYPE.Invalid; pub const CLFS_MGMT_POLICY = extern struct { Version: u32, LengthInBytes: u32, PolicyFlags: u32, PolicyType: CLFS_MGMT_POLICY_TYPE, PolicyParameters: extern union { MaximumSize: extern struct { Containers: u32, }, MinimumSize: extern struct { Containers: u32, }, NewContainerSize: extern struct { SizeInBytes: u32, }, GrowthRate: extern struct { AbsoluteGrowthInContainers: u32, RelativeGrowthPercentage: u32, }, LogTail: extern struct { MinimumAvailablePercentage: u32, MinimumAvailableContainers: u32, }, AutoShrink: extern struct { Percentage: u32, }, AutoGrow: extern struct { Enabled: u32, }, NewContainerPrefix: extern struct { PrefixLengthInBytes: u16, PrefixString: [1]u16, }, NewContainerSuffix: extern struct { NextContainerSuffix: u64, }, NewContainerExtension: extern struct { ExtensionLengthInBytes: u16, ExtensionString: [1]u16, }, }, }; pub const CLFS_MGMT_NOTIFICATION_TYPE = enum(i32) { AdvanceTailNotification = 0, LogFullHandlerNotification = 1, LogUnpinnedNotification = 2, LogWriteNotification = 3, }; pub const ClfsMgmtAdvanceTailNotification = CLFS_MGMT_NOTIFICATION_TYPE.AdvanceTailNotification; pub const ClfsMgmtLogFullHandlerNotification = CLFS_MGMT_NOTIFICATION_TYPE.LogFullHandlerNotification; pub const ClfsMgmtLogUnpinnedNotification = CLFS_MGMT_NOTIFICATION_TYPE.LogUnpinnedNotification; pub const ClfsMgmtLogWriteNotification = CLFS_MGMT_NOTIFICATION_TYPE.LogWriteNotification; pub const CLFS_MGMT_NOTIFICATION = extern struct { Notification: CLFS_MGMT_NOTIFICATION_TYPE, Lsn: CLS_LSN, LogIsPinned: u16, }; pub const PLOG_TAIL_ADVANCE_CALLBACK = fn( hLogFile: ?HANDLE, lsnTarget: CLS_LSN, pvClientContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const PLOG_FULL_HANDLER_CALLBACK = fn( hLogFile: ?HANDLE, dwError: u32, fLogIsPinned: BOOL, pvClientContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const PLOG_UNPINNED_CALLBACK = fn( hLogFile: ?HANDLE, pvClientContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const LOG_MANAGEMENT_CALLBACKS = extern struct { CallbackContext: ?*anyopaque, AdvanceTailCallback: ?PLOG_TAIL_ADVANCE_CALLBACK, LogFullHandlerCallback: ?PLOG_FULL_HANDLER_CALLBACK, LogUnpinnedCallback: ?PLOG_UNPINNED_CALLBACK, }; pub const DISKQUOTA_USER_INFORMATION = extern struct { QuotaUsed: i64, QuotaThreshold: i64, QuotaLimit: i64, }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDiskQuotaUser_Value = @import("../zig.zig").Guid.initString("7988b574-ec89-11cf-9c00-00aa00a14f56"); pub const IID_IDiskQuotaUser = &IID_IDiskQuotaUser_Value; pub const IDiskQuotaUser = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetID: fn( self: *const IDiskQuotaUser, pulID: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetName: fn( self: *const IDiskQuotaUser, pszAccountContainer: ?PWSTR, cchAccountContainer: u32, pszLogonName: ?PWSTR, cchLogonName: u32, pszDisplayName: ?PWSTR, cchDisplayName: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetSidLength: fn( self: *const IDiskQuotaUser, pdwLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetSid: fn( self: *const IDiskQuotaUser, pbSidBuffer: ?*u8, cbSidBuffer: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaThreshold: fn( self: *const IDiskQuotaUser, pllThreshold: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaThresholdText: fn( self: *const IDiskQuotaUser, pszText: ?PWSTR, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaLimit: fn( self: *const IDiskQuotaUser, pllLimit: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaLimitText: fn( self: *const IDiskQuotaUser, pszText: ?PWSTR, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaUsed: fn( self: *const IDiskQuotaUser, pllUsed: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaUsedText: fn( self: *const IDiskQuotaUser, pszText: ?PWSTR, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaInformation: fn( self: *const IDiskQuotaUser, pbQuotaInfo: ?*anyopaque, cbQuotaInfo: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetQuotaThreshold: fn( self: *const IDiskQuotaUser, llThreshold: i64, fWriteThrough: BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetQuotaLimit: fn( self: *const IDiskQuotaUser, llLimit: i64, fWriteThrough: BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Invalidate: fn( self: *const IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAccountStatus: fn( self: *const IDiskQuotaUser, pdwStatus: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetID(self: *const T, pulID: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetID(@ptrCast(*const IDiskQuotaUser, self), pulID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetName(self: *const T, pszAccountContainer: ?PWSTR, cchAccountContainer: u32, pszLogonName: ?PWSTR, cchLogonName: u32, pszDisplayName: ?PWSTR, cchDisplayName: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetName(@ptrCast(*const IDiskQuotaUser, self), pszAccountContainer, cchAccountContainer, pszLogonName, cchLogonName, pszDisplayName, cchDisplayName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetSidLength(self: *const T, pdwLength: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetSidLength(@ptrCast(*const IDiskQuotaUser, self), pdwLength); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetSid(self: *const T, pbSidBuffer: ?*u8, cbSidBuffer: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetSid(@ptrCast(*const IDiskQuotaUser, self), pbSidBuffer, cbSidBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetQuotaThreshold(self: *const T, pllThreshold: ?*i64) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetQuotaThreshold(@ptrCast(*const IDiskQuotaUser, self), pllThreshold); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetQuotaThresholdText(self: *const T, pszText: ?PWSTR, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetQuotaThresholdText(@ptrCast(*const IDiskQuotaUser, self), pszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetQuotaLimit(self: *const T, pllLimit: ?*i64) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetQuotaLimit(@ptrCast(*const IDiskQuotaUser, self), pllLimit); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetQuotaLimitText(self: *const T, pszText: ?PWSTR, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetQuotaLimitText(@ptrCast(*const IDiskQuotaUser, self), pszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetQuotaUsed(self: *const T, pllUsed: ?*i64) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetQuotaUsed(@ptrCast(*const IDiskQuotaUser, self), pllUsed); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetQuotaUsedText(self: *const T, pszText: ?PWSTR, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetQuotaUsedText(@ptrCast(*const IDiskQuotaUser, self), pszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetQuotaInformation(self: *const T, pbQuotaInfo: ?*anyopaque, cbQuotaInfo: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetQuotaInformation(@ptrCast(*const IDiskQuotaUser, self), pbQuotaInfo, cbQuotaInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_SetQuotaThreshold(self: *const T, llThreshold: i64, fWriteThrough: BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).SetQuotaThreshold(@ptrCast(*const IDiskQuotaUser, self), llThreshold, fWriteThrough); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_SetQuotaLimit(self: *const T, llLimit: i64, fWriteThrough: BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).SetQuotaLimit(@ptrCast(*const IDiskQuotaUser, self), llLimit, fWriteThrough); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_Invalidate(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).Invalidate(@ptrCast(*const IDiskQuotaUser, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUser_GetAccountStatus(self: *const T, pdwStatus: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUser.VTable, self.vtable).GetAccountStatus(@ptrCast(*const IDiskQuotaUser, self), pdwStatus); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IEnumDiskQuotaUsers_Value = @import("../zig.zig").Guid.initString("7988b577-ec89-11cf-9c00-00aa00a14f56"); pub const IID_IEnumDiskQuotaUsers = &IID_IEnumDiskQuotaUsers_Value; pub const IEnumDiskQuotaUsers = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumDiskQuotaUsers, cUsers: u32, rgUsers: ?*?*IDiskQuotaUser, pcUsersFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumDiskQuotaUsers, cUsers: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumDiskQuotaUsers, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumDiskQuotaUsers, ppEnum: ?*?*IEnumDiskQuotaUsers, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDiskQuotaUsers_Next(self: *const T, cUsers: u32, rgUsers: ?*?*IDiskQuotaUser, pcUsersFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDiskQuotaUsers.VTable, self.vtable).Next(@ptrCast(*const IEnumDiskQuotaUsers, self), cUsers, rgUsers, pcUsersFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDiskQuotaUsers_Skip(self: *const T, cUsers: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDiskQuotaUsers.VTable, self.vtable).Skip(@ptrCast(*const IEnumDiskQuotaUsers, self), cUsers); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDiskQuotaUsers_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDiskQuotaUsers.VTable, self.vtable).Reset(@ptrCast(*const IEnumDiskQuotaUsers, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDiskQuotaUsers_Clone(self: *const T, ppEnum: ?*?*IEnumDiskQuotaUsers) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDiskQuotaUsers.VTable, self.vtable).Clone(@ptrCast(*const IEnumDiskQuotaUsers, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDiskQuotaUserBatch_Value = @import("../zig.zig").Guid.initString("7988b576-ec89-11cf-9c00-00aa00a14f56"); pub const IID_IDiskQuotaUserBatch = &IID_IDiskQuotaUserBatch_Value; pub const IDiskQuotaUserBatch = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Add: fn( self: *const IDiskQuotaUserBatch, pUser: ?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Remove: fn( self: *const IDiskQuotaUserBatch, pUser: ?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveAll: fn( self: *const IDiskQuotaUserBatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FlushToDisk: fn( self: *const IDiskQuotaUserBatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUserBatch_Add(self: *const T, pUser: ?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUserBatch.VTable, self.vtable).Add(@ptrCast(*const IDiskQuotaUserBatch, self), pUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUserBatch_Remove(self: *const T, pUser: ?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUserBatch.VTable, self.vtable).Remove(@ptrCast(*const IDiskQuotaUserBatch, self), pUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUserBatch_RemoveAll(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUserBatch.VTable, self.vtable).RemoveAll(@ptrCast(*const IDiskQuotaUserBatch, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaUserBatch_FlushToDisk(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaUserBatch.VTable, self.vtable).FlushToDisk(@ptrCast(*const IDiskQuotaUserBatch, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDiskQuotaControl_Value = @import("../zig.zig").Guid.initString("7988b572-ec89-11cf-9c00-00aa00a14f56"); pub const IID_IDiskQuotaControl = &IID_IDiskQuotaControl_Value; pub const IDiskQuotaControl = extern struct { pub const VTable = extern struct { base: IConnectionPointContainer.VTable, Initialize: fn( self: *const IDiskQuotaControl, pszPath: ?[*:0]const u16, bReadWrite: BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetQuotaState: fn( self: *const IDiskQuotaControl, dwState: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaState: fn( self: *const IDiskQuotaControl, pdwState: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetQuotaLogFlags: fn( self: *const IDiskQuotaControl, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuotaLogFlags: fn( self: *const IDiskQuotaControl, pdwFlags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetDefaultQuotaThreshold: fn( self: *const IDiskQuotaControl, llThreshold: i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultQuotaThreshold: fn( self: *const IDiskQuotaControl, pllThreshold: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultQuotaThresholdText: fn( self: *const IDiskQuotaControl, pszText: ?PWSTR, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetDefaultQuotaLimit: fn( self: *const IDiskQuotaControl, llLimit: i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultQuotaLimit: fn( self: *const IDiskQuotaControl, pllLimit: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultQuotaLimitText: fn( self: *const IDiskQuotaControl, pszText: ?PWSTR, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddUserSid: fn( self: *const IDiskQuotaControl, pUserSid: ?PSID, fNameResolution: DISKQUOTA_USERNAME_RESOLVE, ppUser: ?*?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddUserName: fn( self: *const IDiskQuotaControl, pszLogonName: ?[*:0]const u16, fNameResolution: DISKQUOTA_USERNAME_RESOLVE, ppUser: ?*?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeleteUser: fn( self: *const IDiskQuotaControl, pUser: ?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FindUserSid: fn( self: *const IDiskQuotaControl, pUserSid: ?PSID, fNameResolution: DISKQUOTA_USERNAME_RESOLVE, ppUser: ?*?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FindUserName: fn( self: *const IDiskQuotaControl, pszLogonName: ?[*:0]const u16, ppUser: ?*?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateEnumUsers: fn( self: *const IDiskQuotaControl, rgpUserSids: ?*?PSID, cpSids: u32, fNameResolution: DISKQUOTA_USERNAME_RESOLVE, ppEnum: ?*?*IEnumDiskQuotaUsers, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateUserBatch: fn( self: *const IDiskQuotaControl, ppBatch: ?*?*IDiskQuotaUserBatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, InvalidateSidNameCache: fn( self: *const IDiskQuotaControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GiveUserNameResolutionPriority: fn( self: *const IDiskQuotaControl, pUser: ?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ShutdownNameResolution: fn( self: *const IDiskQuotaControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IConnectionPointContainer.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_Initialize(self: *const T, pszPath: ?[*:0]const u16, bReadWrite: BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).Initialize(@ptrCast(*const IDiskQuotaControl, self), pszPath, bReadWrite); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_SetQuotaState(self: *const T, dwState: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).SetQuotaState(@ptrCast(*const IDiskQuotaControl, self), dwState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_GetQuotaState(self: *const T, pdwState: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).GetQuotaState(@ptrCast(*const IDiskQuotaControl, self), pdwState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_SetQuotaLogFlags(self: *const T, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).SetQuotaLogFlags(@ptrCast(*const IDiskQuotaControl, self), dwFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_GetQuotaLogFlags(self: *const T, pdwFlags: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).GetQuotaLogFlags(@ptrCast(*const IDiskQuotaControl, self), pdwFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_SetDefaultQuotaThreshold(self: *const T, llThreshold: i64) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).SetDefaultQuotaThreshold(@ptrCast(*const IDiskQuotaControl, self), llThreshold); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_GetDefaultQuotaThreshold(self: *const T, pllThreshold: ?*i64) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).GetDefaultQuotaThreshold(@ptrCast(*const IDiskQuotaControl, self), pllThreshold); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_GetDefaultQuotaThresholdText(self: *const T, pszText: ?PWSTR, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).GetDefaultQuotaThresholdText(@ptrCast(*const IDiskQuotaControl, self), pszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_SetDefaultQuotaLimit(self: *const T, llLimit: i64) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).SetDefaultQuotaLimit(@ptrCast(*const IDiskQuotaControl, self), llLimit); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_GetDefaultQuotaLimit(self: *const T, pllLimit: ?*i64) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).GetDefaultQuotaLimit(@ptrCast(*const IDiskQuotaControl, self), pllLimit); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_GetDefaultQuotaLimitText(self: *const T, pszText: ?PWSTR, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).GetDefaultQuotaLimitText(@ptrCast(*const IDiskQuotaControl, self), pszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_AddUserSid(self: *const T, pUserSid: ?PSID, fNameResolution: DISKQUOTA_USERNAME_RESOLVE, ppUser: ?*?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).AddUserSid(@ptrCast(*const IDiskQuotaControl, self), pUserSid, fNameResolution, ppUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_AddUserName(self: *const T, pszLogonName: ?[*:0]const u16, fNameResolution: DISKQUOTA_USERNAME_RESOLVE, ppUser: ?*?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).AddUserName(@ptrCast(*const IDiskQuotaControl, self), pszLogonName, fNameResolution, ppUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_DeleteUser(self: *const T, pUser: ?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).DeleteUser(@ptrCast(*const IDiskQuotaControl, self), pUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_FindUserSid(self: *const T, pUserSid: ?PSID, fNameResolution: DISKQUOTA_USERNAME_RESOLVE, ppUser: ?*?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).FindUserSid(@ptrCast(*const IDiskQuotaControl, self), pUserSid, fNameResolution, ppUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_FindUserName(self: *const T, pszLogonName: ?[*:0]const u16, ppUser: ?*?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).FindUserName(@ptrCast(*const IDiskQuotaControl, self), pszLogonName, ppUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_CreateEnumUsers(self: *const T, rgpUserSids: ?*?PSID, cpSids: u32, fNameResolution: DISKQUOTA_USERNAME_RESOLVE, ppEnum: ?*?*IEnumDiskQuotaUsers) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).CreateEnumUsers(@ptrCast(*const IDiskQuotaControl, self), rgpUserSids, cpSids, fNameResolution, ppEnum); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_CreateUserBatch(self: *const T, ppBatch: ?*?*IDiskQuotaUserBatch) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).CreateUserBatch(@ptrCast(*const IDiskQuotaControl, self), ppBatch); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_InvalidateSidNameCache(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).InvalidateSidNameCache(@ptrCast(*const IDiskQuotaControl, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_GiveUserNameResolutionPriority(self: *const T, pUser: ?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).GiveUserNameResolutionPriority(@ptrCast(*const IDiskQuotaControl, self), pUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaControl_ShutdownNameResolution(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaControl.VTable, self.vtable).ShutdownNameResolution(@ptrCast(*const IDiskQuotaControl, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IDiskQuotaEvents_Value = @import("../zig.zig").Guid.initString("7988b579-ec89-11cf-9c00-00aa00a14f56"); pub const IID_IDiskQuotaEvents = &IID_IDiskQuotaEvents_Value; pub const IDiskQuotaEvents = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, OnUserNameChanged: fn( self: *const IDiskQuotaEvents, pUser: ?*IDiskQuotaUser, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDiskQuotaEvents_OnUserNameChanged(self: *const T, pUser: ?*IDiskQuotaUser) callconv(.Inline) HRESULT { return @ptrCast(*const IDiskQuotaEvents.VTable, self.vtable).OnUserNameChanged(@ptrCast(*const IDiskQuotaEvents, self), pUser); } };} pub usingnamespace MethodMixin(@This()); }; pub const EFS_CERTIFICATE_BLOB = extern struct { dwCertEncodingType: u32, cbData: u32, pbData: ?*u8, }; pub const EFS_HASH_BLOB = extern struct { cbData: u32, pbData: ?*u8, }; pub const EFS_RPC_BLOB = extern struct { cbData: u32, pbData: ?*u8, }; pub const EFS_PIN_BLOB = extern struct { cbPadding: u32, cbData: u32, pbData: ?*u8, }; pub const EFS_KEY_INFO = extern struct { dwVersion: u32, Entropy: u32, Algorithm: u32, KeyLength: u32, }; pub const EFS_COMPATIBILITY_INFO = extern struct { EfsVersion: u32, }; pub const EFS_VERSION_INFO = extern struct { EfsVersion: u32, SubVersion: u32, }; pub const EFS_DECRYPTION_STATUS_INFO = extern struct { dwDecryptionError: u32, dwHashOffset: u32, cbHash: u32, }; pub const EFS_ENCRYPTION_STATUS_INFO = extern struct { bHasCurrentKey: BOOL, dwEncryptionError: u32, }; pub const ENCRYPTION_CERTIFICATE = extern struct { cbTotalLength: u32, pUserSid: ?*SID, pCertBlob: ?*EFS_CERTIFICATE_BLOB, }; pub const ENCRYPTION_CERTIFICATE_HASH = extern struct { cbTotalLength: u32, pUserSid: ?*SID, pHash: ?*EFS_HASH_BLOB, lpDisplayInformation: ?PWSTR, }; pub const ENCRYPTION_CERTIFICATE_HASH_LIST = extern struct { nCert_Hash: u32, pUsers: ?*?*ENCRYPTION_CERTIFICATE_HASH, }; pub const ENCRYPTION_CERTIFICATE_LIST = extern struct { nUsers: u32, pUsers: ?*?*ENCRYPTION_CERTIFICATE, }; pub const ENCRYPTED_FILE_METADATA_SIGNATURE = extern struct { dwEfsAccessType: u32, pCertificatesAdded: ?*ENCRYPTION_CERTIFICATE_HASH_LIST, pEncryptionCertificate: ?*ENCRYPTION_CERTIFICATE, pEfsStreamSignature: ?*EFS_RPC_BLOB, }; pub const ENCRYPTION_PROTECTOR = extern struct { cbTotalLength: u32, pUserSid: ?*SID, lpProtectorDescriptor: ?PWSTR, }; pub const ENCRYPTION_PROTECTOR_LIST = extern struct { nProtectors: u32, pProtectors: ?*?*ENCRYPTION_PROTECTOR, }; pub const WofEnumEntryProc = fn( EntryInfo: ?*const anyopaque, UserData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub const WofEnumFilesProc = fn( FilePath: ?[*:0]const u16, ExternalFileInfo: ?*anyopaque, UserData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub const WIM_ENTRY_INFO = extern struct { WimEntryInfoSize: u32, WimType: u32, DataSourceId: LARGE_INTEGER, WimGuid: Guid, WimPath: ?[*:0]const u16, WimIndex: u32, Flags: u32, }; pub const WIM_EXTERNAL_FILE_INFO = extern struct { DataSourceId: LARGE_INTEGER, ResourceHash: [20]u8, Flags: u32, }; pub const WOF_FILE_COMPRESSION_INFO_V0 = extern struct { Algorithm: u32, }; pub const WOF_FILE_COMPRESSION_INFO_V1 = extern struct { Algorithm: u32, Flags: u32, }; pub const TXF_ID = extern struct { Anonymous: extern struct { // WARNING: unable to add field alignment because it's causing a compiler bug LowPart: i64, HighPart: i64, }, }; pub const TXF_LOG_RECORD_BASE = extern struct { Version: u16, RecordType: TXF_LOG_RECORD_TYPE, RecordLength: u32, }; pub const TXF_LOG_RECORD_WRITE = extern struct { // WARNING: unable to add field alignment because it's causing a compiler bug Version: u16, RecordType: u16, RecordLength: u32, Flags: u32, TxfFileId: TXF_ID, KtmGuid: Guid, ByteOffsetInFile: i64, NumBytesWritten: u32, ByteOffsetInStructure: u32, FileNameLength: u32, FileNameByteOffsetInStructure: u32, }; pub const TXF_LOG_RECORD_TRUNCATE = extern struct { // WARNING: unable to add field alignment because it's causing a compiler bug Version: u16, RecordType: u16, RecordLength: u32, Flags: u32, TxfFileId: TXF_ID, KtmGuid: Guid, NewFileSize: i64, FileNameLength: u32, FileNameByteOffsetInStructure: u32, }; pub const TXF_LOG_RECORD_AFFECTED_FILE = extern struct { Version: u16, RecordLength: u32, Flags: u32, TxfFileId: TXF_ID, KtmGuid: Guid, FileNameLength: u32, FileNameByteOffsetInStructure: u32, }; pub const VOLUME_FAILOVER_SET = extern struct { NumberOfDisks: u32, DiskNumbers: [1]u32, }; pub const VOLUME_NUMBER = extern struct { VolumeNumber: u32, VolumeManagerName: [8]u16, }; pub const VOLUME_LOGICAL_OFFSET = extern struct { LogicalOffset: i64, }; pub const VOLUME_PHYSICAL_OFFSET = extern struct { DiskNumber: u32, Offset: i64, }; pub const VOLUME_PHYSICAL_OFFSETS = extern struct { NumberOfPhysicalOffsets: u32, PhysicalOffset: [1]VOLUME_PHYSICAL_OFFSET, }; pub const VOLUME_READ_PLEX_INPUT = extern struct { ByteOffset: LARGE_INTEGER, Length: u32, PlexNumber: u32, }; pub const VOLUME_SET_GPT_ATTRIBUTES_INFORMATION = extern struct { GptAttributes: u64, RevertOnClose: BOOLEAN, ApplyToAllConnectedVolumes: BOOLEAN, Reserved1: u16, Reserved2: u32, }; pub const VOLUME_GET_BC_PROPERTIES_INPUT = extern struct { Version: u32, Reserved1: u32, LowestByteOffset: u64, HighestByteOffset: u64, AccessType: u32, AccessMode: u32, }; pub const VOLUME_GET_BC_PROPERTIES_OUTPUT = extern struct { MaximumRequestsPerPeriod: u32, MinimumPeriod: u32, MaximumRequestSize: u64, EstimatedTimePerRequest: u32, NumOutStandingRequests: u32, RequestSize: u64, }; pub const VOLUME_ALLOCATE_BC_STREAM_INPUT = extern struct { Version: u32, RequestsPerPeriod: u32, Period: u32, RetryFailures: BOOLEAN, Discardable: BOOLEAN, Reserved1: [2]BOOLEAN, LowestByteOffset: u64, HighestByteOffset: u64, AccessType: u32, AccessMode: u32, }; pub const VOLUME_ALLOCATE_BC_STREAM_OUTPUT = extern struct { RequestSize: u64, NumOutStandingRequests: u32, }; pub const FILE_EXTENT = extern struct { VolumeOffset: u64, ExtentLength: u64, }; pub const VOLUME_CRITICAL_IO = extern struct { AccessType: u32, ExtentsCount: u32, Extents: [1]FILE_EXTENT, }; pub const VOLUME_ALLOCATION_HINT_INPUT = extern struct { ClusterSize: u32, NumberOfClusters: u32, StartingClusterNumber: i64, }; pub const VOLUME_ALLOCATION_HINT_OUTPUT = extern struct { Bitmap: [1]u32, }; pub const VOLUME_SHRINK_INFO = extern struct { VolumeSize: u64, }; pub const SHARE_INFO_0 = extern struct { shi0_netname: ?PWSTR, }; pub const SHARE_INFO_1 = extern struct { shi1_netname: ?PWSTR, shi1_type: SHARE_TYPE, shi1_remark: ?PWSTR, }; pub const SHARE_INFO_2 = extern struct { shi2_netname: ?PWSTR, shi2_type: SHARE_TYPE, shi2_remark: ?PWSTR, shi2_permissions: SHARE_INFO_PERMISSIONS, shi2_max_uses: u32, shi2_current_uses: u32, shi2_path: ?PWSTR, shi2_passwd: ?<PASSWORD>, }; pub const SHARE_INFO_501 = extern struct { shi501_netname: ?PWSTR, shi501_type: SHARE_TYPE, shi501_remark: ?PWSTR, shi501_flags: u32, }; pub const SHARE_INFO_502 = extern struct { shi502_netname: ?PWSTR, shi502_type: SHARE_TYPE, shi502_remark: ?PWSTR, shi502_permissions: SHARE_INFO_PERMISSIONS, shi502_max_uses: u32, shi502_current_uses: u32, shi502_path: ?PWSTR, shi502_passwd: ?PWSTR, shi502_reserved: u32, shi502_security_descriptor: ?*SECURITY_DESCRIPTOR, }; pub const SHARE_INFO_503 = extern struct { shi503_netname: ?PWSTR, shi503_type: SHARE_TYPE, shi503_remark: ?PWSTR, shi503_permissions: SHARE_INFO_PERMISSIONS, shi503_max_uses: u32, shi503_current_uses: u32, shi503_path: ?PWSTR, shi503_passwd: ?PWSTR, shi503_servername: ?PWSTR, shi503_reserved: u32, shi503_security_descriptor: ?*SECURITY_DESCRIPTOR, }; pub const SHARE_INFO_1004 = extern struct { shi1004_remark: ?PWSTR, }; pub const SHARE_INFO_1005 = extern struct { shi1005_flags: u32, }; pub const SHARE_INFO_1006 = extern struct { shi1006_max_uses: u32, }; pub const SHARE_INFO_1501 = extern struct { shi1501_reserved: u32, shi1501_security_descriptor: ?*SECURITY_DESCRIPTOR, }; pub const SHARE_INFO_1503 = extern struct { shi1503_sharefilter: Guid, }; pub const SERVER_ALIAS_INFO_0 = extern struct { srvai0_alias: ?PWSTR, srvai0_target: ?PWSTR, srvai0_default: BOOLEAN, srvai0_reserved: u32, }; pub const SESSION_INFO_0 = extern struct { sesi0_cname: ?PWSTR, }; pub const SESSION_INFO_1 = extern struct { sesi1_cname: ?PWSTR, sesi1_username: ?PWSTR, sesi1_num_opens: u32, sesi1_time: u32, sesi1_idle_time: u32, sesi1_user_flags: SESSION_INFO_USER_FLAGS, }; pub const SESSION_INFO_2 = extern struct { sesi2_cname: ?PWSTR, sesi2_username: ?PWSTR, sesi2_num_opens: u32, sesi2_time: u32, sesi2_idle_time: u32, sesi2_user_flags: SESSION_INFO_USER_FLAGS, sesi2_cltype_name: ?PWSTR, }; pub const SESSION_INFO_10 = extern struct { sesi10_cname: ?PWSTR, sesi10_username: ?PWSTR, sesi10_time: u32, sesi10_idle_time: u32, }; pub const SESSION_INFO_502 = extern struct { sesi502_cname: ?PWSTR, sesi502_username: ?PWSTR, sesi502_num_opens: u32, sesi502_time: u32, sesi502_idle_time: u32, sesi502_user_flags: SESSION_INFO_USER_FLAGS, sesi502_cltype_name: ?PWSTR, sesi502_transport: ?PWSTR, }; pub const CONNECTION_INFO_0 = extern struct { coni0_id: u32, }; pub const CONNECTION_INFO_1 = extern struct { coni1_id: u32, coni1_type: SHARE_TYPE, coni1_num_opens: u32, coni1_num_users: u32, coni1_time: u32, coni1_username: ?PWSTR, coni1_netname: ?PWSTR, }; pub const FILE_INFO_2 = extern struct { fi2_id: u32, }; pub const FILE_INFO_3 = extern struct { fi3_id: u32, fi3_permissions: FILE_INFO_FLAGS_PERMISSIONS, fi3_num_locks: u32, fi3_pathname: ?PWSTR, fi3_username: ?PWSTR, }; pub const SERVER_CERTIFICATE_TYPE = enum(i32) { C = 0, }; pub const QUIC = SERVER_CERTIFICATE_TYPE.C; pub const SERVER_CERTIFICATE_INFO_0 = extern struct { srvci0_name: ?PWSTR, srvci0_subject: ?PWSTR, srvci0_issuer: ?PWSTR, srvci0_thumbprint: ?PWSTR, srvci0_friendlyname: ?PWSTR, srvci0_notbefore: ?PWSTR, srvci0_notafter: ?PWSTR, srvci0_storelocation: ?PWSTR, srvci0_storename: ?PWSTR, srvci0_renewalchain: ?PWSTR, srvci0_type: u32, srvci0_flags: u32, }; pub const STAT_WORKSTATION_0 = extern struct { StatisticsStartTime: LARGE_INTEGER, BytesReceived: LARGE_INTEGER, SmbsReceived: LARGE_INTEGER, PagingReadBytesRequested: LARGE_INTEGER, NonPagingReadBytesRequested: LARGE_INTEGER, CacheReadBytesRequested: LARGE_INTEGER, NetworkReadBytesRequested: LARGE_INTEGER, BytesTransmitted: LARGE_INTEGER, SmbsTransmitted: LARGE_INTEGER, PagingWriteBytesRequested: LARGE_INTEGER, NonPagingWriteBytesRequested: LARGE_INTEGER, CacheWriteBytesRequested: LARGE_INTEGER, NetworkWriteBytesRequested: LARGE_INTEGER, InitiallyFailedOperations: u32, FailedCompletionOperations: u32, ReadOperations: u32, RandomReadOperations: u32, ReadSmbs: u32, LargeReadSmbs: u32, SmallReadSmbs: u32, WriteOperations: u32, RandomWriteOperations: u32, WriteSmbs: u32, LargeWriteSmbs: u32, SmallWriteSmbs: u32, RawReadsDenied: u32, RawWritesDenied: u32, NetworkErrors: u32, Sessions: u32, FailedSessions: u32, Reconnects: u32, CoreConnects: u32, Lanman20Connects: u32, Lanman21Connects: u32, LanmanNtConnects: u32, ServerDisconnects: u32, HungSessions: u32, UseCount: u32, FailedUseCount: u32, CurrentCommands: u32, }; pub const STAT_SERVER_0 = extern struct { sts0_start: u32, sts0_fopens: u32, sts0_devopens: u32, sts0_jobsqueued: u32, sts0_sopens: u32, sts0_stimedout: u32, sts0_serrorout: u32, sts0_pwerrors: u32, sts0_permerrors: u32, sts0_syserrors: u32, sts0_bytessent_low: u32, sts0_bytessent_high: u32, sts0_bytesrcvd_low: u32, sts0_bytesrcvd_high: u32, sts0_avresponse: u32, sts0_reqbufneed: u32, sts0_bigbufneed: u32, }; pub const PFN_IO_COMPLETION = fn( pContext: ?*FIO_CONTEXT, lpo: ?*FH_OVERLAPPED, cb: u32, dwCompletionStatus: u32, ) callconv(@import("std").os.windows.WINAPI) void; pub const FH_OVERLAPPED = extern struct { Internal: usize, InternalHigh: usize, Offset: u32, OffsetHigh: u32, hEvent: ?HANDLE, pfnCompletion: ?PFN_IO_COMPLETION, Reserved1: usize, Reserved2: usize, Reserved3: usize, Reserved4: usize, }; pub const FIO_CONTEXT = extern struct { m_dwTempHack: u32, m_dwSignature: u32, m_hFile: ?HANDLE, m_dwLinesOffset: u32, m_dwHeaderLength: u32, }; pub const FCACHE_CREATE_CALLBACK = fn( lpstrName: ?PSTR, lpvData: ?*anyopaque, cbFileSize: ?*u32, cbFileSizeHigh: ?*u32, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; pub const FCACHE_RICHCREATE_CALLBACK = fn( lpstrName: ?PSTR, lpvData: ?*anyopaque, cbFileSize: ?*u32, cbFileSizeHigh: ?*u32, pfDidWeScanIt: ?*BOOL, pfIsStuffed: ?*BOOL, pfStoredWithDots: ?*BOOL, pfStoredWithTerminatingDot: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; pub const CACHE_KEY_COMPARE = fn( cbKey1: u32, lpbKey1: ?*u8, cbKey2: u32, lpbKey2: ?*u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub const CACHE_KEY_HASH = fn( lpbKey: ?*u8, cbKey: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub const CACHE_READ_CALLBACK = fn( cb: u32, lpb: ?*u8, lpvContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub const CACHE_DESTROY_CALLBACK = fn( cb: u32, lpb: ?*u8, ) callconv(@import("std").os.windows.WINAPI) void; pub const CACHE_ACCESS_CHECK = fn( pSecurityDescriptor: ?*SECURITY_DESCRIPTOR, hClientToken: ?HANDLE, dwDesiredAccess: u32, GenericMapping: ?*GENERIC_MAPPING, PrivilegeSet: ?*PRIVILEGE_SET, PrivilegeSetLength: ?*u32, GrantedAccess: ?*u32, AccessStatus: ?*i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub const NAME_CACHE_CONTEXT = extern struct { m_dwSignature: u32, }; pub const IORING_VERSION = enum(i32) { INVALID = 0, @"1" = 1, }; pub const IORING_VERSION_INVALID = IORING_VERSION.INVALID; pub const IORING_VERSION_1 = IORING_VERSION.@"1"; pub const IORING_FEATURE_FLAGS = enum(i32) { FLAGS_NONE = 0, UM_EMULATION = 1, SET_COMPLETION_EVENT = 2, }; pub const IORING_FEATURE_FLAGS_NONE = IORING_FEATURE_FLAGS.FLAGS_NONE; pub const IORING_FEATURE_UM_EMULATION = IORING_FEATURE_FLAGS.UM_EMULATION; pub const IORING_FEATURE_SET_COMPLETION_EVENT = IORING_FEATURE_FLAGS.SET_COMPLETION_EVENT; pub const IORING_OP_CODE = enum(i32) { NOP = 0, READ = 1, REGISTER_FILES = 2, REGISTER_BUFFERS = 3, CANCEL = 4, }; pub const IORING_OP_NOP = IORING_OP_CODE.NOP; pub const IORING_OP_READ = IORING_OP_CODE.READ; pub const IORING_OP_REGISTER_FILES = IORING_OP_CODE.REGISTER_FILES; pub const IORING_OP_REGISTER_BUFFERS = IORING_OP_CODE.REGISTER_BUFFERS; pub const IORING_OP_CANCEL = IORING_OP_CODE.CANCEL; pub const IORING_BUFFER_INFO = extern struct { Address: ?*anyopaque, Length: u32, }; pub const IORING_REGISTERED_BUFFER = extern struct { BufferIndex: u32, Offset: u32, }; pub const HIORING__ = extern struct { unused: i32, }; pub const IORING_SQE_FLAGS = enum(i32) { E = 0, }; pub const IOSQE_FLAGS_NONE = IORING_SQE_FLAGS.E; pub const IORING_CREATE_REQUIRED_FLAGS = enum(i32) { E = 0, }; pub const IORING_CREATE_REQUIRED_FLAGS_NONE = IORING_CREATE_REQUIRED_FLAGS.E; pub const IORING_CREATE_ADVISORY_FLAGS = enum(i32) { E = 0, }; pub const IORING_CREATE_ADVISORY_FLAGS_NONE = IORING_CREATE_ADVISORY_FLAGS.E; pub const IORING_CREATE_FLAGS = extern struct { Required: IORING_CREATE_REQUIRED_FLAGS, Advisory: IORING_CREATE_ADVISORY_FLAGS, }; pub const IORING_INFO = extern struct { IoRingVersion: IORING_VERSION, Flags: IORING_CREATE_FLAGS, SubmissionQueueSize: u32, CompletionQueueSize: u32, }; pub const IORING_CAPABILITIES = extern struct { MaxVersion: IORING_VERSION, MaxSubmissionQueueSize: u32, MaxCompletionQueueSize: u32, FeatureFlags: IORING_FEATURE_FLAGS, }; pub const IORING_REF_KIND = enum(i32) { AW = 0, EGISTERED = 1, }; pub const IORING_REF_RAW = IORING_REF_KIND.AW; pub const IORING_REF_REGISTERED = IORING_REF_KIND.EGISTERED; pub const IORING_HANDLE_REF = extern struct { pub const HandleUnion = extern union { Handle: ?HANDLE, Index: u32, }; Kind: IORING_REF_KIND, Handle: HandleUnion, }; pub const IORING_BUFFER_REF = extern struct { pub const BufferUnion = extern union { Address: ?*anyopaque, IndexAndOffset: IORING_REGISTERED_BUFFER, }; Kind: IORING_REF_KIND, Buffer: BufferUnion, }; pub const IORING_CQE = extern struct { UserData: usize, ResultCode: HRESULT, Information: usize, }; pub const FILE_ID_128 = extern struct { Identifier: [16]u8, }; pub const FILE_NOTIFY_INFORMATION = extern struct { NextEntryOffset: u32, Action: FILE_ACTION, FileNameLength: u32, FileName: [1]u16, }; pub const FILE_NOTIFY_EXTENDED_INFORMATION = extern struct { NextEntryOffset: u32, Action: FILE_ACTION, CreationTime: LARGE_INTEGER, LastModificationTime: LARGE_INTEGER, LastChangeTime: LARGE_INTEGER, LastAccessTime: LARGE_INTEGER, AllocatedLength: LARGE_INTEGER, FileSize: LARGE_INTEGER, FileAttributes: u32, ReparsePointTag: u32, FileId: LARGE_INTEGER, ParentFileId: LARGE_INTEGER, FileNameLength: u32, FileName: [1]u16, }; pub const FILE_SEGMENT_ELEMENT = extern union { Buffer: ?*anyopaque, Alignment: u64, }; pub const REPARSE_GUID_DATA_BUFFER = extern struct { ReparseTag: u32, ReparseDataLength: u16, Reserved: u16, ReparseGuid: Guid, GenericReparseBuffer: extern struct { DataBuffer: [1]u8, }, }; pub const TAPE_ERASE = extern struct { Type: ERASE_TAPE_TYPE, Immediate: BOOLEAN, }; pub const TAPE_PREPARE = extern struct { Operation: PREPARE_TAPE_OPERATION, Immediate: BOOLEAN, }; pub const TAPE_WRITE_MARKS = extern struct { Type: TAPEMARK_TYPE, Count: u32, Immediate: BOOLEAN, }; pub const TAPE_GET_POSITION = extern struct { Type: TAPE_POSITION_TYPE, Partition: u32, Offset: LARGE_INTEGER, }; pub const TAPE_SET_POSITION = extern struct { Method: TAPE_POSITION_METHOD, Partition: u32, Offset: LARGE_INTEGER, Immediate: BOOLEAN, }; pub const TRANSACTION_OUTCOME = enum(i32) { Undetermined = 1, Committed = 2, Aborted = 3, }; pub const TransactionOutcomeUndetermined = TRANSACTION_OUTCOME.Undetermined; pub const TransactionOutcomeCommitted = TRANSACTION_OUTCOME.Committed; pub const TransactionOutcomeAborted = TRANSACTION_OUTCOME.Aborted; pub const STORAGE_BUS_TYPE = enum(i32) { Unknown = 0, Scsi = 1, Atapi = 2, Ata = 3, @"1394" = 4, Ssa = 5, Fibre = 6, Usb = 7, RAID = 8, iScsi = 9, Sas = 10, Sata = 11, Sd = 12, Mmc = 13, Virtual = 14, FileBackedVirtual = 15, Spaces = 16, Nvme = 17, SCM = 18, Ufs = 19, Max = 20, MaxReserved = 127, }; pub const BusTypeUnknown = STORAGE_BUS_TYPE.Unknown; pub const BusTypeScsi = STORAGE_BUS_TYPE.Scsi; pub const BusTypeAtapi = STORAGE_BUS_TYPE.Atapi; pub const BusTypeAta = STORAGE_BUS_TYPE.Ata; pub const BusType1394 = STORAGE_BUS_TYPE.@"1394"; pub const BusTypeSsa = STORAGE_BUS_TYPE.Ssa; pub const BusTypeFibre = STORAGE_BUS_TYPE.Fibre; pub const BusTypeUsb = STORAGE_BUS_TYPE.Usb; pub const BusTypeRAID = STORAGE_BUS_TYPE.RAID; pub const BusTypeiScsi = STORAGE_BUS_TYPE.iScsi; pub const BusTypeSas = STORAGE_BUS_TYPE.Sas; pub const BusTypeSata = STORAGE_BUS_TYPE.Sata; pub const BusTypeSd = STORAGE_BUS_TYPE.Sd; pub const BusTypeMmc = STORAGE_BUS_TYPE.Mmc; pub const BusTypeVirtual = STORAGE_BUS_TYPE.Virtual; pub const BusTypeFileBackedVirtual = STORAGE_BUS_TYPE.FileBackedVirtual; pub const BusTypeSpaces = STORAGE_BUS_TYPE.Spaces; pub const BusTypeNvme = STORAGE_BUS_TYPE.Nvme; pub const BusTypeSCM = STORAGE_BUS_TYPE.SCM; pub const BusTypeUfs = STORAGE_BUS_TYPE.Ufs; pub const BusTypeMax = STORAGE_BUS_TYPE.Max; pub const BusTypeMaxReserved = STORAGE_BUS_TYPE.MaxReserved; pub const OFSTRUCT = extern struct { cBytes: u8, fFixedDisk: u8, nErrCode: u16, Reserved1: u16, Reserved2: u16, szPathName: [128]CHAR, }; pub const PFE_EXPORT_FUNC = fn( // TODO: what to do with BytesParamIndex 2? pbData: ?*u8, pvCallbackContext: ?*anyopaque, ulLength: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub const PFE_IMPORT_FUNC = fn( // TODO: what to do with BytesParamIndex 2? pbData: ?*u8, pvCallbackContext: ?*anyopaque, ulLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub const WIN32_STREAM_ID = extern struct { dwStreamId: WIN_STREAM_ID, dwStreamAttributes: u32, Size: LARGE_INTEGER, dwStreamNameSize: u32, cStreamName: [1]u16, }; pub const LPPROGRESS_ROUTINE = fn( TotalFileSize: LARGE_INTEGER, TotalBytesTransferred: LARGE_INTEGER, StreamSize: LARGE_INTEGER, StreamBytesTransferred: LARGE_INTEGER, dwStreamNumber: u32, dwCallbackReason: LPPROGRESS_ROUTINE_CALLBACK_REASON, hSourceFile: ?HANDLE, hDestinationFile: ?HANDLE, lpData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; pub const COPYFILE2_MESSAGE_TYPE = enum(i32) { NONE = 0, CHUNK_STARTED = 1, CHUNK_FINISHED = 2, STREAM_STARTED = 3, STREAM_FINISHED = 4, POLL_CONTINUE = 5, ERROR = 6, MAX = 7, }; pub const COPYFILE2_CALLBACK_NONE = COPYFILE2_MESSAGE_TYPE.NONE; pub const COPYFILE2_CALLBACK_CHUNK_STARTED = COPYFILE2_MESSAGE_TYPE.CHUNK_STARTED; pub const COPYFILE2_CALLBACK_CHUNK_FINISHED = COPYFILE2_MESSAGE_TYPE.CHUNK_FINISHED; pub const COPYFILE2_CALLBACK_STREAM_STARTED = COPYFILE2_MESSAGE_TYPE.STREAM_STARTED; pub const COPYFILE2_CALLBACK_STREAM_FINISHED = COPYFILE2_MESSAGE_TYPE.STREAM_FINISHED; pub const COPYFILE2_CALLBACK_POLL_CONTINUE = COPYFILE2_MESSAGE_TYPE.POLL_CONTINUE; pub const COPYFILE2_CALLBACK_ERROR = COPYFILE2_MESSAGE_TYPE.ERROR; pub const COPYFILE2_CALLBACK_MAX = COPYFILE2_MESSAGE_TYPE.MAX; pub const COPYFILE2_MESSAGE_ACTION = enum(i32) { CONTINUE = 0, CANCEL = 1, STOP = 2, QUIET = 3, PAUSE = 4, }; pub const COPYFILE2_PROGRESS_CONTINUE = COPYFILE2_MESSAGE_ACTION.CONTINUE; pub const COPYFILE2_PROGRESS_CANCEL = COPYFILE2_MESSAGE_ACTION.CANCEL; pub const COPYFILE2_PROGRESS_STOP = COPYFILE2_MESSAGE_ACTION.STOP; pub const COPYFILE2_PROGRESS_QUIET = COPYFILE2_MESSAGE_ACTION.QUIET; pub const COPYFILE2_PROGRESS_PAUSE = COPYFILE2_MESSAGE_ACTION.PAUSE; pub const COPYFILE2_COPY_PHASE = enum(i32) { NONE = 0, PREPARE_SOURCE = 1, PREPARE_DEST = 2, READ_SOURCE = 3, WRITE_DESTINATION = 4, SERVER_COPY = 5, NAMEGRAFT_COPY = 6, MAX = 7, }; pub const COPYFILE2_PHASE_NONE = COPYFILE2_COPY_PHASE.NONE; pub const COPYFILE2_PHASE_PREPARE_SOURCE = COPYFILE2_COPY_PHASE.PREPARE_SOURCE; pub const COPYFILE2_PHASE_PREPARE_DEST = COPYFILE2_COPY_PHASE.PREPARE_DEST; pub const COPYFILE2_PHASE_READ_SOURCE = COPYFILE2_COPY_PHASE.READ_SOURCE; pub const COPYFILE2_PHASE_WRITE_DESTINATION = COPYFILE2_COPY_PHASE.WRITE_DESTINATION; pub const COPYFILE2_PHASE_SERVER_COPY = COPYFILE2_COPY_PHASE.SERVER_COPY; pub const COPYFILE2_PHASE_NAMEGRAFT_COPY = COPYFILE2_COPY_PHASE.NAMEGRAFT_COPY; pub const COPYFILE2_PHASE_MAX = COPYFILE2_COPY_PHASE.MAX; pub const COPYFILE2_MESSAGE = extern struct { Type: COPYFILE2_MESSAGE_TYPE, dwPadding: u32, Info: extern union { ChunkStarted: extern struct { dwStreamNumber: u32, dwReserved: u32, hSourceFile: ?HANDLE, hDestinationFile: ?HANDLE, uliChunkNumber: ULARGE_INTEGER, uliChunkSize: ULARGE_INTEGER, uliStreamSize: ULARGE_INTEGER, uliTotalFileSize: ULARGE_INTEGER, }, ChunkFinished: extern struct { dwStreamNumber: u32, dwFlags: u32, hSourceFile: ?HANDLE, hDestinationFile: ?HANDLE, uliChunkNumber: ULARGE_INTEGER, uliChunkSize: ULARGE_INTEGER, uliStreamSize: ULARGE_INTEGER, uliStreamBytesTransferred: ULARGE_INTEGER, uliTotalFileSize: ULARGE_INTEGER, uliTotalBytesTransferred: ULARGE_INTEGER, }, StreamStarted: extern struct { dwStreamNumber: u32, dwReserved: u32, hSourceFile: ?HANDLE, hDestinationFile: ?HANDLE, uliStreamSize: ULARGE_INTEGER, uliTotalFileSize: ULARGE_INTEGER, }, StreamFinished: extern struct { dwStreamNumber: u32, dwReserved: u32, hSourceFile: ?HANDLE, hDestinationFile: ?HANDLE, uliStreamSize: ULARGE_INTEGER, uliStreamBytesTransferred: ULARGE_INTEGER, uliTotalFileSize: ULARGE_INTEGER, uliTotalBytesTransferred: ULARGE_INTEGER, }, PollContinue: extern struct { dwReserved: u32, }, Error: extern struct { CopyPhase: COPYFILE2_COPY_PHASE, dwStreamNumber: u32, hrFailure: HRESULT, dwReserved: u32, uliChunkNumber: ULARGE_INTEGER, uliStreamSize: ULARGE_INTEGER, uliStreamBytesTransferred: ULARGE_INTEGER, uliTotalFileSize: ULARGE_INTEGER, uliTotalBytesTransferred: ULARGE_INTEGER, }, }, }; pub const PCOPYFILE2_PROGRESS_ROUTINE = fn( pMessage: ?*const COPYFILE2_MESSAGE, pvCallbackContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) COPYFILE2_MESSAGE_ACTION; pub const COPYFILE2_EXTENDED_PARAMETERS = extern struct { dwSize: u32, dwCopyFlags: u32, pfCancel: ?*BOOL, pProgressRoutine: ?PCOPYFILE2_PROGRESS_ROUTINE, pvCallbackContext: ?*anyopaque, }; pub const COPYFILE2_EXTENDED_PARAMETERS_V2 = extern struct { dwSize: u32, dwCopyFlags: u32, pfCancel: ?*BOOL, pProgressRoutine: ?PCOPYFILE2_PROGRESS_ROUTINE, pvCallbackContext: ?*anyopaque, dwCopyFlagsV2: u32, ioDesiredSize: u32, ioDesiredRate: u32, reserved: [8]?*anyopaque, }; pub const FILE_BASIC_INFO = extern struct { CreationTime: LARGE_INTEGER, LastAccessTime: LARGE_INTEGER, LastWriteTime: LARGE_INTEGER, ChangeTime: LARGE_INTEGER, FileAttributes: u32, }; pub const FILE_STANDARD_INFO = extern struct { AllocationSize: LARGE_INTEGER, EndOfFile: LARGE_INTEGER, NumberOfLinks: u32, DeletePending: BOOLEAN, Directory: BOOLEAN, }; pub const FILE_NAME_INFO = extern struct { FileNameLength: u32, FileName: [1]u16, }; pub const FILE_RENAME_INFO = extern struct { Anonymous: extern union { ReplaceIfExists: BOOLEAN, Flags: u32, }, RootDirectory: ?HANDLE, FileNameLength: u32, FileName: [1]u16, }; pub const FILE_ALLOCATION_INFO = extern struct { AllocationSize: LARGE_INTEGER, }; pub const FILE_END_OF_FILE_INFO = extern struct { EndOfFile: LARGE_INTEGER, }; pub const FILE_STREAM_INFO = extern struct { NextEntryOffset: u32, StreamNameLength: u32, StreamSize: LARGE_INTEGER, StreamAllocationSize: LARGE_INTEGER, StreamName: [1]u16, }; pub const FILE_COMPRESSION_INFO = extern struct { CompressedFileSize: LARGE_INTEGER, CompressionFormat: u16, CompressionUnitShift: u8, ChunkShift: u8, ClusterShift: u8, Reserved: [3]u8, }; pub const FILE_ATTRIBUTE_TAG_INFO = extern struct { FileAttributes: u32, ReparseTag: u32, }; pub const FILE_DISPOSITION_INFO = extern struct { DeleteFileA: BOOLEAN, }; pub const FILE_ID_BOTH_DIR_INFO = extern struct { NextEntryOffset: u32, FileIndex: u32, CreationTime: LARGE_INTEGER, LastAccessTime: LARGE_INTEGER, LastWriteTime: LARGE_INTEGER, ChangeTime: LARGE_INTEGER, EndOfFile: LARGE_INTEGER, AllocationSize: LARGE_INTEGER, FileAttributes: u32, FileNameLength: u32, EaSize: u32, ShortNameLength: i8, ShortName: [12]u16, FileId: LARGE_INTEGER, FileName: [1]u16, }; pub const FILE_FULL_DIR_INFO = extern struct { NextEntryOffset: u32, FileIndex: u32, CreationTime: LARGE_INTEGER, LastAccessTime: LARGE_INTEGER, LastWriteTime: LARGE_INTEGER, ChangeTime: LARGE_INTEGER, EndOfFile: LARGE_INTEGER, AllocationSize: LARGE_INTEGER, FileAttributes: u32, FileNameLength: u32, EaSize: u32, FileName: [1]u16, }; pub const PRIORITY_HINT = enum(i32) { IoPriorityHintVeryLow = 0, IoPriorityHintLow = 1, IoPriorityHintNormal = 2, MaximumIoPriorityHintType = 3, }; pub const IoPriorityHintVeryLow = PRIORITY_HINT.IoPriorityHintVeryLow; pub const IoPriorityHintLow = PRIORITY_HINT.IoPriorityHintLow; pub const IoPriorityHintNormal = PRIORITY_HINT.IoPriorityHintNormal; pub const MaximumIoPriorityHintType = PRIORITY_HINT.MaximumIoPriorityHintType; pub const FILE_IO_PRIORITY_HINT_INFO = extern struct { PriorityHint: PRIORITY_HINT, }; pub const FILE_ALIGNMENT_INFO = extern struct { AlignmentRequirement: u32, }; pub const FILE_STORAGE_INFO = extern struct { LogicalBytesPerSector: u32, PhysicalBytesPerSectorForAtomicity: u32, PhysicalBytesPerSectorForPerformance: u32, FileSystemEffectivePhysicalBytesPerSectorForAtomicity: u32, Flags: u32, ByteOffsetForSectorAlignment: u32, ByteOffsetForPartitionAlignment: u32, }; pub const FILE_ID_INFO = extern struct { VolumeSerialNumber: u64, FileId: FILE_ID_128, }; pub const FILE_ID_EXTD_DIR_INFO = extern struct { NextEntryOffset: u32, FileIndex: u32, CreationTime: LARGE_INTEGER, LastAccessTime: LARGE_INTEGER, LastWriteTime: LARGE_INTEGER, ChangeTime: LARGE_INTEGER, EndOfFile: LARGE_INTEGER, AllocationSize: LARGE_INTEGER, FileAttributes: u32, FileNameLength: u32, EaSize: u32, ReparsePointTag: u32, FileId: FILE_ID_128, FileName: [1]u16, }; pub const FILE_REMOTE_PROTOCOL_INFO = extern struct { StructureVersion: u16, StructureSize: u16, Protocol: u32, ProtocolMajorVersion: u16, ProtocolMinorVersion: u16, ProtocolRevision: u16, Reserved: u16, Flags: u32, GenericReserved: extern struct { Reserved: [8]u32, }, ProtocolSpecific: extern union { Smb2: extern struct { Server: extern struct { Capabilities: u32, }, Share: extern struct { Capabilities: u32, CachingFlags: u32, }, }, Reserved: [16]u32, }, }; pub const FILE_ID_TYPE = enum(i32) { FileIdType = 0, ObjectIdType = 1, ExtendedFileIdType = 2, MaximumFileIdType = 3, }; pub const FileIdType = FILE_ID_TYPE.FileIdType; pub const ObjectIdType = FILE_ID_TYPE.ObjectIdType; pub const ExtendedFileIdType = FILE_ID_TYPE.ExtendedFileIdType; pub const MaximumFileIdType = FILE_ID_TYPE.MaximumFileIdType; pub const FILE_ID_DESCRIPTOR = extern struct { dwSize: u32, Type: FILE_ID_TYPE, Anonymous: extern union { FileId: LARGE_INTEGER, ObjectId: Guid, ExtendedFileId: FILE_ID_128, }, }; //-------------------------------------------------------------------------------- // Section: Functions (411) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SearchPathW( lpPath: ?[*:0]const u16, lpFileName: ?[*:0]const u16, lpExtension: ?[*:0]const u16, nBufferLength: u32, lpBuffer: ?[*:0]u16, lpFilePart: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SearchPathA( lpPath: ?[*:0]const u8, lpFileName: ?[*:0]const u8, lpExtension: ?[*:0]const u8, nBufferLength: u32, lpBuffer: ?[*:0]u8, lpFilePart: ?*?PSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CompareFileTime( lpFileTime1: ?*const FILETIME, lpFileTime2: ?*const FILETIME, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateDirectoryA( lpPathName: ?[*:0]const u8, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateDirectoryW( lpPathName: ?[*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateFileA( lpFileName: ?[*:0]const u8, dwDesiredAccess: FILE_ACCESS_FLAGS, dwShareMode: FILE_SHARE_MODE, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, dwCreationDisposition: FILE_CREATION_DISPOSITION, dwFlagsAndAttributes: FILE_FLAGS_AND_ATTRIBUTES, hTemplateFile: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateFileW( lpFileName: ?[*:0]const u16, dwDesiredAccess: FILE_ACCESS_FLAGS, dwShareMode: FILE_SHARE_MODE, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, dwCreationDisposition: FILE_CREATION_DISPOSITION, dwFlagsAndAttributes: FILE_FLAGS_AND_ATTRIBUTES, hTemplateFile: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn DefineDosDeviceW( dwFlags: DEFINE_DOS_DEVICE_FLAGS, lpDeviceName: ?[*:0]const u16, lpTargetPath: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn DeleteFileA( lpFileName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn DeleteFileW( lpFileName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn DeleteVolumeMountPointW( lpszVolumeMountPoint: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FileTimeToLocalFileTime( lpFileTime: ?*const FILETIME, lpLocalFileTime: ?*FILETIME, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindClose( hFindFile: FindFileHandle, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindCloseChangeNotification( hChangeHandle: FindChangeNotificationHandle, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstChangeNotificationA( lpPathName: ?[*:0]const u8, bWatchSubtree: BOOL, dwNotifyFilter: FILE_NOTIFY_CHANGE, ) callconv(@import("std").os.windows.WINAPI) FindChangeNotificationHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstChangeNotificationW( lpPathName: ?[*:0]const u16, bWatchSubtree: BOOL, dwNotifyFilter: FILE_NOTIFY_CHANGE, ) callconv(@import("std").os.windows.WINAPI) FindChangeNotificationHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstFileA( lpFileName: ?[*:0]const u8, lpFindFileData: ?*WIN32_FIND_DATAA, ) callconv(@import("std").os.windows.WINAPI) FindFileHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstFileW( lpFileName: ?[*:0]const u16, lpFindFileData: ?*WIN32_FIND_DATAW, ) callconv(@import("std").os.windows.WINAPI) FindFileHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstFileExA( lpFileName: ?[*:0]const u8, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: ?*anyopaque, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: ?*anyopaque, dwAdditionalFlags: FIND_FIRST_EX_FLAGS, ) callconv(@import("std").os.windows.WINAPI) FindFileHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstFileExW( lpFileName: ?[*:0]const u16, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: ?*anyopaque, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: ?*anyopaque, dwAdditionalFlags: FIND_FIRST_EX_FLAGS, ) callconv(@import("std").os.windows.WINAPI) FindFileHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstVolumeW( lpszVolumeName: [*:0]u16, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) FindVolumeHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindNextChangeNotification( hChangeHandle: FindChangeNotificationHandle, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindNextFileA( hFindFile: FindFileHandle, lpFindFileData: ?*WIN32_FIND_DATAA, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindNextFileW( hFindFile: ?HANDLE, lpFindFileData: ?*WIN32_FIND_DATAW, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindNextVolumeW( hFindVolume: FindVolumeHandle, lpszVolumeName: [*:0]u16, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindVolumeClose( hFindVolume: FindVolumeHandle, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FlushFileBuffers( hFile: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetDiskFreeSpaceA( lpRootPathName: ?[*:0]const u8, lpSectorsPerCluster: ?*u32, lpBytesPerSector: ?*u32, lpNumberOfFreeClusters: ?*u32, lpTotalNumberOfClusters: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetDiskFreeSpaceW( lpRootPathName: ?[*:0]const u16, lpSectorsPerCluster: ?*u32, lpBytesPerSector: ?*u32, lpNumberOfFreeClusters: ?*u32, lpTotalNumberOfClusters: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetDiskFreeSpaceExA( lpDirectoryName: ?[*:0]const u8, lpFreeBytesAvailableToCaller: ?*ULARGE_INTEGER, lpTotalNumberOfBytes: ?*ULARGE_INTEGER, lpTotalNumberOfFreeBytes: ?*ULARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetDiskFreeSpaceExW( lpDirectoryName: ?[*:0]const u16, lpFreeBytesAvailableToCaller: ?*ULARGE_INTEGER, lpTotalNumberOfBytes: ?*ULARGE_INTEGER, lpTotalNumberOfFreeBytes: ?*ULARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "KERNEL32" fn GetDiskSpaceInformationA( rootPath: ?[*:0]const u8, diskSpaceInfo: ?*DISK_SPACE_INFORMATION, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "KERNEL32" fn GetDiskSpaceInformationW( rootPath: ?[*:0]const u16, diskSpaceInfo: ?*DISK_SPACE_INFORMATION, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetDriveTypeA( lpRootPathName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetDriveTypeW( lpRootPathName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileAttributesA( lpFileName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileAttributesW( lpFileName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileAttributesExA( lpFileName: ?[*:0]const u8, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileAttributesExW( lpFileName: ?[*:0]const u16, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileInformationByHandle( hFile: ?HANDLE, lpFileInformation: ?*BY_HANDLE_FILE_INFORMATION, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileSize( hFile: ?HANDLE, lpFileSizeHigh: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileSizeEx( hFile: ?HANDLE, lpFileSize: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileType( hFile: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetFinalPathNameByHandleA( hFile: ?HANDLE, lpszFilePath: [*:0]u8, cchFilePath: u32, dwFlags: FILE_NAME, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetFinalPathNameByHandleW( hFile: ?HANDLE, lpszFilePath: [*:0]u16, cchFilePath: u32, dwFlags: FILE_NAME, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFileTime( hFile: ?HANDLE, lpCreationTime: ?*FILETIME, lpLastAccessTime: ?*FILETIME, lpLastWriteTime: ?*FILETIME, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFullPathNameW( lpFileName: ?[*:0]const u16, nBufferLength: u32, lpBuffer: ?[*:0]u16, lpFilePart: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetFullPathNameA( lpFileName: ?[*:0]const u8, nBufferLength: u32, lpBuffer: ?[*:0]u8, lpFilePart: ?*?PSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetLogicalDrives( ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetLogicalDriveStringsW( nBufferLength: u32, lpBuffer: ?[*:0]u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetLongPathNameA( lpszShortPath: ?[*:0]const u8, lpszLongPath: ?[*:0]u8, cchBuffer: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetLongPathNameW( lpszShortPath: ?[*:0]const u16, lpszLongPath: ?[*:0]u16, cchBuffer: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn AreShortNamesEnabled( Handle: ?HANDLE, Enabled: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetShortPathNameW( lpszLongPath: ?[*:0]const u16, lpszShortPath: ?[*:0]u16, cchBuffer: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetTempFileNameW( lpPathName: ?[*:0]const u16, lpPrefixString: ?[*:0]const u16, uUnique: u32, lpTempFileName: *[260]u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetVolumeInformationByHandleW( hFile: ?HANDLE, lpVolumeNameBuffer: ?[*:0]u16, nVolumeNameSize: u32, lpVolumeSerialNumber: ?*u32, lpMaximumComponentLength: ?*u32, lpFileSystemFlags: ?*u32, lpFileSystemNameBuffer: ?[*:0]u16, nFileSystemNameSize: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetVolumeInformationW( lpRootPathName: ?[*:0]const u16, lpVolumeNameBuffer: ?[*:0]u16, nVolumeNameSize: u32, lpVolumeSerialNumber: ?*u32, lpMaximumComponentLength: ?*u32, lpFileSystemFlags: ?*u32, lpFileSystemNameBuffer: ?[*:0]u16, nFileSystemNameSize: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetVolumePathNameW( lpszFileName: ?[*:0]const u16, lpszVolumePathName: [*:0]u16, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LocalFileTimeToFileTime( lpLocalFileTime: ?*const FILETIME, lpFileTime: ?*FILETIME, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LockFile( hFile: ?HANDLE, dwFileOffsetLow: u32, dwFileOffsetHigh: u32, nNumberOfBytesToLockLow: u32, nNumberOfBytesToLockHigh: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LockFileEx( hFile: ?HANDLE, dwFlags: LOCK_FILE_FLAGS, dwReserved: u32, nNumberOfBytesToLockLow: u32, nNumberOfBytesToLockHigh: u32, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn QueryDosDeviceW( lpDeviceName: ?[*:0]const u16, lpTargetPath: ?[*:0]u16, ucchMax: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn ReadFile( hFile: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?*anyopaque, nNumberOfBytesToRead: u32, lpNumberOfBytesRead: ?*u32, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn ReadFileEx( hFile: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?*anyopaque, nNumberOfBytesToRead: u32, lpOverlapped: ?*OVERLAPPED, lpCompletionRoutine: ?LPOVERLAPPED_COMPLETION_ROUTINE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn ReadFileScatter( hFile: ?HANDLE, aSegmentArray: ?*FILE_SEGMENT_ELEMENT, nNumberOfBytesToRead: u32, lpReserved: ?*u32, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn RemoveDirectoryA( lpPathName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn RemoveDirectoryW( lpPathName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetEndOfFile( hFile: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFileAttributesA( lpFileName: ?[*:0]const u8, dwFileAttributes: FILE_FLAGS_AND_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFileAttributesW( lpFileName: ?[*:0]const u16, dwFileAttributes: FILE_FLAGS_AND_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn SetFileInformationByHandle( hFile: ?HANDLE, FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, // TODO: what to do with BytesParamIndex 3? lpFileInformation: ?*anyopaque, dwBufferSize: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFilePointer( hFile: ?HANDLE, lDistanceToMove: i32, lpDistanceToMoveHigh: ?*i32, dwMoveMethod: SET_FILE_POINTER_MOVE_METHOD, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFilePointerEx( hFile: ?HANDLE, liDistanceToMove: LARGE_INTEGER, lpNewFilePointer: ?*LARGE_INTEGER, dwMoveMethod: SET_FILE_POINTER_MOVE_METHOD, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFileTime( hFile: ?HANDLE, lpCreationTime: ?*const FILETIME, lpLastAccessTime: ?*const FILETIME, lpLastWriteTime: ?*const FILETIME, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFileValidData( hFile: ?HANDLE, ValidDataLength: i64, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn UnlockFile( hFile: ?HANDLE, dwFileOffsetLow: u32, dwFileOffsetHigh: u32, nNumberOfBytesToUnlockLow: u32, nNumberOfBytesToUnlockHigh: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn UnlockFileEx( hFile: ?HANDLE, dwReserved: u32, nNumberOfBytesToUnlockLow: u32, nNumberOfBytesToUnlockHigh: u32, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn WriteFile( hFile: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?*const anyopaque, nNumberOfBytesToWrite: u32, lpNumberOfBytesWritten: ?*u32, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn WriteFileEx( hFile: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?*const anyopaque, nNumberOfBytesToWrite: u32, lpOverlapped: ?*OVERLAPPED, lpCompletionRoutine: ?LPOVERLAPPED_COMPLETION_ROUTINE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn WriteFileGather( hFile: ?HANDLE, aSegmentArray: ?*FILE_SEGMENT_ELEMENT, nNumberOfBytesToWrite: u32, lpReserved: ?*u32, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetTempPathW( nBufferLength: u32, lpBuffer: ?[*:0]u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetVolumeNameForVolumeMountPointW( lpszVolumeMountPoint: ?[*:0]const u16, lpszVolumeName: [*:0]u16, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetVolumePathNamesForVolumeNameW( lpszVolumeName: ?[*:0]const u16, lpszVolumePathNames: ?[*]u16, cchBufferLength: u32, lpcchReturnLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows8.0' pub extern "KERNEL32" fn CreateFile2( lpFileName: ?[*:0]const u16, dwDesiredAccess: FILE_ACCESS_FLAGS, dwShareMode: FILE_SHARE_MODE, dwCreationDisposition: FILE_CREATION_DISPOSITION, pCreateExParams: ?*CREATEFILE2_EXTENDED_PARAMETERS, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn SetFileIoOverlappedRange( FileHandle: ?HANDLE, OverlappedRangeStart: ?*u8, Length: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetCompressedFileSizeA( lpFileName: ?[*:0]const u8, lpFileSizeHigh: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetCompressedFileSizeW( lpFileName: ?[*:0]const u16, lpFileSizeHigh: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn FindFirstStreamW( lpFileName: ?[*:0]const u16, InfoLevel: STREAM_INFO_LEVELS, lpFindStreamData: ?*anyopaque, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) FindStreamHandle; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn FindNextStreamW( hFindStream: FindStreamHandle, lpFindStreamData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn AreFileApisANSI( ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetTempPathA( nBufferLength: u32, lpBuffer: ?[*:0]u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn FindFirstFileNameW( lpFileName: ?[*:0]const u16, dwFlags: u32, StringLength: ?*u32, LinkName: [*:0]u16, ) callconv(@import("std").os.windows.WINAPI) FindFileNameHandle; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn FindNextFileNameW( hFindStream: FindFileNameHandle, StringLength: ?*u32, LinkName: [*:0]u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetVolumeInformationA( lpRootPathName: ?[*:0]const u8, lpVolumeNameBuffer: ?[*:0]u8, nVolumeNameSize: u32, lpVolumeSerialNumber: ?*u32, lpMaximumComponentLength: ?*u32, lpFileSystemFlags: ?*u32, lpFileSystemNameBuffer: ?[*:0]u8, nFileSystemNameSize: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetTempFileNameA( lpPathName: ?[*:0]const u8, lpPrefixString: ?[*:0]const u8, uUnique: u32, lpTempFileName: *[260]u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFileApisToOEM( ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFileApisToANSI( ) callconv(@import("std").os.windows.WINAPI) void; pub extern "KERNEL32" fn GetTempPath2W( BufferLength: u32, Buffer: ?[*:0]u16, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "KERNEL32" fn GetTempPath2A( BufferLength: u32, Buffer: ?[*:0]u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn CopyFileFromAppW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, bFailIfExists: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn CreateDirectoryFromAppW( lpPathName: ?[*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn CreateFileFromAppW( lpFileName: ?[*:0]const u16, dwDesiredAccess: u32, dwShareMode: u32, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, dwCreationDisposition: u32, dwFlagsAndAttributes: u32, hTemplateFile: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn CreateFile2FromAppW( lpFileName: ?[*:0]const u16, dwDesiredAccess: u32, dwShareMode: u32, dwCreationDisposition: u32, pCreateExParams: ?*CREATEFILE2_EXTENDED_PARAMETERS, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn DeleteFileFromAppW( lpFileName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn FindFirstFileExFromAppW( lpFileName: ?[*:0]const u16, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: ?*anyopaque, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: ?*anyopaque, dwAdditionalFlags: u32, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn GetFileAttributesExFromAppW( lpFileName: ?[*:0]const u16, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn MoveFileFromAppW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn RemoveDirectoryFromAppW( lpPathName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn ReplaceFileFromAppW( lpReplacedFileName: ?[*:0]const u16, lpReplacementFileName: ?[*:0]const u16, lpBackupFileName: ?[*:0]const u16, dwReplaceFlags: u32, lpExclude: ?*anyopaque, lpReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-file-fromapp-l1-1-0" fn SetFileAttributesFromAppW( lpFileName: ?[*:0]const u16, dwFileAttributes: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn VerFindFileA( uFlags: VER_FIND_FILE_FLAGS, szFileName: ?[*:0]const u8, szWinDir: ?[*:0]const u8, szAppDir: ?[*:0]const u8, szCurDir: [*:0]u8, puCurDirLen: ?*u32, szDestDir: [*:0]u8, puDestDirLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) VER_FIND_FILE_STATUS; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn VerFindFileW( uFlags: VER_FIND_FILE_FLAGS, szFileName: ?[*:0]const u16, szWinDir: ?[*:0]const u16, szAppDir: ?[*:0]const u16, szCurDir: [*:0]u16, puCurDirLen: ?*u32, szDestDir: [*:0]u16, puDestDirLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) VER_FIND_FILE_STATUS; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn VerInstallFileA( uFlags: VER_INSTALL_FILE_FLAGS, szSrcFileName: ?[*:0]const u8, szDestFileName: ?[*:0]const u8, szSrcDir: ?[*:0]const u8, szDestDir: ?[*:0]const u8, szCurDir: ?[*:0]const u8, szTmpFile: [*:0]u8, puTmpFileLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) VER_INSTALL_FILE_STATUS; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn VerInstallFileW( uFlags: VER_INSTALL_FILE_FLAGS, szSrcFileName: ?[*:0]const u16, szDestFileName: ?[*:0]const u16, szSrcDir: ?[*:0]const u16, szDestDir: ?[*:0]const u16, szCurDir: ?[*:0]const u16, szTmpFile: [*:0]u16, puTmpFileLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) VER_INSTALL_FILE_STATUS; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn GetFileVersionInfoSizeA( lptstrFilename: ?[*:0]const u8, lpdwHandle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn GetFileVersionInfoSizeW( lptstrFilename: ?[*:0]const u16, lpdwHandle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn GetFileVersionInfoA( lptstrFilename: ?[*:0]const u8, dwHandle: u32, dwLen: u32, // TODO: what to do with BytesParamIndex 2? lpData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn GetFileVersionInfoW( lptstrFilename: ?[*:0]const u16, dwHandle: u32, dwLen: u32, // TODO: what to do with BytesParamIndex 2? lpData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "VERSION" fn GetFileVersionInfoSizeExA( dwFlags: GET_FILE_VERSION_INFO_FLAGS, lpwstrFilename: ?[*:0]const u8, lpdwHandle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "VERSION" fn GetFileVersionInfoSizeExW( dwFlags: GET_FILE_VERSION_INFO_FLAGS, lpwstrFilename: ?[*:0]const u16, lpdwHandle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "VERSION" fn GetFileVersionInfoExA( dwFlags: GET_FILE_VERSION_INFO_FLAGS, lpwstrFilename: ?[*:0]const u8, dwHandle: u32, dwLen: u32, // TODO: what to do with BytesParamIndex 3? lpData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "VERSION" fn GetFileVersionInfoExW( dwFlags: GET_FILE_VERSION_INFO_FLAGS, lpwstrFilename: ?[*:0]const u16, dwHandle: u32, dwLen: u32, // TODO: what to do with BytesParamIndex 3? lpData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn VerLanguageNameA( wLang: u32, szLang: [*:0]u8, cchLang: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "KERNEL32" fn VerLanguageNameW( wLang: u32, szLang: [*:0]u16, cchLang: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn VerQueryValueA( pBlock: ?*const anyopaque, lpSubBlock: ?[*:0]const u8, lplpBuffer: ?*?*anyopaque, puLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "VERSION" fn VerQueryValueW( pBlock: ?*const anyopaque, lpSubBlock: ?[*:0]const u16, lplpBuffer: ?*?*anyopaque, puLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "clfsw32" fn LsnEqual( plsn1: ?*const CLS_LSN, plsn2: ?*const CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; pub extern "clfsw32" fn LsnLess( plsn1: ?*const CLS_LSN, plsn2: ?*const CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; pub extern "clfsw32" fn LsnGreater( plsn1: ?*const CLS_LSN, plsn2: ?*const CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; pub extern "clfsw32" fn LsnNull( plsn: ?*const CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn LsnContainer( plsn: ?*const CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn LsnCreate( cidContainer: u32, offBlock: u32, cRecord: u32, ) callconv(@import("std").os.windows.WINAPI) CLS_LSN; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn LsnBlockOffset( plsn: ?*const CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn LsnRecordSequence( plsn: ?*const CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "clfsw32" fn LsnInvalid( plsn: ?*const CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; pub extern "clfsw32" fn LsnIncrement( plsn: ?*CLS_LSN, ) callconv(@import("std").os.windows.WINAPI) CLS_LSN; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn CreateLogFile( pszLogFileName: ?[*:0]const u16, fDesiredAccess: FILE_ACCESS_FLAGS, dwShareMode: FILE_SHARE_MODE, psaLogFile: ?*SECURITY_ATTRIBUTES, fCreateDisposition: FILE_CREATION_DISPOSITION, fFlagsAndAttributes: FILE_FLAGS_AND_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn DeleteLogByHandle( hLog: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn DeleteLogFile( pszLogFileName: ?[*:0]const u16, pvReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn AddLogContainer( hLog: ?HANDLE, pcbContainer: ?*u64, pwszContainerPath: ?PWSTR, pReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn AddLogContainerSet( hLog: ?HANDLE, cContainer: u16, pcbContainer: ?*u64, rgwszContainerPath: [*]?PWSTR, pReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn RemoveLogContainer( hLog: ?HANDLE, pwszContainerPath: ?PWSTR, fForce: BOOL, pReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn RemoveLogContainerSet( hLog: ?HANDLE, cContainer: u16, rgwszContainerPath: [*]?PWSTR, fForce: BOOL, pReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn SetLogArchiveTail( hLog: ?HANDLE, plsnArchiveTail: ?*CLS_LSN, pReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn SetEndOfLog( hLog: ?HANDLE, plsnEnd: ?*CLS_LSN, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn TruncateLog( pvMarshal: ?*anyopaque, plsnEnd: ?*CLS_LSN, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn CreateLogContainerScanContext( hLog: ?HANDLE, cFromContainer: u32, cContainers: u32, eScanMode: u8, pcxScan: ?*CLS_SCAN_CONTEXT, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ScanLogContainers( pcxScan: ?*CLS_SCAN_CONTEXT, eScanMode: u8, pReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn AlignReservedLog( pvMarshal: ?*anyopaque, cReservedRecords: u32, rgcbReservation: ?*i64, pcbAlignReservation: ?*i64, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn AllocReservedLog( pvMarshal: ?*anyopaque, cReservedRecords: u32, pcbAdjustment: ?*i64, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn FreeReservedLog( pvMarshal: ?*anyopaque, cReservedRecords: u32, pcbAdjustment: ?*i64, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn GetLogFileInformation( hLog: ?HANDLE, pinfoBuffer: ?*CLS_INFORMATION, cbBuffer: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn SetLogArchiveMode( hLog: ?HANDLE, eMode: CLFS_LOG_ARCHIVE_MODE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ReadLogRestartArea( pvMarshal: ?*anyopaque, ppvRestartBuffer: ?*?*anyopaque, pcbRestartBuffer: ?*u32, plsn: ?*CLS_LSN, ppvContext: ?*?*anyopaque, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ReadPreviousLogRestartArea( pvReadContext: ?*anyopaque, ppvRestartBuffer: ?*?*anyopaque, pcbRestartBuffer: ?*u32, plsnRestart: ?*CLS_LSN, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn WriteLogRestartArea( pvMarshal: ?*anyopaque, pvRestartBuffer: ?*anyopaque, cbRestartBuffer: u32, plsnBase: ?*CLS_LSN, fFlags: CLFS_FLAG, pcbWritten: ?*u32, plsnNext: ?*CLS_LSN, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "clfsw32" fn GetLogReservationInfo( pvMarshal: ?*anyopaque, pcbRecordNumber: ?*u32, pcbUserReservation: ?*i64, pcbCommitReservation: ?*i64, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn AdvanceLogBase( pvMarshal: ?*anyopaque, plsnBase: ?*CLS_LSN, fFlags: u32, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn CloseAndResetLogFile( hLog: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn CreateLogMarshallingArea( hLog: ?HANDLE, pfnAllocBuffer: ?CLFS_BLOCK_ALLOCATION, pfnFreeBuffer: ?CLFS_BLOCK_DEALLOCATION, pvBlockAllocContext: ?*anyopaque, cbMarshallingBuffer: u32, cMaxWriteBuffers: u32, cMaxReadBuffers: u32, ppvMarshal: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn DeleteLogMarshallingArea( pvMarshal: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ReserveAndAppendLog( pvMarshal: ?*anyopaque, rgWriteEntries: ?*CLS_WRITE_ENTRY, cWriteEntries: u32, plsnUndoNext: ?*CLS_LSN, plsnPrevious: ?*CLS_LSN, cReserveRecords: u32, rgcbReservation: ?*i64, fFlags: CLFS_FLAG, plsn: ?*CLS_LSN, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ReserveAndAppendLogAligned( pvMarshal: ?*anyopaque, rgWriteEntries: ?*CLS_WRITE_ENTRY, cWriteEntries: u32, cbEntryAlignment: u32, plsnUndoNext: ?*CLS_LSN, plsnPrevious: ?*CLS_LSN, cReserveRecords: u32, rgcbReservation: ?*i64, fFlags: CLFS_FLAG, plsn: ?*CLS_LSN, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn FlushLogBuffers( pvMarshal: ?*anyopaque, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn FlushLogToLsn( pvMarshalContext: ?*anyopaque, plsnFlush: ?*CLS_LSN, plsnLastFlushed: ?*CLS_LSN, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ReadLogRecord( pvMarshal: ?*anyopaque, plsnFirst: ?*CLS_LSN, eContextMode: CLFS_CONTEXT_MODE, ppvReadBuffer: ?*?*anyopaque, pcbReadBuffer: ?*u32, peRecordType: ?*u8, plsnUndoNext: ?*CLS_LSN, plsnPrevious: ?*CLS_LSN, ppvReadContext: ?*?*anyopaque, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ReadNextLogRecord( pvReadContext: ?*anyopaque, ppvBuffer: ?*?*anyopaque, pcbBuffer: ?*u32, peRecordType: ?*u8, plsnUser: ?*CLS_LSN, plsnUndoNext: ?*CLS_LSN, plsnPrevious: ?*CLS_LSN, plsnRecord: ?*CLS_LSN, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn TerminateReadLog( pvCursorContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn PrepareLogArchive( hLog: ?HANDLE, pszBaseLogFileName: [*:0]u16, cLen: u32, plsnLow: ?*const CLS_LSN, plsnHigh: ?*const CLS_LSN, pcActualLength: ?*u32, poffBaseLogFileData: ?*u64, pcbBaseLogFileLength: ?*u64, plsnBase: ?*CLS_LSN, plsnLast: ?*CLS_LSN, plsnCurrentArchiveTail: ?*CLS_LSN, ppvArchiveContext: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ReadLogArchiveMetadata( pvArchiveContext: ?*anyopaque, cbOffset: u32, cbBytesToRead: u32, pbReadBuffer: ?*u8, pcbBytesRead: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn GetNextLogArchiveExtent( pvArchiveContext: ?*anyopaque, rgadExtent: ?*CLS_ARCHIVE_DESCRIPTOR, cDescriptors: u32, pcDescriptorsReturned: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn TerminateLogArchive( pvArchiveContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ValidateLog( pszLogFileName: ?[*:0]const u16, psaLogFile: ?*SECURITY_ATTRIBUTES, pinfoBuffer: ?*CLS_INFORMATION, pcbBuffer: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn GetLogContainerName( hLog: ?HANDLE, cidLogicalContainer: u32, pwstrContainerName: ?[*:0]const u16, cLenContainerName: u32, pcActualLenContainerName: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn GetLogIoStatistics( hLog: ?HANDLE, pvStatsBuffer: ?*anyopaque, cbStatsBuffer: u32, eStatsClass: CLFS_IOSTATS_CLASS, pcbStatsWritten: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn RegisterManageableLogClient( hLog: ?HANDLE, pCallbacks: ?*LOG_MANAGEMENT_CALLBACKS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn DeregisterManageableLogClient( hLog: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn ReadLogNotification( hLog: ?HANDLE, pNotification: ?*CLFS_MGMT_NOTIFICATION, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn InstallLogPolicy( hLog: ?HANDLE, pPolicy: ?*CLFS_MGMT_POLICY, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn RemoveLogPolicy( hLog: ?HANDLE, ePolicyType: CLFS_MGMT_POLICY_TYPE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn QueryLogPolicy( hLog: ?HANDLE, ePolicyType: CLFS_MGMT_POLICY_TYPE, pPolicyBuffer: ?*CLFS_MGMT_POLICY, pcbPolicyBuffer: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn SetLogFileSizeWithPolicy( hLog: ?HANDLE, pDesiredSize: ?*u64, pResultingSize: ?*u64, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn HandleLogFull( hLog: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn LogTailAdvanceFailure( hLog: ?HANDLE, dwReason: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "clfsw32" fn RegisterForLogWriteNotification( hLog: ?HANDLE, cbThreshold: u32, fEnable: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn QueryUsersOnEncryptedFile( lpFileName: ?[*:0]const u16, pUsers: ?*?*ENCRYPTION_CERTIFICATE_HASH_LIST, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn QueryRecoveryAgentsOnEncryptedFile( lpFileName: ?[*:0]const u16, pRecoveryAgents: ?*?*ENCRYPTION_CERTIFICATE_HASH_LIST, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn RemoveUsersFromEncryptedFile( lpFileName: ?[*:0]const u16, pHashes: ?*ENCRYPTION_CERTIFICATE_HASH_LIST, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn AddUsersToEncryptedFile( lpFileName: ?[*:0]const u16, pEncryptionCertificates: ?*ENCRYPTION_CERTIFICATE_LIST, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn SetUserFileEncryptionKey( pEncryptionCertificate: ?*ENCRYPTION_CERTIFICATE, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "ADVAPI32" fn SetUserFileEncryptionKeyEx( pEncryptionCertificate: ?*ENCRYPTION_CERTIFICATE, dwCapabilities: u32, dwFlags: u32, pvReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn FreeEncryptionCertificateHashList( pUsers: ?*ENCRYPTION_CERTIFICATE_HASH_LIST, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn EncryptionDisable( DirPath: ?[*:0]const u16, Disable: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn DuplicateEncryptionInfoFile( SrcFileName: ?[*:0]const u16, DstFileName: ?[*:0]const u16, dwCreationDistribution: u32, dwAttributes: u32, lpSecurityAttributes: ?*const SECURITY_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "ADVAPI32" fn GetEncryptedFileMetadata( lpFileName: ?[*:0]const u16, pcbMetadata: ?*u32, ppbMetadata: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "ADVAPI32" fn SetEncryptedFileMetadata( lpFileName: ?[*:0]const u16, pbOldMetadata: ?*u8, pbNewMetadata: ?*u8, pOwnerHash: ?*ENCRYPTION_CERTIFICATE_HASH, dwOperation: u32, pCertificatesAdded: ?*ENCRYPTION_CERTIFICATE_HASH_LIST, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "ADVAPI32" fn FreeEncryptedFileMetadata( pbMetadata: ?*u8, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "KERNEL32" fn LZStart( ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "KERNEL32" fn LZDone( ) callconv(@import("std").os.windows.WINAPI) void; pub extern "KERNEL32" fn CopyLZFile( hfSource: i32, hfDest: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LZCopy( hfSource: i32, hfDest: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LZInit( hfSource: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetExpandedNameA( lpszSource: ?PSTR, lpszBuffer: *[260]u8, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetExpandedNameW( lpszSource: ?PWSTR, lpszBuffer: *[260]u16, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LZOpenFileA( lpFileName: ?PSTR, lpReOpenBuf: ?*OFSTRUCT, wStyle: LZOPENFILE_STYLE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LZOpenFileW( lpFileName: ?PWSTR, lpReOpenBuf: ?*OFSTRUCT, wStyle: LZOPENFILE_STYLE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LZSeek( hFile: i32, lOffset: i32, iOrigin: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LZRead( hFile: i32, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?PSTR, cbRead: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn LZClose( hFile: i32, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "WOFUTIL" fn WofShouldCompressBinaries( Volume: ?[*:0]const u16, Algorithm: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "WOFUTIL" fn WofGetDriverVersion( FileOrVolumeHandle: ?HANDLE, Provider: u32, WofVersion: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofSetFileDataLocation( FileHandle: ?HANDLE, Provider: u32, ExternalFileInfo: ?*anyopaque, Length: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofIsExternalFile( FilePath: ?[*:0]const u16, IsExternalFile: ?*BOOL, Provider: ?*u32, ExternalFileInfo: ?*anyopaque, BufferLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofEnumEntries( VolumeName: ?[*:0]const u16, Provider: u32, EnumProc: ?WofEnumEntryProc, UserData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofWimAddEntry( VolumeName: ?[*:0]const u16, WimPath: ?[*:0]const u16, WimType: u32, WimIndex: u32, DataSourceId: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofWimEnumFiles( VolumeName: ?[*:0]const u16, DataSourceId: LARGE_INTEGER, EnumProc: ?WofEnumFilesProc, UserData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofWimSuspendEntry( VolumeName: ?[*:0]const u16, DataSourceId: LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofWimRemoveEntry( VolumeName: ?[*:0]const u16, DataSourceId: LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofWimUpdateEntry( VolumeName: ?[*:0]const u16, DataSourceId: LARGE_INTEGER, NewWimPath: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "WOFUTIL" fn WofFileEnumFiles( VolumeName: ?[*:0]const u16, Algorithm: u32, EnumProc: ?WofEnumFilesProc, UserData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "txfw32" fn TxfLogCreateFileReadContext( LogPath: ?[*:0]const u16, BeginningLsn: CLS_LSN, EndingLsn: CLS_LSN, TxfFileId: ?*TXF_ID, TxfLogContext: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "txfw32" fn TxfLogCreateRangeReadContext( LogPath: ?[*:0]const u16, BeginningLsn: CLS_LSN, EndingLsn: CLS_LSN, BeginningVirtualClock: ?*LARGE_INTEGER, EndingVirtualClock: ?*LARGE_INTEGER, RecordTypeMask: u32, TxfLogContext: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "txfw32" fn TxfLogDestroyReadContext( TxfLogContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "txfw32" fn TxfLogReadRecords( TxfLogContext: ?*anyopaque, BufferLength: u32, // TODO: what to do with BytesParamIndex 1? Buffer: ?*anyopaque, BytesUsed: ?*u32, RecordCount: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "txfw32" fn TxfReadMetadataInfo( FileHandle: ?HANDLE, TxfFileId: ?*TXF_ID, LastLsn: ?*CLS_LSN, TransactionState: ?*u32, LockingTransaction: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "txfw32" fn TxfLogRecordGetFileName( // TODO: what to do with BytesParamIndex 1? RecordBuffer: ?*anyopaque, RecordBufferLengthInBytes: u32, // TODO: what to do with BytesParamIndex 3? NameBuffer: ?PWSTR, NameBufferLengthInBytes: ?*u32, TxfId: ?*TXF_ID, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "txfw32" fn TxfLogRecordGetGenericType( RecordBuffer: ?*anyopaque, RecordBufferLengthInBytes: u32, GenericType: ?*u32, VirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "txfw32" fn TxfSetThreadMiniVersionForCreate( MiniVersion: u16, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "txfw32" fn TxfGetThreadMiniVersionForCreate( MiniVersion: ?*u16, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn CreateTransaction( lpTransactionAttributes: ?*SECURITY_ATTRIBUTES, UOW: ?*Guid, CreateOptions: u32, IsolationLevel: u32, IsolationFlags: u32, Timeout: u32, Description: ?PWSTR, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn OpenTransaction( dwDesiredAccess: u32, TransactionId: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn CommitTransaction( TransactionHandle: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn CommitTransactionAsync( TransactionHandle: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RollbackTransaction( TransactionHandle: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RollbackTransactionAsync( TransactionHandle: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn GetTransactionId( TransactionHandle: ?HANDLE, TransactionId: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn GetTransactionInformation( TransactionHandle: ?HANDLE, Outcome: ?*u32, IsolationLevel: ?*u32, IsolationFlags: ?*u32, Timeout: ?*u32, BufferLength: u32, Description: ?[*:0]u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn SetTransactionInformation( TransactionHandle: ?HANDLE, IsolationLevel: u32, IsolationFlags: u32, Timeout: u32, Description: ?PWSTR, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn CreateTransactionManager( lpTransactionAttributes: ?*SECURITY_ATTRIBUTES, LogFileName: ?PWSTR, CreateOptions: u32, CommitStrength: u32, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn OpenTransactionManager( LogFileName: ?PWSTR, DesiredAccess: u32, OpenOptions: u32, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn OpenTransactionManagerById( TransactionManagerId: ?*Guid, DesiredAccess: u32, OpenOptions: u32, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RenameTransactionManager( LogFileName: ?PWSTR, ExistingTransactionManagerGuid: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RollforwardTransactionManager( TransactionManagerHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RecoverTransactionManager( TransactionManagerHandle: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn GetCurrentClockTransactionManager( TransactionManagerHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn GetTransactionManagerId( TransactionManagerHandle: ?HANDLE, TransactionManagerId: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn CreateResourceManager( lpResourceManagerAttributes: ?*SECURITY_ATTRIBUTES, ResourceManagerId: ?*Guid, CreateOptions: u32, TmHandle: ?HANDLE, Description: ?PWSTR, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn OpenResourceManager( dwDesiredAccess: u32, TmHandle: ?HANDLE, ResourceManagerId: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RecoverResourceManager( ResourceManagerHandle: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn GetNotificationResourceManager( ResourceManagerHandle: ?HANDLE, TransactionNotification: ?*TRANSACTION_NOTIFICATION, NotificationLength: u32, dwMilliseconds: u32, ReturnLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn GetNotificationResourceManagerAsync( ResourceManagerHandle: ?HANDLE, TransactionNotification: ?*TRANSACTION_NOTIFICATION, TransactionNotificationLength: u32, ReturnLength: ?*u32, lpOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn SetResourceManagerCompletionPort( ResourceManagerHandle: ?HANDLE, IoCompletionPortHandle: ?HANDLE, CompletionKey: usize, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn CreateEnlistment( lpEnlistmentAttributes: ?*SECURITY_ATTRIBUTES, ResourceManagerHandle: ?HANDLE, TransactionHandle: ?HANDLE, NotificationMask: u32, CreateOptions: u32, EnlistmentKey: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn OpenEnlistment( dwDesiredAccess: u32, ResourceManagerHandle: ?HANDLE, EnlistmentId: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RecoverEnlistment( EnlistmentHandle: ?HANDLE, EnlistmentKey: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn GetEnlistmentRecoveryInformation( EnlistmentHandle: ?HANDLE, BufferSize: u32, Buffer: ?*anyopaque, BufferUsed: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn GetEnlistmentId( EnlistmentHandle: ?HANDLE, EnlistmentId: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn SetEnlistmentRecoveryInformation( EnlistmentHandle: ?HANDLE, BufferSize: u32, Buffer: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn PrepareEnlistment( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn PrePrepareEnlistment( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn CommitEnlistment( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RollbackEnlistment( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn PrePrepareComplete( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn PrepareComplete( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn ReadOnlyEnlistment( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn CommitComplete( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn RollbackComplete( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "ktmw32" fn SinglePhaseReject( EnlistmentHandle: ?HANDLE, TmVirtualClock: ?*LARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetShareAdd( servername: ?PWSTR, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetShareEnum( servername: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetShareEnumSticky( servername: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetShareGetInfo( servername: ?PWSTR, netname: ?PWSTR, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetShareSetInfo( servername: ?PWSTR, netname: ?PWSTR, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetShareDel( servername: ?PWSTR, netname: ?PWSTR, reserved: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetShareDelSticky( servername: ?PWSTR, netname: ?PWSTR, reserved: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetShareCheck( servername: ?PWSTR, device: ?PWSTR, type: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetShareDelEx( servername: ?PWSTR, level: u32, buf: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetServerAliasAdd( servername: ?PWSTR, level: u32, buf: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetServerAliasDel( servername: ?PWSTR, level: u32, buf: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetServerAliasEnum( servername: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resumehandle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetSessionEnum( servername: ?PWSTR, UncClientName: ?PWSTR, username: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetSessionDel( servername: ?PWSTR, UncClientName: ?PWSTR, username: ?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetSessionGetInfo( servername: ?PWSTR, UncClientName: ?PWSTR, username: ?PWSTR, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetConnectionEnum( servername: ?PWSTR, qualifier: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetFileClose( servername: ?PWSTR, fileid: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetFileEnum( servername: ?PWSTR, basepath: ?PWSTR, username: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*usize, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetFileGetInfo( servername: ?PWSTR, fileid: u32, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetStatisticsGet( ServerName: ?*i8, Service: ?*i8, Level: u32, Options: u32, Buffer: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "api-ms-win-core-ioring-l1-1-0" fn QueryIoRingCapabilities( capabilities: ?*IORING_CAPABILITIES, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn IsIoRingOpSupported( ioRing: ?*HIORING__, op: IORING_OP_CODE, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "api-ms-win-core-ioring-l1-1-0" fn CreateIoRing( ioringVersion: IORING_VERSION, flags: IORING_CREATE_FLAGS, submissionQueueSize: u32, completionQueueSize: u32, h: ?*?*HIORING__, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn GetIoRingInfo( ioRing: ?*HIORING__, info: ?*IORING_INFO, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn SubmitIoRing( ioRing: ?*HIORING__, waitOperations: u32, milliseconds: u32, submittedEntries: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn CloseIoRing( ioRing: ?*HIORING__, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn PopIoRingCompletion( ioRing: ?*HIORING__, cqe: ?*IORING_CQE, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn SetIoRingCompletionEvent( ioRing: ?*HIORING__, hEvent: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn BuildIoRingCancelRequest( ioRing: ?*HIORING__, file: IORING_HANDLE_REF, opToCancel: usize, userData: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn BuildIoRingReadFile( ioRing: ?*HIORING__, fileRef: IORING_HANDLE_REF, dataRef: IORING_BUFFER_REF, numberOfBytesToRead: u32, fileOffset: u64, userData: usize, flags: IORING_SQE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn BuildIoRingRegisterFileHandles( ioRing: ?*HIORING__, count: u32, handles: [*]const ?HANDLE, userData: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "api-ms-win-core-ioring-l1-1-0" fn BuildIoRingRegisterBuffers( ioRing: ?*HIORING__, count: u32, buffers: [*]const IORING_BUFFER_INFO, userData: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn Wow64EnableWow64FsRedirection( Wow64FsEnableRedirection: BOOLEAN, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn Wow64DisableWow64FsRedirection( OldValue: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn Wow64RevertWow64FsRedirection( OlValue: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetBinaryTypeA( lpApplicationName: ?[*:0]const u8, lpBinaryType: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetBinaryTypeW( lpApplicationName: ?[*:0]const u16, lpBinaryType: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetShortPathNameA( lpszLongPath: ?[*:0]const u8, lpszShortPath: ?[*:0]u8, cchBuffer: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetLongPathNameTransactedA( lpszShortPath: ?[*:0]const u8, lpszLongPath: ?[*:0]u8, cchBuffer: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetLongPathNameTransactedW( lpszShortPath: ?[*:0]const u16, lpszLongPath: ?[*:0]u16, cchBuffer: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn SetFileCompletionNotificationModes( FileHandle: ?HANDLE, Flags: u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFileShortNameA( hFile: ?HANDLE, lpShortName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetFileShortNameW( hFile: ?HANDLE, lpShortName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetTapePosition( hDevice: ?HANDLE, dwPositionMethod: TAPE_POSITION_METHOD, dwPartition: u32, dwOffsetLow: u32, dwOffsetHigh: u32, bImmediate: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetTapePosition( hDevice: ?HANDLE, dwPositionType: TAPE_POSITION_TYPE, lpdwPartition: ?*u32, lpdwOffsetLow: ?*u32, lpdwOffsetHigh: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn PrepareTape( hDevice: ?HANDLE, dwOperation: PREPARE_TAPE_OPERATION, bImmediate: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn EraseTape( hDevice: ?HANDLE, dwEraseType: ERASE_TAPE_TYPE, bImmediate: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateTapePartition( hDevice: ?HANDLE, dwPartitionMethod: CREATE_TAPE_PARTITION_METHOD, dwCount: u32, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn WriteTapemark( hDevice: ?HANDLE, dwTapemarkType: TAPEMARK_TYPE, dwTapemarkCount: u32, bImmediate: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetTapeStatus( hDevice: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetTapeParameters( hDevice: ?HANDLE, dwOperation: GET_TAPE_DRIVE_PARAMETERS_OPERATION, lpdwSize: ?*u32, // TODO: what to do with BytesParamIndex 2? lpTapeInformation: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetTapeParameters( hDevice: ?HANDLE, dwOperation: TAPE_INFORMATION_TYPE, lpTapeInformation: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn EncryptFileA( lpFileName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn EncryptFileW( lpFileName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn DecryptFileA( lpFileName: ?[*:0]const u8, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn DecryptFileW( lpFileName: ?[*:0]const u16, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn FileEncryptionStatusA( lpFileName: ?[*:0]const u8, lpStatus: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn FileEncryptionStatusW( lpFileName: ?[*:0]const u16, lpStatus: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn OpenEncryptedFileRawA( lpFileName: ?[*:0]const u8, ulFlags: u32, pvContext: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn OpenEncryptedFileRawW( lpFileName: ?[*:0]const u16, ulFlags: u32, pvContext: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn ReadEncryptedFileRaw( pfExportCallback: ?PFE_EXPORT_FUNC, pvCallbackContext: ?*anyopaque, pvContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn WriteEncryptedFileRaw( pfImportCallback: ?PFE_IMPORT_FUNC, pvCallbackContext: ?*anyopaque, pvContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "ADVAPI32" fn CloseEncryptedFileRaw( pvContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn OpenFile( lpFileName: ?[*:0]const u8, lpReOpenBuff: ?*OFSTRUCT, uStyle: LZOPENFILE_STYLE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn BackupRead( hFile: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?*u8, nNumberOfBytesToRead: u32, lpNumberOfBytesRead: ?*u32, bAbort: BOOL, bProcessSecurity: BOOL, lpContext: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn BackupSeek( hFile: ?HANDLE, dwLowBytesToSeek: u32, dwHighBytesToSeek: u32, lpdwLowByteSeeked: ?*u32, lpdwHighByteSeeked: ?*u32, lpContext: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn BackupWrite( hFile: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?*u8, nNumberOfBytesToWrite: u32, lpNumberOfBytesWritten: ?*u32, bAbort: BOOL, bProcessSecurity: BOOL, lpContext: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetLogicalDriveStringsA( nBufferLength: u32, lpBuffer: ?[*:0]u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.1' pub extern "KERNEL32" fn SetSearchPathMode( Flags: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateDirectoryExA( lpTemplateDirectory: ?[*:0]const u8, lpNewDirectory: ?[*:0]const u8, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateDirectoryExW( lpTemplateDirectory: ?[*:0]const u16, lpNewDirectory: ?[*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateDirectoryTransactedA( lpTemplateDirectory: ?[*:0]const u8, lpNewDirectory: ?[*:0]const u8, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateDirectoryTransactedW( lpTemplateDirectory: ?[*:0]const u16, lpNewDirectory: ?[*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn RemoveDirectoryTransactedA( lpPathName: ?[*:0]const u8, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn RemoveDirectoryTransactedW( lpPathName: ?[*:0]const u16, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetFullPathNameTransactedA( lpFileName: ?[*:0]const u8, nBufferLength: u32, lpBuffer: ?[*:0]u8, lpFilePart: ?*?PSTR, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetFullPathNameTransactedW( lpFileName: ?[*:0]const u16, nBufferLength: u32, lpBuffer: ?[*:0]u16, lpFilePart: ?*?PWSTR, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn DefineDosDeviceA( dwFlags: DEFINE_DOS_DEVICE_FLAGS, lpDeviceName: ?[*:0]const u8, lpTargetPath: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn QueryDosDeviceA( lpDeviceName: ?[*:0]const u8, lpTargetPath: ?[*:0]u8, ucchMax: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateFileTransactedA( lpFileName: ?[*:0]const u8, dwDesiredAccess: u32, dwShareMode: FILE_SHARE_MODE, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, dwCreationDisposition: FILE_CREATION_DISPOSITION, dwFlagsAndAttributes: FILE_FLAGS_AND_ATTRIBUTES, hTemplateFile: ?HANDLE, hTransaction: ?HANDLE, pusMiniVersion: ?*TXFS_MINIVERSION, lpExtendedParameter: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateFileTransactedW( lpFileName: ?[*:0]const u16, dwDesiredAccess: u32, dwShareMode: FILE_SHARE_MODE, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, dwCreationDisposition: FILE_CREATION_DISPOSITION, dwFlagsAndAttributes: FILE_FLAGS_AND_ATTRIBUTES, hTemplateFile: ?HANDLE, hTransaction: ?HANDLE, pusMiniVersion: ?*TXFS_MINIVERSION, lpExtendedParameter: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn ReOpenFile( hOriginalFile: ?HANDLE, dwDesiredAccess: FILE_ACCESS_FLAGS, dwShareMode: FILE_SHARE_MODE, dwFlagsAndAttributes: FILE_FLAGS_AND_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn SetFileAttributesTransactedA( lpFileName: ?[*:0]const u8, dwFileAttributes: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn SetFileAttributesTransactedW( lpFileName: ?[*:0]const u16, dwFileAttributes: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetFileAttributesTransactedA( lpFileName: ?[*:0]const u8, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: ?*anyopaque, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetFileAttributesTransactedW( lpFileName: ?[*:0]const u16, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: ?*anyopaque, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetCompressedFileSizeTransactedA( lpFileName: ?[*:0]const u8, lpFileSizeHigh: ?*u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetCompressedFileSizeTransactedW( lpFileName: ?[*:0]const u16, lpFileSizeHigh: ?*u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn DeleteFileTransactedA( lpFileName: ?[*:0]const u8, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn DeleteFileTransactedW( lpFileName: ?[*:0]const u16, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CheckNameLegalDOS8Dot3A( lpName: ?[*:0]const u8, lpOemName: ?[*:0]u8, OemNameSize: u32, pbNameContainsSpaces: ?*BOOL, pbNameLegal: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CheckNameLegalDOS8Dot3W( lpName: ?[*:0]const u16, lpOemName: ?[*:0]u8, OemNameSize: u32, pbNameContainsSpaces: ?*BOOL, pbNameLegal: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn FindFirstFileTransactedA( lpFileName: ?[*:0]const u8, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: ?*anyopaque, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: ?*anyopaque, dwAdditionalFlags: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) FindFileHandle; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn FindFirstFileTransactedW( lpFileName: ?[*:0]const u16, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: ?*anyopaque, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: ?*anyopaque, dwAdditionalFlags: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) FindFileHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CopyFileA( lpExistingFileName: ?[*:0]const u8, lpNewFileName: ?[*:0]const u8, bFailIfExists: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CopyFileW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, bFailIfExists: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CopyFileExA( lpExistingFileName: ?[*:0]const u8, lpNewFileName: ?[*:0]const u8, lpProgressRoutine: ?LPPROGRESS_ROUTINE, lpData: ?*anyopaque, pbCancel: ?*i32, dwCopyFlags: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CopyFileExW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, lpProgressRoutine: ?LPPROGRESS_ROUTINE, lpData: ?*anyopaque, pbCancel: ?*i32, dwCopyFlags: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CopyFileTransactedA( lpExistingFileName: ?[*:0]const u8, lpNewFileName: ?[*:0]const u8, lpProgressRoutine: ?LPPROGRESS_ROUTINE, lpData: ?*anyopaque, pbCancel: ?*i32, dwCopyFlags: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CopyFileTransactedW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, lpProgressRoutine: ?LPPROGRESS_ROUTINE, lpData: ?*anyopaque, pbCancel: ?*i32, dwCopyFlags: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows8.0' pub extern "KERNEL32" fn CopyFile2( pwszExistingFileName: ?[*:0]const u16, pwszNewFileName: ?[*:0]const u16, pExtendedParameters: ?*COPYFILE2_EXTENDED_PARAMETERS, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn MoveFileA( lpExistingFileName: ?[*:0]const u8, lpNewFileName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn MoveFileW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn MoveFileExA( lpExistingFileName: ?[*:0]const u8, lpNewFileName: ?[*:0]const u8, dwFlags: MOVE_FILE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn MoveFileExW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, dwFlags: MOVE_FILE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn MoveFileWithProgressA( lpExistingFileName: ?[*:0]const u8, lpNewFileName: ?[*:0]const u8, lpProgressRoutine: ?LPPROGRESS_ROUTINE, lpData: ?*anyopaque, dwFlags: MOVE_FILE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn MoveFileWithProgressW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, lpProgressRoutine: ?LPPROGRESS_ROUTINE, lpData: ?*anyopaque, dwFlags: MOVE_FILE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn MoveFileTransactedA( lpExistingFileName: ?[*:0]const u8, lpNewFileName: ?[*:0]const u8, lpProgressRoutine: ?LPPROGRESS_ROUTINE, lpData: ?*anyopaque, dwFlags: MOVE_FILE_FLAGS, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn MoveFileTransactedW( lpExistingFileName: ?[*:0]const u16, lpNewFileName: ?[*:0]const u16, lpProgressRoutine: ?LPPROGRESS_ROUTINE, lpData: ?*anyopaque, dwFlags: MOVE_FILE_FLAGS, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn ReplaceFileA( lpReplacedFileName: ?[*:0]const u8, lpReplacementFileName: ?[*:0]const u8, lpBackupFileName: ?[*:0]const u8, dwReplaceFlags: REPLACE_FILE_FLAGS, lpExclude: ?*anyopaque, lpReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn ReplaceFileW( lpReplacedFileName: ?[*:0]const u16, lpReplacementFileName: ?[*:0]const u16, lpBackupFileName: ?[*:0]const u16, dwReplaceFlags: REPLACE_FILE_FLAGS, lpExclude: ?*anyopaque, lpReserved: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateHardLinkA( lpFileName: ?[*:0]const u8, lpExistingFileName: ?[*:0]const u8, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn CreateHardLinkW( lpFileName: ?[*:0]const u16, lpExistingFileName: ?[*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateHardLinkTransactedA( lpFileName: ?[*:0]const u8, lpExistingFileName: ?[*:0]const u8, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateHardLinkTransactedW( lpFileName: ?[*:0]const u16, lpExistingFileName: ?[*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn FindFirstStreamTransactedW( lpFileName: ?[*:0]const u16, InfoLevel: STREAM_INFO_LEVELS, lpFindStreamData: ?*anyopaque, dwFlags: u32, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) FindStreamHandle; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn FindFirstFileNameTransactedW( lpFileName: ?[*:0]const u16, dwFlags: u32, StringLength: ?*u32, LinkName: [*:0]u16, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) FindFileNameHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetVolumeLabelA( lpRootPathName: ?[*:0]const u8, lpVolumeName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetVolumeLabelW( lpRootPathName: ?[*:0]const u16, lpVolumeName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn SetFileBandwidthReservation( hFile: ?HANDLE, nPeriodMilliseconds: u32, nBytesPerPeriod: u32, bDiscardable: BOOL, lpTransferSize: ?*u32, lpNumOutstandingRequests: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetFileBandwidthReservation( hFile: ?HANDLE, lpPeriodMilliseconds: ?*u32, lpBytesPerPeriod: ?*u32, pDiscardable: ?*i32, lpTransferSize: ?*u32, lpNumOutstandingRequests: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn ReadDirectoryChangesW( hDirectory: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?*anyopaque, nBufferLength: u32, bWatchSubtree: BOOL, dwNotifyFilter: FILE_NOTIFY_CHANGE, lpBytesReturned: ?*u32, lpOverlapped: ?*OVERLAPPED, lpCompletionRoutine: ?LPOVERLAPPED_COMPLETION_ROUTINE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows10.0.16299' pub extern "KERNEL32" fn ReadDirectoryChangesExW( hDirectory: ?HANDLE, // TODO: what to do with BytesParamIndex 2? lpBuffer: ?*anyopaque, nBufferLength: u32, bWatchSubtree: BOOL, dwNotifyFilter: FILE_NOTIFY_CHANGE, lpBytesReturned: ?*u32, lpOverlapped: ?*OVERLAPPED, lpCompletionRoutine: ?LPOVERLAPPED_COMPLETION_ROUTINE, ReadDirectoryNotifyInformationClass: READ_DIRECTORY_NOTIFY_INFORMATION_CLASS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstVolumeA( lpszVolumeName: [*:0]u8, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) FindVolumeHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindNextVolumeA( hFindVolume: FindVolumeHandle, lpszVolumeName: [*:0]u8, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstVolumeMountPointA( lpszRootPathName: ?[*:0]const u8, lpszVolumeMountPoint: [*:0]u8, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) FindVolumeMointPointHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindFirstVolumeMountPointW( lpszRootPathName: ?[*:0]const u16, lpszVolumeMountPoint: [*:0]u16, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) FindVolumeMointPointHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindNextVolumeMountPointA( hFindVolumeMountPoint: FindVolumeMointPointHandle, lpszVolumeMountPoint: [*:0]u8, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindNextVolumeMountPointW( hFindVolumeMountPoint: FindVolumeMointPointHandle, lpszVolumeMountPoint: [*:0]u16, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn FindVolumeMountPointClose( hFindVolumeMountPoint: FindVolumeMointPointHandle, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetVolumeMountPointA( lpszVolumeMountPoint: ?[*:0]const u8, lpszVolumeName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn SetVolumeMountPointW( lpszVolumeMountPoint: ?[*:0]const u16, lpszVolumeName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn DeleteVolumeMountPointA( lpszVolumeMountPoint: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetVolumeNameForVolumeMountPointA( lpszVolumeMountPoint: ?[*:0]const u8, lpszVolumeName: [*:0]u8, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetVolumePathNameA( lpszFileName: ?[*:0]const u8, lpszVolumePathName: [*:0]u8, cchBufferLength: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "KERNEL32" fn GetVolumePathNamesForVolumeNameA( lpszVolumeName: ?[*:0]const u8, lpszVolumePathNames: ?[*]u8, cchBufferLength: u32, lpcchReturnLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn GetFileInformationByHandleEx( hFile: ?HANDLE, FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, // TODO: what to do with BytesParamIndex 3? lpFileInformation: ?*anyopaque, dwBufferSize: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn OpenFileById( hVolumeHint: ?HANDLE, lpFileId: ?*FILE_ID_DESCRIPTOR, dwDesiredAccess: FILE_ACCESS_FLAGS, dwShareMode: FILE_SHARE_MODE, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES, dwFlagsAndAttributes: FILE_FLAGS_AND_ATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateSymbolicLinkA( lpSymlinkFileName: ?[*:0]const u8, lpTargetFileName: ?[*:0]const u8, dwFlags: SYMBOLIC_LINK_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateSymbolicLinkW( lpSymlinkFileName: ?[*:0]const u16, lpTargetFileName: ?[*:0]const u16, dwFlags: SYMBOLIC_LINK_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateSymbolicLinkTransactedA( lpSymlinkFileName: ?[*:0]const u8, lpTargetFileName: ?[*:0]const u8, dwFlags: SYMBOLIC_LINK_FLAGS, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "KERNEL32" fn CreateSymbolicLinkTransactedW( lpSymlinkFileName: ?[*:0]const u16, lpTargetFileName: ?[*:0]const u16, dwFlags: SYMBOLIC_LINK_FLAGS, hTransaction: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOLEAN; pub extern "ntdll" fn NtCreateFile( FileHandle: ?*?HANDLE, DesiredAccess: u32, ObjectAttributes: ?*OBJECT_ATTRIBUTES, IoStatusBlock: ?*IO_STATUS_BLOCK, AllocationSize: ?*LARGE_INTEGER, FileAttributes: u32, ShareAccess: FILE_SHARE_MODE, CreateDisposition: NT_CREATE_FILE_DISPOSITION, CreateOptions: u32, EaBuffer: ?*anyopaque, EaLength: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (93) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { pub const WIN32_FIND_DATA = thismodule.WIN32_FIND_DATAA; pub const NTMS_DRIVEINFORMATION = thismodule.NTMS_DRIVEINFORMATIONA; pub const NTMS_CHANGERINFORMATION = thismodule.NTMS_CHANGERINFORMATIONA; pub const NTMS_PMIDINFORMATION = thismodule.NTMS_PMIDINFORMATIONA; pub const NTMS_PARTITIONINFORMATION = thismodule.NTMS_PARTITIONINFORMATIONA; pub const NTMS_DRIVETYPEINFORMATION = thismodule.NTMS_DRIVETYPEINFORMATIONA; pub const NTMS_CHANGERTYPEINFORMATION = thismodule.NTMS_CHANGERTYPEINFORMATIONA; pub const NTMS_LIBREQUESTINFORMATION = thismodule.NTMS_LIBREQUESTINFORMATIONA; pub const NTMS_OPREQUESTINFORMATION = thismodule.NTMS_OPREQUESTINFORMATIONA; pub const NTMS_OBJECTINFORMATION = thismodule.NTMS_OBJECTINFORMATIONA; pub const NTMS_I1_LIBREQUESTINFORMATION = thismodule.NTMS_I1_LIBREQUESTINFORMATIONA; pub const NTMS_I1_PMIDINFORMATION = thismodule.NTMS_I1_PMIDINFORMATIONA; pub const NTMS_I1_PARTITIONINFORMATION = thismodule.NTMS_I1_PARTITIONINFORMATIONA; pub const NTMS_I1_OPREQUESTINFORMATION = thismodule.NTMS_I1_OPREQUESTINFORMATIONA; pub const NTMS_I1_OBJECTINFORMATION = thismodule.NTMS_I1_OBJECTINFORMATIONA; pub const SearchPath = thismodule.SearchPathA; pub const CreateDirectory = thismodule.CreateDirectoryA; pub const CreateFile = thismodule.CreateFileA; pub const DefineDosDevice = thismodule.DefineDosDeviceA; pub const DeleteFile = thismodule.DeleteFileA; pub const DeleteVolumeMountPoint = thismodule.DeleteVolumeMountPointA; pub const FindFirstChangeNotification = thismodule.FindFirstChangeNotificationA; pub const FindFirstFile = thismodule.FindFirstFileA; pub const FindFirstFileEx = thismodule.FindFirstFileExA; pub const FindFirstVolume = thismodule.FindFirstVolumeA; pub const FindNextFile = thismodule.FindNextFileA; pub const FindNextVolume = thismodule.FindNextVolumeA; pub const GetDiskFreeSpace = thismodule.GetDiskFreeSpaceA; pub const GetDiskFreeSpaceEx = thismodule.GetDiskFreeSpaceExA; pub const GetDiskSpaceInformation = thismodule.GetDiskSpaceInformationA; pub const GetDriveType = thismodule.GetDriveTypeA; pub const GetFileAttributes = thismodule.GetFileAttributesA; pub const GetFileAttributesEx = thismodule.GetFileAttributesExA; pub const GetFinalPathNameByHandle = thismodule.GetFinalPathNameByHandleA; pub const GetFullPathName = thismodule.GetFullPathNameA; pub const GetLogicalDriveStrings = thismodule.GetLogicalDriveStringsA; pub const GetLongPathName = thismodule.GetLongPathNameA; pub const GetShortPathName = thismodule.GetShortPathNameA; pub const GetTempFileName = thismodule.GetTempFileNameA; pub const GetVolumeInformation = thismodule.GetVolumeInformationA; pub const GetVolumePathName = thismodule.GetVolumePathNameA; pub const QueryDosDevice = thismodule.QueryDosDeviceA; pub const RemoveDirectory = thismodule.RemoveDirectoryA; pub const SetFileAttributes = thismodule.SetFileAttributesA; pub const GetTempPath = thismodule.GetTempPathA; pub const GetVolumeNameForVolumeMountPoint = thismodule.GetVolumeNameForVolumeMountPointA; pub const GetVolumePathNamesForVolumeName = thismodule.GetVolumePathNamesForVolumeNameA; pub const GetCompressedFileSize = thismodule.GetCompressedFileSizeA; pub const GetTempPath2 = thismodule.GetTempPath2A; pub const VerFindFile = thismodule.VerFindFileA; pub const VerInstallFile = thismodule.VerInstallFileA; pub const GetFileVersionInfoSize = thismodule.GetFileVersionInfoSizeA; pub const GetFileVersionInfo = thismodule.GetFileVersionInfoA; pub const GetFileVersionInfoSizeEx = thismodule.GetFileVersionInfoSizeExA; pub const GetFileVersionInfoEx = thismodule.GetFileVersionInfoExA; pub const VerLanguageName = thismodule.VerLanguageNameA; pub const VerQueryValue = thismodule.VerQueryValueA; pub const GetExpandedName = thismodule.GetExpandedNameA; pub const LZOpenFile = thismodule.LZOpenFileA; pub const GetBinaryType = thismodule.GetBinaryTypeA; pub const GetLongPathNameTransacted = thismodule.GetLongPathNameTransactedA; pub const SetFileShortName = thismodule.SetFileShortNameA; pub const EncryptFile = thismodule.EncryptFileA; pub const DecryptFile = thismodule.DecryptFileA; pub const FileEncryptionStatus = thismodule.FileEncryptionStatusA; pub const OpenEncryptedFileRaw = thismodule.OpenEncryptedFileRawA; pub const CreateDirectoryEx = thismodule.CreateDirectoryExA; pub const CreateDirectoryTransacted = thismodule.CreateDirectoryTransactedA; pub const RemoveDirectoryTransacted = thismodule.RemoveDirectoryTransactedA; pub const GetFullPathNameTransacted = thismodule.GetFullPathNameTransactedA; pub const CreateFileTransacted = thismodule.CreateFileTransactedA; pub const SetFileAttributesTransacted = thismodule.SetFileAttributesTransactedA; pub const GetFileAttributesTransacted = thismodule.GetFileAttributesTransactedA; pub const GetCompressedFileSizeTransacted = thismodule.GetCompressedFileSizeTransactedA; pub const DeleteFileTransacted = thismodule.DeleteFileTransactedA; pub const CheckNameLegalDOS8Dot3 = thismodule.CheckNameLegalDOS8Dot3A; pub const FindFirstFileTransacted = thismodule.FindFirstFileTransactedA; pub const CopyFile = thismodule.CopyFileA; pub const CopyFileEx = thismodule.CopyFileExA; pub const CopyFileTransacted = thismodule.CopyFileTransactedA; pub const MoveFile = thismodule.MoveFileA; pub const MoveFileEx = thismodule.MoveFileExA; pub const MoveFileWithProgress = thismodule.MoveFileWithProgressA; pub const MoveFileTransacted = thismodule.MoveFileTransactedA; pub const ReplaceFile = thismodule.ReplaceFileA; pub const CreateHardLink = thismodule.CreateHardLinkA; pub const CreateHardLinkTransacted = thismodule.CreateHardLinkTransactedA; pub const SetVolumeLabel = thismodule.SetVolumeLabelA; pub const FindFirstVolumeMountPoint = thismodule.FindFirstVolumeMountPointA; pub const FindNextVolumeMountPoint = thismodule.FindNextVolumeMountPointA; pub const SetVolumeMountPoint = thismodule.SetVolumeMountPointA; pub const CreateSymbolicLink = thismodule.CreateSymbolicLinkA; pub const CreateSymbolicLinkTransacted = thismodule.CreateSymbolicLinkTransactedA; }, .wide => struct { pub const WIN32_FIND_DATA = thismodule.WIN32_FIND_DATAW; pub const NTMS_DRIVEINFORMATION = thismodule.NTMS_DRIVEINFORMATIONW; pub const NTMS_CHANGERINFORMATION = thismodule.NTMS_CHANGERINFORMATIONW; pub const NTMS_PMIDINFORMATION = thismodule.NTMS_PMIDINFORMATIONW; pub const NTMS_PARTITIONINFORMATION = thismodule.NTMS_PARTITIONINFORMATIONW; pub const NTMS_DRIVETYPEINFORMATION = thismodule.NTMS_DRIVETYPEINFORMATIONW; pub const NTMS_CHANGERTYPEINFORMATION = thismodule.NTMS_CHANGERTYPEINFORMATIONW; pub const NTMS_LIBREQUESTINFORMATION = thismodule.NTMS_LIBREQUESTINFORMATIONW; pub const NTMS_OPREQUESTINFORMATION = thismodule.NTMS_OPREQUESTINFORMATIONW; pub const NTMS_OBJECTINFORMATION = thismodule.NTMS_OBJECTINFORMATIONW; pub const NTMS_I1_LIBREQUESTINFORMATION = thismodule.NTMS_I1_LIBREQUESTINFORMATIONW; pub const NTMS_I1_PMIDINFORMATION = thismodule.NTMS_I1_PMIDINFORMATIONW; pub const NTMS_I1_PARTITIONINFORMATION = thismodule.NTMS_I1_PARTITIONINFORMATIONW; pub const NTMS_I1_OPREQUESTINFORMATION = thismodule.NTMS_I1_OPREQUESTINFORMATIONW; pub const NTMS_I1_OBJECTINFORMATION = thismodule.NTMS_I1_OBJECTINFORMATIONW; pub const SearchPath = thismodule.SearchPathW; pub const CreateDirectory = thismodule.CreateDirectoryW; pub const CreateFile = thismodule.CreateFileW; pub const DefineDosDevice = thismodule.DefineDosDeviceW; pub const DeleteFile = thismodule.DeleteFileW; pub const DeleteVolumeMountPoint = thismodule.DeleteVolumeMountPointW; pub const FindFirstChangeNotification = thismodule.FindFirstChangeNotificationW; pub const FindFirstFile = thismodule.FindFirstFileW; pub const FindFirstFileEx = thismodule.FindFirstFileExW; pub const FindFirstVolume = thismodule.FindFirstVolumeW; pub const FindNextFile = thismodule.FindNextFileW; pub const FindNextVolume = thismodule.FindNextVolumeW; pub const GetDiskFreeSpace = thismodule.GetDiskFreeSpaceW; pub const GetDiskFreeSpaceEx = thismodule.GetDiskFreeSpaceExW; pub const GetDiskSpaceInformation = thismodule.GetDiskSpaceInformationW; pub const GetDriveType = thismodule.GetDriveTypeW; pub const GetFileAttributes = thismodule.GetFileAttributesW; pub const GetFileAttributesEx = thismodule.GetFileAttributesExW; pub const GetFinalPathNameByHandle = thismodule.GetFinalPathNameByHandleW; pub const GetFullPathName = thismodule.GetFullPathNameW; pub const GetLogicalDriveStrings = thismodule.GetLogicalDriveStringsW; pub const GetLongPathName = thismodule.GetLongPathNameW; pub const GetShortPathName = thismodule.GetShortPathNameW; pub const GetTempFileName = thismodule.GetTempFileNameW; pub const GetVolumeInformation = thismodule.GetVolumeInformationW; pub const GetVolumePathName = thismodule.GetVolumePathNameW; pub const QueryDosDevice = thismodule.QueryDosDeviceW; pub const RemoveDirectory = thismodule.RemoveDirectoryW; pub const SetFileAttributes = thismodule.SetFileAttributesW; pub const GetTempPath = thismodule.GetTempPathW; pub const GetVolumeNameForVolumeMountPoint = thismodule.GetVolumeNameForVolumeMountPointW; pub const GetVolumePathNamesForVolumeName = thismodule.GetVolumePathNamesForVolumeNameW; pub const GetCompressedFileSize = thismodule.GetCompressedFileSizeW; pub const GetTempPath2 = thismodule.GetTempPath2W; pub const VerFindFile = thismodule.VerFindFileW; pub const VerInstallFile = thismodule.VerInstallFileW; pub const GetFileVersionInfoSize = thismodule.GetFileVersionInfoSizeW; pub const GetFileVersionInfo = thismodule.GetFileVersionInfoW; pub const GetFileVersionInfoSizeEx = thismodule.GetFileVersionInfoSizeExW; pub const GetFileVersionInfoEx = thismodule.GetFileVersionInfoExW; pub const VerLanguageName = thismodule.VerLanguageNameW; pub const VerQueryValue = thismodule.VerQueryValueW; pub const GetExpandedName = thismodule.GetExpandedNameW; pub const LZOpenFile = thismodule.LZOpenFileW; pub const GetBinaryType = thismodule.GetBinaryTypeW; pub const GetLongPathNameTransacted = thismodule.GetLongPathNameTransactedW; pub const SetFileShortName = thismodule.SetFileShortNameW; pub const EncryptFile = thismodule.EncryptFileW; pub const DecryptFile = thismodule.DecryptFileW; pub const FileEncryptionStatus = thismodule.FileEncryptionStatusW; pub const OpenEncryptedFileRaw = thismodule.OpenEncryptedFileRawW; pub const CreateDirectoryEx = thismodule.CreateDirectoryExW; pub const CreateDirectoryTransacted = thismodule.CreateDirectoryTransactedW; pub const RemoveDirectoryTransacted = thismodule.RemoveDirectoryTransactedW; pub const GetFullPathNameTransacted = thismodule.GetFullPathNameTransactedW; pub const CreateFileTransacted = thismodule.CreateFileTransactedW; pub const SetFileAttributesTransacted = thismodule.SetFileAttributesTransactedW; pub const GetFileAttributesTransacted = thismodule.GetFileAttributesTransactedW; pub const GetCompressedFileSizeTransacted = thismodule.GetCompressedFileSizeTransactedW; pub const DeleteFileTransacted = thismodule.DeleteFileTransactedW; pub const CheckNameLegalDOS8Dot3 = thismodule.CheckNameLegalDOS8Dot3W; pub const FindFirstFileTransacted = thismodule.FindFirstFileTransactedW; pub const CopyFile = thismodule.CopyFileW; pub const CopyFileEx = thismodule.CopyFileExW; pub const CopyFileTransacted = thismodule.CopyFileTransactedW; pub const MoveFile = thismodule.MoveFileW; pub const MoveFileEx = thismodule.MoveFileExW; pub const MoveFileWithProgress = thismodule.MoveFileWithProgressW; pub const MoveFileTransacted = thismodule.MoveFileTransactedW; pub const ReplaceFile = thismodule.ReplaceFileW; pub const CreateHardLink = thismodule.CreateHardLinkW; pub const CreateHardLinkTransacted = thismodule.CreateHardLinkTransactedW; pub const SetVolumeLabel = thismodule.SetVolumeLabelW; pub const FindFirstVolumeMountPoint = thismodule.FindFirstVolumeMountPointW; pub const FindNextVolumeMountPoint = thismodule.FindNextVolumeMountPointW; pub const SetVolumeMountPoint = thismodule.SetVolumeMountPointW; pub const CreateSymbolicLink = thismodule.CreateSymbolicLinkW; pub const CreateSymbolicLinkTransacted = thismodule.CreateSymbolicLinkTransactedW; }, .unspecified => if (@import("builtin").is_test) struct { pub const WIN32_FIND_DATA = *opaque{}; pub const NTMS_DRIVEINFORMATION = *opaque{}; pub const NTMS_CHANGERINFORMATION = *opaque{}; pub const NTMS_PMIDINFORMATION = *opaque{}; pub const NTMS_PARTITIONINFORMATION = *opaque{}; pub const NTMS_DRIVETYPEINFORMATION = *opaque{}; pub const NTMS_CHANGERTYPEINFORMATION = *opaque{}; pub const NTMS_LIBREQUESTINFORMATION = *opaque{}; pub const NTMS_OPREQUESTINFORMATION = *opaque{}; pub const NTMS_OBJECTINFORMATION = *opaque{}; pub const NTMS_I1_LIBREQUESTINFORMATION = *opaque{}; pub const NTMS_I1_PMIDINFORMATION = *opaque{}; pub const NTMS_I1_PARTITIONINFORMATION = *opaque{}; pub const NTMS_I1_OPREQUESTINFORMATION = *opaque{}; pub const NTMS_I1_OBJECTINFORMATION = *opaque{}; pub const SearchPath = *opaque{}; pub const CreateDirectory = *opaque{}; pub const CreateFile = *opaque{}; pub const DefineDosDevice = *opaque{}; pub const DeleteFile = *opaque{}; pub const DeleteVolumeMountPoint = *opaque{}; pub const FindFirstChangeNotification = *opaque{}; pub const FindFirstFile = *opaque{}; pub const FindFirstFileEx = *opaque{}; pub const FindFirstVolume = *opaque{}; pub const FindNextFile = *opaque{}; pub const FindNextVolume = *opaque{}; pub const GetDiskFreeSpace = *opaque{}; pub const GetDiskFreeSpaceEx = *opaque{}; pub const GetDiskSpaceInformation = *opaque{}; pub const GetDriveType = *opaque{}; pub const GetFileAttributes = *opaque{}; pub const GetFileAttributesEx = *opaque{}; pub const GetFinalPathNameByHandle = *opaque{}; pub const GetFullPathName = *opaque{}; pub const GetLogicalDriveStrings = *opaque{}; pub const GetLongPathName = *opaque{}; pub const GetShortPathName = *opaque{}; pub const GetTempFileName = *opaque{}; pub const GetVolumeInformation = *opaque{}; pub const GetVolumePathName = *opaque{}; pub const QueryDosDevice = *opaque{}; pub const RemoveDirectory = *opaque{}; pub const SetFileAttributes = *opaque{}; pub const GetTempPath = *opaque{}; pub const GetVolumeNameForVolumeMountPoint = *opaque{}; pub const GetVolumePathNamesForVolumeName = *opaque{}; pub const GetCompressedFileSize = *opaque{}; pub const GetTempPath2 = *opaque{}; pub const VerFindFile = *opaque{}; pub const VerInstallFile = *opaque{}; pub const GetFileVersionInfoSize = *opaque{}; pub const GetFileVersionInfo = *opaque{}; pub const GetFileVersionInfoSizeEx = *opaque{}; pub const GetFileVersionInfoEx = *opaque{}; pub const VerLanguageName = *opaque{}; pub const VerQueryValue = *opaque{}; pub const GetExpandedName = *opaque{}; pub const LZOpenFile = *opaque{}; pub const GetBinaryType = *opaque{}; pub const GetLongPathNameTransacted = *opaque{}; pub const SetFileShortName = *opaque{}; pub const EncryptFile = *opaque{}; pub const DecryptFile = *opaque{}; pub const FileEncryptionStatus = *opaque{}; pub const OpenEncryptedFileRaw = *opaque{}; pub const CreateDirectoryEx = *opaque{}; pub const CreateDirectoryTransacted = *opaque{}; pub const RemoveDirectoryTransacted = *opaque{}; pub const GetFullPathNameTransacted = *opaque{}; pub const CreateFileTransacted = *opaque{}; pub const SetFileAttributesTransacted = *opaque{}; pub const GetFileAttributesTransacted = *opaque{}; pub const GetCompressedFileSizeTransacted = *opaque{}; pub const DeleteFileTransacted = *opaque{}; pub const CheckNameLegalDOS8Dot3 = *opaque{}; pub const FindFirstFileTransacted = *opaque{}; pub const CopyFile = *opaque{}; pub const CopyFileEx = *opaque{}; pub const CopyFileTransacted = *opaque{}; pub const MoveFile = *opaque{}; pub const MoveFileEx = *opaque{}; pub const MoveFileWithProgress = *opaque{}; pub const MoveFileTransacted = *opaque{}; pub const ReplaceFile = *opaque{}; pub const CreateHardLink = *opaque{}; pub const CreateHardLinkTransacted = *opaque{}; pub const SetVolumeLabel = *opaque{}; pub const FindFirstVolumeMountPoint = *opaque{}; pub const FindNextVolumeMountPoint = *opaque{}; pub const SetVolumeMountPoint = *opaque{}; pub const CreateSymbolicLink = *opaque{}; pub const CreateSymbolicLinkTransacted = *opaque{}; } else struct { pub const WIN32_FIND_DATA = @compileError("'WIN32_FIND_DATA' requires that UNICODE be set to true or false in the root module"); pub const NTMS_DRIVEINFORMATION = @compileError("'NTMS_DRIVEINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_CHANGERINFORMATION = @compileError("'NTMS_CHANGERINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_PMIDINFORMATION = @compileError("'NTMS_PMIDINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_PARTITIONINFORMATION = @compileError("'NTMS_PARTITIONINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_DRIVETYPEINFORMATION = @compileError("'NTMS_DRIVETYPEINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_CHANGERTYPEINFORMATION = @compileError("'NTMS_CHANGERTYPEINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_LIBREQUESTINFORMATION = @compileError("'NTMS_LIBREQUESTINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_OPREQUESTINFORMATION = @compileError("'NTMS_OPREQUESTINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_OBJECTINFORMATION = @compileError("'NTMS_OBJECTINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_I1_LIBREQUESTINFORMATION = @compileError("'NTMS_I1_LIBREQUESTINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_I1_PMIDINFORMATION = @compileError("'NTMS_I1_PMIDINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_I1_PARTITIONINFORMATION = @compileError("'NTMS_I1_PARTITIONINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_I1_OPREQUESTINFORMATION = @compileError("'NTMS_I1_OPREQUESTINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const NTMS_I1_OBJECTINFORMATION = @compileError("'NTMS_I1_OBJECTINFORMATION' requires that UNICODE be set to true or false in the root module"); pub const SearchPath = @compileError("'SearchPath' requires that UNICODE be set to true or false in the root module"); pub const CreateDirectory = @compileError("'CreateDirectory' requires that UNICODE be set to true or false in the root module"); pub const CreateFile = @compileError("'CreateFile' requires that UNICODE be set to true or false in the root module"); pub const DefineDosDevice = @compileError("'DefineDosDevice' requires that UNICODE be set to true or false in the root module"); pub const DeleteFile = @compileError("'DeleteFile' requires that UNICODE be set to true or false in the root module"); pub const DeleteVolumeMountPoint = @compileError("'DeleteVolumeMountPoint' requires that UNICODE be set to true or false in the root module"); pub const FindFirstChangeNotification = @compileError("'FindFirstChangeNotification' requires that UNICODE be set to true or false in the root module"); pub const FindFirstFile = @compileError("'FindFirstFile' requires that UNICODE be set to true or false in the root module"); pub const FindFirstFileEx = @compileError("'FindFirstFileEx' requires that UNICODE be set to true or false in the root module"); pub const FindFirstVolume = @compileError("'FindFirstVolume' requires that UNICODE be set to true or false in the root module"); pub const FindNextFile = @compileError("'FindNextFile' requires that UNICODE be set to true or false in the root module"); pub const FindNextVolume = @compileError("'FindNextVolume' requires that UNICODE be set to true or false in the root module"); pub const GetDiskFreeSpace = @compileError("'GetDiskFreeSpace' requires that UNICODE be set to true or false in the root module"); pub const GetDiskFreeSpaceEx = @compileError("'GetDiskFreeSpaceEx' requires that UNICODE be set to true or false in the root module"); pub const GetDiskSpaceInformation = @compileError("'GetDiskSpaceInformation' requires that UNICODE be set to true or false in the root module"); pub const GetDriveType = @compileError("'GetDriveType' requires that UNICODE be set to true or false in the root module"); pub const GetFileAttributes = @compileError("'GetFileAttributes' requires that UNICODE be set to true or false in the root module"); pub const GetFileAttributesEx = @compileError("'GetFileAttributesEx' requires that UNICODE be set to true or false in the root module"); pub const GetFinalPathNameByHandle = @compileError("'GetFinalPathNameByHandle' requires that UNICODE be set to true or false in the root module"); pub const GetFullPathName = @compileError("'GetFullPathName' requires that UNICODE be set to true or false in the root module"); pub const GetLogicalDriveStrings = @compileError("'GetLogicalDriveStrings' requires that UNICODE be set to true or false in the root module"); pub const GetLongPathName = @compileError("'GetLongPathName' requires that UNICODE be set to true or false in the root module"); pub const GetShortPathName = @compileError("'GetShortPathName' requires that UNICODE be set to true or false in the root module"); pub const GetTempFileName = @compileError("'GetTempFileName' requires that UNICODE be set to true or false in the root module"); pub const GetVolumeInformation = @compileError("'GetVolumeInformation' requires that UNICODE be set to true or false in the root module"); pub const GetVolumePathName = @compileError("'GetVolumePathName' requires that UNICODE be set to true or false in the root module"); pub const QueryDosDevice = @compileError("'QueryDosDevice' requires that UNICODE be set to true or false in the root module"); pub const RemoveDirectory = @compileError("'RemoveDirectory' requires that UNICODE be set to true or false in the root module"); pub const SetFileAttributes = @compileError("'SetFileAttributes' requires that UNICODE be set to true or false in the root module"); pub const GetTempPath = @compileError("'GetTempPath' requires that UNICODE be set to true or false in the root module"); pub const GetVolumeNameForVolumeMountPoint = @compileError("'GetVolumeNameForVolumeMountPoint' requires that UNICODE be set to true or false in the root module"); pub const GetVolumePathNamesForVolumeName = @compileError("'GetVolumePathNamesForVolumeName' requires that UNICODE be set to true or false in the root module"); pub const GetCompressedFileSize = @compileError("'GetCompressedFileSize' requires that UNICODE be set to true or false in the root module"); pub const GetTempPath2 = @compileError("'GetTempPath2' requires that UNICODE be set to true or false in the root module"); pub const VerFindFile = @compileError("'VerFindFile' requires that UNICODE be set to true or false in the root module"); pub const VerInstallFile = @compileError("'VerInstallFile' requires that UNICODE be set to true or false in the root module"); pub const GetFileVersionInfoSize = @compileError("'GetFileVersionInfoSize' requires that UNICODE be set to true or false in the root module"); pub const GetFileVersionInfo = @compileError("'GetFileVersionInfo' requires that UNICODE be set to true or false in the root module"); pub const GetFileVersionInfoSizeEx = @compileError("'GetFileVersionInfoSizeEx' requires that UNICODE be set to true or false in the root module"); pub const GetFileVersionInfoEx = @compileError("'GetFileVersionInfoEx' requires that UNICODE be set to true or false in the root module"); pub const VerLanguageName = @compileError("'VerLanguageName' requires that UNICODE be set to true or false in the root module"); pub const VerQueryValue = @compileError("'VerQueryValue' requires that UNICODE be set to true or false in the root module"); pub const GetExpandedName = @compileError("'GetExpandedName' requires that UNICODE be set to true or false in the root module"); pub const LZOpenFile = @compileError("'LZOpenFile' requires that UNICODE be set to true or false in the root module"); pub const GetBinaryType = @compileError("'GetBinaryType' requires that UNICODE be set to true or false in the root module"); pub const GetLongPathNameTransacted = @compileError("'GetLongPathNameTransacted' requires that UNICODE be set to true or false in the root module"); pub const SetFileShortName = @compileError("'SetFileShortName' requires that UNICODE be set to true or false in the root module"); pub const EncryptFile = @compileError("'EncryptFile' requires that UNICODE be set to true or false in the root module"); pub const DecryptFile = @compileError("'DecryptFile' requires that UNICODE be set to true or false in the root module"); pub const FileEncryptionStatus = @compileError("'FileEncryptionStatus' requires that UNICODE be set to true or false in the root module"); pub const OpenEncryptedFileRaw = @compileError("'OpenEncryptedFileRaw' requires that UNICODE be set to true or false in the root module"); pub const CreateDirectoryEx = @compileError("'CreateDirectoryEx' requires that UNICODE be set to true or false in the root module"); pub const CreateDirectoryTransacted = @compileError("'CreateDirectoryTransacted' requires that UNICODE be set to true or false in the root module"); pub const RemoveDirectoryTransacted = @compileError("'RemoveDirectoryTransacted' requires that UNICODE be set to true or false in the root module"); pub const GetFullPathNameTransacted = @compileError("'GetFullPathNameTransacted' requires that UNICODE be set to true or false in the root module"); pub const CreateFileTransacted = @compileError("'CreateFileTransacted' requires that UNICODE be set to true or false in the root module"); pub const SetFileAttributesTransacted = @compileError("'SetFileAttributesTransacted' requires that UNICODE be set to true or false in the root module"); pub const GetFileAttributesTransacted = @compileError("'GetFileAttributesTransacted' requires that UNICODE be set to true or false in the root module"); pub const GetCompressedFileSizeTransacted = @compileError("'GetCompressedFileSizeTransacted' requires that UNICODE be set to true or false in the root module"); pub const DeleteFileTransacted = @compileError("'DeleteFileTransacted' requires that UNICODE be set to true or false in the root module"); pub const CheckNameLegalDOS8Dot3 = @compileError("'CheckNameLegalDOS8Dot3' requires that UNICODE be set to true or false in the root module"); pub const FindFirstFileTransacted = @compileError("'FindFirstFileTransacted' requires that UNICODE be set to true or false in the root module"); pub const CopyFile = @compileError("'CopyFile' requires that UNICODE be set to true or false in the root module"); pub const CopyFileEx = @compileError("'CopyFileEx' requires that UNICODE be set to true or false in the root module"); pub const CopyFileTransacted = @compileError("'CopyFileTransacted' requires that UNICODE be set to true or false in the root module"); pub const MoveFile = @compileError("'MoveFile' requires that UNICODE be set to true or false in the root module"); pub const MoveFileEx = @compileError("'MoveFileEx' requires that UNICODE be set to true or false in the root module"); pub const MoveFileWithProgress = @compileError("'MoveFileWithProgress' requires that UNICODE be set to true or false in the root module"); pub const MoveFileTransacted = @compileError("'MoveFileTransacted' requires that UNICODE be set to true or false in the root module"); pub const ReplaceFile = @compileError("'ReplaceFile' requires that UNICODE be set to true or false in the root module"); pub const CreateHardLink = @compileError("'CreateHardLink' requires that UNICODE be set to true or false in the root module"); pub const CreateHardLinkTransacted = @compileError("'CreateHardLinkTransacted' requires that UNICODE be set to true or false in the root module"); pub const SetVolumeLabel = @compileError("'SetVolumeLabel' requires that UNICODE be set to true or false in the root module"); pub const FindFirstVolumeMountPoint = @compileError("'FindFirstVolumeMountPoint' requires that UNICODE be set to true or false in the root module"); pub const FindNextVolumeMountPoint = @compileError("'FindNextVolumeMountPoint' requires that UNICODE be set to true or false in the root module"); pub const SetVolumeMountPoint = @compileError("'SetVolumeMountPoint' requires that UNICODE be set to true or false in the root module"); pub const CreateSymbolicLink = @compileError("'CreateSymbolicLink' requires that UNICODE be set to true or false in the root module"); pub const CreateSymbolicLinkTransacted = @compileError("'CreateSymbolicLinkTransacted' requires that UNICODE be set to true or false in the root module"); }, }; //-------------------------------------------------------------------------------- // Section: Imports (25) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const BOOL = @import("../foundation.zig").BOOL; const BOOLEAN = @import("../foundation.zig").BOOLEAN; const CHAR = @import("../foundation.zig").CHAR; const FILETIME = @import("../foundation.zig").FILETIME; const GENERIC_MAPPING = @import("../security.zig").GENERIC_MAPPING; const HANDLE = @import("../foundation.zig").HANDLE; const HRESULT = @import("../foundation.zig").HRESULT; const IConnectionPointContainer = @import("../system/com.zig").IConnectionPointContainer; const IO_STATUS_BLOCK = @import("../system/windows_programming.zig").IO_STATUS_BLOCK; const IUnknown = @import("../system/com.zig").IUnknown; const LARGE_INTEGER = @import("../foundation.zig").LARGE_INTEGER; const LPOVERLAPPED_COMPLETION_ROUTINE = @import("../system/io.zig").LPOVERLAPPED_COMPLETION_ROUTINE; const NTSTATUS = @import("../foundation.zig").NTSTATUS; const OBJECT_ATTRIBUTES = @import("../system/windows_programming.zig").OBJECT_ATTRIBUTES; const OVERLAPPED = @import("../system/io.zig").OVERLAPPED; const PRIVILEGE_SET = @import("../security.zig").PRIVILEGE_SET; const PSID = @import("../foundation.zig").PSID; const PSTR = @import("../foundation.zig").PSTR; const PWSTR = @import("../foundation.zig").PWSTR; const SECURITY_ATTRIBUTES = @import("../security.zig").SECURITY_ATTRIBUTES; const SECURITY_DESCRIPTOR = @import("../security.zig").SECURITY_DESCRIPTOR; const SID = @import("../security.zig").SID; const SYSTEMTIME = @import("../foundation.zig").SYSTEMTIME; const ULARGE_INTEGER = @import("../foundation.zig").ULARGE_INTEGER; test { // The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476 if (@hasDecl(@This(), "MAXMEDIALABEL")) { _ = MAXMEDIALABEL; } if (@hasDecl(@This(), "CLAIMMEDIALABEL")) { _ = CLAIMMEDIALABEL; } if (@hasDecl(@This(), "CLAIMMEDIALABELEX")) { _ = CLAIMMEDIALABELEX; } if (@hasDecl(@This(), "CLFS_BLOCK_ALLOCATION")) { _ = CLFS_BLOCK_ALLOCATION; } if (@hasDecl(@This(), "CLFS_BLOCK_DEALLOCATION")) { _ = CLFS_BLOCK_DEALLOCATION; } if (@hasDecl(@This(), "PCLFS_COMPLETION_ROUTINE")) { _ = PCLFS_COMPLETION_ROUTINE; } if (@hasDecl(@This(), "PLOG_TAIL_ADVANCE_CALLBACK")) { _ = PLOG_TAIL_ADVANCE_CALLBACK; } if (@hasDecl(@This(), "PLOG_FULL_HANDLER_CALLBACK")) { _ = PLOG_FULL_HANDLER_CALLBACK; } if (@hasDecl(@This(), "PLOG_UNPINNED_CALLBACK")) { _ = PLOG_UNPINNED_CALLBACK; } if (@hasDecl(@This(), "WofEnumEntryProc")) { _ = WofEnumEntryProc; } if (@hasDecl(@This(), "WofEnumFilesProc")) { _ = WofEnumFilesProc; } if (@hasDecl(@This(), "PFN_IO_COMPLETION")) { _ = PFN_IO_COMPLETION; } if (@hasDecl(@This(), "FCACHE_CREATE_CALLBACK")) { _ = FCACHE_CREATE_CALLBACK; } if (@hasDecl(@This(), "FCACHE_RICHCREATE_CALLBACK")) { _ = FCACHE_RICHCREATE_CALLBACK; } if (@hasDecl(@This(), "CACHE_KEY_COMPARE")) { _ = CACHE_KEY_COMPARE; } if (@hasDecl(@This(), "CACHE_KEY_HASH")) { _ = CACHE_KEY_HASH; } if (@hasDecl(@This(), "CACHE_READ_CALLBACK")) { _ = CACHE_READ_CALLBACK; } if (@hasDecl(@This(), "CACHE_DESTROY_CALLBACK")) { _ = CACHE_DESTROY_CALLBACK; } if (@hasDecl(@This(), "CACHE_ACCESS_CHECK")) { _ = CACHE_ACCESS_CHECK; } if (@hasDecl(@This(), "PFE_EXPORT_FUNC")) { _ = PFE_EXPORT_FUNC; } if (@hasDecl(@This(), "PFE_IMPORT_FUNC")) { _ = PFE_IMPORT_FUNC; } if (@hasDecl(@This(), "LPPROGRESS_ROUTINE")) { _ = LPPROGRESS_ROUTINE; } if (@hasDecl(@This(), "PCOPYFILE2_PROGRESS_ROUTINE")) { _ = PCOPYFILE2_PROGRESS_ROUTINE; } @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_system.zig
// TODO: // - If subtle-encoding[1] creates a constant-time implemention, copy that. // - Make en/decoders for segwit addresses? // - The decoder should tell you where in source the error occured. // Though I'd rather wait until https://github.com/ziglang/zig/issues/2647 // is implemented (if it ever is). // // [1]: https://github.com/iqlusioninc/crates/tree/main/subtle-encoding //! A encoder/decoder for Bech32 strings, as specified by BIP 173[^1]. //! This implementation is not constant-time, and may leak information due to //! the use of lookup tables. Replacement by a constant-time solution is a //! long-term desideratum. //! //! A Bech32 string is 90 US-ASCII characters long and consists of four parts: //! //! 1. The human readable part (HRP): 1-83 characters in the range [33-126]. //! This is required, and is copied verbatim at the start. //! 2. The seperator: "1". This character can appear in the HRP, so the last one //! found is used when decoding. //! 3. The data, expanded to a sequence of 5-bit values and encoded using the //! Bech32 charset. This is optional, meaning that the checksum only //! validates the HRP. //! 4. The checksum, a 30-bit integer expanded to six 5-bit values and encoded. //! //! Verifiying that a string is valid for the data it holds is done by //! iteratively computing the checksum using polynomial arithetic for each byte //! in the HRP (twice) and data. The checksum should be equal to 1 at the end, //! which is what it's starting value was. A more thorough explanation of //! how this works can be found under `doc/bech32-polymod.tex`. //! //! Using this package is simple: //! //! ```zig //! const Bech32 = @import("bech32.zig").Bech32; //! ⋮ //! // Encoding //! const hrp = "ziglang" //! const data = [_]u8{ 0xde, 0xad, 0xbe, 0xef }; //! var buf: [Bech32.max_string_size]u8 = undefined; //! //! const str = Bech32.standard.Encoder.encode(&buf, hrp, data); //! // Decoding //! var data_buf[Bech32.max_data_size]u8; //! const res = try Bech32.standard.Decoder.decode(&data_buf, str); //! print("HRP: {s}\nData: {s}", .{res.hrp, std.fmt.fmtSliceHexLower(res.data)}); //! ``` //! //! Implementations are required to output all lowercase strings, and for //! uppercase transformations to be done externally. For convience, the Encoder //! can do this for you if you set the `uppercase` flag at compile time. //! //! [^1]: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki const std = @import("std"); const assert = std.debug.assert; const testing = std.testing; /// TooLong /// : source exceeds the 90 character limit. /// /// MixedCase /// : Both lower and uppercase characters were found in source. /// /// NoSeperator /// : The seperator "1" wasn't found in source. /// /// BadChar /// : A character in the string is outside the valid range. /// /// HRPEmpty, HRPTooLong /// : The HRP provided is empty, or larger than max_hrp_size. /// /// ChecksumEmpty /// : The six checksum digits at the end weren't found. /// /// Invalid /// : The checksum did not equal 1 at the end of decoding. pub const Error = error{ TooLong, MixedCase, NoSeperator, BadChar, HRPEmpty, HRPTooLong, InvalidPadding, ChecksumEmpty, Invalid, }; pub const bech32_charset = "qpzry9x8gf2tvdw0s3jn54khce6mua7l".*; pub const max_string_size = 90; /// Assuming no data. pub const max_hrp_size = max_string_size - 1 - 6; /// Assuming one-char HRP. pub const max_data_len = max_string_size - 1 - 1 - 6; pub const max_data_size = calcReduction(max_data_len); /// Standard Bech32 codecs, lowercase encoded strings. pub const standard = struct { pub const Encoder = Bech32Encoder(bech32_charset, false); pub const Decoder = Bech32Decoder(bech32_charset); }; /// Standard Bech32 codecs, uppercase encoded strings. pub const standard_uppercase = struct { pub const Encoder = Bech32Encoder(bech32_charset, true); pub const Decoder = Bech32Decoder(bech32_charset); }; /// Calculates the space needed for expanding `data` to a sequence of u5s, /// plus a padding bit if neeeded. pub inline fn calcExpansion(len: usize) usize { var size: usize = len * 8; return @divTrunc(size, 5) + @boolToInt(@rem(size, 5) > 0); } /// The inverse of ::calcExpansion pub inline fn calcReduction(len: usize) usize { return @divTrunc(len * 5, 8); } const Polymod = struct { const generator = [5]u30{ 0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3 }; val: u30 = 1, inline fn step(self: *Polymod, value: u8) void { const bitset = self.val >> 25; self.val = (self.val & std.math.maxInt(u25)) << 5; self.val ^= value; inline for (generator) |g, i| { if (bitset >> @truncate(u5, i) & 1 != 0) self.val ^= g; } } inline fn finish(self: *Polymod) void { self.val ^= 1; } }; pub fn Bech32Encoder(set: [32]u8, uppercase: bool) type { return struct { const charset = if (!uppercase) set else blk: { var buf: [32]u8 = undefined; for (buf) |*c, i| c.* = std.ascii.toUpper(set[i]); break :blk buf; }; const transform = if (!uppercase) std.ascii.toLower else std.ascii.toUpper; /// Calculates the space needed for the HRP and the data expansion. pub inline fn calcSize(hrp: []const u8, data: []const u8) usize { assert(hrp.len > 0 and hrp.len <= max_hrp_size); assert(data.len <= max_data_size); const result = hrp.len + 1 + calcExpansion(data.len) + 6; assert(result <= max_string_size); return result; } pub fn eightToFive(dest: []u5, source: []const u8) []const u5 { var acc: u12 = 0; var acc_len: u4 = 0; var i: usize = 0; for (source) |c| { acc = acc << 8 | c; acc_len += 8; while (acc_len >= 5) : (i += 1) { acc_len -= 5; dest[i] = @truncate(u5, acc >> acc_len); } } if (acc_len > 0) { dest[i] = @truncate(u5, acc << 5 - acc_len); i += 1; } return dest[0..i]; } /// Encodes the HRP and data into a Bech32 string and stores the result /// in dest. The function contains a couple assertions that the caller /// should be aware of. The first are limit checks: /// /// - That the HRP doesn't exceed ::max_hrp_size. /// - That the expansion of data doesn't excede max_data_size. See /// ::calcExpansion for how this is done. /// - That the full string doesn't exceed 90 chars. See /// ::calcSize to compute this yourself. /// - That dest is large enough to hold the full string. /// /// Finally, the HRP is checked so that it doesn't contain invalid or /// mixed-case chars. pub fn encode(dest: []u8, hrp: []const u8, data: []const u8) []const u8 { assert(dest.len >= calcSize(hrp, data)); var polymod = Polymod{}; var upper = false; var lower = false; for (hrp) |c, i| { assert(c >= 33 and c <= 126); var lc = c; switch (c) { 'A'...'Z' => { upper = true; lc |= 0b00100000; }, 'a'...'z' => lower = true, else => {}, } polymod.step(lc >> 5); dest[i] = c; } assert(!(upper and lower)); polymod.step(0); var i: usize = 0; while (i < hrp.len) : (i += 1) { polymod.step(dest[i] & 31); dest[i] = transform(dest[i]); } dest[i] = '1'; i += 1; var expanded: [max_data_len]u5 = undefined; const exp = eightToFive(&expanded, data); for (exp) |c| { polymod.step(c); dest[i] = charset[c]; i += 1; } for ([_]u0{0} ** 6) |_| polymod.step(0); polymod.finish(); for ([6]u5{ 0, 1, 2, 3, 4, 5 }) |n| { const shift = 5 * (5 - n); dest[i] = charset[@truncate(u5, polymod.val >> shift)]; i += 1; } return dest[0..i]; } }; } pub const Result = struct { hrp: []const u8, data: []const u8 }; pub fn Bech32Decoder(set: [32]u8) type { return struct { const reverse_charset = blk: { var buf = [_]?u5{null} ** 256; for (set) |c, i| { buf[c] = i; buf[std.ascii.toUpper(c)] = i; } break :blk buf; }; pub fn calcSizeForSlice(source: []const u8) Error!usize { if (source.len > max_string_size) return error.TooLong; const sep = std.mem.lastIndexOfScalar(u8, source, '1') orelse return error.NoSeperator; if (sep == 0) return error.HRPEmpty; if (sep > max_hrp_size) return error.HRPTooLong; const data = if (source.len - (sep + 1) < 6) return error.ChecksumEmpty else source[sep + 1 .. source.len - 6]; return calcReduction(data.len); } pub fn fiveToEight(dest: []u8, source: []const u5) Error![]const u8 { var acc: u12 = 0; var acc_len: u4 = 0; var i: usize = 0; for (source) |c| { acc = acc << 5 | c; acc_len += 5; while (acc_len >= 8) : (i += 1) { acc_len -= 8; dest[i] = @truncate(u8, acc >> acc_len); } } if (acc_len > 5 or @truncate(u8, acc << 8 - acc_len) != 0) return error.InvalidPadding; return dest[0..i]; } /// Decodes and validates the Bech32 string `source`, and writes any /// data found to to `dest`. The returned Result has two members: /// /// - `hrp`, which is a slice of `source` /// - `data`, which is a slice of `dest`. pub fn decode(dest: []u8, source: []const u8) Error!Result { assert(dest.len >= try calcSizeForSlice(source)); const sep = std.mem.lastIndexOfScalar(u8, source, '1') orelse unreachable; const hrp = source[0..sep]; const data = source[sep + 1 .. source.len - 6]; const checksum = source[source.len - 6 ..]; var pmod_buf: [max_hrp_size]u8 = undefined; var res = Result{ .hrp = hrp, .data = &[0]u8{} }; var polymod = Polymod{}; var upper = false; var lower = false; for (hrp) |c, i| { var lc = c; switch (c) { 0...32, 127...255 => return error.BadChar, 'A'...'Z' => { upper = true; lc |= 0b00100000; }, 'a'...'z' => lower = true, else => {}, } polymod.step(lc >> 5); pmod_buf[i] = c; } if (upper and lower) return error.MixedCase; polymod.step(0); for (pmod_buf[0..hrp.len]) |c| polymod.step(c & 31); var convert_buf: [max_data_len]u5 = undefined; for (data) |c, i| { if (std.ascii.isUpper(c)) upper = true; if (std.ascii.isLower(c)) lower = true; const rev = reverse_charset[c] orelse return error.BadChar; polymod.step(rev); convert_buf[i] = rev; } if (upper and lower) return error.MixedCase; res.data = try fiveToEight(dest, convert_buf[0..data.len]); for (checksum) |c| { if (std.ascii.isUpper(c)) upper = true; if (std.ascii.isLower(c)) lower = true; const rev = reverse_charset[c] orelse return error.BadChar; polymod.step(rev); } if (upper and lower) return error.MixedCase; if (polymod.val != 1) return error.Invalid; return res; } }; } test "bech32 test vectors" { var lower_buf: [max_string_size]u8 = undefined; var data_buf: [max_data_size]u8 = undefined; var encoded_buf: [max_string_size]u8 = undefined; for (good_strings) |str| { var lower = std.ascii.lowerString(&lower_buf, str); const res = standard.Decoder.decode(&data_buf, str) catch |err| std.debug.panic("Expected string to be valid: {s} {s}\n", .{ str, @errorName(err) }); const enc = standard.Encoder.encode(&encoded_buf, res.hrp, res.data); try std.testing.expectEqualStrings(lower, enc); const pos = std.mem.lastIndexOfScalar(u8, lower, '1') orelse unreachable; lower[pos + 1] = 'z'; try std.testing.expectError(error.Invalid, standard.Decoder.decode(&data_buf, lower)); } for (bad_strings) |i| try testing.expectError(i.err, standard.Decoder.decode(&data_buf, i.str)); } const good_strings = [_][]const u8{ "A12UEL5L", "a12uel5l", "an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs", "11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", "split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", }; const Bad = struct { str: []const u8, err: anyerror }; fn new(str: []const u8, err: anyerror) Bad { return Bad{ .str = str, .err = err }; } const bad_strings = [_]Bad{ // Invalid checksum new("split1checkupstagehandshakeupstreamerranterredcaperred2y9e2w", error.Invalid), new("split1checkupstagehandshakeupstreamerranterredcaperred2y9e2w", error.Invalid), // Invalid character (space) and (DEL) in hrp new("s lit1checkupstagehandshakeupstreamerranterredcaperredp8hs2p", error.BadChar), new("spl\x7ft1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", error.BadChar), // Invalid character (o) in data part new("split1cheo2y9e2w", error.BadChar), // Short checksum. new("split1a2y9w", error.ChecksumEmpty), // Empty hrp new("1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", error.HRPEmpty), // Too long new("11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", error.TooLong), // Mixed case HRP, data and checksum. new("Foo1999999", error.MixedCase), new("foo1qQzzzzzz", error.MixedCase), new("foo1qzzzzzZ", error.MixedCase), // BIP 173 invalid vectors. new("\x201nwldj5", error.BadChar), new("an84characterslonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1569pvx", error.TooLong), new("pzry9x0s0muk", error.NoSeperator), new("1pzry9x0s0muk", error.HRPEmpty), new("x1b4n0q5v", error.BadChar), new("li1dgmt3", error.ChecksumEmpty), new("de1lg7wt\xff", error.BadChar), // checksum calculated with uppercase form of HRP. new("A1G7SGD8", error.Invalid), new("10a06t8", error.HRPEmpty), new("1qzzfhee", error.HRPEmpty), };
bech32.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const data = @embedFile("data/day20.txt"); const EntriesList = std.ArrayList(Record); const dim = 10; const pitch = 11; const Record = struct { id: u32, data: *const [dim][pitch]u8, fn top(grid: Record, o: Orientation) EdgeIterator { return switch (o) { .Top => .{ .pos = 0, .stride = 1, .grid = grid }, .Right => .{ .pos = dim-1, .stride = pitch, .grid = grid }, .Bottom => .{ .pos = dim * pitch - 2, .stride = -1, .grid = grid }, .Left => .{ .pos = pitch * (dim-1), .stride = -pitch, .grid = grid }, .FTop => .{ .pos = dim-1, .stride = -1, .grid = grid }, .FLeft => .{ .pos = 0, .stride = pitch, .grid = grid }, .FBottom => .{ .pos = pitch * (dim-1), .stride = 1, .grid = grid }, .FRight => .{ .pos = dim * pitch - 2, .stride = -pitch, .grid = grid }, }; } fn right(grid: Record, o: Orientation) EdgeIterator { return grid.top(o.clockwise(1)); } fn bottom(grid: Record, o: Orientation) EdgeIterator { return grid.top(o.clockwise(2)); } fn left(grid: Record, o: Orientation) EdgeIterator { return grid.top(o.clockwise(3)); } fn row(grid: Record, o: Orientation, idx: i32) EdgeIterator { var iter = grid.top(o); switch (o) { .Top, .FTop => iter.pos += idx * pitch, .Right, .FRight => iter.pos -= idx, .Bottom, .FBottom => iter.pos -= idx * pitch, .Left, .FLeft => iter.pos += idx, } return iter; } }; pub fn main() !void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); const ally = &arena.allocator; var grids = std.mem.split(data, "\n\n"); var entries = EntriesList.init(ally); try entries.ensureCapacity(400); var result: usize = 0; while (grids.next()) |gridStr| { if (gridStr.len == 0) continue; var parts = std.mem.split(gridStr, "\n"); var line = parts.next().?; var tok = line[5..]; tok = tok[0..tok.len-1]; const id = std.fmt.parseUnsigned(u32, tok, 10) catch unreachable; var grid = parts.rest(); var ptr = @ptrCast(*const[dim][pitch]u8, grid.ptr); try entries.append(.{ .id = id, .data = ptr, }); } const num = entries.items.len; var config = Config.init(entries.items, ally); findConfig(&config); var tl = config.tiles[config.order[0].tile].id; var tr = config.tiles[config.order[config.width-1].tile].id; var bl = config.tiles[config.order[num - config.width].tile].id; var br = config.tiles[config.order[num - 1].tile].id; var height = @divExact(num, config.width); var y: usize = 0; while (y < height) : (y += 1) { var r: i32 = 0; while (r < dim) : (r += 1) { var x: usize = 0; while (x < config.width) : (x += 1) { var idx = y * config.width + x; var rowit = config.tiles[config.order[idx].tile].row(config.order[idx].orientation, r); var d: i32 = 0; while (d < dim) : (d += 1) { print("{c}", .{rowit.at(d)}); } print(" ", .{}); } print("\n", .{}); } print("\n", .{}); } var buf_width = config.width * (dim - 2); var buf_height = height * (dim - 2); var buffer = try ally.alloc(u8, buf_height * (buf_width + 1)); var buf_pos: usize = 0; y = 0; while (y < height) : (y += 1) { var r: i32 = 1; while (r < dim-1) : (r += 1) { var x: usize = 0; while (x < config.width) : (x += 1) { var idx = y * config.width + x; var rowit = config.tiles[config.order[idx].tile].row(config.order[idx].orientation, r); var d: i32 = 1; while (d < dim-1) : (d += 1) { buffer[buf_pos] = rowit.at(d); buf_pos += 1; } } buffer[buf_pos] = '\n'; buf_pos += 1; } } assert(buf_pos == buffer.len); print("\n\ncombined:\n{}\n", .{buffer}); const d0 = Buffer.fromString( \\..................#. \\#....##....##....### \\.#..#..#..#..#..#... \\ ); const d1 = Buffer.fromString( \\ # \\### ## ## # \\ # # # # # # \\ ); const d2 = Buffer.fromString( \\ # # # # # # \\# ## ## ### \\ # \\ ); const d3 = Buffer.fromString( \\ # # # # # # \\### ## ## # \\ # \\ ); const d4 = Buffer.fromString( \\ # \\## \\ # \\ # \\ \\ \\ # \\ # \\ # \\ # \\ \\ \\ # \\ # \\ # \\ # \\ \\ \\ # \\ # \\ ); const d5 = Buffer.fromString( \\ # \\ # \\ \\ \\ # \\ # \\ # \\ # \\ \\ \\ # \\ # \\ # \\ # \\ \\ \\ # \\ # \\## \\ # \\ ); const d6 = Buffer.fromString( \\ # \\ ## \\ # \\# \\ \\ \\# \\ # \\ # \\# \\ \\ \\# \\ # \\ # \\# \\ \\ \\# \\ # \\ ); const d7 = Buffer.fromString( \\ # \\# \\ \\ \\# \\ # \\ # \\# \\ \\ \\# \\ # \\ # \\# \\ \\ \\# \\ # \\ ## \\ # \\ ); const b = Buffer.fromString(buffer); const c0 = countInstances(b, d0); const c1 = countInstances(b, d1); const c2 = countInstances(b, d2); const c3 = countInstances(b, d3); const c4 = countInstances(b, d4); const c5 = countInstances(b, d5); const c6 = countInstances(b, d6); const c7 = countInstances(b, d7); print("Result: {}\n", .{@as(u64, tl) * tr * bl * br}); print("dragons:\n{}\n", .{buffer}); print("roughness: {}\n", .{std.mem.count(u8, buffer, "#")}); } const Buffer = struct { pitch: usize, width: usize, height: usize, buffer: [*]const u8, pub fn fromString(str: []const u8) Buffer { var width = std.mem.indexOfScalar(u8, str, '\n').?; return .{ .pitch = width + 1, .width = width, .height = @divExact(str.len, width+1), .buffer = str.ptr, }; } pub fn at(self: Buffer, x: usize, y: usize) u8 { assert(x < self.width); assert(y < self.height); return self.buffer[y * self.pitch + x]; } pub fn set(self: Buffer, x: usize, y: usize, val: u8) void { var ptr: [*]u8 = @intToPtr([*]u8, @ptrToInt(self.buffer)); ptr[y * self.pitch + x] = val; } }; fn countInstances(haystack: Buffer, needle: Buffer) usize { print("searching {}x{}\n{}\n", .{needle.width, needle.height, needle.buffer[0..needle.pitch * needle.height]}); var y: usize = 0; while (y < haystack.height - needle.height) : (y += 1) { var x: usize = 0; position: while (x < haystack.width - needle.width) : (x += 1) { var oy: usize = 0; while (oy < needle.height) : (oy += 1) { var ox: usize = 0; while (ox < needle.width) : (ox += 1) { if (needle.at(ox, oy) == '#') { if (haystack.at(x + ox, y + oy) != '#' and haystack.at(x + ox, y + oy) != 'O') { continue :position; } } } } oy = 0; while (oy < needle.height) : (oy += 1) { var ox: usize = 0; while (ox < needle.width) : (ox += 1) { if (needle.at(ox, oy) == '#') { haystack.set(x + ox, y + oy, 'O'); } } } } } return 0; } const Orientation = enum { Top, Right, Bottom, Left, FTop, FLeft, FBottom, FRight, pub fn clockwise(self: Orientation, amt: u2) Orientation { const int = @enumToInt(self); const rotated = ((int +% amt) & 3) | (int & 4); return @intToEnum(Orientation, rotated); } const values = [_]Orientation{ .Top, .Right, .Bottom, .Left, .FTop, .FLeft, .FBottom, .FRight, }; }; const EdgeIterator = struct { pos: i32, stride: i32, grid: Record, fn at(self: EdgeIterator, idx: i32) u8 { return @ptrCast([*]const u8, self.grid.data)[@intCast(usize, self.pos + self.stride * idx)]; } fn equals(self: EdgeIterator, other: EdgeIterator) bool { var i: i32 = 0; while (i < dim) : (i += 1) { if (self.at(i) != other.at(dim - 1 - i)) return false; } return true; } }; const TileConfig = struct { tile: u32, orientation: Orientation, }; const Config = struct { width: u32, tiles: []const Record, order: []TileConfig, used: []bool, pub fn init(tiles: []const Record, alloc: *std.mem.Allocator) Config { const order = alloc.alloc(TileConfig, tiles.len) catch unreachable; const used = alloc.alloc(bool, tiles.len) catch unreachable; std.mem.set(bool, used, false); return Config{ .width = undefined, .tiles = tiles, .order = order, .used = used, }; } }; fn findConfig(config: *Config) void { var w: u32 = 2; while (w < config.tiles.len) : (w += 1) { if (config.tiles.len % w == 0) { config.width = w; findConfigRecursive(config, 0) catch return; } } unreachable; } fn findConfigRecursive(config: *Config, index: usize) error{Found}!void { if (index >= config.tiles.len) return error.Found; for (config.used) |*v, i| { if (!v.*) { v.* = true; for (Orientation.values) |o| { if (index % config.width == 0 or config.tiles[i].left(o).equals(config.tiles[config.order[index-1].tile].right(config.order[index-1].orientation))) { if (index < config.width or config.tiles[i].top(o).equals(config.tiles[config.order[index-config.width].tile].bottom(config.order[index-config.width].orientation))) { config.order[index] = .{ .tile = @intCast(u32, i), .orientation = o, }; try findConfigRecursive(config, index + 1); } } } v.* = false; } } }
src/day20.zig
const std = @import("std"); const zp = @import("zplay"); const dig = zp.deps.dig; const fontawesome = dig.fontawesome; var regular_font: *dig.Font = undefined; var solid_font: *dig.Font = undefined; const codepoints = [_][:0]const u8{ fontawesome.ICON_FA_AD, fontawesome.ICON_FA_ADDRESS_BOOK, fontawesome.ICON_FA_ADDRESS_CARD, fontawesome.ICON_FA_ADJUST, fontawesome.ICON_FA_AIR_FRESHENER, fontawesome.ICON_FA_ALIGN_CENTER, fontawesome.ICON_FA_ALIGN_JUSTIFY, fontawesome.ICON_FA_ALIGN_LEFT, fontawesome.ICON_FA_ALIGN_RIGHT, fontawesome.ICON_FA_ALLERGIES, fontawesome.ICON_FA_AMBULANCE, fontawesome.ICON_FA_AMERICAN_SIGN_LANGUAGE_INTERPRETING, fontawesome.ICON_FA_ANCHOR, fontawesome.ICON_FA_ANGLE_DOUBLE_DOWN, fontawesome.ICON_FA_ANGLE_DOUBLE_LEFT, fontawesome.ICON_FA_ANGLE_DOUBLE_RIGHT, fontawesome.ICON_FA_ANGLE_DOUBLE_UP, fontawesome.ICON_FA_ANGLE_DOWN, fontawesome.ICON_FA_ANGLE_LEFT, fontawesome.ICON_FA_ANGLE_RIGHT, fontawesome.ICON_FA_ANGLE_UP, fontawesome.ICON_FA_ANGRY, fontawesome.ICON_FA_ANKH, fontawesome.ICON_FA_APPLE_ALT, fontawesome.ICON_FA_ARCHIVE, fontawesome.ICON_FA_ARCHWAY, fontawesome.ICON_FA_ARROW_ALT_CIRCLE_DOWN, fontawesome.ICON_FA_ARROW_ALT_CIRCLE_LEFT, fontawesome.ICON_FA_ARROW_ALT_CIRCLE_RIGHT, fontawesome.ICON_FA_ARROW_ALT_CIRCLE_UP, fontawesome.ICON_FA_ARROW_CIRCLE_DOWN, fontawesome.ICON_FA_ARROW_CIRCLE_LEFT, fontawesome.ICON_FA_ARROW_CIRCLE_RIGHT, fontawesome.ICON_FA_ARROW_CIRCLE_UP, fontawesome.ICON_FA_ARROW_DOWN, fontawesome.ICON_FA_ARROW_LEFT, fontawesome.ICON_FA_ARROW_RIGHT, fontawesome.ICON_FA_ARROW_UP, fontawesome.ICON_FA_ARROWS_ALT, fontawesome.ICON_FA_ARROWS_ALT_H, fontawesome.ICON_FA_ARROWS_ALT_V, fontawesome.ICON_FA_ASSISTIVE_LISTENING_SYSTEMS, fontawesome.ICON_FA_ASTERISK, fontawesome.ICON_FA_AT, fontawesome.ICON_FA_ATLAS, fontawesome.ICON_FA_ATOM, fontawesome.ICON_FA_AUDIO_DESCRIPTION, fontawesome.ICON_FA_AWARD, fontawesome.ICON_FA_BABY, fontawesome.ICON_FA_BABY_CARRIAGE, fontawesome.ICON_FA_BACKSPACE, fontawesome.ICON_FA_BACKWARD, fontawesome.ICON_FA_BACON, fontawesome.ICON_FA_BACTERIA, fontawesome.ICON_FA_BACTERIUM, fontawesome.ICON_FA_BAHAI, fontawesome.ICON_FA_BALANCE_SCALE, fontawesome.ICON_FA_BALANCE_SCALE_LEFT, fontawesome.ICON_FA_BALANCE_SCALE_RIGHT, fontawesome.ICON_FA_BAN, fontawesome.ICON_FA_BAND_AID, fontawesome.ICON_FA_BARCODE, fontawesome.ICON_FA_BARS, fontawesome.ICON_FA_BASEBALL_BALL, fontawesome.ICON_FA_BASKETBALL_BALL, fontawesome.ICON_FA_BATH, fontawesome.ICON_FA_BATTERY_EMPTY, fontawesome.ICON_FA_BATTERY_FULL, fontawesome.ICON_FA_BATTERY_HALF, fontawesome.ICON_FA_BATTERY_QUARTER, fontawesome.ICON_FA_BATTERY_THREE_QUARTERS, fontawesome.ICON_FA_BED, fontawesome.ICON_FA_BEER, fontawesome.ICON_FA_BELL, fontawesome.ICON_FA_BELL_SLASH, fontawesome.ICON_FA_BEZIER_CURVE, fontawesome.ICON_FA_BIBLE, fontawesome.ICON_FA_BICYCLE, fontawesome.ICON_FA_BIKING, fontawesome.ICON_FA_BINOCULARS, fontawesome.ICON_FA_BIOHAZARD, fontawesome.ICON_FA_BIRTHDAY_CAKE, fontawesome.ICON_FA_BLENDER, fontawesome.ICON_FA_BLENDER_PHONE, fontawesome.ICON_FA_BLIND, fontawesome.ICON_FA_BLOG, fontawesome.ICON_FA_BOLD, fontawesome.ICON_FA_BOLT, fontawesome.ICON_FA_BOMB, fontawesome.ICON_FA_BONE, fontawesome.ICON_FA_BONG, fontawesome.ICON_FA_BOOK, fontawesome.ICON_FA_BOOK_DEAD, fontawesome.ICON_FA_BOOK_MEDICAL, fontawesome.ICON_FA_BOOK_OPEN, fontawesome.ICON_FA_BOOK_READER, fontawesome.ICON_FA_BOOKMARK, fontawesome.ICON_FA_BORDER_ALL, fontawesome.ICON_FA_BORDER_NONE, fontawesome.ICON_FA_BORDER_STYLE, fontawesome.ICON_FA_BOWLING_BALL, fontawesome.ICON_FA_BOX, fontawesome.ICON_FA_BOX_OPEN, fontawesome.ICON_FA_BOX_TISSUE, fontawesome.ICON_FA_BOXES, fontawesome.ICON_FA_BRAILLE, fontawesome.ICON_FA_BRAIN, fontawesome.ICON_FA_BREAD_SLICE, fontawesome.ICON_FA_BRIEFCASE, fontawesome.ICON_FA_BRIEFCASE_MEDICAL, fontawesome.ICON_FA_BROADCAST_TOWER, fontawesome.ICON_FA_BROOM, fontawesome.ICON_FA_BRUSH, fontawesome.ICON_FA_BUG, fontawesome.ICON_FA_BUILDING, fontawesome.ICON_FA_BULLHORN, fontawesome.ICON_FA_BULLSEYE, fontawesome.ICON_FA_BURN, fontawesome.ICON_FA_BUS, fontawesome.ICON_FA_BUS_ALT, fontawesome.ICON_FA_BUSINESS_TIME, fontawesome.ICON_FA_CALCULATOR, fontawesome.ICON_FA_CALENDAR, fontawesome.ICON_FA_CALENDAR_ALT, fontawesome.ICON_FA_CALENDAR_CHECK, fontawesome.ICON_FA_CALENDAR_DAY, fontawesome.ICON_FA_CALENDAR_MINUS, fontawesome.ICON_FA_CALENDAR_PLUS, fontawesome.ICON_FA_CALENDAR_TIMES, fontawesome.ICON_FA_CALENDAR_WEEK, fontawesome.ICON_FA_CAMERA, fontawesome.ICON_FA_CAMERA_RETRO, fontawesome.ICON_FA_CAMPGROUND, fontawesome.ICON_FA_CANDY_CANE, fontawesome.ICON_FA_CANNABIS, fontawesome.ICON_FA_CAPSULES, fontawesome.ICON_FA_CAR, fontawesome.ICON_FA_CAR_ALT, fontawesome.ICON_FA_CAR_BATTERY, fontawesome.ICON_FA_CAR_CRASH, fontawesome.ICON_FA_CAR_SIDE, fontawesome.ICON_FA_CARAVAN, fontawesome.ICON_FA_CARET_DOWN, fontawesome.ICON_FA_CARET_LEFT, fontawesome.ICON_FA_CARET_RIGHT, fontawesome.ICON_FA_CARET_SQUARE_DOWN, fontawesome.ICON_FA_CARET_SQUARE_LEFT, fontawesome.ICON_FA_CARET_SQUARE_RIGHT, fontawesome.ICON_FA_CARET_SQUARE_UP, fontawesome.ICON_FA_CARET_UP, fontawesome.ICON_FA_CARROT, fontawesome.ICON_FA_CART_ARROW_DOWN, fontawesome.ICON_FA_CART_PLUS, fontawesome.ICON_FA_CASH_REGISTER, fontawesome.ICON_FA_CAT, fontawesome.ICON_FA_CERTIFICATE, fontawesome.ICON_FA_CHAIR, fontawesome.ICON_FA_CHALKBOARD, fontawesome.ICON_FA_CHALKBOARD_TEACHER, fontawesome.ICON_FA_CHARGING_STATION, fontawesome.ICON_FA_CHART_AREA, fontawesome.ICON_FA_CHART_BAR, fontawesome.ICON_FA_CHART_LINE, fontawesome.ICON_FA_CHART_PIE, fontawesome.ICON_FA_CHECK, fontawesome.ICON_FA_CHECK_CIRCLE, fontawesome.ICON_FA_CHECK_DOUBLE, fontawesome.ICON_FA_CHECK_SQUARE, fontawesome.ICON_FA_CHEESE, fontawesome.ICON_FA_CHESS, fontawesome.ICON_FA_CHESS_BISHOP, fontawesome.ICON_FA_CHESS_BOARD, fontawesome.ICON_FA_CHESS_KING, fontawesome.ICON_FA_CHESS_KNIGHT, fontawesome.ICON_FA_CHESS_PAWN, fontawesome.ICON_FA_CHESS_QUEEN, fontawesome.ICON_FA_CHESS_ROOK, fontawesome.ICON_FA_CHEVRON_CIRCLE_DOWN, fontawesome.ICON_FA_CHEVRON_CIRCLE_LEFT, fontawesome.ICON_FA_CHEVRON_CIRCLE_RIGHT, fontawesome.ICON_FA_CHEVRON_CIRCLE_UP, fontawesome.ICON_FA_CHEVRON_DOWN, fontawesome.ICON_FA_CHEVRON_LEFT, fontawesome.ICON_FA_CHEVRON_RIGHT, fontawesome.ICON_FA_CHEVRON_UP, fontawesome.ICON_FA_CHILD, fontawesome.ICON_FA_CHURCH, fontawesome.ICON_FA_CIRCLE, fontawesome.ICON_FA_CIRCLE_NOTCH, fontawesome.ICON_FA_CITY, fontawesome.ICON_FA_CLINIC_MEDICAL, fontawesome.ICON_FA_CLIPBOARD, fontawesome.ICON_FA_CLIPBOARD_CHECK, fontawesome.ICON_FA_CLIPBOARD_LIST, fontawesome.ICON_FA_CLOCK, fontawesome.ICON_FA_CLONE, fontawesome.ICON_FA_CLOSED_CAPTIONING, fontawesome.ICON_FA_CLOUD, fontawesome.ICON_FA_CLOUD_DOWNLOAD_ALT, fontawesome.ICON_FA_CLOUD_MEATBALL, fontawesome.ICON_FA_CLOUD_MOON, fontawesome.ICON_FA_CLOUD_MOON_RAIN, fontawesome.ICON_FA_CLOUD_RAIN, fontawesome.ICON_FA_CLOUD_SHOWERS_HEAVY, fontawesome.ICON_FA_CLOUD_SUN, fontawesome.ICON_FA_CLOUD_SUN_RAIN, fontawesome.ICON_FA_CLOUD_UPLOAD_ALT, fontawesome.ICON_FA_COCKTAIL, fontawesome.ICON_FA_CODE, fontawesome.ICON_FA_CODE_BRANCH, fontawesome.ICON_FA_COFFEE, fontawesome.ICON_FA_COG, fontawesome.ICON_FA_COGS, fontawesome.ICON_FA_COINS, fontawesome.ICON_FA_COLUMNS, fontawesome.ICON_FA_COMMENT, fontawesome.ICON_FA_COMMENT_ALT, fontawesome.ICON_FA_COMMENT_DOLLAR, fontawesome.ICON_FA_COMMENT_DOTS, fontawesome.ICON_FA_COMMENT_MEDICAL, fontawesome.ICON_FA_COMMENT_SLASH, fontawesome.ICON_FA_COMMENTS, fontawesome.ICON_FA_COMMENTS_DOLLAR, fontawesome.ICON_FA_COMPACT_DISC, fontawesome.ICON_FA_COMPASS, fontawesome.ICON_FA_COMPRESS, fontawesome.ICON_FA_COMPRESS_ALT, fontawesome.ICON_FA_COMPRESS_ARROWS_ALT, fontawesome.ICON_FA_CONCIERGE_BELL, fontawesome.ICON_FA_COOKIE, fontawesome.ICON_FA_COOKIE_BITE, fontawesome.ICON_FA_COPY, fontawesome.ICON_FA_COPYRIGHT, fontawesome.ICON_FA_COUCH, fontawesome.ICON_FA_CREDIT_CARD, fontawesome.ICON_FA_CROP, fontawesome.ICON_FA_CROP_ALT, fontawesome.ICON_FA_CROSS, fontawesome.ICON_FA_CROSSHAIRS, fontawesome.ICON_FA_CROW, fontawesome.ICON_FA_CROWN, fontawesome.ICON_FA_CRUTCH, fontawesome.ICON_FA_CUBE, fontawesome.ICON_FA_CUBES, fontawesome.ICON_FA_CUT, fontawesome.ICON_FA_DATABASE, fontawesome.ICON_FA_DEAF, fontawesome.ICON_FA_DEMOCRAT, fontawesome.ICON_FA_DESKTOP, fontawesome.ICON_FA_DHARMACHAKRA, fontawesome.ICON_FA_DIAGNOSES, fontawesome.ICON_FA_DICE, fontawesome.ICON_FA_DICE_D20, fontawesome.ICON_FA_DICE_D6, fontawesome.ICON_FA_DICE_FIVE, fontawesome.ICON_FA_DICE_FOUR, fontawesome.ICON_FA_DICE_ONE, fontawesome.ICON_FA_DICE_SIX, fontawesome.ICON_FA_DICE_THREE, fontawesome.ICON_FA_DICE_TWO, fontawesome.ICON_FA_DIGITAL_TACHOGRAPH, fontawesome.ICON_FA_DIRECTIONS, fontawesome.ICON_FA_DISEASE, fontawesome.ICON_FA_DIVIDE, fontawesome.ICON_FA_DIZZY, fontawesome.ICON_FA_DNA, fontawesome.ICON_FA_DOG, fontawesome.ICON_FA_DOLLAR_SIGN, fontawesome.ICON_FA_DOLLY, fontawesome.ICON_FA_DOLLY_FLATBED, fontawesome.ICON_FA_DONATE, fontawesome.ICON_FA_DOOR_CLOSED, fontawesome.ICON_FA_DOOR_OPEN, fontawesome.ICON_FA_DOT_CIRCLE, fontawesome.ICON_FA_DOVE, fontawesome.ICON_FA_DOWNLOAD, fontawesome.ICON_FA_DRAFTING_COMPASS, fontawesome.ICON_FA_DRAGON, fontawesome.ICON_FA_DRAW_POLYGON, fontawesome.ICON_FA_DRUM, fontawesome.ICON_FA_DRUM_STEELPAN, fontawesome.ICON_FA_DRUMSTICK_BITE, fontawesome.ICON_FA_DUMBBELL, fontawesome.ICON_FA_DUMPSTER, fontawesome.ICON_FA_DUMPSTER_FIRE, fontawesome.ICON_FA_DUNGEON, fontawesome.ICON_FA_EDIT, fontawesome.ICON_FA_EGG, fontawesome.ICON_FA_EJECT, fontawesome.ICON_FA_ELLIPSIS_H, fontawesome.ICON_FA_ELLIPSIS_V, fontawesome.ICON_FA_ENVELOPE, fontawesome.ICON_FA_ENVELOPE_OPEN, fontawesome.ICON_FA_ENVELOPE_OPEN_TEXT, fontawesome.ICON_FA_ENVELOPE_SQUARE, fontawesome.ICON_FA_EQUALS, fontawesome.ICON_FA_ERASER, fontawesome.ICON_FA_ETHERNET, fontawesome.ICON_FA_EURO_SIGN, fontawesome.ICON_FA_EXCHANGE_ALT, fontawesome.ICON_FA_EXCLAMATION, fontawesome.ICON_FA_EXCLAMATION_CIRCLE, fontawesome.ICON_FA_EXCLAMATION_TRIANGLE, fontawesome.ICON_FA_EXPAND, fontawesome.ICON_FA_EXPAND_ALT, fontawesome.ICON_FA_EXPAND_ARROWS_ALT, fontawesome.ICON_FA_EXTERNAL_LINK_ALT, fontawesome.ICON_FA_EXTERNAL_LINK_SQUARE_ALT, fontawesome.ICON_FA_EYE, fontawesome.ICON_FA_EYE_DROPPER, fontawesome.ICON_FA_EYE_SLASH, fontawesome.ICON_FA_FAN, fontawesome.ICON_FA_FAST_BACKWARD, fontawesome.ICON_FA_FAST_FORWARD, fontawesome.ICON_FA_FAUCET, fontawesome.ICON_FA_FAX, fontawesome.ICON_FA_FEATHER, fontawesome.ICON_FA_FEATHER_ALT, fontawesome.ICON_FA_FEMALE, fontawesome.ICON_FA_FIGHTER_JET, fontawesome.ICON_FA_FILE, fontawesome.ICON_FA_FILE_ALT, fontawesome.ICON_FA_FILE_ARCHIVE, fontawesome.ICON_FA_FILE_AUDIO, fontawesome.ICON_FA_FILE_CODE, fontawesome.ICON_FA_FILE_CONTRACT, fontawesome.ICON_FA_FILE_CSV, fontawesome.ICON_FA_FILE_DOWNLOAD, fontawesome.ICON_FA_FILE_EXCEL, fontawesome.ICON_FA_FILE_EXPORT, fontawesome.ICON_FA_FILE_IMAGE, fontawesome.ICON_FA_FILE_IMPORT, fontawesome.ICON_FA_FILE_INVOICE, fontawesome.ICON_FA_FILE_INVOICE_DOLLAR, fontawesome.ICON_FA_FILE_MEDICAL, fontawesome.ICON_FA_FILE_MEDICAL_ALT, fontawesome.ICON_FA_FILE_PDF, fontawesome.ICON_FA_FILE_POWERPOINT, fontawesome.ICON_FA_FILE_PRESCRIPTION, fontawesome.ICON_FA_FILE_SIGNATURE, fontawesome.ICON_FA_FILE_UPLOAD, fontawesome.ICON_FA_FILE_VIDEO, fontawesome.ICON_FA_FILE_WORD, fontawesome.ICON_FA_FILL, fontawesome.ICON_FA_FILL_DRIP, fontawesome.ICON_FA_FILM, fontawesome.ICON_FA_FILTER, fontawesome.ICON_FA_FINGERPRINT, fontawesome.ICON_FA_FIRE, fontawesome.ICON_FA_FIRE_ALT, fontawesome.ICON_FA_FIRE_EXTINGUISHER, fontawesome.ICON_FA_FIRST_AID, fontawesome.ICON_FA_FISH, fontawesome.ICON_FA_FIST_RAISED, fontawesome.ICON_FA_FLAG, fontawesome.ICON_FA_FLAG_CHECKERED, fontawesome.ICON_FA_FLAG_USA, fontawesome.ICON_FA_FLASK, fontawesome.ICON_FA_FLUSHED, fontawesome.ICON_FA_FOLDER, fontawesome.ICON_FA_FOLDER_MINUS, fontawesome.ICON_FA_FOLDER_OPEN, fontawesome.ICON_FA_FOLDER_PLUS, fontawesome.ICON_FA_FONT, fontawesome.ICON_FA_FONT_AWESOME_LOGO_FULL, fontawesome.ICON_FA_FOOTBALL_BALL, fontawesome.ICON_FA_FORWARD, fontawesome.ICON_FA_FROG, fontawesome.ICON_FA_FROWN, fontawesome.ICON_FA_FROWN_OPEN, fontawesome.ICON_FA_FUNNEL_DOLLAR, fontawesome.ICON_FA_FUTBOL, fontawesome.ICON_FA_GAMEPAD, fontawesome.ICON_FA_GAS_PUMP, fontawesome.ICON_FA_GAVEL, fontawesome.ICON_FA_GEM, fontawesome.ICON_FA_GENDERLESS, fontawesome.ICON_FA_GHOST, fontawesome.ICON_FA_GIFT, fontawesome.ICON_FA_GIFTS, fontawesome.ICON_FA_GLASS_CHEERS, fontawesome.ICON_FA_GLASS_MARTINI, fontawesome.ICON_FA_GLASS_MARTINI_ALT, fontawesome.ICON_FA_GLASS_WHISKEY, fontawesome.ICON_FA_GLASSES, fontawesome.ICON_FA_GLOBE, fontawesome.ICON_FA_GLOBE_AFRICA, fontawesome.ICON_FA_GLOBE_AMERICAS, fontawesome.ICON_FA_GLOBE_ASIA, fontawesome.ICON_FA_GLOBE_EUROPE, fontawesome.ICON_FA_GOLF_BALL, fontawesome.ICON_FA_GOPURAM, fontawesome.ICON_FA_GRADUATION_CAP, fontawesome.ICON_FA_GREATER_THAN, fontawesome.ICON_FA_GREATER_THAN_EQUAL, fontawesome.ICON_FA_GRIMACE, fontawesome.ICON_FA_GRIN, fontawesome.ICON_FA_GRIN_ALT, fontawesome.ICON_FA_GRIN_BEAM, fontawesome.ICON_FA_GRIN_BEAM_SWEAT, fontawesome.ICON_FA_GRIN_HEARTS, fontawesome.ICON_FA_GRIN_SQUINT, fontawesome.ICON_FA_GRIN_SQUINT_TEARS, fontawesome.ICON_FA_GRIN_STARS, fontawesome.ICON_FA_GRIN_TEARS, fontawesome.ICON_FA_GRIN_TONGUE, fontawesome.ICON_FA_GRIN_TONGUE_SQUINT, fontawesome.ICON_FA_GRIN_TONGUE_WINK, fontawesome.ICON_FA_GRIN_WINK, fontawesome.ICON_FA_GRIP_HORIZONTAL, fontawesome.ICON_FA_GRIP_LINES, fontawesome.ICON_FA_GRIP_LINES_VERTICAL, fontawesome.ICON_FA_GRIP_VERTICAL, fontawesome.ICON_FA_GUITAR, fontawesome.ICON_FA_H_SQUARE, fontawesome.ICON_FA_HAMBURGER, fontawesome.ICON_FA_HAMMER, fontawesome.ICON_FA_HAMSA, fontawesome.ICON_FA_HAND_HOLDING, fontawesome.ICON_FA_HAND_HOLDING_HEART, fontawesome.ICON_FA_HAND_HOLDING_MEDICAL, fontawesome.ICON_FA_HAND_HOLDING_USD, fontawesome.ICON_FA_HAND_HOLDING_WATER, fontawesome.ICON_FA_HAND_LIZARD, fontawesome.ICON_FA_HAND_MIDDLE_FINGER, fontawesome.ICON_FA_HAND_PAPER, fontawesome.ICON_FA_HAND_PEACE, fontawesome.ICON_FA_HAND_POINT_DOWN, fontawesome.ICON_FA_HAND_POINT_LEFT, fontawesome.ICON_FA_HAND_POINT_RIGHT, fontawesome.ICON_FA_HAND_POINT_UP, fontawesome.ICON_FA_HAND_POINTER, fontawesome.ICON_FA_HAND_ROCK, fontawesome.ICON_FA_HAND_SCISSORS, fontawesome.ICON_FA_HAND_SPARKLES, fontawesome.ICON_FA_HAND_SPOCK, fontawesome.ICON_FA_HANDS, fontawesome.ICON_FA_HANDS_HELPING, fontawesome.ICON_FA_HANDS_WASH, fontawesome.ICON_FA_HANDSHAKE, fontawesome.ICON_FA_HANDSHAKE_ALT_SLASH, fontawesome.ICON_FA_HANDSHAKE_SLASH, fontawesome.ICON_FA_HANUKIAH, fontawesome.ICON_FA_HARD_HAT, fontawesome.ICON_FA_HASHTAG, fontawesome.ICON_FA_HAT_COWBOY, fontawesome.ICON_FA_HAT_COWBOY_SIDE, fontawesome.ICON_FA_HAT_WIZARD, fontawesome.ICON_FA_HDD, fontawesome.ICON_FA_HEAD_SIDE_COUGH, fontawesome.ICON_FA_HEAD_SIDE_COUGH_SLASH, fontawesome.ICON_FA_HEAD_SIDE_MASK, fontawesome.ICON_FA_HEAD_SIDE_VIRUS, fontawesome.ICON_FA_HEADING, fontawesome.ICON_FA_HEADPHONES, fontawesome.ICON_FA_HEADPHONES_ALT, fontawesome.ICON_FA_HEADSET, fontawesome.ICON_FA_HEART, fontawesome.ICON_FA_HEART_BROKEN, fontawesome.ICON_FA_HEARTBEAT, fontawesome.ICON_FA_HELICOPTER, fontawesome.ICON_FA_HIGHLIGHTER, fontawesome.ICON_FA_HIKING, fontawesome.ICON_FA_HIPPO, fontawesome.ICON_FA_HISTORY, fontawesome.ICON_FA_HOCKEY_PUCK, fontawesome.ICON_FA_HOLLY_BERRY, fontawesome.ICON_FA_HOME, fontawesome.ICON_FA_HORSE, fontawesome.ICON_FA_HORSE_HEAD, fontawesome.ICON_FA_HOSPITAL, fontawesome.ICON_FA_HOSPITAL_ALT, fontawesome.ICON_FA_HOSPITAL_SYMBOL, fontawesome.ICON_FA_HOSPITAL_USER, fontawesome.ICON_FA_HOT_TUB, fontawesome.ICON_FA_HOTDOG, fontawesome.ICON_FA_HOTEL, fontawesome.ICON_FA_HOURGLASS, fontawesome.ICON_FA_HOURGLASS_END, fontawesome.ICON_FA_HOURGLASS_HALF, fontawesome.ICON_FA_HOURGLASS_START, fontawesome.ICON_FA_HOUSE_DAMAGE, fontawesome.ICON_FA_HOUSE_USER, fontawesome.ICON_FA_HRYVNIA, fontawesome.ICON_FA_I_CURSOR, fontawesome.ICON_FA_ICE_CREAM, fontawesome.ICON_FA_ICICLES, fontawesome.ICON_FA_ICONS, fontawesome.ICON_FA_ID_BADGE, fontawesome.ICON_FA_ID_CARD, fontawesome.ICON_FA_ID_CARD_ALT, fontawesome.ICON_FA_IGLOO, fontawesome.ICON_FA_IMAGE, fontawesome.ICON_FA_IMAGES, fontawesome.ICON_FA_INBOX, fontawesome.ICON_FA_INDENT, fontawesome.ICON_FA_INDUSTRY, fontawesome.ICON_FA_INFINITY, fontawesome.ICON_FA_INFO, fontawesome.ICON_FA_INFO_CIRCLE, fontawesome.ICON_FA_ITALIC, fontawesome.ICON_FA_JEDI, fontawesome.ICON_FA_JOINT, fontawesome.ICON_FA_JOURNAL_WHILLS, fontawesome.ICON_FA_KAABA, fontawesome.ICON_FA_KEY, fontawesome.ICON_FA_KEYBOARD, fontawesome.ICON_FA_KHANDA, fontawesome.ICON_FA_KISS, fontawesome.ICON_FA_KISS_BEAM, fontawesome.ICON_FA_KISS_WINK_HEART, fontawesome.ICON_FA_KIWI_BIRD, fontawesome.ICON_FA_LANDMARK, fontawesome.ICON_FA_LANGUAGE, fontawesome.ICON_FA_LAPTOP, fontawesome.ICON_FA_LAPTOP_CODE, fontawesome.ICON_FA_LAPTOP_HOUSE, fontawesome.ICON_FA_LAPTOP_MEDICAL, fontawesome.ICON_FA_LAUGH, fontawesome.ICON_FA_LAUGH_BEAM, fontawesome.ICON_FA_LAUGH_SQUINT, fontawesome.ICON_FA_LAUGH_WINK, fontawesome.ICON_FA_LAYER_GROUP, fontawesome.ICON_FA_LEAF, fontawesome.ICON_FA_LEMON, fontawesome.ICON_FA_LESS_THAN, fontawesome.ICON_FA_LESS_THAN_EQUAL, fontawesome.ICON_FA_LEVEL_DOWN_ALT, fontawesome.ICON_FA_LEVEL_UP_ALT, fontawesome.ICON_FA_LIFE_RING, fontawesome.ICON_FA_LIGHTBULB, fontawesome.ICON_FA_LINK, fontawesome.ICON_FA_LIRA_SIGN, fontawesome.ICON_FA_LIST, fontawesome.ICON_FA_LIST_ALT, fontawesome.ICON_FA_LIST_OL, fontawesome.ICON_FA_LIST_UL, fontawesome.ICON_FA_LOCATION_ARROW, fontawesome.ICON_FA_LOCK, fontawesome.ICON_FA_LOCK_OPEN, fontawesome.ICON_FA_LONG_ARROW_ALT_DOWN, fontawesome.ICON_FA_LONG_ARROW_ALT_LEFT, fontawesome.ICON_FA_LONG_ARROW_ALT_RIGHT, fontawesome.ICON_FA_LONG_ARROW_ALT_UP, fontawesome.ICON_FA_LOW_VISION, fontawesome.ICON_FA_LUGGAGE_CART, fontawesome.ICON_FA_LUNGS, fontawesome.ICON_FA_LUNGS_VIRUS, fontawesome.ICON_FA_MAGIC, fontawesome.ICON_FA_MAGNET, fontawesome.ICON_FA_MAIL_BULK, fontawesome.ICON_FA_MALE, fontawesome.ICON_FA_MAP, fontawesome.ICON_FA_MAP_MARKED, fontawesome.ICON_FA_MAP_MARKED_ALT, fontawesome.ICON_FA_MAP_MARKER, fontawesome.ICON_FA_MAP_MARKER_ALT, fontawesome.ICON_FA_MAP_PIN, fontawesome.ICON_FA_MAP_SIGNS, fontawesome.ICON_FA_MARKER, fontawesome.ICON_FA_MARS, fontawesome.ICON_FA_MARS_DOUBLE, fontawesome.ICON_FA_MARS_STROKE, fontawesome.ICON_FA_MARS_STROKE_H, fontawesome.ICON_FA_MARS_STROKE_V, fontawesome.ICON_FA_MASK, fontawesome.ICON_FA_MEDAL, fontawesome.ICON_FA_MEDKIT, fontawesome.ICON_FA_MEH, fontawesome.ICON_FA_MEH_BLANK, fontawesome.ICON_FA_MEH_ROLLING_EYES, fontawesome.ICON_FA_MEMORY, fontawesome.ICON_FA_MENORAH, fontawesome.ICON_FA_MERCURY, fontawesome.ICON_FA_METEOR, fontawesome.ICON_FA_MICROCHIP, fontawesome.ICON_FA_MICROPHONE, fontawesome.ICON_FA_MICROPHONE_ALT, fontawesome.ICON_FA_MICROPHONE_ALT_SLASH, fontawesome.ICON_FA_MICROPHONE_SLASH, fontawesome.ICON_FA_MICROSCOPE, fontawesome.ICON_FA_MINUS, fontawesome.ICON_FA_MINUS_CIRCLE, fontawesome.ICON_FA_MINUS_SQUARE, fontawesome.ICON_FA_MITTEN, fontawesome.ICON_FA_MOBILE, fontawesome.ICON_FA_MOBILE_ALT, fontawesome.ICON_FA_MONEY_BILL, fontawesome.ICON_FA_MONEY_BILL_ALT, fontawesome.ICON_FA_MONEY_BILL_WAVE, fontawesome.ICON_FA_MONEY_BILL_WAVE_ALT, fontawesome.ICON_FA_MONEY_CHECK, fontawesome.ICON_FA_MONEY_CHECK_ALT, fontawesome.ICON_FA_MONUMENT, fontawesome.ICON_FA_MOON, fontawesome.ICON_FA_MORTAR_PESTLE, fontawesome.ICON_FA_MOSQUE, fontawesome.ICON_FA_MOTORCYCLE, fontawesome.ICON_FA_MOUNTAIN, fontawesome.ICON_FA_MOUSE, fontawesome.ICON_FA_MOUSE_POINTER, fontawesome.ICON_FA_MUG_HOT, fontawesome.ICON_FA_MUSIC, fontawesome.ICON_FA_NETWORK_WIRED, fontawesome.ICON_FA_NEUTER, fontawesome.ICON_FA_NEWSPAPER, fontawesome.ICON_FA_NOT_EQUAL, fontawesome.ICON_FA_NOTES_MEDICAL, fontawesome.ICON_FA_OBJECT_GROUP, fontawesome.ICON_FA_OBJECT_UNGROUP, fontawesome.ICON_FA_OIL_CAN, fontawesome.ICON_FA_OM, fontawesome.ICON_FA_OTTER, fontawesome.ICON_FA_OUTDENT, fontawesome.ICON_FA_PAGER, fontawesome.ICON_FA_PAINT_BRUSH, fontawesome.ICON_FA_PAINT_ROLLER, fontawesome.ICON_FA_PALETTE, fontawesome.ICON_FA_PALLET, fontawesome.ICON_FA_PAPER_PLANE, fontawesome.ICON_FA_PAPERCLIP, fontawesome.ICON_FA_PARACHUTE_BOX, fontawesome.ICON_FA_PARAGRAPH, fontawesome.ICON_FA_PARKING, fontawesome.ICON_FA_PASSPORT, fontawesome.ICON_FA_PASTAFARIANISM, fontawesome.ICON_FA_PASTE, fontawesome.ICON_FA_PAUSE, fontawesome.ICON_FA_PAUSE_CIRCLE, fontawesome.ICON_FA_PAW, fontawesome.ICON_FA_PEACE, fontawesome.ICON_FA_PEN, fontawesome.ICON_FA_PEN_ALT, fontawesome.ICON_FA_PEN_FANCY, fontawesome.ICON_FA_PEN_NIB, fontawesome.ICON_FA_PEN_SQUARE, fontawesome.ICON_FA_PENCIL_ALT, fontawesome.ICON_FA_PENCIL_RULER, fontawesome.ICON_FA_PEOPLE_ARROWS, fontawesome.ICON_FA_PEOPLE_CARRY, fontawesome.ICON_FA_PEPPER_HOT, fontawesome.ICON_FA_PERCENT, fontawesome.ICON_FA_PERCENTAGE, fontawesome.ICON_FA_PERSON_BOOTH, fontawesome.ICON_FA_PHONE, fontawesome.ICON_FA_PHONE_ALT, fontawesome.ICON_FA_PHONE_SLASH, fontawesome.ICON_FA_PHONE_SQUARE, fontawesome.ICON_FA_PHONE_SQUARE_ALT, fontawesome.ICON_FA_PHONE_VOLUME, fontawesome.ICON_FA_PHOTO_VIDEO, fontawesome.ICON_FA_PIGGY_BANK, fontawesome.ICON_FA_PILLS, fontawesome.ICON_FA_PIZZA_SLICE, fontawesome.ICON_FA_PLACE_OF_WORSHIP, fontawesome.ICON_FA_PLANE, fontawesome.ICON_FA_PLANE_ARRIVAL, fontawesome.ICON_FA_PLANE_DEPARTURE, fontawesome.ICON_FA_PLANE_SLASH, fontawesome.ICON_FA_PLAY, fontawesome.ICON_FA_PLAY_CIRCLE, fontawesome.ICON_FA_PLUG, fontawesome.ICON_FA_PLUS, fontawesome.ICON_FA_PLUS_CIRCLE, fontawesome.ICON_FA_PLUS_SQUARE, fontawesome.ICON_FA_PODCAST, fontawesome.ICON_FA_POLL, fontawesome.ICON_FA_POLL_H, fontawesome.ICON_FA_POO, fontawesome.ICON_FA_POO_STORM, fontawesome.ICON_FA_POOP, fontawesome.ICON_FA_PORTRAIT, fontawesome.ICON_FA_POUND_SIGN, fontawesome.ICON_FA_POWER_OFF, fontawesome.ICON_FA_PRAY, fontawesome.ICON_FA_PRAYING_HANDS, fontawesome.ICON_FA_PRESCRIPTION, fontawesome.ICON_FA_PRESCRIPTION_BOTTLE, fontawesome.ICON_FA_PRESCRIPTION_BOTTLE_ALT, fontawesome.ICON_FA_PRINT, fontawesome.ICON_FA_PROCEDURES, fontawesome.ICON_FA_PROJECT_DIAGRAM, fontawesome.ICON_FA_PUMP_MEDICAL, fontawesome.ICON_FA_PUMP_SOAP, fontawesome.ICON_FA_PUZZLE_PIECE, fontawesome.ICON_FA_QRCODE, fontawesome.ICON_FA_QUESTION, fontawesome.ICON_FA_QUESTION_CIRCLE, fontawesome.ICON_FA_QUIDDITCH, fontawesome.ICON_FA_QUOTE_LEFT, fontawesome.ICON_FA_QUOTE_RIGHT, fontawesome.ICON_FA_QURAN, fontawesome.ICON_FA_RADIATION, fontawesome.ICON_FA_RADIATION_ALT, fontawesome.ICON_FA_RAINBOW, fontawesome.ICON_FA_RANDOM, fontawesome.ICON_FA_RECEIPT, fontawesome.ICON_FA_RECORD_VINYL, fontawesome.ICON_FA_RECYCLE, fontawesome.ICON_FA_REDO, fontawesome.ICON_FA_REDO_ALT, fontawesome.ICON_FA_REGISTERED, fontawesome.ICON_FA_REMOVE_FORMAT, fontawesome.ICON_FA_REPLY, fontawesome.ICON_FA_REPLY_ALL, fontawesome.ICON_FA_REPUBLICAN, fontawesome.ICON_FA_RESTROOM, fontawesome.ICON_FA_RETWEET, fontawesome.ICON_FA_RIBBON, fontawesome.ICON_FA_RING, fontawesome.ICON_FA_ROAD, fontawesome.ICON_FA_ROBOT, fontawesome.ICON_FA_ROCKET, fontawesome.ICON_FA_ROUTE, fontawesome.ICON_FA_RSS, fontawesome.ICON_FA_RSS_SQUARE, fontawesome.ICON_FA_RUBLE_SIGN, fontawesome.ICON_FA_RULER, fontawesome.ICON_FA_RULER_COMBINED, fontawesome.ICON_FA_RULER_HORIZONTAL, fontawesome.ICON_FA_RULER_VERTICAL, fontawesome.ICON_FA_RUNNING, fontawesome.ICON_FA_RUPEE_SIGN, fontawesome.ICON_FA_SAD_CRY, fontawesome.ICON_FA_SAD_TEAR, fontawesome.ICON_FA_SATELLITE, fontawesome.ICON_FA_SATELLITE_DISH, fontawesome.ICON_FA_SAVE, fontawesome.ICON_FA_SCHOOL, fontawesome.ICON_FA_SCREWDRIVER, fontawesome.ICON_FA_SCROLL, fontawesome.ICON_FA_SD_CARD, fontawesome.ICON_FA_SEARCH, fontawesome.ICON_FA_SEARCH_DOLLAR, fontawesome.ICON_FA_SEARCH_LOCATION, fontawesome.ICON_FA_SEARCH_MINUS, fontawesome.ICON_FA_SEARCH_PLUS, fontawesome.ICON_FA_SEEDLING, fontawesome.ICON_FA_SERVER, fontawesome.ICON_FA_SHAPES, fontawesome.ICON_FA_SHARE, fontawesome.ICON_FA_SHARE_ALT, fontawesome.ICON_FA_SHARE_ALT_SQUARE, fontawesome.ICON_FA_SHARE_SQUARE, fontawesome.ICON_FA_SHEKEL_SIGN, fontawesome.ICON_FA_SHIELD_ALT, fontawesome.ICON_FA_SHIELD_VIRUS, fontawesome.ICON_FA_SHIP, fontawesome.ICON_FA_SHIPPING_FAST, fontawesome.ICON_FA_SHOE_PRINTS, fontawesome.ICON_FA_SHOPPING_BAG, fontawesome.ICON_FA_SHOPPING_BASKET, fontawesome.ICON_FA_SHOPPING_CART, fontawesome.ICON_FA_SHOWER, fontawesome.ICON_FA_SHUTTLE_VAN, fontawesome.ICON_FA_SIGN, fontawesome.ICON_FA_SIGN_IN_ALT, fontawesome.ICON_FA_SIGN_LANGUAGE, fontawesome.ICON_FA_SIGN_OUT_ALT, fontawesome.ICON_FA_SIGNAL, fontawesome.ICON_FA_SIGNATURE, fontawesome.ICON_FA_SIM_CARD, fontawesome.ICON_FA_SINK, fontawesome.ICON_FA_SITEMAP, fontawesome.ICON_FA_SKATING, fontawesome.ICON_FA_SKIING, fontawesome.ICON_FA_SKIING_NORDIC, fontawesome.ICON_FA_SKULL, fontawesome.ICON_FA_SKULL_CROSSBONES, fontawesome.ICON_FA_SLASH, fontawesome.ICON_FA_SLEIGH, fontawesome.ICON_FA_SLIDERS_H, fontawesome.ICON_FA_SMILE, fontawesome.ICON_FA_SMILE_BEAM, fontawesome.ICON_FA_SMILE_WINK, fontawesome.ICON_FA_SMOG, fontawesome.ICON_FA_SMOKING, fontawesome.ICON_FA_SMOKING_BAN, fontawesome.ICON_FA_SMS, fontawesome.ICON_FA_SNOWBOARDING, fontawesome.ICON_FA_SNOWFLAKE, fontawesome.ICON_FA_SNOWMAN, fontawesome.ICON_FA_SNOWPLOW, fontawesome.ICON_FA_SOAP, fontawesome.ICON_FA_SOCKS, fontawesome.ICON_FA_SOLAR_PANEL, fontawesome.ICON_FA_SORT, fontawesome.ICON_FA_SORT_ALPHA_DOWN, fontawesome.ICON_FA_SORT_ALPHA_DOWN_ALT, fontawesome.ICON_FA_SORT_ALPHA_UP, fontawesome.ICON_FA_SORT_ALPHA_UP_ALT, fontawesome.ICON_FA_SORT_AMOUNT_DOWN, fontawesome.ICON_FA_SORT_AMOUNT_DOWN_ALT, fontawesome.ICON_FA_SORT_AMOUNT_UP, fontawesome.ICON_FA_SORT_AMOUNT_UP_ALT, fontawesome.ICON_FA_SORT_DOWN, fontawesome.ICON_FA_SORT_NUMERIC_DOWN, fontawesome.ICON_FA_SORT_NUMERIC_DOWN_ALT, fontawesome.ICON_FA_SORT_NUMERIC_UP, fontawesome.ICON_FA_SORT_NUMERIC_UP_ALT, fontawesome.ICON_FA_SORT_UP, fontawesome.ICON_FA_SPA, fontawesome.ICON_FA_SPACE_SHUTTLE, fontawesome.ICON_FA_SPELL_CHECK, fontawesome.ICON_FA_SPIDER, fontawesome.ICON_FA_SPINNER, fontawesome.ICON_FA_SPLOTCH, fontawesome.ICON_FA_SPRAY_CAN, fontawesome.ICON_FA_SQUARE, fontawesome.ICON_FA_SQUARE_FULL, fontawesome.ICON_FA_SQUARE_ROOT_ALT, fontawesome.ICON_FA_STAMP, fontawesome.ICON_FA_STAR, fontawesome.ICON_FA_STAR_AND_CRESCENT, fontawesome.ICON_FA_STAR_HALF, fontawesome.ICON_FA_STAR_HALF_ALT, fontawesome.ICON_FA_STAR_OF_DAVID, fontawesome.ICON_FA_STAR_OF_LIFE, fontawesome.ICON_FA_STEP_BACKWARD, fontawesome.ICON_FA_STEP_FORWARD, fontawesome.ICON_FA_STETHOSCOPE, fontawesome.ICON_FA_STICKY_NOTE, fontawesome.ICON_FA_STOP, fontawesome.ICON_FA_STOP_CIRCLE, fontawesome.ICON_FA_STOPWATCH, fontawesome.ICON_FA_STOPWATCH_20, fontawesome.ICON_FA_STORE, fontawesome.ICON_FA_STORE_ALT, fontawesome.ICON_FA_STORE_ALT_SLASH, fontawesome.ICON_FA_STORE_SLASH, fontawesome.ICON_FA_STREAM, fontawesome.ICON_FA_STREET_VIEW, fontawesome.ICON_FA_STRIKETHROUGH, fontawesome.ICON_FA_STROOPWAFEL, fontawesome.ICON_FA_SUBSCRIPT, fontawesome.ICON_FA_SUBWAY, fontawesome.ICON_FA_SUITCASE, fontawesome.ICON_FA_SUITCASE_ROLLING, fontawesome.ICON_FA_SUN, fontawesome.ICON_FA_SUPERSCRIPT, fontawesome.ICON_FA_SURPRISE, fontawesome.ICON_FA_SWATCHBOOK, fontawesome.ICON_FA_SWIMMER, fontawesome.ICON_FA_SWIMMING_POOL, fontawesome.ICON_FA_SYNAGOGUE, fontawesome.ICON_FA_SYNC, fontawesome.ICON_FA_SYNC_ALT, fontawesome.ICON_FA_SYRINGE, fontawesome.ICON_FA_TABLE, fontawesome.ICON_FA_TABLE_TENNIS, fontawesome.ICON_FA_TABLET, fontawesome.ICON_FA_TABLET_ALT, fontawesome.ICON_FA_TABLETS, fontawesome.ICON_FA_TACHOMETER_ALT, fontawesome.ICON_FA_TAG, fontawesome.ICON_FA_TAGS, fontawesome.ICON_FA_TAPE, fontawesome.ICON_FA_TASKS, fontawesome.ICON_FA_TAXI, fontawesome.ICON_FA_TEETH, fontawesome.ICON_FA_TEETH_OPEN, fontawesome.ICON_FA_TEMPERATURE_HIGH, fontawesome.ICON_FA_TEMPERATURE_LOW, fontawesome.ICON_FA_TENGE, fontawesome.ICON_FA_TERMINAL, fontawesome.ICON_FA_TEXT_HEIGHT, fontawesome.ICON_FA_TEXT_WIDTH, fontawesome.ICON_FA_TH, fontawesome.ICON_FA_TH_LARGE, fontawesome.ICON_FA_TH_LIST, fontawesome.ICON_FA_THEATER_MASKS, fontawesome.ICON_FA_THERMOMETER, fontawesome.ICON_FA_THERMOMETER_EMPTY, fontawesome.ICON_FA_THERMOMETER_FULL, fontawesome.ICON_FA_THERMOMETER_HALF, fontawesome.ICON_FA_THERMOMETER_QUARTER, fontawesome.ICON_FA_THERMOMETER_THREE_QUARTERS, fontawesome.ICON_FA_THUMBS_DOWN, fontawesome.ICON_FA_THUMBS_UP, fontawesome.ICON_FA_THUMBTACK, fontawesome.ICON_FA_TICKET_ALT, fontawesome.ICON_FA_TIMES, fontawesome.ICON_FA_TIMES_CIRCLE, fontawesome.ICON_FA_TINT, fontawesome.ICON_FA_TINT_SLASH, fontawesome.ICON_FA_TIRED, fontawesome.ICON_FA_TOGGLE_OFF, fontawesome.ICON_FA_TOGGLE_ON, fontawesome.ICON_FA_TOILET, fontawesome.ICON_FA_TOILET_PAPER, fontawesome.ICON_FA_TOILET_PAPER_SLASH, fontawesome.ICON_FA_TOOLBOX, fontawesome.ICON_FA_TOOLS, fontawesome.ICON_FA_TOOTH, fontawesome.ICON_FA_TORAH, fontawesome.ICON_FA_TORII_GATE, fontawesome.ICON_FA_TRACTOR, fontawesome.ICON_FA_TRADEMARK, fontawesome.ICON_FA_TRAFFIC_LIGHT, fontawesome.ICON_FA_TRAILER, fontawesome.ICON_FA_TRAIN, fontawesome.ICON_FA_TRAM, fontawesome.ICON_FA_TRANSGENDER, fontawesome.ICON_FA_TRANSGENDER_ALT, fontawesome.ICON_FA_TRASH, fontawesome.ICON_FA_TRASH_ALT, fontawesome.ICON_FA_TRASH_RESTORE, fontawesome.ICON_FA_TRASH_RESTORE_ALT, fontawesome.ICON_FA_TREE, fontawesome.ICON_FA_TROPHY, fontawesome.ICON_FA_TRUCK, fontawesome.ICON_FA_TRUCK_LOADING, fontawesome.ICON_FA_TRUCK_MONSTER, fontawesome.ICON_FA_TRUCK_MOVING, fontawesome.ICON_FA_TRUCK_PICKUP, fontawesome.ICON_FA_TSHIRT, fontawesome.ICON_FA_TTY, fontawesome.ICON_FA_TV, fontawesome.ICON_FA_UMBRELLA, fontawesome.ICON_FA_UMBRELLA_BEACH, fontawesome.ICON_FA_UNDERLINE, fontawesome.ICON_FA_UNDO, fontawesome.ICON_FA_UNDO_ALT, fontawesome.ICON_FA_UNIVERSAL_ACCESS, fontawesome.ICON_FA_UNIVERSITY, fontawesome.ICON_FA_UNLINK, fontawesome.ICON_FA_UNLOCK, fontawesome.ICON_FA_UNLOCK_ALT, fontawesome.ICON_FA_UPLOAD, fontawesome.ICON_FA_USER, fontawesome.ICON_FA_USER_ALT, fontawesome.ICON_FA_USER_ALT_SLASH, fontawesome.ICON_FA_USER_ASTRONAUT, fontawesome.ICON_FA_USER_CHECK, fontawesome.ICON_FA_USER_CIRCLE, fontawesome.ICON_FA_USER_CLOCK, fontawesome.ICON_FA_USER_COG, fontawesome.ICON_FA_USER_EDIT, fontawesome.ICON_FA_USER_FRIENDS, fontawesome.ICON_FA_USER_GRADUATE, fontawesome.ICON_FA_USER_INJURED, fontawesome.ICON_FA_USER_LOCK, fontawesome.ICON_FA_USER_MD, fontawesome.ICON_FA_USER_MINUS, fontawesome.ICON_FA_USER_NINJA, fontawesome.ICON_FA_USER_NURSE, fontawesome.ICON_FA_USER_PLUS, fontawesome.ICON_FA_USER_SECRET, fontawesome.ICON_FA_USER_SHIELD, fontawesome.ICON_FA_USER_SLASH, fontawesome.ICON_FA_USER_TAG, fontawesome.ICON_FA_USER_TIE, fontawesome.ICON_FA_USER_TIMES, fontawesome.ICON_FA_USERS, fontawesome.ICON_FA_USERS_COG, fontawesome.ICON_FA_USERS_SLASH, fontawesome.ICON_FA_UTENSIL_SPOON, fontawesome.ICON_FA_UTENSILS, fontawesome.ICON_FA_VECTOR_SQUARE, fontawesome.ICON_FA_VENUS, fontawesome.ICON_FA_VENUS_DOUBLE, fontawesome.ICON_FA_VENUS_MARS, fontawesome.ICON_FA_VEST, fontawesome.ICON_FA_VEST_PATCHES, fontawesome.ICON_FA_VIAL, fontawesome.ICON_FA_VIALS, fontawesome.ICON_FA_VIDEO, fontawesome.ICON_FA_VIDEO_SLASH, fontawesome.ICON_FA_VIHARA, fontawesome.ICON_FA_VIRUS, fontawesome.ICON_FA_VIRUS_SLASH, fontawesome.ICON_FA_VIRUSES, fontawesome.ICON_FA_VOICEMAIL, fontawesome.ICON_FA_VOLLEYBALL_BALL, fontawesome.ICON_FA_VOLUME_DOWN, fontawesome.ICON_FA_VOLUME_MUTE, fontawesome.ICON_FA_VOLUME_OFF, fontawesome.ICON_FA_VOLUME_UP, fontawesome.ICON_FA_VOTE_YEA, fontawesome.ICON_FA_VR_CARDBOARD, fontawesome.ICON_FA_WALKING, fontawesome.ICON_FA_WALLET, fontawesome.ICON_FA_WAREHOUSE, fontawesome.ICON_FA_WATER, fontawesome.ICON_FA_WAVE_SQUARE, fontawesome.ICON_FA_WEIGHT, fontawesome.ICON_FA_WEIGHT_HANGING, fontawesome.ICON_FA_WHEELCHAIR, fontawesome.ICON_FA_WIFI, fontawesome.ICON_FA_WIND, fontawesome.ICON_FA_WINDOW_CLOSE, fontawesome.ICON_FA_WINDOW_MAXIMIZE, fontawesome.ICON_FA_WINDOW_MINIMIZE, fontawesome.ICON_FA_WINDOW_RESTORE, fontawesome.ICON_FA_WINE_BOTTLE, fontawesome.ICON_FA_WINE_GLASS, fontawesome.ICON_FA_WINE_GLASS_ALT, fontawesome.ICON_FA_WON_SIGN, fontawesome.ICON_FA_WRENCH, fontawesome.ICON_FA_X_RAY, fontawesome.ICON_FA_YEN_SIGN, fontawesome.ICON_FA_YIN_YANG, }; const codepoint_names = [_][:0]const u8{ "AD", "ADDRESS_BOOK", "ADDRESS_CARD", "ADJUST", "AIR_FRESHENER", "ALIGN_CENTER", "ALIGN_JUSTIFY", "ALIGN_LEFT", "ALIGN_RIGHT", "ALLERGIES", "AMBULANCE", "AMERICAN_SIGN_LANGUAGE_INTERPRETING", "ANCHOR", "ANGLE_DOUBLE_DOWN", "ANGLE_DOUBLE_LEFT", "ANGLE_DOUBLE_RIGHT", "ANGLE_DOUBLE_UP", "ANGLE_DOWN", "ANGLE_LEFT", "ANGLE_RIGHT", "ANGLE_UP", "ANGRY", "ANKH", "APPLE_ALT", "ARCHIVE", "ARCHWAY", "ARROW_ALT_CIRCLE_DOWN", "ARROW_ALT_CIRCLE_LEFT", "ARROW_ALT_CIRCLE_RIGHT", "ARROW_ALT_CIRCLE_UP", "ARROW_CIRCLE_DOWN", "ARROW_CIRCLE_LEFT", "ARROW_CIRCLE_RIGHT", "ARROW_CIRCLE_UP", "ARROW_DOWN", "ARROW_LEFT", "ARROW_RIGHT", "ARROW_UP", "ARROWS_ALT", "ARROWS_ALT_H", "ARROWS_ALT_V", "ASSISTIVE_LISTENING_SYSTEMS", "ASTERISK", "AT", "ATLAS", "ATOM", "AUDIO_DESCRIPTION", "AWARD", "BABY", "BABY_CARRIAGE", "BACKSPACE", "BACKWARD", "BACON", "BACTERIA", "BACTERIUM", "BAHAI", "BALANCE_SCALE", "BALANCE_SCALE_LEFT", "BALANCE_SCALE_RIGHT", "BAN", "BAND_AID", "BARCODE", "BARS", "BASEBALL_BALL", "BASKETBALL_BALL", "BATH", "BATTERY_EMPTY", "BATTERY_FULL", "BATTERY_HALF", "BATTERY_QUARTER", "BATTERY_THREE_QUARTERS", "BED", "BEER", "BELL", "BELL_SLASH", "BEZIER_CURVE", "BIBLE", "BICYCLE", "BIKING", "BINOCULARS", "BIOHAZARD", "BIRTHDAY_CAKE", "BLENDER", "BLENDER_PHONE", "BLIND", "BLOG", "BOLD", "BOLT", "BOMB", "BONE", "BONG", "BOOK", "BOOK_DEAD", "BOOK_MEDICAL", "BOOK_OPEN", "BOOK_READER", "BOOKMARK", "BORDER_ALL", "BORDER_NONE", "BORDER_STYLE", "BOWLING_BALL", "BOX", "BOX_OPEN", "BOX_TISSUE", "BOXES", "BRAILLE", "BRAIN", "BREAD_SLICE", "BRIEFCASE", "BRIEFCASE_MEDICAL", "BROADCAST_TOWER", "BROOM", "BRUSH", "BUG", "BUILDING", "BULLHORN", "BULLSEYE", "BURN", "BUS", "BUS_ALT", "BUSINESS_TIME", "CALCULATOR", "CALENDAR", "CALENDAR_ALT", "CALENDAR_CHECK", "CALENDAR_DAY", "CALENDAR_MINUS", "CALENDAR_PLUS", "CALENDAR_TIMES", "CALENDAR_WEEK", "CAMERA", "CAMERA_RETRO", "CAMPGROUND", "CANDY_CANE", "CANNABIS", "CAPSULES", "CAR", "CAR_ALT", "CAR_BATTERY", "CAR_CRASH", "CAR_SIDE", "CARAVAN", "CARET_DOWN", "CARET_LEFT", "CARET_RIGHT", "CARET_SQUARE_DOWN", "CARET_SQUARE_LEFT", "CARET_SQUARE_RIGHT", "CARET_SQUARE_UP", "CARET_UP", "CARROT", "CART_ARROW_DOWN", "CART_PLUS", "CASH_REGISTER", "CAT", "CERTIFICATE", "CHAIR", "CHALKBOARD", "CHALKBOARD_TEACHER", "CHARGING_STATION", "CHART_AREA", "CHART_BAR", "CHART_LINE", "CHART_PIE", "CHECK", "CHECK_CIRCLE", "CHECK_DOUBLE", "CHECK_SQUARE", "CHEESE", "CHESS", "CHESS_BISHOP", "CHESS_BOARD", "CHESS_KING", "CHESS_KNIGHT", "CHESS_PAWN", "CHESS_QUEEN", "CHESS_ROOK", "CHEVRON_CIRCLE_DOWN", "CHEVRON_CIRCLE_LEFT", "CHEVRON_CIRCLE_RIGHT", "CHEVRON_CIRCLE_UP", "CHEVRON_DOWN", "CHEVRON_LEFT", "CHEVRON_RIGHT", "CHEVRON_UP", "CHILD", "CHURCH", "CIRCLE", "CIRCLE_NOTCH", "CITY", "CLINIC_MEDICAL", "CLIPBOARD", "CLIPBOARD_CHECK", "CLIPBOARD_LIST", "CLOCK", "CLONE", "CLOSED_CAPTIONING", "CLOUD", "CLOUD_DOWNLOAD_ALT", "CLOUD_MEATBALL", "CLOUD_MOON", "CLOUD_MOON_RAIN", "CLOUD_RAIN", "CLOUD_SHOWERS_HEAVY", "CLOUD_SUN", "CLOUD_SUN_RAIN", "CLOUD_UPLOAD_ALT", "COCKTAIL", "CODE", "CODE_BRANCH", "COFFEE", "COG", "COGS", "COINS", "COLUMNS", "COMMENT", "COMMENT_ALT", "COMMENT_DOLLAR", "COMMENT_DOTS", "COMMENT_MEDICAL", "COMMENT_SLASH", "COMMENTS", "COMMENTS_DOLLAR", "COMPACT_DISC", "COMPASS", "COMPRESS", "COMPRESS_ALT", "COMPRESS_ARROWS_ALT", "CONCIERGE_BELL", "COOKIE", "COOKIE_BITE", "COPY", "COPYRIGHT", "COUCH", "CREDIT_CARD", "CROP", "CROP_ALT", "CROSS", "CROSSHAIRS", "CROW", "CROWN", "CRUTCH", "CUBE", "CUBES", "CUT", "DATABASE", "DEAF", "DEMOCRAT", "DESKTOP", "DHARMACHAKRA", "DIAGNOSES", "DICE", "DICE_D20", "DICE_D6", "DICE_FIVE", "DICE_FOUR", "DICE_ONE", "DICE_SIX", "DICE_THREE", "DICE_TWO", "DIGITAL_TACHOGRAPH", "DIRECTIONS", "DISEASE", "DIVIDE", "DIZZY", "DNA", "DOG", "DOLLAR_SIGN", "DOLLY", "DOLLY_FLATBED", "DONATE", "DOOR_CLOSED", "DOOR_OPEN", "DOT_CIRCLE", "DOVE", "DOWNLOAD", "DRAFTING_COMPASS", "DRAGON", "DRAW_POLYGON", "DRUM", "DRUM_STEELPAN", "DRUMSTICK_BITE", "DUMBBELL", "DUMPSTER", "DUMPSTER_FIRE", "DUNGEON", "EDIT", "EGG", "EJECT", "ELLIPSIS_H", "ELLIPSIS_V", "ENVELOPE", "ENVELOPE_OPEN", "ENVELOPE_OPEN_TEXT", "ENVELOPE_SQUARE", "EQUALS", "ERASER", "ETHERNET", "EURO_SIGN", "EXCHANGE_ALT", "EXCLAMATION", "EXCLAMATION_CIRCLE", "EXCLAMATION_TRIANGLE", "EXPAND", "EXPAND_ALT", "EXPAND_ARROWS_ALT", "EXTERNAL_LINK_ALT", "EXTERNAL_LINK_SQUARE_ALT", "EYE", "EYE_DROPPER", "EYE_SLASH", "FAN", "FAST_BACKWARD", "FAST_FORWARD", "FAUCET", "FAX", "FEATHER", "FEATHER_ALT", "FEMALE", "FIGHTER_JET", "FILE", "FILE_ALT", "FILE_ARCHIVE", "FILE_AUDIO", "FILE_CODE", "FILE_CONTRACT", "FILE_CSV", "FILE_DOWNLOAD", "FILE_EXCEL", "FILE_EXPORT", "FILE_IMAGE", "FILE_IMPORT", "FILE_INVOICE", "FILE_INVOICE_DOLLAR", "FILE_MEDICAL", "FILE_MEDICAL_ALT", "FILE_PDF", "FILE_POWERPOINT", "FILE_PRESCRIPTION", "FILE_SIGNATURE", "FILE_UPLOAD", "FILE_VIDEO", "FILE_WORD", "FILL", "FILL_DRIP", "FILM", "FILTER", "FINGERPRINT", "FIRE", "FIRE_ALT", "FIRE_EXTINGUISHER", "FIRST_AID", "FISH", "FIST_RAISED", "FLAG", "FLAG_CHECKERED", "FLAG_USA", "FLASK", "FLUSHED", "FOLDER", "FOLDER_MINUS", "FOLDER_OPEN", "FOLDER_PLUS", "FONT", "FONT_AWESOME_LOGO_FULL", "FOOTBALL_BALL", "FORWARD", "FROG", "FROWN", "FROWN_OPEN", "FUNNEL_DOLLAR", "FUTBOL", "GAMEPAD", "GAS_PUMP", "GAVEL", "GEM", "GENDERLESS", "GHOST", "GIFT", "GIFTS", "GLASS_CHEERS", "GLASS_MARTINI", "GLASS_MARTINI_ALT", "GLASS_WHISKEY", "GLASSES", "GLOBE", "GLOBE_AFRICA", "GLOBE_AMERICAS", "GLOBE_ASIA", "GLOBE_EUROPE", "GOLF_BALL", "GOPURAM", "GRADUATION_CAP", "GREATER_THAN", "GREATER_THAN_EQUAL", "GRIMACE", "GRIN", "GRIN_ALT", "GRIN_BEAM", "GRIN_BEAM_SWEAT", "GRIN_HEARTS", "GRIN_SQUINT", "GRIN_SQUINT_TEARS", "GRIN_STARS", "GRIN_TEARS", "GRIN_TONGUE", "GRIN_TONGUE_SQUINT", "GRIN_TONGUE_WINK", "GRIN_WINK", "GRIP_HORIZONTAL", "GRIP_LINES", "GRIP_LINES_VERTICAL", "GRIP_VERTICAL", "GUITAR", "H_SQUARE", "HAMBURGER", "HAMMER", "HAMSA", "HAND_HOLDING", "HAND_HOLDING_HEART", "HAND_HOLDING_MEDICAL", "HAND_HOLDING_USD", "HAND_HOLDING_WATER", "HAND_LIZARD", "HAND_MIDDLE_FINGER", "HAND_PAPER", "HAND_PEACE", "HAND_POINT_DOWN", "HAND_POINT_LEFT", "HAND_POINT_RIGHT", "HAND_POINT_UP", "HAND_POINTER", "HAND_ROCK", "HAND_SCISSORS", "HAND_SPARKLES", "HAND_SPOCK", "HANDS", "HANDS_HELPING", "HANDS_WASH", "HANDSHAKE", "HANDSHAKE_ALT_SLASH", "HANDSHAKE_SLASH", "HANUKIAH", "HARD_HAT", "HASHTAG", "HAT_COWBOY", "HAT_COWBOY_SIDE", "HAT_WIZARD", "HDD", "HEAD_SIDE_COUGH", "HEAD_SIDE_COUGH_SLASH", "HEAD_SIDE_MASK", "HEAD_SIDE_VIRUS", "HEADING", "HEADPHONES", "HEADPHONES_ALT", "HEADSET", "HEART", "HEART_BROKEN", "HEARTBEAT", "HELICOPTER", "HIGHLIGHTER", "HIKING", "HIPPO", "HISTORY", "HOCKEY_PUCK", "HOLLY_BERRY", "HOME", "HORSE", "HORSE_HEAD", "HOSPITAL", "HOSPITAL_ALT", "HOSPITAL_SYMBOL", "HOSPITAL_USER", "HOT_TUB", "HOTDOG", "HOTEL", "HOURGLASS", "HOURGLASS_END", "HOURGLASS_HALF", "HOURGLASS_START", "HOUSE_DAMAGE", "HOUSE_USER", "HRYVNIA", "I_CURSOR", "ICE_CREAM", "ICICLES", "ICONS", "ID_BADGE", "ID_CARD", "ID_CARD_ALT", "IGLOO", "IMAGE", "IMAGES", "INBOX", "INDENT", "INDUSTRY", "INFINITY", "INFO", "INFO_CIRCLE", "ITALIC", "JEDI", "JOINT", "JOURNAL_WHILLS", "KAABA", "KEY", "KEYBOARD", "KHANDA", "KISS", "KISS_BEAM", "KISS_WINK_HEART", "KIWI_BIRD", "LANDMARK", "LANGUAGE", "LAPTOP", "LAPTOP_CODE", "LAPTOP_HOUSE", "LAPTOP_MEDICAL", "LAUGH", "LAUGH_BEAM", "LAUGH_SQUINT", "LAUGH_WINK", "LAYER_GROUP", "LEAF", "LEMON", "LESS_THAN", "LESS_THAN_EQUAL", "LEVEL_DOWN_ALT", "LEVEL_UP_ALT", "LIFE_RING", "LIGHTBULB", "LINK", "LIRA_SIGN", "LIST", "LIST_ALT", "LIST_OL", "LIST_UL", "LOCATION_ARROW", "LOCK", "LOCK_OPEN", "LONG_ARROW_ALT_DOWN", "LONG_ARROW_ALT_LEFT", "LONG_ARROW_ALT_RIGHT", "LONG_ARROW_ALT_UP", "LOW_VISION", "LUGGAGE_CART", "LUNGS", "LUNGS_VIRUS", "MAGIC", "MAGNET", "MAIL_BULK", "MALE", "MAP", "MAP_MARKED", "MAP_MARKED_ALT", "MAP_MARKER", "MAP_MARKER_ALT", "MAP_PIN", "MAP_SIGNS", "MARKER", "MARS", "MARS_DOUBLE", "MARS_STROKE", "MARS_STROKE_H", "MARS_STROKE_V", "MASK", "MEDAL", "MEDKIT", "MEH", "MEH_BLANK", "MEH_ROLLING_EYES", "MEMORY", "MENORAH", "MERCURY", "METEOR", "MICROCHIP", "MICROPHONE", "MICROPHONE_ALT", "MICROPHONE_ALT_SLASH", "MICROPHONE_SLASH", "MICROSCOPE", "MINUS", "MINUS_CIRCLE", "MINUS_SQUARE", "MITTEN", "MOBILE", "MOBILE_ALT", "MONEY_BILL", "MONEY_BILL_ALT", "MONEY_BILL_WAVE", "MONEY_BILL_WAVE_ALT", "MONEY_CHECK", "MONEY_CHECK_ALT", "MONUMENT", "MOON", "MORTAR_PESTLE", "MOSQUE", "MOTORCYCLE", "MOUNTAIN", "MOUSE", "MOUSE_POINTER", "MUG_HOT", "MUSIC", "NETWORK_WIRED", "NEUTER", "NEWSPAPER", "NOT_EQUAL", "NOTES_MEDICAL", "OBJECT_GROUP", "OBJECT_UNGROUP", "OIL_CAN", "OM", "OTTER", "OUTDENT", "PAGER", "PAINT_BRUSH", "PAINT_ROLLER", "PALETTE", "PALLET", "PAPER_PLANE", "PAPERCLIP", "PARACHUTE_BOX", "PARAGRAPH", "PARKING", "PASSPORT", "PASTAFARIANISM", "PASTE", "PAUSE", "PAUSE_CIRCLE", "PAW", "PEACE", "PEN", "PEN_ALT", "PEN_FANCY", "PEN_NIB", "PEN_SQUARE", "PENCIL_ALT", "PENCIL_RULER", "PEOPLE_ARROWS", "PEOPLE_CARRY", "PEPPER_HOT", "PERCENT", "PERCENTAGE", "PERSON_BOOTH", "PHONE", "PHONE_ALT", "PHONE_SLASH", "PHONE_SQUARE", "PHONE_SQUARE_ALT", "PHONE_VOLUME", "PHOTO_VIDEO", "PIGGY_BANK", "PILLS", "PIZZA_SLICE", "PLACE_OF_WORSHIP", "PLANE", "PLANE_ARRIVAL", "PLANE_DEPARTURE", "PLANE_SLASH", "PLAY", "PLAY_CIRCLE", "PLUG", "PLUS", "PLUS_CIRCLE", "PLUS_SQUARE", "PODCAST", "POLL", "POLL_H", "POO", "POO_STORM", "POOP", "PORTRAIT", "POUND_SIGN", "POWER_OFF", "PRAY", "PRAYING_HANDS", "PRESCRIPTION", "PRESCRIPTION_BOTTLE", "PRESCRIPTION_BOTTLE_ALT", "PRINT", "PROCEDURES", "PROJECT_DIAGRAM", "PUMP_MEDICAL", "PUMP_SOAP", "PUZZLE_PIECE", "QRCODE", "QUESTION", "QUESTION_CIRCLE", "QUIDDITCH", "QUOTE_LEFT", "QUOTE_RIGHT", "QURAN", "RADIATION", "RADIATION_ALT", "RAINBOW", "RANDOM", "RECEIPT", "RECORD_VINYL", "RECYCLE", "REDO", "REDO_ALT", "REGISTERED", "REMOVE_FORMAT", "REPLY", "REPLY_ALL", "REPUBLICAN", "RESTROOM", "RETWEET", "RIBBON", "RING", "ROAD", "ROBOT", "ROCKET", "ROUTE", "RSS", "RSS_SQUARE", "RUBLE_SIGN", "RULER", "RULER_COMBINED", "RULER_HORIZONTAL", "RULER_VERTICAL", "RUNNING", "RUPEE_SIGN", "SAD_CRY", "SAD_TEAR", "SATELLITE", "SATELLITE_DISH", "SAVE", "SCHOOL", "SCREWDRIVER", "SCROLL", "SD_CARD", "SEARCH", "SEARCH_DOLLAR", "SEARCH_LOCATION", "SEARCH_MINUS", "SEARCH_PLUS", "SEEDLING", "SERVER", "SHAPES", "SHARE", "SHARE_ALT", "SHARE_ALT_SQUARE", "SHARE_SQUARE", "SHEKEL_SIGN", "SHIELD_ALT", "SHIELD_VIRUS", "SHIP", "SHIPPING_FAST", "SHOE_PRINTS", "SHOPPING_BAG", "SHOPPING_BASKET", "SHOPPING_CART", "SHOWER", "SHUTTLE_VAN", "SIGN", "SIGN_IN_ALT", "SIGN_LANGUAGE", "SIGN_OUT_ALT", "SIGNAL", "SIGNATURE", "SIM_CARD", "SINK", "SITEMAP", "SKATING", "SKIING", "SKIING_NORDIC", "SKULL", "SKULL_CROSSBONES", "SLASH", "SLEIGH", "SLIDERS_H", "SMILE", "SMILE_BEAM", "SMILE_WINK", "SMOG", "SMOKING", "SMOKING_BAN", "SMS", "SNOWBOARDING", "SNOWFLAKE", "SNOWMAN", "SNOWPLOW", "SOAP", "SOCKS", "SOLAR_PANEL", "SORT", "SORT_ALPHA_DOWN", "SORT_ALPHA_DOWN_ALT", "SORT_ALPHA_UP", "SORT_ALPHA_UP_ALT", "SORT_AMOUNT_DOWN", "SORT_AMOUNT_DOWN_ALT", "SORT_AMOUNT_UP", "SORT_AMOUNT_UP_ALT", "SORT_DOWN", "SORT_NUMERIC_DOWN", "SORT_NUMERIC_DOWN_ALT", "SORT_NUMERIC_UP", "SORT_NUMERIC_UP_ALT", "SORT_UP", "SPA", "SPACE_SHUTTLE", "SPELL_CHECK", "SPIDER", "SPINNER", "SPLOTCH", "SPRAY_CAN", "SQUARE", "SQUARE_FULL", "SQUARE_ROOT_ALT", "STAMP", "STAR", "STAR_AND_CRESCENT", "STAR_HALF", "STAR_HALF_ALT", "STAR_OF_DAVID", "STAR_OF_LIFE", "STEP_BACKWARD", "STEP_FORWARD", "STETHOSCOPE", "STICKY_NOTE", "STOP", "STOP_CIRCLE", "STOPWATCH", "STOPWATCH_20", "STORE", "STORE_ALT", "STORE_ALT_SLASH", "STORE_SLASH", "STREAM", "STREET_VIEW", "STRIKETHROUGH", "STROOPWAFEL", "SUBSCRIPT", "SUBWAY", "SUITCASE", "SUITCASE_ROLLING", "SUN", "SUPERSCRIPT", "SURPRISE", "SWATCHBOOK", "SWIMMER", "SWIMMING_POOL", "SYNAGOGUE", "SYNC", "SYNC_ALT", "SYRINGE", "TABLE", "TABLE_TENNIS", "TABLET", "TABLET_ALT", "TABLETS", "TACHOMETER_ALT", "TAG", "TAGS", "TAPE", "TASKS", "TAXI", "TEETH", "TEETH_OPEN", "TEMPERATURE_HIGH", "TEMPERATURE_LOW", "TENGE", "TERMINAL", "TEXT_HEIGHT", "TEXT_WIDTH", "TH", "TH_LARGE", "TH_LIST", "THEATER_MASKS", "THERMOMETER", "THERMOMETER_EMPTY", "THERMOMETER_FULL", "THERMOMETER_HALF", "THERMOMETER_QUARTER", "THERMOMETER_THREE_QUARTERS", "THUMBS_DOWN", "THUMBS_UP", "THUMBTACK", "TICKET_ALT", "TIMES", "TIMES_CIRCLE", "TINT", "TINT_SLASH", "TIRED", "TOGGLE_OFF", "TOGGLE_ON", "TOILET", "TOILET_PAPER", "TOILET_PAPER_SLASH", "TOOLBOX", "TOOLS", "TOOTH", "TORAH", "TORII_GATE", "TRACTOR", "TRADEMARK", "TRAFFIC_LIGHT", "TRAILER", "TRAIN", "TRAM", "TRANSGENDER", "TRANSGENDER_ALT", "TRASH", "TRASH_ALT", "TRASH_RESTORE", "TRASH_RESTORE_ALT", "TREE", "TROPHY", "TRUCK", "TRUCK_LOADING", "TRUCK_MONSTER", "TRUCK_MOVING", "TRUCK_PICKUP", "TSHIRT", "TTY", "TV", "UMBRELLA", "UMBRELLA_BEACH", "UNDERLINE", "UNDO", "UNDO_ALT", "UNIVERSAL_ACCESS", "UNIVERSITY", "UNLINK", "UNLOCK", "UNLOCK_ALT", "UPLOAD", "USER", "USER_ALT", "USER_ALT_SLASH", "USER_ASTRONAUT", "USER_CHECK", "USER_CIRCLE", "USER_CLOCK", "USER_COG", "USER_EDIT", "USER_FRIENDS", "USER_GRADUATE", "USER_INJURED", "USER_LOCK", "USER_MD", "USER_MINUS", "USER_NINJA", "USER_NURSE", "USER_PLUS", "USER_SECRET", "USER_SHIELD", "USER_SLASH", "USER_TAG", "USER_TIE", "USER_TIMES", "USERS", "USERS_COG", "USERS_SLASH", "UTENSIL_SPOON", "UTENSILS", "VECTOR_SQUARE", "VENUS", "VENUS_DOUBLE", "VENUS_MARS", "VEST", "VEST_PATCHES", "VIAL", "VIALS", "VIDEO", "VIDEO_SLASH", "VIHARA", "VIRUS", "VIRUS_SLASH", "VIRUSES", "VOICEMAIL", "VOLLEYBALL_BALL", "VOLUME_DOWN", "VOLUME_MUTE", "VOLUME_OFF", "VOLUME_UP", "VOTE_YEA", "VR_CARDBOARD", "WALKING", "WALLET", "WAREHOUSE", "WATER", "WAVE_SQUARE", "WEIGHT", "WEIGHT_HANGING", "WHEELCHAIR", "WIFI", "WIND", "WINDOW_CLOSE", "WINDOW_MAXIMIZE", "WINDOW_MINIMIZE", "WINDOW_RESTORE", "WINE_BOTTLE", "WINE_GLASS", "WINE_GLASS_ALT", "WON_SIGN", "WRENCH", "X_RAY", "YEN_SIGN", "YIN_YANG", }; fn init(ctx: *zp.Context) anyerror!void { std.log.info("game init", .{}); // init imgui try dig.init(ctx.window); regular_font = try dig.loadFontAwesome(30, true, true); solid_font = try dig.loadFontAwesome(30, false, true); } fn printIcons(column_size: usize) void { if (dig.beginTable( "table", @intCast(c_int, column_size), .{ .flags = dig.c.ImGuiTableFlags_Borders }, )) { var count: usize = 0; for (codepoints) |c, i| { if (dig.isCharRenderable(c)) { if (count % column_size == 0) { dig.tableNextRow(0, 50); } _ = dig.tableNextColumn(); _ = dig.text(codepoint_names[i].ptr); dig.newLine(); dig.newLine(); dig.sameLine(.{ .offset_from_start_x = dig.getColumnWidth(dig.getColumnIndex()) - 40, .spacing = 10 }); _ = dig.text(c.ptr); count += 1; } } dig.endTable(); } } fn loop(ctx: *zp.Context) void { while (ctx.pollEvent()) |e| { _ = dig.processEvent(e); switch (e) { .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 => {}, } } ctx.graphics.clear(true, false, false, [4]f32{ 0.45, 0.55, 0.6, 1.0 }); dig.beginFrame(); defer dig.endFrame(); const column_size = 5; if (dig.begin("font-awesome-regular", null, 0)) { dig.pushFont(regular_font); printIcons(column_size); dig.popFont(); } dig.end(); if (dig.begin("font-awesome-solid", null, 0)) { dig.pushFont(solid_font); printIcons(column_size); dig.popFont(); } dig.end(); //dig.showMetricsWindow(null); } 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_resizable = true, .enable_maximized = true, }); }
examples/imgui_fontawesome.zig
const std = @import("std"); pub const PoolError = error{ PoolIsFull, HandleIsUnacquired, HandleIsOutOfBounds, HandleIsReleased, }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Returns a struct that maintains a pool of data. Handles returned by /// `Pool.add()` can be used to get/set the data in zero or more columns. /// /// See `handles.zig` for more information on `index_bits` and `cycle_bits`, /// and handles in general. /// /// `TResource` identifies type of resource referenced by a handle, and /// provides a type-safe distinction between two otherwise equivalently /// configured `Handle` types, such as: /// * `const BufferHandle = Handle(16, 16, Buffer);` /// * `const TextureHandle = Handle(16, 16, Texture);` /// /// `TColumns` is a struct that defines the column names, and the element types /// of the column arrays. /// /// ```zig /// const Texture = gpu.Texture; /// /// const TexturePool = Pool(16, 16, Texture, struct { obj:Texture, desc:Texture.Descriptor }); /// const TextureHandle = TexturePool.Handle; /// /// const GPA = std.heap.GeneralPurposeAllocator; /// var gpa = GPA(.{}){}; /// var pool = try TestPool.initMaxCapacity(gpa.allocator()); /// defer pool.deinit(); /// /// // creating a texture and adding it to the pool returns a handle /// const desc : Texture.Descriptor = .{ ... }; /// const obj = device.createTexture(desc); /// const handle : TextureHandle = pool.add(.{ .obj = obj, .desc = desc }); /// /// // elsewhere, use the handle to get `obj` or `desc` as needed /// const obj = pool.getColumn(handle, .obj); /// const desc = pool.getColumn(handle, .desc); /// ``` pub fn Pool( comptime index_bits: u8, comptime cycle_bits: u8, comptime TResource: type, comptime TColumns: type, ) type { // Handle performs compile time checks on index_bits & cycle_bits const ring_queue = @import("embedded_ring_queue.zig"); const handles = @import("handle.zig"); const utils = @import("utils.zig"); if (!utils.isStruct(TColumns)) @compileError("TColumns must be a struct"); const assert = std.debug.assert; const meta = std.meta; const Allocator = std.mem.Allocator; const MultiArrayList = std.MultiArrayList; const StructOfSlices = utils.StructOfSlices; const RingQueue = ring_queue.EmbeddedRingQueue; return struct { const Self = @This(); pub const Error = PoolError; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - pub const Resource = TResource; pub const Handle = handles.Handle(index_bits, cycle_bits, TResource); pub const AddressableHandle = Handle.AddressableHandle; pub const AddressableIndex = Handle.AddressableIndex; pub const AddressableCycle = Handle.AddressableCycle; pub const max_index: usize = Handle.max_index; pub const max_cycle: usize = Handle.max_cycle; pub const max_capacity: usize = Handle.max_count; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - pub const Columns = TColumns; pub const ColumnSlices = StructOfSlices(Columns); pub const Column = meta.FieldEnum(Columns); pub const column_fields = meta.fields(Columns); pub const column_count = column_fields.len; pub fn ColumnType(comptime column: Column) type { return meta.fieldInfo(Columns, column).field_type; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const private_fields = meta.fields(struct { @"Pool._free_queue": AddressableIndex, @"Pool._curr_cycle": AddressableCycle, }); const Storage = MultiArrayList(@Type(.{ .Struct = .{ .layout = std.builtin.Type.ContainerLayout.Auto, .fields = private_fields ++ column_fields, .decls = &.{}, .is_tuple = false, } })); const FreeQueue = RingQueue(AddressableIndex); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _allocator: Allocator = undefined, _storage: Storage = .{}, _free_queue: FreeQueue = .{}, _curr_cycle: []AddressableCycle = &.{}, columns: ColumnSlices = undefined, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Returns an initialized `Pool` that will use `allocator` for all /// allocations. The `Pool` stores all handles and columns in a single /// memory allocation backed by `std.MultiArrayList`. pub fn init(allocator: Allocator) Self { var self = Self{ ._allocator = allocator }; updateSlices(self); return self; } /// Returns an initialized `Pool` that will use `allocator` for all /// allocations, with at least `min_capacity` preallocated. pub fn initCapacity(allocator: Allocator, min_capacity: usize) !Self { var self = Self{ ._allocator = allocator }; try self.reserve(min_capacity); return self; } /// Returns an initialized `Pool` that will use `allocator` for all /// allocations, with the `Pool.max_capacity` preallocated. pub fn initMaxCapacity(allocator: Allocator) !Self { return initCapacity(allocator, max_capacity); } /// Releases all resources assocated with an initialized pool. pub fn deinit(self: *Self) void { self.clear(); self._storage.deinit(self._allocator); self.* = .{}; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Returns the capacity of the pool, i.e. the maximum number of handles /// it can contain without allocating additional memory. pub fn capacity(self: Self) usize { return self._storage.capacity; } /// Requests the capacity of the pool be at least `min_capacity`. /// If the pool `capacity()` is already equal to or greater than /// `min_capacity`, `reserve()` has no effect. pub fn reserve(self: *Self, min_capacity: usize) !void { const old_capacity = self._storage.capacity; if (min_capacity <= old_capacity) return; if (min_capacity > max_capacity) return Error.PoolIsFull; try self._storage.setCapacity(self._allocator, min_capacity); updateSlices(self); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Returns the number of live handles. pub fn liveHandleCount(self: Self) usize { return self._storage.len - self._free_queue.len(); } /// Returns `true` if `handle` is live, otherwise `false`. pub fn isLiveHandle(self: Self, handle: Handle) bool { return self.isLiveAddressableHandle(handle.addressable()); } /// Checks whether `handle` is live, otherwise returns one of: /// * `Error.HandleIsUnacquired` /// * `Error.HandleIsOutOfBounds` /// * `Error.HandleIsReleased` /// Unlike `std.debug.assert()`, this check is evaluated in all builds. pub fn requireLiveHandle(self: Self, handle: Handle) Error!void { try self.requireLiveAddressableHandle(handle.addressable()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Returns an iterator that can enumerate each live index. /// The iterator is invalidated by calls to `add()`. pub fn liveIndices(self: Self) LiveIndexIterator { return .{ .curr_cycle = self._curr_cycle }; } pub const LiveIndexIterator = struct { curr_cycle: []const AddressableCycle = &.{}, next_index: AddressableIndex = 0, pub fn next(self: *LiveIndexIterator) ?AddressableIndex { while (self.next_index < self.curr_cycle.len) { const curr_index = self.next_index; self.next_index += 1; if (isLiveCycle(self.curr_cycle[curr_index])) return curr_index; } return null; } }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Returns an iterator that can enumerate each live handle. /// The iterator is invalidated by calls to `add()`. pub fn liveHandles(self: Self) LiveHandleIterator { return .{ .live_indices = liveIndices(self) }; } pub const LiveHandleIterator = struct { live_indices: LiveIndexIterator = .{}, pub fn next(self: *LiveHandleIterator) ?Handle { if (self.live_indices.next()) |index| { const ahandle = AddressableHandle{ .index = index, .cycle = self.live_indices.curr_cycle[index], }; return ahandle.handle(); } return null; } }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Releases all live `Handles` and calls `deinit()` on columns if /// defined. pub fn clear(self: *Self) void { var ahandle = AddressableHandle{ .index = 0 }; for (self._curr_cycle) |cycle| { if (isLiveCycle(cycle)) { ahandle.cycle = cycle; self.releaseAddressableHandleUnchecked(ahandle); } ahandle.index += 1; } } /// Adds `values` and returns a live `Handle` if possible, otherwise /// returns one of: /// * `Error.PoolIsFull` /// * `Allocator.Error.OutOfMemory` pub fn add(self: *Self, values: Columns) !Handle { const ahandle = try self.acquireAddressableHandle(); self.initColumnsAt(ahandle.index, values); return ahandle.handle(); } /// Adds `values` and returns a live `Handle` if possible, otherwise /// returns null. pub fn addIfNotFull(self: *Self, values: Columns) ?Handle { const ahandle = self.acquireAddressableHandle() catch { return null; }; self.initColumnsAt(ahandle.index, values); return ahandle.handle(); } /// Adds `values` and returns a live `Handle` if possible, otherwise /// calls `std.debug.assert(false)` and returns `Handle.nil`. pub fn addAssumeNotFull(self: *Self, values: Columns) Handle { const ahandle = self.acquireAddressableHandle() catch { assert(false); return Handle.nil; }; self.initColumnsAt(ahandle.index, values); return ahandle.handle(); } /// Removes (and invalidates) `handle` if live, otherwise returns one /// of: /// * `Error.HandleIsUnacquired` /// * `Error.HandleIsOutOfBounds` /// * `Error.HandleIsReleased` pub fn remove(self: *Self, handle: Handle) !void { try self.releaseAddressableHandle(handle.addressable()); } /// Removes (and invalidates) `handle` if live. /// Returns `true` if removed, otherwise `false`. pub fn removeIfLive(self: *Self, handle: Handle) bool { const ahandle = handle.addressable(); if (self.isLiveAddressableHandle(ahandle)) { self.releaseAddressableHandleUnchecked(ahandle); return true; } return false; } /// Attempts to remove (and invalidates) `handle` assuming it is live. /// Liveness of `handle` is checked by `std.debug.assert()`. pub fn removeAssumeLive(self: *Self, handle: Handle) void { const ahandle = handle.addressable(); assert(self.isLiveAddressableHandle(ahandle)); self.releaseAddressableHandleUnchecked(ahandle); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Gets a column pointer if `handle` is live, otherwise returns one of: /// * `Error.HandleIsUnacquired` /// * `Error.HandleIsOutOfBounds` /// * `Error.HandleIsReleased` pub fn getColumnPtr(self: Self, handle: Handle, comptime column: Column) !*ColumnType(column) { const ahandle = handle.addressable(); try self.requireLiveAddressableHandle(ahandle); return self.getColumnPtrUnchecked(ahandle, column); } /// Gets a column value if `handle` is live, otherwise returns one of: /// * `Error.HandleIsUnacquired` /// * `Error.HandleIsOutOfBounds` /// * `Error.HandleIsReleased` pub fn getColumn(self: Self, handle: Handle, comptime column: Column) !ColumnType(column) { const ahandle = handle.addressable(); try self.requireLiveAddressableHandle(ahandle); return self.getColumnUnchecked(ahandle, column); } /// Gets column values if `handle` is live, otherwise returns one of: /// * `Error.HandleIsUnacquired` /// * `Error.HandleIsOutOfBounds` /// * `Error.HandleIsReleased` pub fn getColumns(self: Self, handle: Handle) !Columns { const ahandle = handle.addressable(); try self.requireLiveAddressableHandle(ahandle); return self.getColumnsUnchecked(ahandle); } /// Sets a column value if `handle` is live, otherwise returns one of: /// * `Error.HandleIsUnacquired` /// * `Error.HandleIsOutOfBounds` /// * `Error.HandleIsReleased` pub fn setColumn(self: Self, handle: Handle, comptime column: Column, value: ColumnType(column)) !void { const ahandle = handle.addressable(); try self.requireLiveAddressableHandle(ahandle); self.setColumnUnchecked(ahandle, column, value); } /// Sets column values if `handle` is live, otherwise returns one of: /// * `Error.HandleIsUnacquired` /// * `Error.HandleIsOutOfBounds` /// * `Error.HandleIsReleased` pub fn setColumns(self: Self, handle: Handle, values: Columns) !void { const ahandle = handle.addressable(); try self.requireLiveAddressableHandle(ahandle); self.setColumnsUnchecked(ahandle, values); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Gets a column pointer if `handle` is live, otherwise `null`. pub fn getColumnPtrIfLive(self: Self, handle: Handle, comptime column: Column) ?*ColumnType(column) { const ahandle = handle.addressable(); if (self.isLiveAddressableHandle(ahandle)) { return self.getColumnPtrUnchecked(ahandle, column); } return null; } /// Gets a column value if `handle` is live, otherwise `null`. pub fn getColumnIfLive(self: Self, handle: Handle, comptime column: Column) ?ColumnType(column) { const ahandle = handle.addressable(); if (self.isLiveAddressableHandle(ahandle)) { return self.getColumnUnchecked(ahandle, column); } return null; } /// Gets column values if `handle` is live, otherwise `null`. pub fn getColumnsIfLive(self: Self, handle: Handle) ?Columns { const ahandle = handle.addressable(); if (self.isLiveAddressableHandle(ahandle)) { return self.getColumnsUnchecked(ahandle); } return null; } /// Sets a column value if `handle` is live. /// Returns `true` if the column value was set, otherwise `false`. pub fn setColumnIfLive(self: Self, handle: Handle, comptime column: Column, value: ColumnType(column)) bool { const ahandle = handle.addressable(); if (self.isLiveAddressableHandle(ahandle)) { self.setColumnUnchecked(ahandle, column, value); return true; } return false; } /// Sets column values if `handle` is live. /// Returns `true` if the column value was set, otherwise `false`. pub fn setColumnsIfLive(self: Self, handle: Handle, values: Columns) bool { const ahandle = handle.addressable(); if (self.isLiveAddressableHandle(ahandle)) { self.setColumnsUnchecked(ahandle, values); return true; } return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Attempts to get a column pointer assuming `handle` is live. /// Liveness of `handle` is checked by `std.debug.assert()`. pub fn getColumnPtrAssumeLive(self: Self, handle: Handle, comptime column: Column) *ColumnType(column) { const ahandle = handle.addressable(); assert(self.isLiveAddressableHandle(ahandle)); return self.getColumnPtrUnchecked(ahandle, column); } /// Attempts to get a column value assuming `handle` is live. /// Liveness of `handle` is checked by `std.debug.assert()`. pub fn getColumnAssumeLive(self: Self, handle: Handle, comptime column: Column) ColumnType(column) { const ahandle = handle.addressable(); assert(self.isLiveAddressableHandle(ahandle)); return self.getColumnUnchecked(ahandle, column); } /// Attempts to get column values assuming `handle` is live. /// Liveness of `handle` is checked by `std.debug.assert()`. pub fn getColumnsAssumeLive(self: Self, handle: Handle) Columns { const ahandle = handle.addressable(); assert(self.isLiveAddressableHandle(ahandle)); return self.getColumnsUnchecked(ahandle); } /// Attempts to set a column value assuming `handle` is live. /// Liveness of `handle` is checked by `std.debug.assert()`. pub fn setColumnAssumeLive(self: Self, handle: Handle, comptime column: Column, value: ColumnType(column)) void { const ahandle = handle.addressable(); assert(self.isLiveAddressableHandle(ahandle)); self.setColumnUnchecked(ahandle, column, value); } /// Attempts to set column values assuming `handle` is live. /// Liveness of `handle` is checked by `std.debug.assert()`. pub fn setColumnsAssumeLive(self: Self, handle: Handle, values: Columns) void { const ahandle = handle.addressable(); assert(self.isLiveAddressableHandle(ahandle)); self.setColumnsUnchecked(ahandle, values); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fn getColumnPtrUnchecked(self: Self, handle: AddressableHandle, comptime column: Column) *ColumnType(column) { const column_field = meta.fieldInfo(Columns, column); return &@field(self.columns, column_field.name)[handle.index]; } fn getColumnUnchecked(self: Self, handle: AddressableHandle, comptime column: Column) ColumnType(column) { return self.getColumnPtrUnchecked(handle, column).*; } fn getColumnsUnchecked(self: Self, handle: AddressableHandle) Columns { var values: Columns = undefined; inline for (column_fields) |column_field| { @field(values, column_field.name) = @field(self.columns, column_field.name)[handle.index]; } return values; } fn setColumnUnchecked(self: Self, handle: AddressableHandle, comptime column: Column, value: ColumnType(column)) void { const column_field = meta.fieldInfo(Columns, column); self.deinitColumnAt(handle.index, column_field); @field(self.columns, column_field.name)[handle.index] = value; } fn setColumnsUnchecked(self: Self, handle: AddressableHandle, values: Columns) void { self.deinitColumnsAt(handle.index); self.initColumnsAt(handle.index, values); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const StructField = std.builtin.Type.StructField; fn initColumnsAt(self: Self, index: AddressableIndex, values: Columns) void { inline for (column_fields) |column_field| { @field(self.columns, column_field.name)[index] = @field(values, column_field.name); } } /// Call `value.deinit()` if defined. fn deinitColumnAt(self: Self, index: AddressableIndex, comptime column_field: StructField) void { switch (@typeInfo(column_field.field_type)) { .Struct, .Enum, .Union, .Opaque => { if (@hasDecl(column_field.field_type, "deinit")) { @field(self.columns, column_field.name)[index].deinit(); } }, else => {}, } } /// Call `values.deinit()` if defined. fn deinitColumnsAt(self: Self, index: AddressableIndex) void { if (@hasDecl(Columns, "deinit")) { var values: Columns = undefined; inline for (column_fields) |column_field| { @field(values, column_field.name) = @field(self.columns, column_field.name)[index]; } values.deinit(); inline for (column_fields) |column_field| { @field(self.columns, column_field.name)[index] = @field(values, column_field.name); } } else { inline for (column_fields) |column_field| { self.deinitColumnAt(index, column_field); } } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fn updateSlices(self: *Self) void { var slice = self._storage.slice(); self._free_queue.storage = slice.items(.@"Pool._free_queue"); self._curr_cycle = slice.items(.@"Pool._curr_cycle"); inline for (column_fields) |column_field, i| { const F = column_field.field_type; const p = slice.ptrs[private_fields.len + i]; const f = @ptrCast([*]F, @alignCast(@alignOf(F), p)); @field(self.columns, column_field.name) = f[0..slice.len]; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fn isLiveAddressableHandle( self: Self, handle: AddressableHandle, ) bool { if (isFreeCycle(handle.cycle)) return false; if (handle.index >= self._curr_cycle.len) return false; if (handle.cycle != self._curr_cycle[handle.index]) return false; return true; } fn requireLiveAddressableHandle( self: Self, handle: AddressableHandle, ) Error!void { if (isFreeCycle(handle.cycle)) return Error.HandleIsUnacquired; if (handle.index >= self._curr_cycle.len) return Error.HandleIsOutOfBounds; if (handle.cycle != self._curr_cycle[handle.index]) return Error.HandleIsReleased; } fn acquireAddressableHandle(self: *Self) !AddressableHandle { if (self._storage.len == max_capacity) { return Error.PoolIsFull; } var handle = AddressableHandle{}; if (self.didGetNewHandleNoResize(&handle)) { assert(self.isLiveAddressableHandle(handle)); return handle; } if (self.didDequeueFreeIndex(&handle.index)) { handle.cycle = self.incrementAndReturnCycle(handle.index); assert(self.isLiveAddressableHandle(handle)); return handle; } try self.getNewHandleAfterResize(&handle); assert(self.isLiveAddressableHandle(handle)); return handle; } fn releaseAddressableHandle( self: *Self, handle: AddressableHandle, ) !void { try self.requireLiveAddressableHandle(handle); self.releaseAddressableHandleUnchecked(handle); } fn releaseAddressableHandleUnchecked( self: *Self, handle: AddressableHandle, ) void { self.deinitColumnsAt(handle.index); self.incrementCycle(handle.index); self.enqueueFreeIndex(handle.index); } fn tryReleaseAddressableHandle( self: *Self, handle: AddressableHandle, ) bool { if (self.isLiveAddressableHandle(handle)) { self.releaseAddressableHandleUnchecked(handle); return true; } return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /// Even cycles (least significant bit is `0`) are "free". fn isFreeCycle(cycle: AddressableCycle) bool { return (cycle & @as(AddressableCycle, 1)) == @as(AddressableCycle, 0); } /// Odd cycles (least significant bit is `1`) are "live". fn isLiveCycle(cycle: AddressableCycle) bool { return (cycle & @as(AddressableCycle, 1)) == @as(AddressableCycle, 1); } fn incrementCycle(self: *Self, index: AddressableIndex) void { const new_cycle = self._curr_cycle[index] +% 1; self._curr_cycle[index] = new_cycle; } fn incrementAndReturnCycle( self: *Self, index: AddressableIndex, ) AddressableCycle { const new_cycle = self._curr_cycle[index] +% 1; self._curr_cycle[index] = new_cycle; return new_cycle; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fn enqueueFreeIndex(self: *Self, index: AddressableIndex) void { self._free_queue.enqueueAssumeNotFull(index); } fn didDequeueFreeIndex(self: *Self, index: *AddressableIndex) bool { return self._free_queue.dequeueIfNotEmpty(index); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fn didGetNewHandleNoResize(self: *Self, handle: *AddressableHandle) bool { if (self._storage.len < max_capacity and self._storage.len < self._storage.capacity) { const new_index = self._storage.addOneAssumeCapacity(); updateSlices(self); self._curr_cycle[new_index] = 1; handle.index = @intCast(AddressableIndex, new_index); handle.cycle = 1; return true; } return false; } fn getNewHandleAfterResize(self: *Self, handle: *AddressableHandle) !void { const new_index = try self._storage.addOne(self._allocator); updateSlices(self); self._curr_cycle[new_index] = 1; handle.index = @intCast(AddressableIndex, new_index); handle.cycle = 1; } }; } //------------------------------------------------------------------------------ const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const expectError = std.testing.expectError; const DeinitCounter = struct { const Self = @This(); counter: *u32, fn init(_counter: *u32) Self { return Self{ .counter = _counter }; } fn deinit(self: *Self) void { self.counter.* += 1; } }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool with no columns" { const TestPool = Pool(8, 8, void, struct {}); try expectEqual(@as(usize, 0), TestPool.column_count); try expectEqual(@as(usize, 0), @sizeOf(TestPool.ColumnSlices)); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); const handle = try pool.add(.{}); defer _ = pool.removeIfLive(handle); try pool.requireLiveHandle(handle); try expect(pool.isLiveHandle(handle)); try expectEqual(@as(u8, 0), handle.addressable().index); try expectEqual(@as(u8, 1), handle.addressable().cycle); try expectEqual(@as(usize, 1), pool.liveHandleCount()); } test "Pool with one column" { const TestPool = Pool(8, 8, void, struct { a: u32 }); try expectEqual(@as(usize, 1), TestPool.column_count); try expectEqual(@sizeOf([]u32), @sizeOf(TestPool.ColumnSlices)); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); const handle = try pool.add(.{ .a = 123 }); defer _ = pool.removeIfLive(handle); try pool.requireLiveHandle(handle); try expect(pool.isLiveHandle(handle)); try expectEqual(@as(usize, 1), pool.liveHandleCount()); try expectEqual(@as(u8, 0), handle.addressable().index); try expectEqual(@as(u8, 1), handle.addressable().cycle); try expectEqual(@as(u32, 123), try pool.getColumn(handle, .a)); try pool.setColumn(handle, .a, 456); try expectEqual(@as(u32, 456), try pool.getColumn(handle, .a)); } test "Pool with two columns" { const TestPool = Pool(8, 8, void, struct { a: u32, b: u64 }); try expectEqual(@as(usize, 2), TestPool.column_count); try expectEqual(@sizeOf([]u32) * 2, @sizeOf(TestPool.ColumnSlices)); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); const handle = try pool.add(.{ .a = 123, .b = 456 }); defer _ = pool.removeIfLive(handle); try pool.requireLiveHandle(handle); try expect(pool.isLiveHandle(handle)); try expectEqual(@as(usize, 1), pool.liveHandleCount()); try expectEqual(@as(u8, 0), handle.addressable().index); try expectEqual(@as(u8, 1), handle.addressable().cycle); try expectEqual(@as(u32, 123), try pool.getColumn(handle, .a)); try pool.setColumn(handle, .a, 456); try expectEqual(@as(u32, 456), try pool.getColumn(handle, .a)); try expectEqual(@as(u64, 456), try pool.getColumn(handle, .b)); try pool.setColumn(handle, .b, 123); try expectEqual(@as(u64, 123), try pool.getColumn(handle, .b)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.liveHandleCount()" { const TestPool = Pool(8, 8, void, struct {}); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{}); try expectEqual(@as(usize, 1), pool.liveHandleCount()); const handle1 = try pool.add(.{}); try expectEqual(@as(usize, 2), pool.liveHandleCount()); try pool.remove(handle0); try expectEqual(@as(usize, 1), pool.liveHandleCount()); try pool.remove(handle1); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle2 = try pool.add(.{}); try expectEqual(@as(usize, 1), pool.liveHandleCount()); try pool.remove(handle2); try expectEqual(@as(usize, 0), pool.liveHandleCount()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.isLiveHandle()" { const TestPool = Pool(8, 8, void, struct {}); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const unacquiredHandle = TestPool.Handle.init(0, 0); try expect(!pool.isLiveHandle(unacquiredHandle)); const outOfBoundsHandle = TestPool.Handle.init(1, 1); try expect(!pool.isLiveHandle(outOfBoundsHandle)); const handle = try pool.add(.{}); try expect(pool.isLiveHandle(handle)); try pool.remove(handle); try expect(!pool.isLiveHandle(handle)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.requireLiveHandle()" { const TestPool = Pool(8, 8, void, struct {}); try expectEqual(@as(usize, 0), TestPool.column_count); try expectEqual(@as(usize, 0), @sizeOf(TestPool.ColumnSlices)); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const unacquiredHandle = TestPool.Handle.init(0, 0); try expectError(TestPool.Error.HandleIsUnacquired, pool.requireLiveHandle(unacquiredHandle)); const outOfBoundsHandle = TestPool.Handle.init(1, 1); try expectError(TestPool.Error.HandleIsOutOfBounds, pool.requireLiveHandle(outOfBoundsHandle)); const handle = try pool.add(.{}); try pool.requireLiveHandle(handle); try pool.remove(handle); try expectError(TestPool.Error.HandleIsReleased, pool.requireLiveHandle(handle)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.liveIndices()" { const TestPool = Pool(8, 8, void, struct {}); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{}); const handle1 = try pool.add(.{}); const handle2 = try pool.add(.{}); try expectEqual(@as(usize, 3), pool.liveHandleCount()); var live_indices = pool.liveIndices(); try expectEqual(handle0.addressable().index, live_indices.next().?); try expectEqual(handle1.addressable().index, live_indices.next().?); try expectEqual(handle2.addressable().index, live_indices.next().?); try expect(null == live_indices.next()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.liveHandles()" { const TestPool = Pool(8, 8, void, struct {}); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{}); const handle1 = try pool.add(.{}); const handle2 = try pool.add(.{}); try expectEqual(@as(usize, 3), pool.liveHandleCount()); var live_handles = pool.liveHandles(); try expectEqual(handle0.id, live_handles.next().?.id); try expectEqual(handle1.id, live_handles.next().?.id); try expectEqual(handle2.id, live_handles.next().?.id); try expect(null == live_handles.next()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.clear()" { const TestPool = Pool(8, 8, void, struct {}); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{}); const handle1 = try pool.add(.{}); const handle2 = try pool.add(.{}); try expectEqual(@as(usize, 3), pool.liveHandleCount()); try expect(pool.isLiveHandle(handle0)); try expect(pool.isLiveHandle(handle1)); try expect(pool.isLiveHandle(handle2)); pool.clear(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); try expect(!pool.isLiveHandle(handle0)); try expect(!pool.isLiveHandle(handle1)); try expect(!pool.isLiveHandle(handle2)); } test "Pool.clear() calls Columns.deinit()" { const TestPool = Pool(2, 6, void, DeinitCounter); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; _ = try pool.add(DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 0), deinit_count); pool.clear(); try expectEqual(@as(u32, 1), deinit_count); } test "Pool.clear() calls ColumnType.deinit()" { const TestPool = Pool(2, 6, void, struct { a: DeinitCounter, b: DeinitCounter }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; _ = try pool.add(.{ .a = DeinitCounter.init(&deinit_count), .b = DeinitCounter.init(&deinit_count), }); try expectEqual(@as(u32, 0), deinit_count); pool.clear(); try expectEqual(@as(u32, 2), deinit_count); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.add()" { const TestPool = Pool(2, 6, void, struct {}); try expectEqual(@sizeOf(u8), @sizeOf(TestPool.Handle)); try expectEqual(@as(usize, 4), TestPool.max_capacity); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{}); const handle1 = try pool.add(.{}); const handle2 = try pool.add(.{}); const handle3 = try pool.add(.{}); try expectEqual(@as(usize, 4), pool.liveHandleCount()); try expect(pool.isLiveHandle(handle0)); try expect(pool.isLiveHandle(handle1)); try expect(pool.isLiveHandle(handle2)); try expect(pool.isLiveHandle(handle3)); try expectError(TestPool.Error.PoolIsFull, pool.add(.{})); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.remove()" { const TestPool = Pool(2, 6, void, struct {}); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{}); const handle1 = try pool.add(.{}); const handle2 = try pool.add(.{}); const handle3 = try pool.add(.{}); try pool.remove(handle0); try pool.remove(handle1); try pool.remove(handle2); try pool.remove(handle3); try expectError(TestPool.Error.HandleIsReleased, pool.remove(handle0)); try expectError(TestPool.Error.HandleIsReleased, pool.remove(handle1)); try expectError(TestPool.Error.HandleIsReleased, pool.remove(handle2)); try expectError(TestPool.Error.HandleIsReleased, pool.remove(handle3)); } test "Pool.remove() calls Columns.deinit()" { const TestPool = Pool(2, 6, void, DeinitCounter); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; const handle = try pool.add(DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 0), deinit_count); try pool.remove(handle); try expectEqual(@as(u32, 1), deinit_count); } test "Pool.remove() calls ColumnType.deinit()" { const TestPool = Pool(2, 6, void, struct { a: DeinitCounter, b: DeinitCounter }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; const handle = try pool.add(.{ .a = DeinitCounter.init(&deinit_count), .b = DeinitCounter.init(&deinit_count), }); try expectEqual(@as(u32, 0), deinit_count); try pool.remove(handle); try expectEqual(@as(u32, 2), deinit_count); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.removeIfLive()" { const TestPool = Pool(2, 6, void, struct {}); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{}); const handle1 = try pool.add(.{}); const handle2 = try pool.add(.{}); const handle3 = try pool.add(.{}); try expect(pool.isLiveHandle(handle0)); try expect(pool.isLiveHandle(handle1)); try expect(pool.isLiveHandle(handle2)); try expect(pool.isLiveHandle(handle3)); try expect(pool.removeIfLive(handle0)); try expect(pool.removeIfLive(handle1)); try expect(pool.removeIfLive(handle2)); try expect(pool.removeIfLive(handle3)); try expect(!pool.isLiveHandle(handle0)); try expect(!pool.isLiveHandle(handle1)); try expect(!pool.isLiveHandle(handle2)); try expect(!pool.isLiveHandle(handle3)); try expect(!pool.removeIfLive(handle0)); try expect(!pool.removeIfLive(handle1)); try expect(!pool.removeIfLive(handle2)); try expect(!pool.removeIfLive(handle3)); } test "Pool.removeIfLive() calls Columns.deinit()" { const TestPool = Pool(2, 6, void, DeinitCounter); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; const handle = try pool.add(DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 0), deinit_count); try expect(pool.removeIfLive(handle)); try expectEqual(@as(u32, 1), deinit_count); } test "Pool.removeIfLive() calls ColumnType.deinit()" { const TestPool = Pool(2, 6, void, struct { a: DeinitCounter, b: DeinitCounter }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; const handle = try pool.add(.{ .a = DeinitCounter.init(&deinit_count), .b = DeinitCounter.init(&deinit_count), }); try expectEqual(@as(u32, 0), deinit_count); try expect(pool.removeIfLive(handle)); try expectEqual(@as(u32, 2), deinit_count); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.getColumnPtr*()" { const TestPool = Pool(2, 6, void, struct { a: u32 }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{ .a = 0 }); const handle1 = try pool.add(.{ .a = 1 }); const handle2 = try pool.add(.{ .a = 2 }); const handle3 = try pool.add(.{ .a = 3 }); const a0ptr: *u32 = try pool.getColumnPtr(handle0, .a); const a1ptr: *u32 = try pool.getColumnPtr(handle1, .a); const a2ptr: *u32 = try pool.getColumnPtr(handle2, .a); const a3ptr: *u32 = try pool.getColumnPtr(handle3, .a); try expectEqual(@as(u32, 0), a0ptr.*); try expectEqual(@as(u32, 1), a1ptr.*); try expectEqual(@as(u32, 2), a2ptr.*); try expectEqual(@as(u32, 3), a3ptr.*); try expectEqual(a0ptr, pool.getColumnPtrIfLive(handle0, .a).?); try expectEqual(a1ptr, pool.getColumnPtrIfLive(handle1, .a).?); try expectEqual(a2ptr, pool.getColumnPtrIfLive(handle2, .a).?); try expectEqual(a3ptr, pool.getColumnPtrIfLive(handle3, .a).?); try expectEqual(a0ptr, pool.getColumnPtrAssumeLive(handle0, .a)); try expectEqual(a1ptr, pool.getColumnPtrAssumeLive(handle1, .a)); try expectEqual(a2ptr, pool.getColumnPtrAssumeLive(handle2, .a)); try expectEqual(a3ptr, pool.getColumnPtrAssumeLive(handle3, .a)); try pool.remove(handle0); try pool.remove(handle1); try pool.remove(handle2); try pool.remove(handle3); try expectError(TestPool.Error.HandleIsReleased, pool.getColumnPtr(handle0, .a)); try expectError(TestPool.Error.HandleIsReleased, pool.getColumnPtr(handle1, .a)); try expectError(TestPool.Error.HandleIsReleased, pool.getColumnPtr(handle2, .a)); try expectError(TestPool.Error.HandleIsReleased, pool.getColumnPtr(handle3, .a)); try expect(null == pool.getColumnPtrIfLive(handle0, .a)); try expect(null == pool.getColumnPtrIfLive(handle1, .a)); try expect(null == pool.getColumnPtrIfLive(handle2, .a)); try expect(null == pool.getColumnPtrIfLive(handle3, .a)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.getColumn*()" { const TestPool = Pool(2, 6, void, struct { a: u32 }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{ .a = 0 }); const handle1 = try pool.add(.{ .a = 1 }); const handle2 = try pool.add(.{ .a = 2 }); const handle3 = try pool.add(.{ .a = 3 }); try expectEqual(@as(u32, 0), try pool.getColumn(handle0, .a)); try expectEqual(@as(u32, 1), try pool.getColumn(handle1, .a)); try expectEqual(@as(u32, 2), try pool.getColumn(handle2, .a)); try expectEqual(@as(u32, 3), try pool.getColumn(handle3, .a)); try expectEqual(@as(u32, 0), pool.getColumnIfLive(handle0, .a).?); try expectEqual(@as(u32, 1), pool.getColumnIfLive(handle1, .a).?); try expectEqual(@as(u32, 2), pool.getColumnIfLive(handle2, .a).?); try expectEqual(@as(u32, 3), pool.getColumnIfLive(handle3, .a).?); try expectEqual(@as(u32, 0), pool.getColumnAssumeLive(handle0, .a)); try expectEqual(@as(u32, 1), pool.getColumnAssumeLive(handle1, .a)); try expectEqual(@as(u32, 2), pool.getColumnAssumeLive(handle2, .a)); try expectEqual(@as(u32, 3), pool.getColumnAssumeLive(handle3, .a)); try pool.remove(handle0); try pool.remove(handle1); try pool.remove(handle2); try pool.remove(handle3); try expectError(TestPool.Error.HandleIsReleased, pool.getColumn(handle0, .a)); try expectError(TestPool.Error.HandleIsReleased, pool.getColumn(handle1, .a)); try expectError(TestPool.Error.HandleIsReleased, pool.getColumn(handle2, .a)); try expectError(TestPool.Error.HandleIsReleased, pool.getColumn(handle3, .a)); try expect(null == pool.getColumnIfLive(handle0, .a)); try expect(null == pool.getColumnIfLive(handle1, .a)); try expect(null == pool.getColumnIfLive(handle2, .a)); try expect(null == pool.getColumnIfLive(handle3, .a)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.setColumn*()" { const TestPool = Pool(2, 6, void, struct { a: u32 }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{ .a = 0 }); const handle1 = try pool.add(.{ .a = 1 }); const handle2 = try pool.add(.{ .a = 2 }); const handle3 = try pool.add(.{ .a = 3 }); try expectEqual(@as(u32, 0), try pool.getColumn(handle0, .a)); try expectEqual(@as(u32, 1), try pool.getColumn(handle1, .a)); try expectEqual(@as(u32, 2), try pool.getColumn(handle2, .a)); try expectEqual(@as(u32, 3), try pool.getColumn(handle3, .a)); try expectEqual(@as(u32, 0), pool.getColumnIfLive(handle0, .a).?); try expectEqual(@as(u32, 1), pool.getColumnIfLive(handle1, .a).?); try expectEqual(@as(u32, 2), pool.getColumnIfLive(handle2, .a).?); try expectEqual(@as(u32, 3), pool.getColumnIfLive(handle3, .a).?); try expectEqual(@as(u32, 0), pool.getColumnAssumeLive(handle0, .a)); try expectEqual(@as(u32, 1), pool.getColumnAssumeLive(handle1, .a)); try expectEqual(@as(u32, 2), pool.getColumnAssumeLive(handle2, .a)); try expectEqual(@as(u32, 3), pool.getColumnAssumeLive(handle3, .a)); try pool.setColumn(handle0, .a, 10); try pool.setColumn(handle1, .a, 11); try pool.setColumn(handle2, .a, 12); try pool.setColumn(handle3, .a, 13); try expect(pool.setColumnIfLive(handle0, .a, 20)); try expect(pool.setColumnIfLive(handle1, .a, 21)); try expect(pool.setColumnIfLive(handle2, .a, 22)); try expect(pool.setColumnIfLive(handle3, .a, 23)); pool.setColumnAssumeLive(handle0, .a, 30); pool.setColumnAssumeLive(handle1, .a, 31); pool.setColumnAssumeLive(handle2, .a, 32); pool.setColumnAssumeLive(handle3, .a, 33); try expectEqual(@as(u32, 30), try pool.getColumn(handle0, .a)); try expectEqual(@as(u32, 31), try pool.getColumn(handle1, .a)); try expectEqual(@as(u32, 32), try pool.getColumn(handle2, .a)); try expectEqual(@as(u32, 33), try pool.getColumn(handle3, .a)); try expectEqual(@as(u32, 30), pool.getColumnIfLive(handle0, .a).?); try expectEqual(@as(u32, 31), pool.getColumnIfLive(handle1, .a).?); try expectEqual(@as(u32, 32), pool.getColumnIfLive(handle2, .a).?); try expectEqual(@as(u32, 33), pool.getColumnIfLive(handle3, .a).?); try expectEqual(@as(u32, 30), pool.getColumnAssumeLive(handle0, .a)); try expectEqual(@as(u32, 31), pool.getColumnAssumeLive(handle1, .a)); try expectEqual(@as(u32, 32), pool.getColumnAssumeLive(handle2, .a)); try expectEqual(@as(u32, 33), pool.getColumnAssumeLive(handle3, .a)); try pool.remove(handle0); try pool.remove(handle1); try pool.remove(handle2); try pool.remove(handle3); try expectError(TestPool.Error.HandleIsReleased, pool.setColumn(handle0, .a, 40)); try expectError(TestPool.Error.HandleIsReleased, pool.setColumn(handle1, .a, 41)); try expectError(TestPool.Error.HandleIsReleased, pool.setColumn(handle2, .a, 42)); try expectError(TestPool.Error.HandleIsReleased, pool.setColumn(handle3, .a, 43)); try expect(!pool.setColumnIfLive(handle0, .a, 50)); try expect(!pool.setColumnIfLive(handle1, .a, 51)); try expect(!pool.setColumnIfLive(handle2, .a, 52)); try expect(!pool.setColumnIfLive(handle3, .a, 53)); // setColumnAssumeLive() would fail an assert() } test "Pool.setColumn*() calls ColumnType.deinit()" { const TestPool = Pool(2, 6, void, struct { a: DeinitCounter, b: DeinitCounter }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; const handle = try pool.add(.{ .a = DeinitCounter.init(&deinit_count), .b = DeinitCounter.init(&deinit_count), }); try expectEqual(@as(u32, 0), deinit_count); try pool.setColumn(handle, .a, DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 1), deinit_count); try pool.setColumn(handle, .b, DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 2), deinit_count); try expect(pool.setColumnIfLive(handle, .a, DeinitCounter.init(&deinit_count))); try expectEqual(@as(u32, 3), deinit_count); try expect(pool.setColumnIfLive(handle, .b, DeinitCounter.init(&deinit_count))); try expectEqual(@as(u32, 4), deinit_count); pool.setColumnAssumeLive(handle, .a, DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 5), deinit_count); pool.setColumnAssumeLive(handle, .b, DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 6), deinit_count); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test "Pool.setColumns*()" { const TestPool = Pool(2, 6, void, struct { a: u32 }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); try expectEqual(@as(usize, 0), pool.liveHandleCount()); const handle0 = try pool.add(.{ .a = 0 }); const handle1 = try pool.add(.{ .a = 1 }); const handle2 = try pool.add(.{ .a = 2 }); const handle3 = try pool.add(.{ .a = 3 }); try expectEqual(@as(u32, 0), try pool.getColumn(handle0, .a)); try expectEqual(@as(u32, 1), try pool.getColumn(handle1, .a)); try expectEqual(@as(u32, 2), try pool.getColumn(handle2, .a)); try expectEqual(@as(u32, 3), try pool.getColumn(handle3, .a)); try expectEqual(@as(u32, 0), pool.getColumnIfLive(handle0, .a).?); try expectEqual(@as(u32, 1), pool.getColumnIfLive(handle1, .a).?); try expectEqual(@as(u32, 2), pool.getColumnIfLive(handle2, .a).?); try expectEqual(@as(u32, 3), pool.getColumnIfLive(handle3, .a).?); try expectEqual(@as(u32, 0), pool.getColumnAssumeLive(handle0, .a)); try expectEqual(@as(u32, 1), pool.getColumnAssumeLive(handle1, .a)); try expectEqual(@as(u32, 2), pool.getColumnAssumeLive(handle2, .a)); try expectEqual(@as(u32, 3), pool.getColumnAssumeLive(handle3, .a)); try pool.setColumns(handle0, .{ .a = 10 }); try pool.setColumns(handle1, .{ .a = 11 }); try pool.setColumns(handle2, .{ .a = 12 }); try pool.setColumns(handle3, .{ .a = 13 }); try expect(pool.setColumnsIfLive(handle0, .{ .a = 20 })); try expect(pool.setColumnsIfLive(handle1, .{ .a = 21 })); try expect(pool.setColumnsIfLive(handle2, .{ .a = 22 })); try expect(pool.setColumnsIfLive(handle3, .{ .a = 23 })); pool.setColumnsAssumeLive(handle0, .{ .a = 30 }); pool.setColumnsAssumeLive(handle1, .{ .a = 31 }); pool.setColumnsAssumeLive(handle2, .{ .a = 32 }); pool.setColumnsAssumeLive(handle3, .{ .a = 33 }); try expectEqual(@as(u32, 30), try pool.getColumn(handle0, .a)); try expectEqual(@as(u32, 31), try pool.getColumn(handle1, .a)); try expectEqual(@as(u32, 32), try pool.getColumn(handle2, .a)); try expectEqual(@as(u32, 33), try pool.getColumn(handle3, .a)); try expectEqual(@as(u32, 30), pool.getColumnIfLive(handle0, .a).?); try expectEqual(@as(u32, 31), pool.getColumnIfLive(handle1, .a).?); try expectEqual(@as(u32, 32), pool.getColumnIfLive(handle2, .a).?); try expectEqual(@as(u32, 33), pool.getColumnIfLive(handle3, .a).?); try expectEqual(@as(u32, 30), pool.getColumnAssumeLive(handle0, .a)); try expectEqual(@as(u32, 31), pool.getColumnAssumeLive(handle1, .a)); try expectEqual(@as(u32, 32), pool.getColumnAssumeLive(handle2, .a)); try expectEqual(@as(u32, 33), pool.getColumnAssumeLive(handle3, .a)); try pool.remove(handle0); try pool.remove(handle1); try pool.remove(handle2); try pool.remove(handle3); try expectError(TestPool.Error.HandleIsReleased, pool.setColumns(handle0, .{ .a = 40 })); try expectError(TestPool.Error.HandleIsReleased, pool.setColumns(handle1, .{ .a = 41 })); try expectError(TestPool.Error.HandleIsReleased, pool.setColumns(handle2, .{ .a = 42 })); try expectError(TestPool.Error.HandleIsReleased, pool.setColumns(handle3, .{ .a = 43 })); try expect(!pool.setColumnsIfLive(handle0, .{ .a = 50 })); try expect(!pool.setColumnsIfLive(handle1, .{ .a = 51 })); try expect(!pool.setColumnsIfLive(handle2, .{ .a = 52 })); try expect(!pool.setColumnsIfLive(handle3, .{ .a = 53 })); // setColumnsAssumeLive() would fail an assert() } test "Pool.setColumns() calls Columns.deinit()" { const TestPool = Pool(2, 6, void, DeinitCounter); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; const handle = try pool.add(DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 0), deinit_count); try pool.setColumns(handle, DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 1), deinit_count); try expect(pool.setColumnsIfLive(handle, DeinitCounter.init(&deinit_count))); try expectEqual(@as(u32, 2), deinit_count); pool.setColumnsAssumeLive(handle, DeinitCounter.init(&deinit_count)); try expectEqual(@as(u32, 3), deinit_count); } test "Pool.setColumns() calls ColumnType.deinit()" { const TestPool = Pool(2, 6, void, struct { a: DeinitCounter, b: DeinitCounter }); var pool = try TestPool.initMaxCapacity(std.testing.allocator); defer pool.deinit(); var deinit_count: u32 = 0; const handle = try pool.add(.{ .a = DeinitCounter.init(&deinit_count), .b = DeinitCounter.init(&deinit_count), }); try expectEqual(@as(u32, 0), deinit_count); try pool.setColumns(handle, .{ .a = DeinitCounter.init(&deinit_count), .b = DeinitCounter.init(&deinit_count), }); try expectEqual(@as(u32, 2), deinit_count); try expect(pool.setColumnsIfLive(handle, .{ .a = DeinitCounter.init(&deinit_count), .b = DeinitCounter.init(&deinit_count), })); try expectEqual(@as(u32, 4), deinit_count); pool.setColumnsAssumeLive(handle, .{ .a = DeinitCounter.init(&deinit_count), .b = DeinitCounter.init(&deinit_count), }); try expectEqual(@as(u32, 6), deinit_count); } //------------------------------------------------------------------------------
libs/zpool/src/pool.zig
const std = @import("std"); pub fn GenericCoord(comptime Self: type) type { return struct { pub fn init(coord: anytype) Self { var self: Self = undefined; inline for (@typeInfo(Self).Struct.fields) |field, i| { @field(self, field.name) = coord[i]; } return self; } pub fn add(self: *const Self, other: Self) Self { var result = self.*; result.mutAdd(other); return result; } pub fn subtract(self: *const Self, other: Self) Self { var result = self.*; inline for (@typeInfo(Self).Struct.fields) |field| { @field(result, field.name) -= @field(other, field.name); } return result; } pub fn multiply(self: *const Self, factor: isize) Self { var result = self.*; result.mutMultiply(factor); return result; } pub fn mutAdd(self: *Self, other: Self) void { inline for (@typeInfo(Self).Struct.fields) |field| { @field(self, field.name) += @field(other, field.name); } } pub fn mutMultiply(self: *Self, factor: isize) void { inline for (@typeInfo(Self).Struct.fields) |field| { @field(self, field.name) *= factor; } } pub fn mutRotate90DegreesClockwise(self: *Self) void { if (@typeInfo(Self).Struct.fields.len != 2) { @compileError("Cannot rotate coord which doesn't have 2 points"); } const old_coord = self.*; @field(self, @typeInfo(Self).Struct.fields[0].name) = @field(old_coord, @typeInfo(Self).Struct.fields[1].name); @field(self, @typeInfo(Self).Struct.fields[1].name) = -@field(old_coord, @typeInfo(Self).Struct.fields[0].name); } pub fn mutRotate90DegreesCounterclockwise(self: *Self) void { if (@typeInfo(Self).Struct.fields.len != 2) { @compileError("Cannot rotate coord which doesn't have 2 points"); } const old_coord = self.*; @field(self, @typeInfo(Self).Struct.fields[0].name) = -@field(old_coord, @typeInfo(Self).Struct.fields[1].name); @field(self, @typeInfo(Self).Struct.fields[1].name) = @field(old_coord, @typeInfo(Self).Struct.fields[0].name); } pub fn distanceFromOrigin(self: *const Self) usize { var dist: usize = 0; inline for (@typeInfo(Self).Struct.fields) |field| { dist += std.math.absCast(@field(self, field.name)); } return dist; } pub fn equals(self: *const Self, other: ?Self) bool { if (other == null) { return false; } inline for (@typeInfo(Self).Struct.fields) |field| { if (@field(self, field.name) != @field(other.?, field.name)) { return false; } } return true; } pub fn neighbors(self: *const Self, include_self: bool) GenericCoordNeighborIterator(Self) { return GenericCoordNeighborIterator(Self).init(self.*, include_self); } }; } pub const Coord = struct { row: isize, col: isize, pub usingnamespace GenericCoord(Coord); }; pub const Coord2D = struct { x: isize, y: isize, pub usingnamespace GenericCoord(Coord2D); }; pub const Coord3D = struct { x: isize, y: isize, z: isize, pub usingnamespace GenericCoord(Coord3D); }; pub const PredefinedCoord = struct { pub const ORIGIN = Coord.init(.{0, 0}); pub const UP = Coord.init(.{-1, 0}); pub const RIGHT = Coord.init(.{0, 1}); pub const DOWN = Coord.init(.{1, 0}); pub const LEFT = Coord.init(.{0, -1}); }; pub fn GenericCoordRange(comptime C: type) type { return struct { const Self = @This(); first: C = undefined, last: C = undefined, never_touched: bool = true, pub fn init() Self { return .{}; } pub fn initWithBounds(first: C, last: C) Self { return .{ .first = first, .last = last }; } pub fn amend(self: *Self, coord: C) void { if (self.never_touched) { self.first = coord; self.last = coord; self.never_touched = false; } else { inline for (@typeInfo(C).Struct.fields) |field| { @field(self.first, field.name) = std.math.min(@field(self.first, field.name), @field(coord, field.name)); @field(self.last, field.name) = std.math.max(@field(self.last, field.name), @field(coord, field.name)); } } } pub fn coordInRange(self: *const Self, coord: C) bool { inline for (@typeInfo(C).Struct.fields) |field| { if (@field(coord, field.name) < @field(self.first, field.name)) { return false; } if (@field(coord, field.name) > @field(self.last, field.name)) { return false; } } return true; } pub fn iterator(self: *const Self) GenericCoordRangeIterator(C) { return GenericCoordRangeIterator(C).init(self.first, self.last); } }; } pub const CoordRange = GenericCoordRange(Coord); pub const CoordRange2D = GenericCoordRange(Coord2D); pub fn GenericCoordRangeIterator(comptime C: type) type { return struct { const Self = @This(); first: C, last: C, curr: C, completed: bool = false, pub fn init(first: C, last: C) Self { return .{ .first = first, .last = last, .curr = first }; } pub fn next(self: *Self) ?C { if (self.completed) { return null; } comptime var field_idx = @typeInfo(C).Struct.fields.len; var res = self.curr; var go = true; // required because breaking out of inline loop crashes compiler inline while (field_idx > 0) : (field_idx -= 1) { const field_name = @typeInfo(C).Struct.fields[field_idx - 1].name; if (go) { if (@field(self.curr, field_name) == @field(self.last, field_name)) { if (field_idx == 1) { self.completed = true; } else { // Next field shall be incremented in the next iteration @field(self.curr, field_name) = @field(self.first, field_name); } } else { @field(self.curr, field_name) += 1; // break; // can't break here, crashes compiler, so next line is used as a hack go = false; } } } return res; } }; } pub const CoordRangeIterator = GenericCoordRangeIterator(Coord); pub const CoordRangeIterator2D = GenericCoordRangeIterator(Coord2D); pub const CoordRangeIterator3D = GenericCoordRangeIterator(Coord3D); pub fn GenericCoordNeighborIterator(comptime C: type) type { return struct { const Self = @This(); center: ?C, range_iter: GenericCoordRangeIterator(C), pub fn init(center: C, include_self: bool) Self { var offset: C = undefined; inline for (@typeInfo(C).Struct.fields) |field| { @field(offset, field.name) = 1; } return .{ .center = if (include_self) null else center, .range_iter = GenericCoordRangeIterator(C).init( center.subtract(offset), center.add(offset) ) }; } pub fn next(self: *Self) ?C { const curr = self.range_iter.next(); if (self.center != null and self.center.?.equals(curr)) { return self.range_iter.next(); } return curr; } }; } pub const CoordNeighborIterator = GenericCoordNeighborIterator(Coord); pub const CoordNeighborIterator2D = GenericCoordNeighborIterator(Coord2D);
src/main/zig/lib/coord.zig
const std = @import("std"); const tools = @import("tools"); const with_trace = false; const assert = std.debug.assert; fn trace(comptime fmt: []const u8, args: anytype) void { if (with_trace) std.debug.print(fmt, args); } pub fn main() anyerror!void { const stdout = std.io.getStdOut().writer(); var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); const limit = 1 * 1024 * 1024 * 1024; const text = try std.fs.cwd().readFileAlloc(allocator, "day10.txt", limit); defer allocator.free(text); const Dest = union(enum) { output: u32, bot: u32, }; const Bot = struct { val: [2]?u32 = [2]?u32{ null, null }, low: ?Dest = null, hi: ?Dest = null, }; var bots = [1]Bot{.{}} ** 250; var bot_count: u32 = 0; { var it = std.mem.tokenize(u8, text, "\n"); while (it.next()) |line| { const parse = tools.match_pattern; if (parse("value {} goes to bot {}", line)) |vals| { trace("value-{} -> bot{}\n", .{ vals[0], vals[1] }); const bot = &bots[vals[1]]; if (bot.val[0] == null) { bot.val[0] = vals[0]; } else { assert(bot.val[1] == null); bot.val[1] = vals[0]; } } else if (parse("bot {} gives low to bot {} and high to bot {}", line)) |vals| { trace("bot{} -> bot{},bot{}\n", .{ vals[0], vals[1], vals[2] }); const bot = &bots[vals[0]]; assert(bot.low == null and bot.hi == null); bot.low = .{ .bot = vals[1] }; bot.hi = .{ .bot = vals[2] }; } else if (parse("bot {} gives low to output {} and high to bot {}", line)) |vals| { trace("bot{} -> out{},bot{}\n", .{ vals[0], vals[1], vals[2] }); const bot = &bots[vals[0]]; assert(bot.low == null and bot.hi == null); bot.low = .{ .output = vals[1] }; bot.hi = .{ .bot = vals[2] }; } else if (parse("bot {} gives low to output {} and high to output {}", line)) |vals| { trace("bot{} -> out{},out{}\n", .{ vals[0], vals[1], vals[2] }); const bot = &bots[vals[0]]; assert(bot.low == null and bot.hi == null); bot.low = .{ .output = vals[1] }; bot.hi = .{ .output = vals[2] }; } else if (parse("bot {} gives low to bot {} and high to output {}", line)) |vals| { trace("bot{} -> bot{},bot{}\n", .{ vals[0], vals[1], vals[2] }); const bot = &bots[vals[0]]; assert(bot.low == null and bot.hi == null); bot.low = .{ .bot = vals[1] }; bot.hi = .{ .output = vals[2] }; } else { trace("can't parse: '{}'", .{line}); unreachable; } } } var outputs: [1000]u32 = undefined; var changed = true; while (changed) { changed = false; for (bots) |*bot, ibot| { if (bot.val[0]) |v0| { if (bot.val[1]) |v1| { changed = true; assert(bot.low != null and bot.hi != null); const vlow = if (v0 < v1) v0 else v1; const vhi = if (v0 >= v1) v0 else v1; if (vlow == 17 and vhi == 61) try stdout.print("bot n°{} is doing the compare\n", .{ibot}); switch (bot.low.?) { .output => |o| { trace("bot n°{} puts val-{} to output{}\n", .{ ibot, vlow, o }); outputs[o] = vlow; }, .bot => |b| { trace("bot n°{} gives val-{} to bot n°{}\n", .{ ibot, vlow, b }); const to = &bots[b]; if (to.val[0] == null) { to.val[0] = vlow; } else { assert(to.val[1] == null); to.val[1] = vlow; } }, } bot.val[0] = null; switch (bot.hi.?) { .output => |o| { trace("bot n°{} puts val-{} to output{}\n", .{ ibot, vhi, o }); outputs[o] = vhi; }, .bot => |b| { trace("bot n°{} gives val-{} to bot n°{}\n", .{ ibot, vhi, b }); const to = &bots[b]; if (to.val[0] == null) { to.val[0] = vhi; } else { assert(to.val[1] == null); to.val[1] = vhi; } }, } bot.val[1] = null; } } } } try stdout.print("outputs[{}, {}, {}] = {}\n", .{ outputs[0], outputs[1], outputs[2], outputs[0] * outputs[1] * outputs[2] }); }
2016/day10.zig
const std = @import("std"); const Cell = struct { row: u8, col: u8, marked: bool }; const Cells = std.AutoHashMap(u32, Cell); const Board = struct { cells: Cells, row_sums: [5]u32, col_sums: [5]u32, won: bool, fn justWon(self: Board, row: u8, col: u8) bool { return !self.won and (self.row_sums[row] == 0 or self.col_sums[col] == 0); } fn score(self: Board, called_num: u32) u32 { var unmarked_sum: u32 = 0; var contents_iter = self.cells.iterator(); while (contents_iter.next()) |entry| { if (!entry.value_ptr.*.marked) { unmarked_sum += entry.key_ptr.*; } } return called_num * unmarked_sum; } }; pub fn main() !void { var gpalloc = std.heap.GeneralPurposeAllocator(.{}){}; var allocator = &gpalloc.allocator; defer std.debug.assert(!gpalloc.deinit()); const file = try std.fs.cwd().openFile("../inputs/04.txt", .{}); defer file.close(); const reader = file.reader(); var calls_buf: [512]u8 = undefined; const calls_line = try reader.readUntilDelimiter(&calls_buf, '\n'); var boards = std.ArrayList(Board).init(allocator); defer { for (boards.items) |*board| { board.cells.deinit(); } boards.deinit(); } var row: u8 = 0; var col: u8 = 0; var buf: [32]u8 = undefined; while (try reader.readUntilDelimiterOrEof(&buf, '\n')) |line| { if (line.len == 0) { const board = Board{ .cells = Cells.init(allocator), // There are zeros in the boards, so we need to add 1 for each number. .row_sums = [_]u32{5} ** 5, .col_sums = [_]u32{5} ** 5, .won = false, }; try boards.append(board); row = 0; col = 0; continue; } col = 0; var board = &boards.items[boards.items.len - 1]; var iter = std.mem.tokenize(u8, line, " "); while (iter.next()) |v| { const num = try std.fmt.parseInt(u32, v, 10); try board.cells.put(num, Cell{ .row = row, .col = col, .marked = false }); board.row_sums[row] += num; board.col_sums[col] += num; col += 1; } row += 1; } var winners: u32 = 0; var iter = std.mem.tokenize(u8, calls_line, ","); while (iter.next()) |v| { const num = try std.fmt.parseInt(u32, v, 10); for (boards.items) |*board| { if (board.cells.getPtr(num)) |cell| { cell.marked = true; board.row_sums[cell.row] -= 1 + num; board.col_sums[cell.col] -= 1 + num; if (board.justWon(cell.row, cell.col)) { board.won = true; winners += 1; if (winners == 1) { std.log.info("Bingo! Part 1: {d}", .{board.score(num)}); } else if (winners == boards.items.len) { std.log.info("Bingo! Part 2: {d}", .{board.score(num)}); return; } } } } } }
2021/zig/04.zig
const std = @import("std"); const TestData = struct { year_a: u64, year_b: u64, expected_result: u64 }; /// Helper function to populate the array as Zig doesn't seem to support assigning directly in array /// fn createTestData(a: u64, b: u64, expected_result: u64) TestData { return TestData{ .year_a = a, .year_b = b, .expected_result = expected_result }; } /// Reddit Daily Challenge #376 /// https://www.reddit.com/r/dailyprogrammer/comments/b0nuoh/20190313_challenge_376_intermediate_the_revised/ /// /// Given two positive year numbers (with the second one greater than or equal to the first), /// find out how many leap days (Feb 29ths) appear between Jan 1 of the first year, and Jan 1 of the second year in the Revised Julian Calendar. /// This is equivalent to asking how many leap years there are in the interval between the two years, including the first but excluding the second. /// pub fn main() !void { const tests = [_]TestData{ createTestData(2016, 2017, 1), createTestData(2019, 2020, 0), createTestData(1900, 1901, 0), createTestData(2000, 2001, 1), createTestData(2800, 2801, 0), createTestData(123456, 123456, 0), createTestData(1234, 5678, 1077), createTestData(123456, 7891011, 1881475), createTestData(123456789101112, 1314151617181920, 288412747246240), }; const stdout = std.io.getStdOut().outStream(); for (tests) |t| { const leap_count = leaps(t.year_a, t.year_b); if (leap_count != t.expected_result) try stdout.print("Failed '{}' => '{}'. Expected: {} Actual: {}\n", .{ t.year_a, t.year_b, t.expected_result, leap_count }); } try stdout.print("Completed {} Tests\n", .{tests.len}); } /// The Revised Julian Calendar is a calendar system very similar to the familiar Gregorian Calendar, but slightly more accurate in terms of average year length. The Revised Julian Calendar has a leap day on Feb 29th of leap years as follows: /// Years that are evenly divisible by 4 are leap years. /// Exception: Years that are evenly divisible by 100 are not leap years. /// Exception to the exception: Years for which the remainder when divided by 900 is either 200 or 600 are leap years. /// For instance, 2000 is an exception to the exception: the remainder when dividing 2000 by 900 is 200. So 2000 is a leap year in the Revised Julian Calendar /// fn leaps(year_a: u64, year_b: u64) u64 { return totalLeaps(year_b) - totalLeaps(year_a); } /// Calculate the number of leap years to the given year starting at zero /// inline fn totalLeaps(year: u64) u64 { const y = year - 1; return y / 4 - y / 100 + (y - 200) / 900 + (y - 600) / 900; }
376_RevisedJulianCalendar/main.zig
const xcb = @import("../xcb.zig"); pub const id = xcb.Extension{ .name = "X-Resource", .global_id = 0 }; /// @brief Client pub const Client = struct { @"resource_base": u32, @"resource_mask": u32, }; /// @brief Type pub const Type = struct { @"resource_type": xcb.ATOM, @"count": u32, }; pub const ClientIdMask = extern enum(c_uint) { @"ClientXID" = 1, @"LocalClientPID" = 2, }; /// @brief ClientIdSpec pub const ClientIdSpec = struct { @"client": u32, @"mask": u32, }; /// @brief ClientIdValue pub const ClientIdValue = struct { @"spec": xcb.res.ClientIdSpec, @"length": u32, @"value": []u32, }; /// @brief ResourceIdSpec pub const ResourceIdSpec = struct { @"resource": u32, @"type": u32, }; /// @brief ResourceSizeSpec pub const ResourceSizeSpec = struct { @"spec": xcb.res.ResourceIdSpec, @"bytes": u32, @"ref_count": u32, @"use_count": u32, }; /// @brief ResourceSizeValue pub const ResourceSizeValue = struct { @"size": xcb.res.ResourceSizeSpec, @"num_cross_references": u32, @"cross_references": []xcb.res.ResourceSizeSpec, }; /// @brief QueryVersioncookie pub const QueryVersioncookie = struct { sequence: c_uint, }; /// @brief QueryVersionRequest pub const QueryVersionRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 0, @"length": u16, @"client_major": u8, @"client_minor": u8, }; /// @brief QueryVersionReply pub const QueryVersionReply = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, @"length": u32, @"server_major": u16, @"server_minor": u16, }; /// @brief QueryClientscookie pub const QueryClientscookie = struct { sequence: c_uint, }; /// @brief QueryClientsRequest pub const QueryClientsRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 1, @"length": u16, }; /// @brief QueryClientsReply pub const QueryClientsReply = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, @"length": u32, @"num_clients": u32, @"pad1": [20]u8, @"clients": []xcb.res.Client, }; /// @brief QueryClientResourcescookie pub const QueryClientResourcescookie = struct { sequence: c_uint, }; /// @brief QueryClientResourcesRequest pub const QueryClientResourcesRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 2, @"length": u16, @"xid": u32, }; /// @brief QueryClientResourcesReply pub const QueryClientResourcesReply = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, @"length": u32, @"num_types": u32, @"pad1": [20]u8, @"types": []xcb.res.Type, }; /// @brief QueryClientPixmapBytescookie pub const QueryClientPixmapBytescookie = struct { sequence: c_uint, }; /// @brief QueryClientPixmapBytesRequest pub const QueryClientPixmapBytesRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 3, @"length": u16, @"xid": u32, }; /// @brief QueryClientPixmapBytesReply pub const QueryClientPixmapBytesReply = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, @"length": u32, @"bytes": u32, @"bytes_overflow": u32, }; /// @brief QueryClientIdscookie pub const QueryClientIdscookie = struct { sequence: c_uint, }; /// @brief QueryClientIdsRequest pub const QueryClientIdsRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 4, @"length": u16, @"num_specs": u32, @"specs": []const xcb.res.ClientIdSpec, }; /// @brief QueryClientIdsReply pub const QueryClientIdsReply = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, @"length": u32, @"num_ids": u32, @"pad1": [20]u8, @"ids": []xcb.res.ClientIdValue, }; /// @brief QueryResourceBytescookie pub const QueryResourceBytescookie = struct { sequence: c_uint, }; /// @brief QueryResourceBytesRequest pub const QueryResourceBytesRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 5, @"length": u16, @"client": u32, @"num_specs": u32, @"specs": []const xcb.res.ResourceIdSpec, }; /// @brief QueryResourceBytesReply pub const QueryResourceBytesReply = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, @"length": u32, @"num_sizes": u32, @"pad1": [20]u8, @"sizes": []xcb.res.ResourceSizeValue, }; test "" { @import("std").testing.refAllDecls(@This()); }
src/auto/res.zig
const std = @import("std"); const mem = std.mem; const testing = std.testing; /// Create a new trie with the given key and value types. pub fn Trieton(comptime K: type, comptime V: type) type { return struct { const NodeMap = std.AutoHashMap(K, Node); const Node = struct { value: ?V, children: ?NodeMap, fn init() Node { return Node{ .value = null, .children = null, }; } fn deinit(self: *Node) void { if (self.children) |*children| { var iter = children.iterator(); while (iter.next()) |entry| { entry.value_ptr.deinit(); } children.deinit(); } } }; allocator: *mem.Allocator, root: Node, pub fn init(allocator: *mem.Allocator) Self { return Self{ .allocator = allocator, .root = Node.init(), }; } const Self = @This(); pub fn deinit(self: *Self) void { self.root.deinit(); } /// add a value for the specified key. Keys are slices of the key value type. pub fn add(self: *Self, key: []const K, value: V) !void { var current = &self.root; for (key) |k| { if (current.children == null) current.children = NodeMap.init(self.allocator); var result = try current.children.?.getOrPut(k); if (!result.found_existing) { result.value_ptr.* = Node.init(); } current = result.value_ptr; } current.value = value; } /// Lookup is returned from the find method on a successful match. The index field refers to /// the index of the element in the key slice that produced the match. pub const Lookup = struct { index: usize, value: V, }; /// finds the matching value for the given key, null otherwise. pub fn find(self: Self, key: []const K) ?Lookup { var current = &self.root; var result: ?Lookup = null; for (key) |k, i| { if (current.children == null or current.children.?.get(k) == null) break; current = &current.children.?.get(k).?; if (current.value) |value| { result = .{ .index = i, .value = value, }; } } return result; } }; } test "Byte Trieton" { const ByteTrie = Trieton(u8, void); const Lookup = ByteTrie.Lookup; var byte_trie = ByteTrie.init(std.testing.allocator); defer byte_trie.deinit(); try byte_trie.add(&[_]u8{ 1, 2 }, {}); try byte_trie.add(&[_]u8{ 1, 2, 3 }, {}); try testing.expectEqual(Lookup{ .index = 2, .value = {} }, byte_trie.find(&[_]u8{ 1, 2, 3 }).?); try testing.expectEqual(Lookup{ .index = 1, .value = {} }, byte_trie.find(&[_]u8{ 1, 2 }).?); try testing.expectEqual(byte_trie.find(&[_]u8{1}), null); } test "Code Point Map Trieton" { const CodePointTrie = Trieton(u21, u21); const Lookup = CodePointTrie.Lookup; var cpmap_trie = CodePointTrie.init(std.testing.allocator); defer cpmap_trie.deinit(); try cpmap_trie.add(&[_]u21{ 1, 2 }, 0x2112); try cpmap_trie.add(&[_]u21{ 1, 2, 3 }, 0x3113); try testing.expectEqual(Lookup{ .index = 2, .value = 0x3113 }, cpmap_trie.find(&[_]u21{ 1, 2, 3 }).?); try testing.expectEqual(Lookup{ .index = 1, .value = 0x2112 }, cpmap_trie.find(&[_]u21{ 1, 2 }).?); try testing.expect(cpmap_trie.find(&[_]u21{1}) == null); }
src/trieton.zig
const builtin = @import("builtin"); const warn = @import("std").debug.warn; const druzhba = @import("../druzhba.zig"); const intToStr = @import("../comptimeutils.zig").intToStr; // Please do not run `zig fmt` on this source... It makes chained fn calls ugly. const traceInPortName = "port"; const traceOutPortName = "port"; /// Create a class that logs method calls via `std.debug.warn`. /// /// The class has two ports: an inbound port and an outbound port, both named /// `port` and having the signature `sig`. All method invocations on the inbound /// ports are forwarded to the outbound port. Before and after method calls are /// forwarded, their method names and parameter values as well as an optional /// custom label specified via an attribute are written to `std.debug.warn`. /// /// Beware that parameters and return values are outputted simply by calling /// `std.debug.warn`. This means all pointers within them are assumed to be /// valid. Since this component is intended to be used only during development, /// this shouldn't be a big problem. pub fn Trace(comptime Sig: druzhba.Sig) druzhba.Class { return druzhba.defineClass() .attr(?[]const u8) .in(traceInPortName, Sig, struct { fn ___(comptime Self: type) type { return struct { pub fn __vtable__() Sig.Vtable(Self) { const Vtable = Sig.Vtable(Self); comptime var vtable: Vtable = undefined; comptime { var i = 0; while (i < @memberCount(Vtable)) { const name = @memberName(Vtable, i); const FnType = @memberType(Vtable, i); @field(vtable, name) = @field( traceOneMethod(Self, FnType, name), "call" ++ intToStr(argCount(FnType) - 1), ); i += 1; } } return vtable; } }; } }.___) .out(traceOutPortName, Sig) .build(); } pub const TraceIo = struct { in_port: druzhba.InPort, out_port: druzhba.OutPort, }; /// Add a trace component. pub fn addTrace( comptime ctx: *druzhba.ComposeCtx, comptime Sig: druzhba.Sig, comptime label: ?[]const u8, ) TraceIo { const cell = ctx.new(Trace(Sig)).withAttr(label); return TraceIo { .in_port = cell.in("port"), .out_port = cell.out("port"), }; } /// Attach a trace component to the specified `InPort` or `OutPort`, and returns /// a port of the same type. pub fn wrapTrace( comptime ctx: *druzhba.ComposeCtx, comptime port: var, comptime label: ?[]const u8, ) @typeOf(port) { if (@typeOf(port) == druzhba.InPort) { const io = addTrace(ctx, port.PortSig(), label); ctx.connect(io.out_port, port); return io.in_port; } else if (@typeOf(port) == druzhba.OutPort) { const io = addTrace(ctx, port.PortSig(), label); ctx.connect(port, io.in_port); return io.out_port; } else { @compileError(@typeName(@typeOf(port)) ++ " is neither `InPort` nor `OutPort`."); } } /// Generates the implementation for a single method handled by `Trace`. fn traceOneMethod(comptime Self: type, comptime Fn: type, comptime method_name: []const u8) type { const Ret = Fn.ReturnType; const A0 = ArgType(Fn, 1); const A1 = ArgType(Fn, 2); const A2 = ArgType(Fn, 3); const A3 = ArgType(Fn, 4); const A4 = ArgType(Fn, 5); const A5 = ArgType(Fn, 6); return struct { fn call0(self: Self) Ret { traceEnter(self, method_name); return traceLeave(self, method_name, self.out(traceOutPortName).invoke(method_name)); } fn call1(self: Self, a0: A0) Ret { traceEnter(self, method_name, a0); return traceLeave(self, method_name, self.out(traceOutPortName).invoke(method_name, a0), a0); } fn call2(self: Self, a0: A0, a1: A1) Ret { traceEnter(self, method_name, a0, a1); return traceLeave(self, method_name, self.out(traceOutPortName).invoke(method_name, a0, a1), a0, a1); } fn call3(self: Self, a0: A0, a1: A1, a2: A2) Ret { traceEnter(self, method_name, a0, a1, a2); return traceLeave(self, method_name, self.out(traceOutPortName).invoke(method_name, a0, a1, a2), a0, a1, a2); } fn call4(self: Self, a0: A0, a1: A1, a2: A2, a3: A3) Ret { traceEnter(self, method_name, a0, a1, a2, a3); return traceLeave(self, method_name, self.out(traceOutPortName).invoke(method_name, a0, a1, a2, a3), a0, a1, a2, a3); } fn call5(self: Self, a0: A0, a1: A1, a2: A2, a3: A3, a4: A4) Ret { traceEnter(self, method_name, a0, a1, a2, a3, a4); return traceLeave(self, method_name, self.out(traceOutPortName).invoke(method_name, a0, a1, a2, a3, a4), a0, a1, a2, a3, a4); } fn call6(self: Self, a0: A0, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) Ret { traceEnter(self, method_name, a0, a1, a2, a3, a4, a5); return traceLeave(self, method_name, self.out(traceOutPortName).invoke(method_name, a0, a1, a2, a3, a4, a5), a0, a1, a2, a3, a4, a5); } // TODO: more parameters... }; } fn argCount(comptime ty: type) usize { switch (@typeInfo(ty)) { builtin.TypeId.Fn => |fn_info| { return fn_info.args.len; }, else => @compileError("not a function type"), } } fn ArgType(comptime ty: type, comptime i: usize) type { switch (@typeInfo(ty)) { builtin.TypeId.Fn => |fn_info| { if (i < fn_info.args.len) { return fn_info.args[i].arg_type.?; } else { return void; } }, else => @compileError("not a function type"), } } fn traceEnter(self: var, method_name: []const u8, args: ...) void { traceCommon(self, "enter", method_name, args); warn("\n"); } fn traceLeave(self: var, method_name: []const u8, ret_value: var, args: ...) @typeOf(ret_value) { traceCommon(self, "leave", method_name, args); warn(" = "); debugValue(ret_value); warn("\n"); return ret_value; } fn traceCommon(self: var, dir: []const u8, method_name: []const u8, args: ...) void { if (self.attr().*) |label| { warn("{}", label); } warn(" [{}] {}(", dir, method_name); if (args.len > 0) { debugValue(args[0]); comptime var i = 1; inline while (i < args.len) { warn(", "); debugValue(args[i]); i += 1; } } warn(")"); } fn debugValue(val: var) void { // Compiler bug: Var args can't handle void // <https://github.com/ziglang/zig/issues/557> if (@typeOf(val) == void) { warn("void"); } else { warn("{}", val); } }
druzhba/components/trace.zig
const builtin = @import("builtin"); const std = @import("../std.zig"); const maxInt = std.math.maxInt; usingnamespace std.c; pub const _errno = switch (builtin.abi) { .android => struct { extern "c" var __errno: c_int; fn getErrno() *c_int { return &__errno; } }.getErrno, else => struct { extern "c" fn __errno_location() *c_int; }.__errno_location, }; pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); pub const AI_PASSIVE = 0x01; pub const AI_CANONNAME = 0x02; pub const AI_NUMERICHOST = 0x04; pub const AI_V4MAPPED = 0x08; pub const AI_ALL = 0x10; pub const AI_ADDRCONFIG = 0x20; pub const AI_NUMERICSERV = 0x400; pub const NI_NUMERICHOST = 0x01; pub const NI_NUMERICSERV = 0x02; pub const NI_NOFQDN = 0x04; pub const NI_NAMEREQD = 0x08; pub const NI_DGRAM = 0x10; pub const NI_NUMERICSCOPE = 0x100; pub const EAI_BADFLAGS = -1; pub const EAI_NONAME = -2; pub const EAI_AGAIN = -3; pub const EAI_FAIL = -4; pub const EAI_FAMILY = -6; pub const EAI_SOCKTYPE = -7; pub const EAI_SERVICE = -8; pub const EAI_MEMORY = -10; pub const EAI_SYSTEM = -11; pub const EAI_OVERFLOW = -12; pub const EAI_NODATA = -5; pub const EAI_ADDRFAMILY = -9; pub const EAI_INPROGRESS = -100; pub const EAI_CANCELED = -101; pub const EAI_NOTCANCELED = -102; pub const EAI_ALLDONE = -103; pub const EAI_INTR = -104; pub const EAI_IDN_ENCODE = -105; pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int; pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int; pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: ?*epoll_event) c_int; pub extern "c" fn epoll_create1(flags: c_uint) c_int; pub extern "c" fn epoll_wait(epfd: fd_t, events: [*]epoll_event, maxevents: c_uint, timeout: c_int) c_int; pub extern "c" fn epoll_pwait( epfd: fd_t, events: [*]epoll_event, maxevents: c_int, timeout: c_int, sigmask: *const sigset_t, ) c_int; pub extern "c" fn inotify_init1(flags: c_uint) c_int; pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*]const u8, mask: u32) c_int; /// See std.elf for constants for this pub extern "c" fn getauxval(__type: c_ulong) c_ulong; pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int; pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; pub const pthread_attr_t = extern struct { __size: [56]u8, __align: c_long, }; pub const pthread_mutex_t = extern struct { size: [__SIZEOF_PTHREAD_MUTEX_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_MUTEX_T, }; pub const pthread_cond_t = extern struct { size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T, }; const __SIZEOF_PTHREAD_COND_T = 48; const __SIZEOF_PTHREAD_MUTEX_T = if (builtin.os == .fuchsia) 40 else switch (builtin.abi) { .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24, .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (builtin.arch) { .aarch64 => 48, .x86_64 => if (builtin.abi == .gnux32) 40 else 32, .mips64, .powerpc64, .powerpc64le, .sparcv9 => 40, else => if (@sizeOf(usize) == 8) 40 else 24, }, else => unreachable, }; pub const RTLD_LAZY = 1; pub const RTLD_NOW = 2; pub const RTLD_NOLOAD = 4; pub const RTLD_NODELETE = 4096; pub const RTLD_GLOBAL = 256; pub const RTLD_LOCAL = 0;
lib/std/c/linux.zig
// MIT License // // Copyright (c) 2016 <NAME> // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // Be aware that this implementation has the following limitations: // // - Is not round-trip accurate for all values // - Only supports round-to-zero // - Does not handle denormals const std = @import("../std.zig"); const ascii = std.ascii; // The mantissa field in FloatRepr is 64bit wide and holds only 19 digits // without overflowing const max_digits = 19; const f64_plus_zero: u64 = 0x0000000000000000; const f64_minus_zero: u64 = 0x8000000000000000; const f64_plus_infinity: u64 = 0x7FF0000000000000; const f64_minus_infinity: u64 = 0xFFF0000000000000; const Z96 = struct { d0: u32, d1: u32, d2: u32, // d = s >> 1 fn shiftRight1(d: *Z96, s: Z96) callconv(.Inline) void { d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31); d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31); d.d2 = s.d2 >> 1; } // d = s << 1 fn shiftLeft1(d: *Z96, s: Z96) callconv(.Inline) void { d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31); d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31); d.d0 = s.d0 << 1; } // d += s fn add(d: *Z96, s: Z96) callconv(.Inline) void { var w = @as(u64, d.d0) + @as(u64, s.d0); d.d0 = @truncate(u32, w); w >>= 32; w += @as(u64, d.d1) + @as(u64, s.d1); d.d1 = @truncate(u32, w); w >>= 32; w += @as(u64, d.d2) + @as(u64, s.d2); d.d2 = @truncate(u32, w); } // d -= s fn sub(d: *Z96, s: Z96) callconv(.Inline) void { var w = @as(u64, d.d0) -% @as(u64, s.d0); d.d0 = @truncate(u32, w); w >>= 32; w += @as(u64, d.d1) -% @as(u64, s.d1); d.d1 = @truncate(u32, w); w >>= 32; w += @as(u64, d.d2) -% @as(u64, s.d2); d.d2 = @truncate(u32, w); } }; const FloatRepr = struct { negative: bool, exponent: i32, mantissa: u64, }; fn convertRepr(comptime T: type, n: FloatRepr) T { const mask28: u32 = 0xf << 28; var s: Z96 = undefined; var q: Z96 = undefined; var r: Z96 = undefined; s.d0 = @truncate(u32, n.mantissa); s.d1 = @truncate(u32, n.mantissa >> 32); s.d2 = 0; var binary_exponent: i32 = 92; var exp = n.exponent; while (exp > 0) : (exp -= 1) { q.shiftLeft1(s); // q = p << 1 r.shiftLeft1(q); // r = p << 2 s.shiftLeft1(r); // p = p << 3 s.add(q); // p = (p << 3) + (p << 1) while (s.d2 & mask28 != 0) { q.shiftRight1(s); binary_exponent += 1; s = q; } } while (exp < 0) { while (s.d2 & (1 << 31) == 0) { q.shiftLeft1(s); binary_exponent -= 1; s = q; } q.d2 = s.d2 / 10; r.d1 = s.d2 % 10; r.d2 = (s.d1 >> 8) | (r.d1 << 24); q.d1 = r.d2 / 10; r.d1 = r.d2 % 10; r.d2 = ((s.d1 & 0xff) << 16) | (s.d0 >> 16) | (r.d1 << 24); r.d0 = r.d2 / 10; r.d1 = r.d2 % 10; q.d1 = (q.d1 << 8) | ((r.d0 & 0x00ff0000) >> 16); q.d0 = r.d0 << 16; r.d2 = (s.d0 *% 0xffff) | (r.d1 << 16); q.d0 |= r.d2 / 10; s = q; exp += 1; } if (s.d0 != 0 or s.d1 != 0 or s.d2 != 0) { while (s.d2 & mask28 == 0) { q.shiftLeft1(s); binary_exponent -= 1; s = q; } } binary_exponent += 1023; const repr: u64 = blk: { if (binary_exponent > 2046) { break :blk if (n.negative) f64_minus_infinity else f64_plus_infinity; } else if (binary_exponent < 1) { break :blk if (n.negative) f64_minus_zero else f64_plus_zero; } else if (s.d2 != 0) { const binexs2 = @intCast(u64, binary_exponent) << 52; const rr = (@as(u64, s.d2 & ~mask28) << 24) | ((@as(u64, s.d1) + 128) >> 8) | binexs2; break :blk if (n.negative) rr | (1 << 63) else rr; } else { break :blk 0; } }; const f = @bitCast(f64, repr); return @floatCast(T, f); } const State = enum { MaybeSign, LeadingMantissaZeros, LeadingFractionalZeros, MantissaIntegral, MantissaFractional, ExponentSign, LeadingExponentZeros, Exponent, }; const ParseResult = enum { Ok, PlusZero, MinusZero, PlusInf, MinusInf, }; fn parseRepr(s: []const u8, n: *FloatRepr) !ParseResult { var digit_index: usize = 0; var negative = false; var negative_exp = false; var exponent: i32 = 0; var state = State.MaybeSign; var i: usize = 0; while (i < s.len) { const c = s[i]; switch (state) { .MaybeSign => { state = .LeadingMantissaZeros; if (c == '+') { i += 1; } else if (c == '-') { n.negative = true; i += 1; } else if (ascii.isDigit(c) or c == '.') { // continue } else { return error.InvalidCharacter; } }, .LeadingMantissaZeros => { if (c == '0') { i += 1; } else if (c == '.') { i += 1; state = .LeadingFractionalZeros; } else { state = .MantissaIntegral; } }, .LeadingFractionalZeros => { if (c == '0') { i += 1; if (n.exponent > std.math.minInt(i32)) { n.exponent -= 1; } } else { state = .MantissaFractional; } }, .MantissaIntegral => { if (ascii.isDigit(c)) { if (digit_index < max_digits) { n.mantissa *%= 10; n.mantissa += c - '0'; digit_index += 1; } else if (n.exponent < std.math.maxInt(i32)) { n.exponent += 1; } i += 1; } else if (c == '.') { i += 1; state = .MantissaFractional; } else { state = .MantissaFractional; } }, .MantissaFractional => { if (ascii.isDigit(c)) { if (digit_index < max_digits) { n.mantissa *%= 10; n.mantissa += c - '0'; n.exponent -%= 1; digit_index += 1; } i += 1; } else if (c == 'e' or c == 'E') { i += 1; state = .ExponentSign; } else { state = .ExponentSign; } }, .ExponentSign => { if (c == '+') { i += 1; } else if (c == '-') { negative_exp = true; i += 1; } state = .LeadingExponentZeros; }, .LeadingExponentZeros => { if (c == '0') { i += 1; } else { state = .Exponent; } }, .Exponent => { if (ascii.isDigit(c)) { if (exponent < std.math.maxInt(i32) / 10) { exponent *= 10; exponent += @intCast(i32, c - '0'); } i += 1; } else { return error.InvalidCharacter; } }, } } if (negative_exp) exponent = -exponent; n.exponent += exponent; if (n.mantissa == 0) { return if (n.negative) .MinusZero else .PlusZero; } else if (n.exponent > 309) { return if (n.negative) .MinusInf else .PlusInf; } else if (n.exponent < -328) { return if (n.negative) .MinusZero else .PlusZero; } return .Ok; } fn caseInEql(a: []const u8, b: []const u8) bool { if (a.len != b.len) return false; for (a) |_, i| { if (ascii.toUpper(a[i]) != ascii.toUpper(b[i])) { return false; } } return true; } pub fn parseFloat(comptime T: type, s: []const u8) !T { if (s.len == 0 or (s.len == 1 and (s[0] == '+' or s[0] == '-'))) { return error.InvalidCharacter; } if (caseInEql(s, "nan")) { return std.math.nan(T); } else if (caseInEql(s, "inf") or caseInEql(s, "+inf")) { return std.math.inf(T); } else if (caseInEql(s, "-inf")) { return -std.math.inf(T); } var r = FloatRepr{ .negative = false, .exponent = 0, .mantissa = 0, }; return switch (try parseRepr(s, &r)) { .Ok => convertRepr(T, r), .PlusZero => 0.0, .MinusZero => -@as(T, 0.0), .PlusInf => std.math.inf(T), .MinusInf => -std.math.inf(T), }; } test "fmt.parseFloat" { const testing = std.testing; const expect = testing.expect; const expectEqual = testing.expectEqual; const approxEqAbs = std.math.approxEqAbs; const epsilon = 1e-7; inline for ([_]type{ f16, f32, f64, f128 }) |T| { const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); try testing.expectError(error.InvalidCharacter, parseFloat(T, "")); try testing.expectError(error.InvalidCharacter, parseFloat(T, " 1")); try testing.expectError(error.InvalidCharacter, parseFloat(T, "1abc")); try testing.expectError(error.InvalidCharacter, parseFloat(T, "+")); try testing.expectError(error.InvalidCharacter, parseFloat(T, "-")); try expectEqual(try parseFloat(T, "0"), 0.0); try expectEqual(try parseFloat(T, "0"), 0.0); try expectEqual(try parseFloat(T, "+0"), 0.0); try expectEqual(try parseFloat(T, "-0"), 0.0); try expectEqual(try parseFloat(T, "0e0"), 0); try expectEqual(try parseFloat(T, "2e3"), 2000.0); try expectEqual(try parseFloat(T, "1e0"), 1.0); try expectEqual(try parseFloat(T, "-2e3"), -2000.0); try expectEqual(try parseFloat(T, "-1e0"), -1.0); try expectEqual(try parseFloat(T, "1.234e3"), 1234); try expect(approxEqAbs(T, try parseFloat(T, "3.141"), 3.141, epsilon)); try expect(approxEqAbs(T, try parseFloat(T, "-3.141"), -3.141, epsilon)); try expectEqual(try parseFloat(T, "1e-700"), 0); try expectEqual(try parseFloat(T, "1e+700"), std.math.inf(T)); try expectEqual(@bitCast(Z, try parseFloat(T, "nAn")), @bitCast(Z, std.math.nan(T))); try expectEqual(try parseFloat(T, "inF"), std.math.inf(T)); try expectEqual(try parseFloat(T, "-INF"), -std.math.inf(T)); try expectEqual(try parseFloat(T, "0.4e0066999999999999999999999999999999999999999999999999999"), std.math.inf(T)); if (T != f16) { try expect(approxEqAbs(T, try parseFloat(T, "1e-2"), 0.01, epsilon)); try expect(approxEqAbs(T, try parseFloat(T, "1234e-2"), 12.34, epsilon)); try expect(approxEqAbs(T, try parseFloat(T, "123142.1"), 123142.1, epsilon)); try expect(approxEqAbs(T, try parseFloat(T, "-123142.1124"), @as(T, -123142.1124), epsilon)); try expect(approxEqAbs(T, try parseFloat(T, "0.7062146892655368"), @as(T, 0.7062146892655368), epsilon)); try expect(approxEqAbs(T, try parseFloat(T, "2.71828182845904523536"), @as(T, 2.718281828459045), epsilon)); } } }
lib/std/fmt/parse_float.zig
const std = @import("std"); const cast = std.meta.cast; const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels pub const Limbs = [4]u64; /// The function addcarryxU64 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 addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { @setRuntimeSafety(mode == .Debug); var t: u64 = undefined; const carry1 = @addWithOverflow(u64, arg2, arg3, &t); const carry2 = @addWithOverflow(u64, t, arg1, out1); out2.* = @boolToInt(carry1) | @boolToInt(carry2); } /// The function subborrowxU64 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 subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { @setRuntimeSafety(mode == .Debug); var t: u64 = undefined; const carry1 = @subWithOverflow(u64, arg2, arg3, &t); const carry2 = @subWithOverflow(u64, t, arg1, out1); out2.* = @boolToInt(carry1) | @boolToInt(carry2); } /// The function mulxU64 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 mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void { @setRuntimeSafety(mode == .Debug); const x = @as(u128, arg1) * @as(u128, arg2); out1.* = @truncate(u64, x); out2.* = @truncate(u64, x >> 64); } /// The function cmovznzU64 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 cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { @setRuntimeSafety(mode == .Debug); const mask = 0 -% @as(u64, arg1); out1.* = (mask & arg3) | ((~mask) & arg2); } /// The function mul 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]] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn mul(out1: *[4]u64, arg1: [4]u64, arg2: [4]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[1]); const x2 = (arg1[2]); const x3 = (arg1[3]); const x4 = (arg1[0]); var x5: u64 = undefined; var x6: u64 = undefined; mulxU64(&x5, &x6, x4, (arg2[3])); var x7: u64 = undefined; var x8: u64 = undefined; mulxU64(&x7, &x8, x4, (arg2[2])); var x9: u64 = undefined; var x10: u64 = undefined; mulxU64(&x9, &x10, x4, (arg2[1])); var x11: u64 = undefined; var x12: u64 = undefined; mulxU64(&x11, &x12, x4, (arg2[0])); var x13: u64 = undefined; var x14: u1 = undefined; addcarryxU64(&x13, &x14, 0x0, x12, x9); var x15: u64 = undefined; var x16: u1 = undefined; addcarryxU64(&x15, &x16, x14, x10, x7); var x17: u64 = undefined; var x18: u1 = undefined; addcarryxU64(&x17, &x18, x16, x8, x5); const x19 = (cast(u64, x18) + x6); var x20: u64 = undefined; var x21: u64 = undefined; mulxU64(&x20, &x21, x11, 0xffffffff00000001); var x22: u64 = undefined; var x23: u64 = undefined; mulxU64(&x22, &x23, x11, 0xffffffff); var x24: u64 = undefined; var x25: u64 = undefined; mulxU64(&x24, &x25, x11, 0xffffffffffffffff); var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU64(&x26, &x27, 0x0, x25, x22); const x28 = (cast(u64, x27) + x23); var x29: u64 = undefined; var x30: u1 = undefined; addcarryxU64(&x29, &x30, 0x0, x11, x24); var x31: u64 = undefined; var x32: u1 = undefined; addcarryxU64(&x31, &x32, x30, x13, x26); var x33: u64 = undefined; var x34: u1 = undefined; addcarryxU64(&x33, &x34, x32, x15, x28); var x35: u64 = undefined; var x36: u1 = undefined; addcarryxU64(&x35, &x36, x34, x17, x20); var x37: u64 = undefined; var x38: u1 = undefined; addcarryxU64(&x37, &x38, x36, x19, x21); var x39: u64 = undefined; var x40: u64 = undefined; mulxU64(&x39, &x40, x1, (arg2[3])); var x41: u64 = undefined; var x42: u64 = undefined; mulxU64(&x41, &x42, x1, (arg2[2])); var x43: u64 = undefined; var x44: u64 = undefined; mulxU64(&x43, &x44, x1, (arg2[1])); var x45: u64 = undefined; var x46: u64 = undefined; mulxU64(&x45, &x46, x1, (arg2[0])); var x47: u64 = undefined; var x48: u1 = undefined; addcarryxU64(&x47, &x48, 0x0, x46, x43); var x49: u64 = undefined; var x50: u1 = undefined; addcarryxU64(&x49, &x50, x48, x44, x41); var x51: u64 = undefined; var x52: u1 = undefined; addcarryxU64(&x51, &x52, x50, x42, x39); const x53 = (cast(u64, x52) + x40); var x54: u64 = undefined; var x55: u1 = undefined; addcarryxU64(&x54, &x55, 0x0, x31, x45); var x56: u64 = undefined; var x57: u1 = undefined; addcarryxU64(&x56, &x57, x55, x33, x47); var x58: u64 = undefined; var x59: u1 = undefined; addcarryxU64(&x58, &x59, x57, x35, x49); var x60: u64 = undefined; var x61: u1 = undefined; addcarryxU64(&x60, &x61, x59, x37, x51); var x62: u64 = undefined; var x63: u1 = undefined; addcarryxU64(&x62, &x63, x61, cast(u64, x38), x53); var x64: u64 = undefined; var x65: u64 = undefined; mulxU64(&x64, &x65, x54, 0xffffffff00000001); var x66: u64 = undefined; var x67: u64 = undefined; mulxU64(&x66, &x67, x54, 0xffffffff); var x68: u64 = undefined; var x69: u64 = undefined; mulxU64(&x68, &x69, x54, 0xffffffffffffffff); var x70: u64 = undefined; var x71: u1 = undefined; addcarryxU64(&x70, &x71, 0x0, x69, x66); const x72 = (cast(u64, x71) + x67); var x73: u64 = undefined; var x74: u1 = undefined; addcarryxU64(&x73, &x74, 0x0, x54, x68); var x75: u64 = undefined; var x76: u1 = undefined; addcarryxU64(&x75, &x76, x74, x56, x70); var x77: u64 = undefined; var x78: u1 = undefined; addcarryxU64(&x77, &x78, x76, x58, x72); var x79: u64 = undefined; var x80: u1 = undefined; addcarryxU64(&x79, &x80, x78, x60, x64); var x81: u64 = undefined; var x82: u1 = undefined; addcarryxU64(&x81, &x82, x80, x62, x65); const x83 = (cast(u64, x82) + cast(u64, x63)); var x84: u64 = undefined; var x85: u64 = undefined; mulxU64(&x84, &x85, x2, (arg2[3])); var x86: u64 = undefined; var x87: u64 = undefined; mulxU64(&x86, &x87, x2, (arg2[2])); var x88: u64 = undefined; var x89: u64 = undefined; mulxU64(&x88, &x89, x2, (arg2[1])); var x90: u64 = undefined; var x91: u64 = undefined; mulxU64(&x90, &x91, x2, (arg2[0])); var x92: u64 = undefined; var x93: u1 = undefined; addcarryxU64(&x92, &x93, 0x0, x91, x88); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, x93, x89, x86); var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x87, x84); const x98 = (cast(u64, x97) + x85); var x99: u64 = undefined; var x100: u1 = undefined; addcarryxU64(&x99, &x100, 0x0, x75, x90); var x101: u64 = undefined; var x102: u1 = undefined; addcarryxU64(&x101, &x102, x100, x77, x92); var x103: u64 = undefined; var x104: u1 = undefined; addcarryxU64(&x103, &x104, x102, x79, x94); var x105: u64 = undefined; var x106: u1 = undefined; addcarryxU64(&x105, &x106, x104, x81, x96); var x107: u64 = undefined; var x108: u1 = undefined; addcarryxU64(&x107, &x108, x106, x83, x98); var x109: u64 = undefined; var x110: u64 = undefined; mulxU64(&x109, &x110, x99, 0xffffffff00000001); var x111: u64 = undefined; var x112: u64 = undefined; mulxU64(&x111, &x112, x99, 0xffffffff); var x113: u64 = undefined; var x114: u64 = undefined; mulxU64(&x113, &x114, x99, 0xffffffffffffffff); var x115: u64 = undefined; var x116: u1 = undefined; addcarryxU64(&x115, &x116, 0x0, x114, x111); const x117 = (cast(u64, x116) + x112); var x118: u64 = undefined; var x119: u1 = undefined; addcarryxU64(&x118, &x119, 0x0, x99, x113); var x120: u64 = undefined; var x121: u1 = undefined; addcarryxU64(&x120, &x121, x119, x101, x115); var x122: u64 = undefined; var x123: u1 = undefined; addcarryxU64(&x122, &x123, x121, x103, x117); var x124: u64 = undefined; var x125: u1 = undefined; addcarryxU64(&x124, &x125, x123, x105, x109); var x126: u64 = undefined; var x127: u1 = undefined; addcarryxU64(&x126, &x127, x125, x107, x110); const x128 = (cast(u64, x127) + cast(u64, x108)); var x129: u64 = undefined; var x130: u64 = undefined; mulxU64(&x129, &x130, x3, (arg2[3])); var x131: u64 = undefined; var x132: u64 = undefined; mulxU64(&x131, &x132, x3, (arg2[2])); var x133: u64 = undefined; var x134: u64 = undefined; mulxU64(&x133, &x134, x3, (arg2[1])); var x135: u64 = undefined; var x136: u64 = undefined; mulxU64(&x135, &x136, x3, (arg2[0])); var x137: u64 = undefined; var x138: u1 = undefined; addcarryxU64(&x137, &x138, 0x0, x136, x133); var x139: u64 = undefined; var x140: u1 = undefined; addcarryxU64(&x139, &x140, x138, x134, x131); var x141: u64 = undefined; var x142: u1 = undefined; addcarryxU64(&x141, &x142, x140, x132, x129); const x143 = (cast(u64, x142) + x130); var x144: u64 = undefined; var x145: u1 = undefined; addcarryxU64(&x144, &x145, 0x0, x120, x135); var x146: u64 = undefined; var x147: u1 = undefined; addcarryxU64(&x146, &x147, x145, x122, x137); var x148: u64 = undefined; var x149: u1 = undefined; addcarryxU64(&x148, &x149, x147, x124, x139); var x150: u64 = undefined; var x151: u1 = undefined; addcarryxU64(&x150, &x151, x149, x126, x141); var x152: u64 = undefined; var x153: u1 = undefined; addcarryxU64(&x152, &x153, x151, x128, x143); var x154: u64 = undefined; var x155: u64 = undefined; mulxU64(&x154, &x155, x144, 0xffffffff00000001); var x156: u64 = undefined; var x157: u64 = undefined; mulxU64(&x156, &x157, x144, 0xffffffff); var x158: u64 = undefined; var x159: u64 = undefined; mulxU64(&x158, &x159, x144, 0xffffffffffffffff); var x160: u64 = undefined; var x161: u1 = undefined; addcarryxU64(&x160, &x161, 0x0, x159, x156); const x162 = (cast(u64, x161) + x157); var x163: u64 = undefined; var x164: u1 = undefined; addcarryxU64(&x163, &x164, 0x0, x144, x158); var x165: u64 = undefined; var x166: u1 = undefined; addcarryxU64(&x165, &x166, x164, x146, x160); var x167: u64 = undefined; var x168: u1 = undefined; addcarryxU64(&x167, &x168, x166, x148, x162); var x169: u64 = undefined; var x170: u1 = undefined; addcarryxU64(&x169, &x170, x168, x150, x154); var x171: u64 = undefined; var x172: u1 = undefined; addcarryxU64(&x171, &x172, x170, x152, x155); const x173 = (cast(u64, x172) + cast(u64, x153)); var x174: u64 = undefined; var x175: u1 = undefined; subborrowxU64(&x174, &x175, 0x0, x165, 0xffffffffffffffff); var x176: u64 = undefined; var x177: u1 = undefined; subborrowxU64(&x176, &x177, x175, x167, 0xffffffff); var x178: u64 = undefined; var x179: u1 = undefined; subborrowxU64(&x178, &x179, x177, x169, cast(u64, 0x0)); var x180: u64 = undefined; var x181: u1 = undefined; subborrowxU64(&x180, &x181, x179, x171, 0xffffffff00000001); var x182: u64 = undefined; var x183: u1 = undefined; subborrowxU64(&x182, &x183, x181, x173, cast(u64, 0x0)); var x184: u64 = undefined; cmovznzU64(&x184, x183, x174, x165); var x185: u64 = undefined; cmovznzU64(&x185, x183, x176, x167); var x186: u64 = undefined; cmovznzU64(&x186, x183, x178, x169); var x187: u64 = undefined; cmovznzU64(&x187, x183, x180, x171); out1[0] = x184; out1[1] = x185; out1[2] = x186; out1[3] = x187; } /// The function square 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]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn square(out1: *[4]u64, arg1: [4]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[1]); const x2 = (arg1[2]); const x3 = (arg1[3]); const x4 = (arg1[0]); var x5: u64 = undefined; var x6: u64 = undefined; mulxU64(&x5, &x6, x4, (arg1[3])); var x7: u64 = undefined; var x8: u64 = undefined; mulxU64(&x7, &x8, x4, (arg1[2])); var x9: u64 = undefined; var x10: u64 = undefined; mulxU64(&x9, &x10, x4, (arg1[1])); var x11: u64 = undefined; var x12: u64 = undefined; mulxU64(&x11, &x12, x4, (arg1[0])); var x13: u64 = undefined; var x14: u1 = undefined; addcarryxU64(&x13, &x14, 0x0, x12, x9); var x15: u64 = undefined; var x16: u1 = undefined; addcarryxU64(&x15, &x16, x14, x10, x7); var x17: u64 = undefined; var x18: u1 = undefined; addcarryxU64(&x17, &x18, x16, x8, x5); const x19 = (cast(u64, x18) + x6); var x20: u64 = undefined; var x21: u64 = undefined; mulxU64(&x20, &x21, x11, 0xffffffff00000001); var x22: u64 = undefined; var x23: u64 = undefined; mulxU64(&x22, &x23, x11, 0xffffffff); var x24: u64 = undefined; var x25: u64 = undefined; mulxU64(&x24, &x25, x11, 0xffffffffffffffff); var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU64(&x26, &x27, 0x0, x25, x22); const x28 = (cast(u64, x27) + x23); var x29: u64 = undefined; var x30: u1 = undefined; addcarryxU64(&x29, &x30, 0x0, x11, x24); var x31: u64 = undefined; var x32: u1 = undefined; addcarryxU64(&x31, &x32, x30, x13, x26); var x33: u64 = undefined; var x34: u1 = undefined; addcarryxU64(&x33, &x34, x32, x15, x28); var x35: u64 = undefined; var x36: u1 = undefined; addcarryxU64(&x35, &x36, x34, x17, x20); var x37: u64 = undefined; var x38: u1 = undefined; addcarryxU64(&x37, &x38, x36, x19, x21); var x39: u64 = undefined; var x40: u64 = undefined; mulxU64(&x39, &x40, x1, (arg1[3])); var x41: u64 = undefined; var x42: u64 = undefined; mulxU64(&x41, &x42, x1, (arg1[2])); var x43: u64 = undefined; var x44: u64 = undefined; mulxU64(&x43, &x44, x1, (arg1[1])); var x45: u64 = undefined; var x46: u64 = undefined; mulxU64(&x45, &x46, x1, (arg1[0])); var x47: u64 = undefined; var x48: u1 = undefined; addcarryxU64(&x47, &x48, 0x0, x46, x43); var x49: u64 = undefined; var x50: u1 = undefined; addcarryxU64(&x49, &x50, x48, x44, x41); var x51: u64 = undefined; var x52: u1 = undefined; addcarryxU64(&x51, &x52, x50, x42, x39); const x53 = (cast(u64, x52) + x40); var x54: u64 = undefined; var x55: u1 = undefined; addcarryxU64(&x54, &x55, 0x0, x31, x45); var x56: u64 = undefined; var x57: u1 = undefined; addcarryxU64(&x56, &x57, x55, x33, x47); var x58: u64 = undefined; var x59: u1 = undefined; addcarryxU64(&x58, &x59, x57, x35, x49); var x60: u64 = undefined; var x61: u1 = undefined; addcarryxU64(&x60, &x61, x59, x37, x51); var x62: u64 = undefined; var x63: u1 = undefined; addcarryxU64(&x62, &x63, x61, cast(u64, x38), x53); var x64: u64 = undefined; var x65: u64 = undefined; mulxU64(&x64, &x65, x54, 0xffffffff00000001); var x66: u64 = undefined; var x67: u64 = undefined; mulxU64(&x66, &x67, x54, 0xffffffff); var x68: u64 = undefined; var x69: u64 = undefined; mulxU64(&x68, &x69, x54, 0xffffffffffffffff); var x70: u64 = undefined; var x71: u1 = undefined; addcarryxU64(&x70, &x71, 0x0, x69, x66); const x72 = (cast(u64, x71) + x67); var x73: u64 = undefined; var x74: u1 = undefined; addcarryxU64(&x73, &x74, 0x0, x54, x68); var x75: u64 = undefined; var x76: u1 = undefined; addcarryxU64(&x75, &x76, x74, x56, x70); var x77: u64 = undefined; var x78: u1 = undefined; addcarryxU64(&x77, &x78, x76, x58, x72); var x79: u64 = undefined; var x80: u1 = undefined; addcarryxU64(&x79, &x80, x78, x60, x64); var x81: u64 = undefined; var x82: u1 = undefined; addcarryxU64(&x81, &x82, x80, x62, x65); const x83 = (cast(u64, x82) + cast(u64, x63)); var x84: u64 = undefined; var x85: u64 = undefined; mulxU64(&x84, &x85, x2, (arg1[3])); var x86: u64 = undefined; var x87: u64 = undefined; mulxU64(&x86, &x87, x2, (arg1[2])); var x88: u64 = undefined; var x89: u64 = undefined; mulxU64(&x88, &x89, x2, (arg1[1])); var x90: u64 = undefined; var x91: u64 = undefined; mulxU64(&x90, &x91, x2, (arg1[0])); var x92: u64 = undefined; var x93: u1 = undefined; addcarryxU64(&x92, &x93, 0x0, x91, x88); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, x93, x89, x86); var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x87, x84); const x98 = (cast(u64, x97) + x85); var x99: u64 = undefined; var x100: u1 = undefined; addcarryxU64(&x99, &x100, 0x0, x75, x90); var x101: u64 = undefined; var x102: u1 = undefined; addcarryxU64(&x101, &x102, x100, x77, x92); var x103: u64 = undefined; var x104: u1 = undefined; addcarryxU64(&x103, &x104, x102, x79, x94); var x105: u64 = undefined; var x106: u1 = undefined; addcarryxU64(&x105, &x106, x104, x81, x96); var x107: u64 = undefined; var x108: u1 = undefined; addcarryxU64(&x107, &x108, x106, x83, x98); var x109: u64 = undefined; var x110: u64 = undefined; mulxU64(&x109, &x110, x99, 0xffffffff00000001); var x111: u64 = undefined; var x112: u64 = undefined; mulxU64(&x111, &x112, x99, 0xffffffff); var x113: u64 = undefined; var x114: u64 = undefined; mulxU64(&x113, &x114, x99, 0xffffffffffffffff); var x115: u64 = undefined; var x116: u1 = undefined; addcarryxU64(&x115, &x116, 0x0, x114, x111); const x117 = (cast(u64, x116) + x112); var x118: u64 = undefined; var x119: u1 = undefined; addcarryxU64(&x118, &x119, 0x0, x99, x113); var x120: u64 = undefined; var x121: u1 = undefined; addcarryxU64(&x120, &x121, x119, x101, x115); var x122: u64 = undefined; var x123: u1 = undefined; addcarryxU64(&x122, &x123, x121, x103, x117); var x124: u64 = undefined; var x125: u1 = undefined; addcarryxU64(&x124, &x125, x123, x105, x109); var x126: u64 = undefined; var x127: u1 = undefined; addcarryxU64(&x126, &x127, x125, x107, x110); const x128 = (cast(u64, x127) + cast(u64, x108)); var x129: u64 = undefined; var x130: u64 = undefined; mulxU64(&x129, &x130, x3, (arg1[3])); var x131: u64 = undefined; var x132: u64 = undefined; mulxU64(&x131, &x132, x3, (arg1[2])); var x133: u64 = undefined; var x134: u64 = undefined; mulxU64(&x133, &x134, x3, (arg1[1])); var x135: u64 = undefined; var x136: u64 = undefined; mulxU64(&x135, &x136, x3, (arg1[0])); var x137: u64 = undefined; var x138: u1 = undefined; addcarryxU64(&x137, &x138, 0x0, x136, x133); var x139: u64 = undefined; var x140: u1 = undefined; addcarryxU64(&x139, &x140, x138, x134, x131); var x141: u64 = undefined; var x142: u1 = undefined; addcarryxU64(&x141, &x142, x140, x132, x129); const x143 = (cast(u64, x142) + x130); var x144: u64 = undefined; var x145: u1 = undefined; addcarryxU64(&x144, &x145, 0x0, x120, x135); var x146: u64 = undefined; var x147: u1 = undefined; addcarryxU64(&x146, &x147, x145, x122, x137); var x148: u64 = undefined; var x149: u1 = undefined; addcarryxU64(&x148, &x149, x147, x124, x139); var x150: u64 = undefined; var x151: u1 = undefined; addcarryxU64(&x150, &x151, x149, x126, x141); var x152: u64 = undefined; var x153: u1 = undefined; addcarryxU64(&x152, &x153, x151, x128, x143); var x154: u64 = undefined; var x155: u64 = undefined; mulxU64(&x154, &x155, x144, 0xffffffff00000001); var x156: u64 = undefined; var x157: u64 = undefined; mulxU64(&x156, &x157, x144, 0xffffffff); var x158: u64 = undefined; var x159: u64 = undefined; mulxU64(&x158, &x159, x144, 0xffffffffffffffff); var x160: u64 = undefined; var x161: u1 = undefined; addcarryxU64(&x160, &x161, 0x0, x159, x156); const x162 = (cast(u64, x161) + x157); var x163: u64 = undefined; var x164: u1 = undefined; addcarryxU64(&x163, &x164, 0x0, x144, x158); var x165: u64 = undefined; var x166: u1 = undefined; addcarryxU64(&x165, &x166, x164, x146, x160); var x167: u64 = undefined; var x168: u1 = undefined; addcarryxU64(&x167, &x168, x166, x148, x162); var x169: u64 = undefined; var x170: u1 = undefined; addcarryxU64(&x169, &x170, x168, x150, x154); var x171: u64 = undefined; var x172: u1 = undefined; addcarryxU64(&x171, &x172, x170, x152, x155); const x173 = (cast(u64, x172) + cast(u64, x153)); var x174: u64 = undefined; var x175: u1 = undefined; subborrowxU64(&x174, &x175, 0x0, x165, 0xffffffffffffffff); var x176: u64 = undefined; var x177: u1 = undefined; subborrowxU64(&x176, &x177, x175, x167, 0xffffffff); var x178: u64 = undefined; var x179: u1 = undefined; subborrowxU64(&x178, &x179, x177, x169, cast(u64, 0x0)); var x180: u64 = undefined; var x181: u1 = undefined; subborrowxU64(&x180, &x181, x179, x171, 0xffffffff00000001); var x182: u64 = undefined; var x183: u1 = undefined; subborrowxU64(&x182, &x183, x181, x173, cast(u64, 0x0)); var x184: u64 = undefined; cmovznzU64(&x184, x183, x174, x165); var x185: u64 = undefined; cmovznzU64(&x185, x183, x176, x167); var x186: u64 = undefined; cmovznzU64(&x186, x183, x178, x169); var x187: u64 = undefined; cmovznzU64(&x187, x183, x180, x171); out1[0] = x184; out1[1] = x185; out1[2] = x186; out1[3] = x187; } /// The function add 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]] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn add(out1: *[4]u64, arg1: [4]u64, arg2: [4]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; addcarryxU64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); var x3: u64 = undefined; var x4: u1 = undefined; addcarryxU64(&x3, &x4, x2, (arg1[1]), (arg2[1])); var x5: u64 = undefined; var x6: u1 = undefined; addcarryxU64(&x5, &x6, x4, (arg1[2]), (arg2[2])); var x7: u64 = undefined; var x8: u1 = undefined; addcarryxU64(&x7, &x8, x6, (arg1[3]), (arg2[3])); var x9: u64 = undefined; var x10: u1 = undefined; subborrowxU64(&x9, &x10, 0x0, x1, 0xffffffffffffffff); var x11: u64 = undefined; var x12: u1 = undefined; subborrowxU64(&x11, &x12, x10, x3, 0xffffffff); var x13: u64 = undefined; var x14: u1 = undefined; subborrowxU64(&x13, &x14, x12, x5, cast(u64, 0x0)); var x15: u64 = undefined; var x16: u1 = undefined; subborrowxU64(&x15, &x16, x14, x7, 0xffffffff00000001); var x17: u64 = undefined; var x18: u1 = undefined; subborrowxU64(&x17, &x18, x16, cast(u64, x8), cast(u64, 0x0)); var x19: u64 = undefined; cmovznzU64(&x19, x18, x9, x1); var x20: u64 = undefined; cmovznzU64(&x20, x18, x11, x3); var x21: u64 = undefined; cmovznzU64(&x21, x18, x13, x5); var x22: u64 = undefined; cmovznzU64(&x22, x18, x15, x7); out1[0] = x19; out1[1] = x20; out1[2] = x21; out1[3] = x22; } /// The function sub 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]] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn sub(out1: *[4]u64, arg1: [4]u64, arg2: [4]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; subborrowxU64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); var x3: u64 = undefined; var x4: u1 = undefined; subborrowxU64(&x3, &x4, x2, (arg1[1]), (arg2[1])); var x5: u64 = undefined; var x6: u1 = undefined; subborrowxU64(&x5, &x6, x4, (arg1[2]), (arg2[2])); var x7: u64 = undefined; var x8: u1 = undefined; subborrowxU64(&x7, &x8, x6, (arg1[3]), (arg2[3])); var x9: u64 = undefined; cmovznzU64(&x9, x8, cast(u64, 0x0), 0xffffffffffffffff); var x10: u64 = undefined; var x11: u1 = undefined; addcarryxU64(&x10, &x11, 0x0, x1, x9); var x12: u64 = undefined; var x13: u1 = undefined; addcarryxU64(&x12, &x13, x11, x3, (x9 & 0xffffffff)); var x14: u64 = undefined; var x15: u1 = undefined; addcarryxU64(&x14, &x15, x13, x5, cast(u64, 0x0)); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, x15, x7, (x9 & 0xffffffff00000001)); out1[0] = x10; out1[1] = x12; out1[2] = x14; out1[3] = x16; } /// The function opp 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]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn opp(out1: *[4]u64, arg1: [4]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; subborrowxU64(&x1, &x2, 0x0, cast(u64, 0x0), (arg1[0])); var x3: u64 = undefined; var x4: u1 = undefined; subborrowxU64(&x3, &x4, x2, cast(u64, 0x0), (arg1[1])); var x5: u64 = undefined; var x6: u1 = undefined; subborrowxU64(&x5, &x6, x4, cast(u64, 0x0), (arg1[2])); var x7: u64 = undefined; var x8: u1 = undefined; subborrowxU64(&x7, &x8, x6, cast(u64, 0x0), (arg1[3])); var x9: u64 = undefined; cmovznzU64(&x9, x8, cast(u64, 0x0), 0xffffffffffffffff); var x10: u64 = undefined; var x11: u1 = undefined; addcarryxU64(&x10, &x11, 0x0, x1, x9); var x12: u64 = undefined; var x13: u1 = undefined; addcarryxU64(&x12, &x13, x11, x3, (x9 & 0xffffffff)); var x14: u64 = undefined; var x15: u1 = undefined; addcarryxU64(&x14, &x15, x13, x5, cast(u64, 0x0)); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, x15, x7, (x9 & 0xffffffff00000001)); out1[0] = x10; out1[1] = x12; out1[2] = x14; out1[3] = x16; } /// The function fromMontgomery 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)^4) mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromMontgomery(out1: *[4]u64, arg1: [4]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[0]); var x2: u64 = undefined; var x3: u64 = undefined; mulxU64(&x2, &x3, x1, 0xffffffff00000001); var x4: u64 = undefined; var x5: u64 = undefined; mulxU64(&x4, &x5, x1, 0xffffffff); var x6: u64 = undefined; var x7: u64 = undefined; mulxU64(&x6, &x7, x1, 0xffffffffffffffff); var x8: u64 = undefined; var x9: u1 = undefined; addcarryxU64(&x8, &x9, 0x0, x7, x4); var x10: u64 = undefined; var x11: u1 = undefined; addcarryxU64(&x10, &x11, 0x0, x1, x6); var x12: u64 = undefined; var x13: u1 = undefined; addcarryxU64(&x12, &x13, x11, cast(u64, 0x0), x8); var x14: u64 = undefined; var x15: u1 = undefined; addcarryxU64(&x14, &x15, 0x0, x12, (arg1[1])); var x16: u64 = undefined; var x17: u64 = undefined; mulxU64(&x16, &x17, x14, 0xffffffff00000001); var x18: u64 = undefined; var x19: u64 = undefined; mulxU64(&x18, &x19, x14, 0xffffffff); var x20: u64 = undefined; var x21: u64 = undefined; mulxU64(&x20, &x21, x14, 0xffffffffffffffff); var x22: u64 = undefined; var x23: u1 = undefined; addcarryxU64(&x22, &x23, 0x0, x21, x18); var x24: u64 = undefined; var x25: u1 = undefined; addcarryxU64(&x24, &x25, 0x0, x14, x20); var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU64(&x26, &x27, x25, (cast(u64, x15) + (cast(u64, x13) + (cast(u64, x9) + x5))), x22); var x28: u64 = undefined; var x29: u1 = undefined; addcarryxU64(&x28, &x29, x27, x2, (cast(u64, x23) + x19)); var x30: u64 = undefined; var x31: u1 = undefined; addcarryxU64(&x30, &x31, x29, x3, x16); var x32: u64 = undefined; var x33: u1 = undefined; addcarryxU64(&x32, &x33, 0x0, x26, (arg1[2])); var x34: u64 = undefined; var x35: u1 = undefined; addcarryxU64(&x34, &x35, x33, x28, cast(u64, 0x0)); var x36: u64 = undefined; var x37: u1 = undefined; addcarryxU64(&x36, &x37, x35, x30, cast(u64, 0x0)); var x38: u64 = undefined; var x39: u64 = undefined; mulxU64(&x38, &x39, x32, 0xffffffff00000001); var x40: u64 = undefined; var x41: u64 = undefined; mulxU64(&x40, &x41, x32, 0xffffffff); var x42: u64 = undefined; var x43: u64 = undefined; mulxU64(&x42, &x43, x32, 0xffffffffffffffff); var x44: u64 = undefined; var x45: u1 = undefined; addcarryxU64(&x44, &x45, 0x0, x43, x40); var x46: u64 = undefined; var x47: u1 = undefined; addcarryxU64(&x46, &x47, 0x0, x32, x42); var x48: u64 = undefined; var x49: u1 = undefined; addcarryxU64(&x48, &x49, x47, x34, x44); var x50: u64 = undefined; var x51: u1 = undefined; addcarryxU64(&x50, &x51, x49, x36, (cast(u64, x45) + x41)); var x52: u64 = undefined; var x53: u1 = undefined; addcarryxU64(&x52, &x53, x51, (cast(u64, x37) + (cast(u64, x31) + x17)), x38); var x54: u64 = undefined; var x55: u1 = undefined; addcarryxU64(&x54, &x55, 0x0, x48, (arg1[3])); var x56: u64 = undefined; var x57: u1 = undefined; addcarryxU64(&x56, &x57, x55, x50, cast(u64, 0x0)); var x58: u64 = undefined; var x59: u1 = undefined; addcarryxU64(&x58, &x59, x57, x52, cast(u64, 0x0)); var x60: u64 = undefined; var x61: u64 = undefined; mulxU64(&x60, &x61, x54, 0xffffffff00000001); var x62: u64 = undefined; var x63: u64 = undefined; mulxU64(&x62, &x63, x54, 0xffffffff); var x64: u64 = undefined; var x65: u64 = undefined; mulxU64(&x64, &x65, x54, 0xffffffffffffffff); var x66: u64 = undefined; var x67: u1 = undefined; addcarryxU64(&x66, &x67, 0x0, x65, x62); var x68: u64 = undefined; var x69: u1 = undefined; addcarryxU64(&x68, &x69, 0x0, x54, x64); var x70: u64 = undefined; var x71: u1 = undefined; addcarryxU64(&x70, &x71, x69, x56, x66); var x72: u64 = undefined; var x73: u1 = undefined; addcarryxU64(&x72, &x73, x71, x58, (cast(u64, x67) + x63)); var x74: u64 = undefined; var x75: u1 = undefined; addcarryxU64(&x74, &x75, x73, (cast(u64, x59) + (cast(u64, x53) + x39)), x60); const x76 = (cast(u64, x75) + x61); var x77: u64 = undefined; var x78: u1 = undefined; subborrowxU64(&x77, &x78, 0x0, x70, 0xffffffffffffffff); var x79: u64 = undefined; var x80: u1 = undefined; subborrowxU64(&x79, &x80, x78, x72, 0xffffffff); var x81: u64 = undefined; var x82: u1 = undefined; subborrowxU64(&x81, &x82, x80, x74, cast(u64, 0x0)); var x83: u64 = undefined; var x84: u1 = undefined; subborrowxU64(&x83, &x84, x82, x76, 0xffffffff00000001); var x85: u64 = undefined; var x86: u1 = undefined; subborrowxU64(&x85, &x86, x84, cast(u64, 0x0), cast(u64, 0x0)); var x87: u64 = undefined; cmovznzU64(&x87, x86, x77, x70); var x88: u64 = undefined; cmovznzU64(&x88, x86, x79, x72); var x89: u64 = undefined; cmovznzU64(&x89, x86, x81, x74); var x90: u64 = undefined; cmovznzU64(&x90, x86, x83, x76); out1[0] = x87; out1[1] = x88; out1[2] = x89; out1[3] = x90; } /// The function toMontgomery 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]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn toMontgomery(out1: *[4]u64, arg1: [4]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[1]); const x2 = (arg1[2]); const x3 = (arg1[3]); const x4 = (arg1[0]); var x5: u64 = undefined; var x6: u64 = undefined; mulxU64(&x5, &x6, x4, 0x4fffffffd); var x7: u64 = undefined; var x8: u64 = undefined; mulxU64(&x7, &x8, x4, 0xfffffffffffffffe); var x9: u64 = undefined; var x10: u64 = undefined; mulxU64(&x9, &x10, x4, 0xfffffffbffffffff); var x11: u64 = undefined; var x12: u64 = undefined; mulxU64(&x11, &x12, x4, 0x3); var x13: u64 = undefined; var x14: u1 = undefined; addcarryxU64(&x13, &x14, 0x0, x12, x9); var x15: u64 = undefined; var x16: u1 = undefined; addcarryxU64(&x15, &x16, x14, x10, x7); var x17: u64 = undefined; var x18: u1 = undefined; addcarryxU64(&x17, &x18, x16, x8, x5); var x19: u64 = undefined; var x20: u64 = undefined; mulxU64(&x19, &x20, x11, 0xffffffff00000001); var x21: u64 = undefined; var x22: u64 = undefined; mulxU64(&x21, &x22, x11, 0xffffffff); var x23: u64 = undefined; var x24: u64 = undefined; mulxU64(&x23, &x24, x11, 0xffffffffffffffff); var x25: u64 = undefined; var x26: u1 = undefined; addcarryxU64(&x25, &x26, 0x0, x24, x21); var x27: u64 = undefined; var x28: u1 = undefined; addcarryxU64(&x27, &x28, 0x0, x11, x23); var x29: u64 = undefined; var x30: u1 = undefined; addcarryxU64(&x29, &x30, x28, x13, x25); var x31: u64 = undefined; var x32: u1 = undefined; addcarryxU64(&x31, &x32, x30, x15, (cast(u64, x26) + x22)); var x33: u64 = undefined; var x34: u1 = undefined; addcarryxU64(&x33, &x34, x32, x17, x19); var x35: u64 = undefined; var x36: u1 = undefined; addcarryxU64(&x35, &x36, x34, (cast(u64, x18) + x6), x20); var x37: u64 = undefined; var x38: u64 = undefined; mulxU64(&x37, &x38, x1, 0x4fffffffd); var x39: u64 = undefined; var x40: u64 = undefined; mulxU64(&x39, &x40, x1, 0xfffffffffffffffe); var x41: u64 = undefined; var x42: u64 = undefined; mulxU64(&x41, &x42, x1, 0xfffffffbffffffff); var x43: u64 = undefined; var x44: u64 = undefined; mulxU64(&x43, &x44, x1, 0x3); var x45: u64 = undefined; var x46: u1 = undefined; addcarryxU64(&x45, &x46, 0x0, x44, x41); var x47: u64 = undefined; var x48: u1 = undefined; addcarryxU64(&x47, &x48, x46, x42, x39); var x49: u64 = undefined; var x50: u1 = undefined; addcarryxU64(&x49, &x50, x48, x40, x37); var x51: u64 = undefined; var x52: u1 = undefined; addcarryxU64(&x51, &x52, 0x0, x29, x43); var x53: u64 = undefined; var x54: u1 = undefined; addcarryxU64(&x53, &x54, x52, x31, x45); var x55: u64 = undefined; var x56: u1 = undefined; addcarryxU64(&x55, &x56, x54, x33, x47); var x57: u64 = undefined; var x58: u1 = undefined; addcarryxU64(&x57, &x58, x56, x35, x49); var x59: u64 = undefined; var x60: u64 = undefined; mulxU64(&x59, &x60, x51, 0xffffffff00000001); var x61: u64 = undefined; var x62: u64 = undefined; mulxU64(&x61, &x62, x51, 0xffffffff); var x63: u64 = undefined; var x64: u64 = undefined; mulxU64(&x63, &x64, x51, 0xffffffffffffffff); var x65: u64 = undefined; var x66: u1 = undefined; addcarryxU64(&x65, &x66, 0x0, x64, x61); var x67: u64 = undefined; var x68: u1 = undefined; addcarryxU64(&x67, &x68, 0x0, x51, x63); var x69: u64 = undefined; var x70: u1 = undefined; addcarryxU64(&x69, &x70, x68, x53, x65); var x71: u64 = undefined; var x72: u1 = undefined; addcarryxU64(&x71, &x72, x70, x55, (cast(u64, x66) + x62)); var x73: u64 = undefined; var x74: u1 = undefined; addcarryxU64(&x73, &x74, x72, x57, x59); var x75: u64 = undefined; var x76: u1 = undefined; addcarryxU64(&x75, &x76, x74, ((cast(u64, x58) + cast(u64, x36)) + (cast(u64, x50) + x38)), x60); var x77: u64 = undefined; var x78: u64 = undefined; mulxU64(&x77, &x78, x2, 0x4fffffffd); var x79: u64 = undefined; var x80: u64 = undefined; mulxU64(&x79, &x80, x2, 0xfffffffffffffffe); var x81: u64 = undefined; var x82: u64 = undefined; mulxU64(&x81, &x82, x2, 0xfffffffbffffffff); var x83: u64 = undefined; var x84: u64 = undefined; mulxU64(&x83, &x84, x2, 0x3); var x85: u64 = undefined; var x86: u1 = undefined; addcarryxU64(&x85, &x86, 0x0, x84, x81); var x87: u64 = undefined; var x88: u1 = undefined; addcarryxU64(&x87, &x88, x86, x82, x79); var x89: u64 = undefined; var x90: u1 = undefined; addcarryxU64(&x89, &x90, x88, x80, x77); var x91: u64 = undefined; var x92: u1 = undefined; addcarryxU64(&x91, &x92, 0x0, x69, x83); var x93: u64 = undefined; var x94: u1 = undefined; addcarryxU64(&x93, &x94, x92, x71, x85); var x95: u64 = undefined; var x96: u1 = undefined; addcarryxU64(&x95, &x96, x94, x73, x87); var x97: u64 = undefined; var x98: u1 = undefined; addcarryxU64(&x97, &x98, x96, x75, x89); var x99: u64 = undefined; var x100: u64 = undefined; mulxU64(&x99, &x100, x91, 0xffffffff00000001); var x101: u64 = undefined; var x102: u64 = undefined; mulxU64(&x101, &x102, x91, 0xffffffff); var x103: u64 = undefined; var x104: u64 = undefined; mulxU64(&x103, &x104, x91, 0xffffffffffffffff); var x105: u64 = undefined; var x106: u1 = undefined; addcarryxU64(&x105, &x106, 0x0, x104, x101); var x107: u64 = undefined; var x108: u1 = undefined; addcarryxU64(&x107, &x108, 0x0, x91, x103); var x109: u64 = undefined; var x110: u1 = undefined; addcarryxU64(&x109, &x110, x108, x93, x105); var x111: u64 = undefined; var x112: u1 = undefined; addcarryxU64(&x111, &x112, x110, x95, (cast(u64, x106) + x102)); var x113: u64 = undefined; var x114: u1 = undefined; addcarryxU64(&x113, &x114, x112, x97, x99); var x115: u64 = undefined; var x116: u1 = undefined; addcarryxU64(&x115, &x116, x114, ((cast(u64, x98) + cast(u64, x76)) + (cast(u64, x90) + x78)), x100); var x117: u64 = undefined; var x118: u64 = undefined; mulxU64(&x117, &x118, x3, 0x4fffffffd); var x119: u64 = undefined; var x120: u64 = undefined; mulxU64(&x119, &x120, x3, 0xfffffffffffffffe); var x121: u64 = undefined; var x122: u64 = undefined; mulxU64(&x121, &x122, x3, 0xfffffffbffffffff); var x123: u64 = undefined; var x124: u64 = undefined; mulxU64(&x123, &x124, x3, 0x3); var x125: u64 = undefined; var x126: u1 = undefined; addcarryxU64(&x125, &x126, 0x0, x124, x121); var x127: u64 = undefined; var x128: u1 = undefined; addcarryxU64(&x127, &x128, x126, x122, x119); var x129: u64 = undefined; var x130: u1 = undefined; addcarryxU64(&x129, &x130, x128, x120, x117); var x131: u64 = undefined; var x132: u1 = undefined; addcarryxU64(&x131, &x132, 0x0, x109, x123); var x133: u64 = undefined; var x134: u1 = undefined; addcarryxU64(&x133, &x134, x132, x111, x125); var x135: u64 = undefined; var x136: u1 = undefined; addcarryxU64(&x135, &x136, x134, x113, x127); var x137: u64 = undefined; var x138: u1 = undefined; addcarryxU64(&x137, &x138, x136, x115, x129); var x139: u64 = undefined; var x140: u64 = undefined; mulxU64(&x139, &x140, x131, 0xffffffff00000001); var x141: u64 = undefined; var x142: u64 = undefined; mulxU64(&x141, &x142, x131, 0xffffffff); var x143: u64 = undefined; var x144: u64 = undefined; mulxU64(&x143, &x144, x131, 0xffffffffffffffff); var x145: u64 = undefined; var x146: u1 = undefined; addcarryxU64(&x145, &x146, 0x0, x144, x141); var x147: u64 = undefined; var x148: u1 = undefined; addcarryxU64(&x147, &x148, 0x0, x131, x143); var x149: u64 = undefined; var x150: u1 = undefined; addcarryxU64(&x149, &x150, x148, x133, x145); var x151: u64 = undefined; var x152: u1 = undefined; addcarryxU64(&x151, &x152, x150, x135, (cast(u64, x146) + x142)); var x153: u64 = undefined; var x154: u1 = undefined; addcarryxU64(&x153, &x154, x152, x137, x139); var x155: u64 = undefined; var x156: u1 = undefined; addcarryxU64(&x155, &x156, x154, ((cast(u64, x138) + cast(u64, x116)) + (cast(u64, x130) + x118)), x140); var x157: u64 = undefined; var x158: u1 = undefined; subborrowxU64(&x157, &x158, 0x0, x149, 0xffffffffffffffff); var x159: u64 = undefined; var x160: u1 = undefined; subborrowxU64(&x159, &x160, x158, x151, 0xffffffff); var x161: u64 = undefined; var x162: u1 = undefined; subborrowxU64(&x161, &x162, x160, x153, cast(u64, 0x0)); var x163: u64 = undefined; var x164: u1 = undefined; subborrowxU64(&x163, &x164, x162, x155, 0xffffffff00000001); var x165: u64 = undefined; var x166: u1 = undefined; subborrowxU64(&x165, &x166, x164, cast(u64, x156), cast(u64, 0x0)); var x167: u64 = undefined; cmovznzU64(&x167, x166, x157, x149); var x168: u64 = undefined; cmovznzU64(&x168, x166, x159, x151); var x169: u64 = undefined; cmovznzU64(&x169, x166, x161, x153); var x170: u64 = undefined; cmovznzU64(&x170, x166, x163, x155); out1[0] = x167; out1[1] = x168; out1[2] = x169; out1[3] = x170; } /// The function nonzero 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]] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn nonzero(out1: *u64, arg1: [4]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | (arg1[3])))); out1.* = x1; } /// The function selectznz 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]] /// arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); var x2: u64 = undefined; cmovznzU64(&x2, arg1, (arg2[1]), (arg3[1])); var x3: u64 = undefined; cmovznzU64(&x3, arg1, (arg2[2]), (arg3[2])); var x4: u64 = undefined; cmovznzU64(&x4, arg1, (arg2[3]), (arg3[3])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; } /// The function toBytes 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..31] /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// 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]] pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[3]); const x2 = (arg1[2]); const x3 = (arg1[1]); const x4 = (arg1[0]); const x5 = cast(u8, (x4 & cast(u64, 0xff))); const x6 = (x4 >> 8); const x7 = cast(u8, (x6 & cast(u64, 0xff))); const x8 = (x6 >> 8); const x9 = cast(u8, (x8 & cast(u64, 0xff))); const x10 = (x8 >> 8); const x11 = cast(u8, (x10 & cast(u64, 0xff))); const x12 = (x10 >> 8); const x13 = cast(u8, (x12 & cast(u64, 0xff))); const x14 = (x12 >> 8); const x15 = cast(u8, (x14 & cast(u64, 0xff))); const x16 = (x14 >> 8); const x17 = cast(u8, (x16 & cast(u64, 0xff))); const x18 = cast(u8, (x16 >> 8)); const x19 = cast(u8, (x3 & cast(u64, 0xff))); const x20 = (x3 >> 8); const x21 = cast(u8, (x20 & cast(u64, 0xff))); const x22 = (x20 >> 8); const x23 = cast(u8, (x22 & cast(u64, 0xff))); const x24 = (x22 >> 8); const x25 = cast(u8, (x24 & cast(u64, 0xff))); const x26 = (x24 >> 8); const x27 = cast(u8, (x26 & cast(u64, 0xff))); const x28 = (x26 >> 8); const x29 = cast(u8, (x28 & cast(u64, 0xff))); const x30 = (x28 >> 8); const x31 = cast(u8, (x30 & cast(u64, 0xff))); const x32 = cast(u8, (x30 >> 8)); const x33 = cast(u8, (x2 & cast(u64, 0xff))); const x34 = (x2 >> 8); const x35 = cast(u8, (x34 & cast(u64, 0xff))); const x36 = (x34 >> 8); const x37 = cast(u8, (x36 & cast(u64, 0xff))); const x38 = (x36 >> 8); const x39 = cast(u8, (x38 & cast(u64, 0xff))); const x40 = (x38 >> 8); const x41 = cast(u8, (x40 & cast(u64, 0xff))); const x42 = (x40 >> 8); const x43 = cast(u8, (x42 & cast(u64, 0xff))); const x44 = (x42 >> 8); const x45 = cast(u8, (x44 & cast(u64, 0xff))); const x46 = cast(u8, (x44 >> 8)); const x47 = cast(u8, (x1 & cast(u64, 0xff))); const x48 = (x1 >> 8); const x49 = cast(u8, (x48 & cast(u64, 0xff))); const x50 = (x48 >> 8); const x51 = cast(u8, (x50 & cast(u64, 0xff))); const x52 = (x50 >> 8); const x53 = cast(u8, (x52 & cast(u64, 0xff))); const x54 = (x52 >> 8); const x55 = cast(u8, (x54 & cast(u64, 0xff))); const x56 = (x54 >> 8); const x57 = cast(u8, (x56 & cast(u64, 0xff))); const x58 = (x56 >> 8); const x59 = cast(u8, (x58 & cast(u64, 0xff))); const x60 = cast(u8, (x58 >> 8)); out1[0] = x5; out1[1] = x7; out1[2] = x9; out1[3] = x11; out1[4] = x13; out1[5] = x15; out1[6] = x17; out1[7] = x18; out1[8] = x19; out1[9] = x21; out1[10] = x23; out1[11] = x25; out1[12] = x27; out1[13] = x29; out1[14] = x31; out1[15] = x32; out1[16] = x33; out1[17] = x35; out1[18] = x37; out1[19] = x39; out1[20] = x41; out1[21] = x43; out1[22] = x45; out1[23] = x46; out1[24] = x47; out1[25] = x49; out1[26] = x51; out1[27] = x53; out1[28] = x55; out1[29] = x57; out1[30] = x59; out1[31] = x60; } /// The function fromBytes 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]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { @setRuntimeSafety(mode == .Debug); const x1 = (cast(u64, (arg1[31])) << 56); const x2 = (cast(u64, (arg1[30])) << 48); const x3 = (cast(u64, (arg1[29])) << 40); const x4 = (cast(u64, (arg1[28])) << 32); const x5 = (cast(u64, (arg1[27])) << 24); const x6 = (cast(u64, (arg1[26])) << 16); const x7 = (cast(u64, (arg1[25])) << 8); const x8 = (arg1[24]); const x9 = (cast(u64, (arg1[23])) << 56); const x10 = (cast(u64, (arg1[22])) << 48); const x11 = (cast(u64, (arg1[21])) << 40); const x12 = (cast(u64, (arg1[20])) << 32); const x13 = (cast(u64, (arg1[19])) << 24); const x14 = (cast(u64, (arg1[18])) << 16); const x15 = (cast(u64, (arg1[17])) << 8); const x16 = (arg1[16]); const x17 = (cast(u64, (arg1[15])) << 56); const x18 = (cast(u64, (arg1[14])) << 48); const x19 = (cast(u64, (arg1[13])) << 40); const x20 = (cast(u64, (arg1[12])) << 32); const x21 = (cast(u64, (arg1[11])) << 24); const x22 = (cast(u64, (arg1[10])) << 16); const x23 = (cast(u64, (arg1[9])) << 8); const x24 = (arg1[8]); const x25 = (cast(u64, (arg1[7])) << 56); const x26 = (cast(u64, (arg1[6])) << 48); const x27 = (cast(u64, (arg1[5])) << 40); const x28 = (cast(u64, (arg1[4])) << 32); const x29 = (cast(u64, (arg1[3])) << 24); const x30 = (cast(u64, (arg1[2])) << 16); const x31 = (cast(u64, (arg1[1])) << 8); const x32 = (arg1[0]); const x33 = (x31 + cast(u64, x32)); const x34 = (x30 + x33); const x35 = (x29 + x34); const x36 = (x28 + x35); const x37 = (x27 + x36); const x38 = (x26 + x37); const x39 = (x25 + x38); const x40 = (x23 + cast(u64, x24)); const x41 = (x22 + x40); const x42 = (x21 + x41); const x43 = (x20 + x42); const x44 = (x19 + x43); const x45 = (x18 + x44); const x46 = (x17 + x45); const x47 = (x15 + cast(u64, x16)); const x48 = (x14 + x47); const x49 = (x13 + x48); const x50 = (x12 + x49); const x51 = (x11 + x50); const x52 = (x10 + x51); const x53 = (x9 + x52); const x54 = (x7 + cast(u64, x8)); const x55 = (x6 + x54); const x56 = (x5 + x55); const x57 = (x4 + x56); const x58 = (x3 + x57); const x59 = (x2 + x58); const x60 = (x1 + x59); out1[0] = x39; out1[1] = x46; out1[2] = x53; out1[3] = x60; } /// The function setOne 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]] pub fn setOne(out1: *[4]u64) void { @setRuntimeSafety(mode == .Debug); out1[0] = cast(u64, 0x1); out1[1] = 0xffffffff00000000; out1[2] = 0xffffffffffffffff; out1[3] = 0xfffffffe; } /// The function msat 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]] pub fn msat(out1: *[5]u64) void { @setRuntimeSafety(mode == .Debug); out1[0] = 0xffffffffffffffff; out1[1] = 0xffffffff; out1[2] = cast(u64, 0x0); out1[3] = 0xffffffff00000001; out1[4] = cast(u64, 0x0); } /// The function divstep 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]] /// arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[4]u64, arg1: u64, arg2: [5]u64, arg3: [5]u64, arg4: [4]u64, arg5: [4]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; addcarryxU64(&x1, &x2, 0x0, (~arg1), cast(u64, 0x1)); const x3 = (cast(u1, (x1 >> 63)) & cast(u1, ((arg3[0]) & cast(u64, 0x1)))); var x4: u64 = undefined; var x5: u1 = undefined; addcarryxU64(&x4, &x5, 0x0, (~arg1), cast(u64, 0x1)); var x6: u64 = undefined; cmovznzU64(&x6, x3, arg1, x4); var x7: u64 = undefined; cmovznzU64(&x7, x3, (arg2[0]), (arg3[0])); var x8: u64 = undefined; cmovznzU64(&x8, x3, (arg2[1]), (arg3[1])); var x9: u64 = undefined; cmovznzU64(&x9, x3, (arg2[2]), (arg3[2])); var x10: u64 = undefined; cmovznzU64(&x10, x3, (arg2[3]), (arg3[3])); var x11: u64 = undefined; cmovznzU64(&x11, x3, (arg2[4]), (arg3[4])); var x12: u64 = undefined; var x13: u1 = undefined; addcarryxU64(&x12, &x13, 0x0, cast(u64, 0x1), (~(arg2[0]))); var x14: u64 = undefined; var x15: u1 = undefined; addcarryxU64(&x14, &x15, x13, cast(u64, 0x0), (~(arg2[1]))); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, x15, cast(u64, 0x0), (~(arg2[2]))); var x18: u64 = undefined; var x19: u1 = undefined; addcarryxU64(&x18, &x19, x17, cast(u64, 0x0), (~(arg2[3]))); var x20: u64 = undefined; var x21: u1 = undefined; addcarryxU64(&x20, &x21, x19, cast(u64, 0x0), (~(arg2[4]))); var x22: u64 = undefined; cmovznzU64(&x22, x3, (arg3[0]), x12); var x23: u64 = undefined; cmovznzU64(&x23, x3, (arg3[1]), x14); var x24: u64 = undefined; cmovznzU64(&x24, x3, (arg3[2]), x16); var x25: u64 = undefined; cmovznzU64(&x25, x3, (arg3[3]), x18); var x26: u64 = undefined; cmovznzU64(&x26, x3, (arg3[4]), x20); var x27: u64 = undefined; cmovznzU64(&x27, x3, (arg4[0]), (arg5[0])); var x28: u64 = undefined; cmovznzU64(&x28, x3, (arg4[1]), (arg5[1])); var x29: u64 = undefined; cmovznzU64(&x29, x3, (arg4[2]), (arg5[2])); var x30: u64 = undefined; cmovznzU64(&x30, x3, (arg4[3]), (arg5[3])); var x31: u64 = undefined; var x32: u1 = undefined; addcarryxU64(&x31, &x32, 0x0, x27, x27); var x33: u64 = undefined; var x34: u1 = undefined; addcarryxU64(&x33, &x34, x32, x28, x28); var x35: u64 = undefined; var x36: u1 = undefined; addcarryxU64(&x35, &x36, x34, x29, x29); var x37: u64 = undefined; var x38: u1 = undefined; addcarryxU64(&x37, &x38, x36, x30, x30); var x39: u64 = undefined; var x40: u1 = undefined; subborrowxU64(&x39, &x40, 0x0, x31, 0xffffffffffffffff); var x41: u64 = undefined; var x42: u1 = undefined; subborrowxU64(&x41, &x42, x40, x33, 0xffffffff); var x43: u64 = undefined; var x44: u1 = undefined; subborrowxU64(&x43, &x44, x42, x35, cast(u64, 0x0)); var x45: u64 = undefined; var x46: u1 = undefined; subborrowxU64(&x45, &x46, x44, x37, 0xffffffff00000001); var x47: u64 = undefined; var x48: u1 = undefined; subborrowxU64(&x47, &x48, x46, cast(u64, x38), cast(u64, 0x0)); const x49 = (arg4[3]); const x50 = (arg4[2]); const x51 = (arg4[1]); const x52 = (arg4[0]); var x53: u64 = undefined; var x54: u1 = undefined; subborrowxU64(&x53, &x54, 0x0, cast(u64, 0x0), x52); var x55: u64 = undefined; var x56: u1 = undefined; subborrowxU64(&x55, &x56, x54, cast(u64, 0x0), x51); var x57: u64 = undefined; var x58: u1 = undefined; subborrowxU64(&x57, &x58, x56, cast(u64, 0x0), x50); var x59: u64 = undefined; var x60: u1 = undefined; subborrowxU64(&x59, &x60, x58, cast(u64, 0x0), x49); var x61: u64 = undefined; cmovznzU64(&x61, x60, cast(u64, 0x0), 0xffffffffffffffff); var x62: u64 = undefined; var x63: u1 = undefined; addcarryxU64(&x62, &x63, 0x0, x53, x61); var x64: u64 = undefined; var x65: u1 = undefined; addcarryxU64(&x64, &x65, x63, x55, (x61 & 0xffffffff)); var x66: u64 = undefined; var x67: u1 = undefined; addcarryxU64(&x66, &x67, x65, x57, cast(u64, 0x0)); var x68: u64 = undefined; var x69: u1 = undefined; addcarryxU64(&x68, &x69, x67, x59, (x61 & 0xffffffff00000001)); var x70: u64 = undefined; cmovznzU64(&x70, x3, (arg5[0]), x62); var x71: u64 = undefined; cmovznzU64(&x71, x3, (arg5[1]), x64); var x72: u64 = undefined; cmovznzU64(&x72, x3, (arg5[2]), x66); var x73: u64 = undefined; cmovznzU64(&x73, x3, (arg5[3]), x68); const x74 = cast(u1, (x22 & cast(u64, 0x1))); var x75: u64 = undefined; cmovznzU64(&x75, x74, cast(u64, 0x0), x7); var x76: u64 = undefined; cmovznzU64(&x76, x74, cast(u64, 0x0), x8); var x77: u64 = undefined; cmovznzU64(&x77, x74, cast(u64, 0x0), x9); var x78: u64 = undefined; cmovznzU64(&x78, x74, cast(u64, 0x0), x10); var x79: u64 = undefined; cmovznzU64(&x79, x74, cast(u64, 0x0), x11); var x80: u64 = undefined; var x81: u1 = undefined; addcarryxU64(&x80, &x81, 0x0, x22, x75); var x82: u64 = undefined; var x83: u1 = undefined; addcarryxU64(&x82, &x83, x81, x23, x76); var x84: u64 = undefined; var x85: u1 = undefined; addcarryxU64(&x84, &x85, x83, x24, x77); var x86: u64 = undefined; var x87: u1 = undefined; addcarryxU64(&x86, &x87, x85, x25, x78); var x88: u64 = undefined; var x89: u1 = undefined; addcarryxU64(&x88, &x89, x87, x26, x79); var x90: u64 = undefined; cmovznzU64(&x90, x74, cast(u64, 0x0), x27); var x91: u64 = undefined; cmovznzU64(&x91, x74, cast(u64, 0x0), x28); var x92: u64 = undefined; cmovznzU64(&x92, x74, cast(u64, 0x0), x29); var x93: u64 = undefined; cmovznzU64(&x93, x74, cast(u64, 0x0), x30); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, 0x0, x70, x90); var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x71, x91); var x98: u64 = undefined; var x99: u1 = undefined; addcarryxU64(&x98, &x99, x97, x72, x92); var x100: u64 = undefined; var x101: u1 = undefined; addcarryxU64(&x100, &x101, x99, x73, x93); var x102: u64 = undefined; var x103: u1 = undefined; subborrowxU64(&x102, &x103, 0x0, x94, 0xffffffffffffffff); var x104: u64 = undefined; var x105: u1 = undefined; subborrowxU64(&x104, &x105, x103, x96, 0xffffffff); var x106: u64 = undefined; var x107: u1 = undefined; subborrowxU64(&x106, &x107, x105, x98, cast(u64, 0x0)); var x108: u64 = undefined; var x109: u1 = undefined; subborrowxU64(&x108, &x109, x107, x100, 0xffffffff00000001); var x110: u64 = undefined; var x111: u1 = undefined; subborrowxU64(&x110, &x111, x109, cast(u64, x101), cast(u64, 0x0)); var x112: u64 = undefined; var x113: u1 = undefined; addcarryxU64(&x112, &x113, 0x0, x6, cast(u64, 0x1)); const x114 = ((x80 >> 1) | ((x82 << 63) & 0xffffffffffffffff)); const x115 = ((x82 >> 1) | ((x84 << 63) & 0xffffffffffffffff)); const x116 = ((x84 >> 1) | ((x86 << 63) & 0xffffffffffffffff)); const x117 = ((x86 >> 1) | ((x88 << 63) & 0xffffffffffffffff)); const x118 = ((x88 & 0x8000000000000000) | (x88 >> 1)); var x119: u64 = undefined; cmovznzU64(&x119, x48, x39, x31); var x120: u64 = undefined; cmovznzU64(&x120, x48, x41, x33); var x121: u64 = undefined; cmovznzU64(&x121, x48, x43, x35); var x122: u64 = undefined; cmovznzU64(&x122, x48, x45, x37); var x123: u64 = undefined; cmovznzU64(&x123, x111, x102, x94); var x124: u64 = undefined; cmovznzU64(&x124, x111, x104, x96); var x125: u64 = undefined; cmovznzU64(&x125, x111, x106, x98); var x126: u64 = undefined; cmovznzU64(&x126, x111, x108, x100); out1.* = x112; out2[0] = x7; out2[1] = x8; out2[2] = x9; out2[3] = x10; out2[4] = x11; out3[0] = x114; out3[1] = x115; out3[2] = x116; out3[3] = x117; out3[4] = x118; out4[0] = x119; out4[1] = x120; out4[2] = x121; out4[3] = x122; out5[0] = x123; out5[1] = x124; out5[2] = x125; out5[3] = x126; } /// The function divstepPrecomp 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]] pub fn divstepPrecomp(out1: *[4]u64) void { @setRuntimeSafety(mode == .Debug); out1[0] = 0x67ffffffb8000000; out1[1] = 0xc000000038000000; out1[2] = 0xd80000007fffffff; out1[3] = 0x2fffffffffffffff; }
lib/std/crypto/pcurves/p256/p256_64.zig
const std = @import("std"); const testing = std.testing; const glfw = @import("glfw"); const gpu = @import("gpu"); const util = @import("util.zig"); const c = @import("c.zig").c; /// For now, this contains nothing. In the future, this will include application configuration that /// can only be specified at compile-time. pub const AppConfig = struct {}; pub const VSyncMode = enum { /// Potential screen tearing. /// No synchronization with monitor, render frames as fast as possible. none, /// No tearing, synchronizes rendering with monitor refresh rate, rendering frames when ready. /// /// Tries to stay one frame ahead of the monitor, so when it's ready for the next frame it is /// already prepared. double, /// No tearing, synchronizes rendering with monitor refresh rate, rendering frames when ready. /// /// Tries to stay two frames ahead of the monitor, so when it's ready for the next frame it is /// already prepared. triple, }; /// Application options that can be configured at init time. pub const Options = struct { /// The title of the window. title: [*:0]const u8 = "Mach engine", /// The width of the window. width: u32 = 640, /// The height of the window. height: u32 = 480, /// Monitor synchronization modes. vsync: VSyncMode = .double, /// GPU features required by the application. required_features: ?[]gpu.Feature = null, /// GPU limits required by the application. required_limits: ?gpu.Limits = null, /// Whether the application has a preference for low power or high performance GPU. power_preference: gpu.PowerPreference = .none, }; /// Default GLFW error handling callback fn glfwErrorCallback(error_code: glfw.Error, description: [:0]const u8) void { std.debug.print("glfw: {}: {s}\n", .{ error_code, description }); } /// A Mach application. /// /// The Context type is your own data type which can later be accessed via app.context from within /// the frame function you pass to run(). pub fn App(comptime Context: type, comptime config: AppConfig) type { _ = config; return struct { context: Context, device: gpu.Device, window: glfw.Window, backend_type: gpu.Adapter.BackendType, allocator: std.mem.Allocator, swap_chain: ?gpu.SwapChain, swap_chain_format: gpu.Texture.Format, /// The amount of time (in seconds) that has passed since the last frame was rendered. /// /// For example, if you are animating a cube which should rotate 360 degrees every second, /// instead of writing (360.0 / 60.0) and assuming the frame rate is 60hz, write /// (360.0 * app.delta_time) delta_time: f64 = 0, delta_time_ns: u64 = 0, // Internals native_instance: gpu.NativeInstance, surface: ?gpu.Surface, current_desc: gpu.SwapChain.Descriptor, target_desc: gpu.SwapChain.Descriptor, timer: std.time.Timer, const Self = @This(); pub fn init(allocator: std.mem.Allocator, context: Context, options: Options) !Self { const backend_type = try util.detectBackendType(allocator); glfw.setErrorCallback(glfwErrorCallback); try glfw.init(.{}); // Create the test window and discover adapters using it (esp. for OpenGL) var hints = util.glfwWindowHintsForBackend(backend_type); hints.cocoa_retina_framebuffer = true; const window = try glfw.Window.create( options.width, options.height, options.title, null, null, hints, ); const backend_procs = c.machDawnNativeGetProcs(); c.dawnProcSetProcs(backend_procs); const instance = c.machDawnNativeInstance_init(); var native_instance = gpu.NativeInstance.wrap(c.machDawnNativeInstance_get(instance).?); // Discover e.g. OpenGL adapters. try util.discoverAdapters(instance, window, backend_type); // Request an adapter. // // TODO: It would be nice if we could use gpu_interface.waitForAdapter here, however the webgpu.h // API does not yet have a way to specify what type of backend you want (vulkan, opengl, etc.) // In theory, I suppose we shouldn't need to and Dawn should just pick the best adapter - but in // practice if Vulkan is not supported today waitForAdapter/requestAdapter merely generates an error. // // const gpu_interface = native_instance.interface(); // const backend_adapter = switch (gpu_interface.waitForAdapter(&.{ // .power_preference = .high_performance, // })) { // .adapter => |v| v, // .err => |err| { // std.debug.print("mach: failed to get adapter: error={} {s}\n", .{ err.code, err.message }); // std.process.exit(1); // }, // }; const adapters = c.machDawnNativeInstance_getAdapters(instance); var dawn_adapter: ?c.MachDawnNativeAdapter = null; var i: usize = 0; while (i < c.machDawnNativeAdapters_length(adapters)) : (i += 1) { const adapter = c.machDawnNativeAdapters_index(adapters, i); const properties = c.machDawnNativeAdapter_getProperties(adapter); const found_backend_type = @intToEnum(gpu.Adapter.BackendType, c.machDawnNativeAdapterProperties_getBackendType(properties)); if (found_backend_type == backend_type) { dawn_adapter = adapter; break; } } if (dawn_adapter == null) { std.debug.print("mach: no matching adapter found for {s}", .{@tagName(backend_type)}); std.debug.print("-> maybe try GPU_BACKEND=opengl ?\n", .{}); std.process.exit(1); } std.debug.assert(dawn_adapter != null); const backend_adapter = gpu.NativeInstance.fromWGPUAdapter(c.machDawnNativeAdapter_get(dawn_adapter.?).?); // Print which adapter we are going to use. const props = backend_adapter.properties; std.debug.print("mach: found {s} backend on {s} adapter: {s}, {s}\n", .{ gpu.Adapter.backendTypeName(props.backend_type), gpu.Adapter.typeName(props.adapter_type), props.name, props.driver_description, }); const device = switch (backend_adapter.waitForDevice(&.{ .required_features = options.required_features, .required_limits = options.required_limits, })) { .device => |v| v, .err => |err| { // TODO: return a proper error type std.debug.print("mach: failed to get device: error={} {s}\n", .{ err.code, err.message }); std.process.exit(1); }, }; var framebuffer_size = try window.getFramebufferSize(); // If targeting OpenGL, we can't use the newer WGPUSurface API. Instead, we need to use the // older Dawn-specific API. https://bugs.chromium.org/p/dawn/issues/detail?id=269&q=surface&can=2 const use_legacy_api = backend_type == .opengl or backend_type == .opengles; var descriptor: gpu.SwapChain.Descriptor = undefined; var swap_chain: ?gpu.SwapChain = null; var swap_chain_format: gpu.Texture.Format = undefined; var surface: ?gpu.Surface = null; if (!use_legacy_api) { swap_chain_format = .bgra8_unorm; descriptor = .{ .label = "basic swap chain", .usage = .{ .render_attachment = true }, .format = swap_chain_format, .width = framebuffer_size.width, .height = framebuffer_size.height, .present_mode = switch (options.vsync) { .none => .immediate, .double => .fifo, .triple => .mailbox, }, .implementation = 0, }; surface = util.createSurfaceForWindow( &native_instance, window, comptime util.detectGLFWOptions(), ); } else { const binding = c.machUtilsCreateBinding(@enumToInt(backend_type), @ptrCast(*c.GLFWwindow, window.handle), @ptrCast(c.WGPUDevice, device.ptr)); if (binding == null) { @panic("failed to create Dawn backend binding"); } descriptor = std.mem.zeroes(gpu.SwapChain.Descriptor); descriptor.implementation = c.machUtilsBackendBinding_getSwapChainImplementation(binding); swap_chain = device.nativeCreateSwapChain(null, &descriptor); swap_chain_format = @intToEnum(gpu.Texture.Format, @intCast(u32, c.machUtilsBackendBinding_getPreferredSwapChainTextureFormat(binding))); swap_chain.?.configure( swap_chain_format, .{ .render_attachment = true }, framebuffer_size.width, framebuffer_size.height, ); } device.setUncapturedErrorCallback(&util.printUnhandledErrorCallback); return Self{ .context = context, .device = device, .window = window, .backend_type = backend_type, .allocator = allocator, .native_instance = native_instance, .surface = surface, .swap_chain = swap_chain, .swap_chain_format = swap_chain_format, .timer = try std.time.Timer.start(), .current_desc = descriptor, .target_desc = descriptor, }; } const Funcs = struct { // Run once per frame frame: fn (app: *Self, ctx: Context) error{OutOfMemory}!void, // Run once at the start, and whenever the swapchain is recreated resize: ?fn (app: *Self, ctx: Context, width: u32, height: u32) error{OutOfMemory}!void = null, }; pub fn run(app: *Self, funcs: Funcs) !void { if (app.swap_chain != null and funcs.resize != null) { try funcs.resize.?(app, app.context, app.current_desc.width, app.current_desc.height); } while (!app.window.shouldClose()) { try glfw.pollEvents(); app.delta_time_ns = app.timer.lap(); app.delta_time = @intToFloat(f64, app.delta_time_ns) / @intToFloat(f64, std.time.ns_per_s); var framebuffer_size = try app.window.getFramebufferSize(); app.target_desc.width = framebuffer_size.width; app.target_desc.height = framebuffer_size.height; if (app.swap_chain == null or !app.current_desc.equal(&app.target_desc)) { const use_legacy_api = app.surface == null; if (!use_legacy_api) { app.swap_chain = app.device.nativeCreateSwapChain(app.surface, &app.target_desc); } else app.swap_chain.?.configure( app.swap_chain_format, .{ .render_attachment = true }, app.target_desc.width, app.target_desc.height, ); if (funcs.resize) |f| { try f(app, app.context, app.target_desc.width, app.target_desc.height); } app.current_desc = app.target_desc; } try funcs.frame(app, app.context); } } }; } test "glfw_basic" { _ = Options; _ = App; glfw.basicTest() catch unreachable; }
src/main.zig
const std = @import("std"); const mem = std.mem; const Allocator = std.mem.Allocator; const assert = std.debug.assert; const BigIntConst = std.math.big.int.Const; const BigIntMutable = std.math.big.int.Mutable; const ast = std.zig.ast; const Type = @import("type.zig").Type; const Value = @import("value.zig").Value; const TypedValue = @import("TypedValue.zig"); const ir = @import("ir.zig"); const Module = @import("Module.zig"); const LazySrcLoc = Module.LazySrcLoc; /// The minimum amount of information needed to represent a list of ZIR instructions. /// Once this structure is completed, it can be used to generate TZIR, followed by /// machine code, without any memory access into the AST tree token list, node list, /// or source bytes. Exceptions include: /// * Compile errors, which may need to reach into these data structures to /// create a useful report. /// * In the future, possibly inline assembly, which needs to get parsed and /// handled by the codegen backend, and errors reported there. However for now, /// inline assembly is not an exception. pub const Code = struct { /// There is always implicitly a `block` instruction at index 0. /// This is so that `break_inline` can break from the root block. instructions: std.MultiArrayList(Inst).Slice, /// In order to store references to strings in fewer bytes, we copy all /// string bytes into here. String bytes can be null. It is up to whomever /// is referencing the data here whether they want to store both index and length, /// thus allowing null bytes, or store only index, and use null-termination. The /// `string_bytes` array is agnostic to either usage. string_bytes: []u8, /// The meaning of this data is determined by `Inst.Tag` value. extra: []u32, /// Returns the requested data, as well as the new index which is at the start of the /// trailers for the object. pub fn extraData(code: Code, comptime T: type, index: usize) struct { data: T, end: usize } { const fields = std.meta.fields(T); var i: usize = index; var result: T = undefined; inline for (fields) |field| { @field(result, field.name) = switch (field.field_type) { u32 => code.extra[i], Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]), else => unreachable, }; i += 1; } return .{ .data = result, .end = i, }; } /// Given an index into `string_bytes` returns the null-terminated string found there. pub fn nullTerminatedString(code: Code, index: usize) [:0]const u8 { var end: usize = index; while (code.string_bytes[end] != 0) { end += 1; } return code.string_bytes[index..end :0]; } pub fn refSlice(code: Code, start: usize, len: usize) []Inst.Ref { const raw_slice = code.extra[start..][0..len]; return @bitCast([]Inst.Ref, raw_slice); } pub fn deinit(code: *Code, gpa: *Allocator) void { code.instructions.deinit(gpa); gpa.free(code.string_bytes); gpa.free(code.extra); code.* = undefined; } /// For debugging purposes, like dumpFn but for unanalyzed zir blocks pub fn dump( code: Code, gpa: *Allocator, kind: []const u8, scope: *Module.Scope, param_count: usize, ) !void { var arena = std.heap.ArenaAllocator.init(gpa); defer arena.deinit(); var writer: Writer = .{ .gpa = gpa, .arena = &arena.allocator, .scope = scope, .code = code, .indent = 0, .param_count = param_count, }; const decl_name = scope.srcDecl().?.name; const stderr = std.io.getStdErr().writer(); try stderr.print("ZIR {s} {s} %0 ", .{ kind, decl_name }); try writer.writeInstToStream(stderr, 0); try stderr.print(" // end ZIR {s} {s}\n\n", .{ kind, decl_name }); } }; /// These are untyped instructions generated from an Abstract Syntax Tree. /// The data here is immutable because it is possible to have multiple /// analyses on the same ZIR happening at the same time. pub const Inst = struct { tag: Tag, data: Data, /// These names are used directly as the instruction names in the text format. pub const Tag = enum(u8) { /// Arithmetic addition, asserts no integer overflow. /// Uses the `pl_node` union field. Payload is `Bin`. add, /// Twos complement wrapping integer addition. /// Uses the `pl_node` union field. Payload is `Bin`. addwrap, /// Allocates stack local memory. /// Uses the `un_node` union field. The operand is the type of the allocated object. /// The node source location points to a var decl node. /// Indicates the beginning of a new statement in debug info. alloc, /// Same as `alloc` except mutable. alloc_mut, /// Same as `alloc` except the type is inferred. /// Uses the `node` union field. alloc_inferred, /// Same as `alloc_inferred` except mutable. alloc_inferred_mut, /// Array concatenation. `a ++ b` /// Uses the `pl_node` union field. Payload is `Bin`. array_cat, /// Array multiplication `a ** b` /// Uses the `pl_node` union field. Payload is `Bin`. array_mul, /// `[N]T` syntax. No source location provided. /// Uses the `bin` union field. lhs is length, rhs is element type. array_type, /// `[N:S]T` syntax. No source location provided. /// Uses the `array_type_sentinel` field. array_type_sentinel, /// Given a pointer to an indexable object, returns the len property. This is /// used by for loops. This instruction also emits a for-loop specific compile /// error if the indexable object is not indexable. /// Uses the `un_node` field. The AST node is the for loop node. indexable_ptr_len, /// Type coercion. No source location attached. /// Uses the `bin` field. as, /// Type coercion to the function's return type. /// Uses the `pl_node` field. Payload is `As`. AST node could be many things. as_node, /// Inline assembly. Non-volatile. /// Uses the `pl_node` union field. Payload is `Asm`. AST node is the assembly node. @"asm", /// Inline assembly with the volatile attribute. /// Uses the `pl_node` union field. Payload is `Asm`. AST node is the assembly node. asm_volatile, /// Bitwise AND. `&` bit_and, /// Bitcast a value to a different type. /// Uses the pl_node field with payload `Bin`. bitcast, /// A typed result location pointer is bitcasted to a new result location pointer. /// The new result location pointer has an inferred type. /// Uses the un_node field. bitcast_result_ptr, /// Bitwise NOT. `~` /// Uses `un_node`. bit_not, /// Bitwise OR. `|` bit_or, /// A labeled block of code, which can return a value. /// Uses the `pl_node` union field. Payload is `Block`. block, /// A list of instructions which are analyzed in the parent context, without /// generating a runtime block. Must terminate with an "inline" variant of /// a noreturn instruction. /// Uses the `pl_node` union field. Payload is `Block`. block_inline, /// Boolean AND. See also `bit_and`. /// Uses the `pl_node` union field. Payload is `Bin`. bool_and, /// Boolean NOT. See also `bit_not`. /// Uses the `un_node` field. bool_not, /// Boolean OR. See also `bit_or`. /// Uses the `pl_node` union field. Payload is `Bin`. bool_or, /// Short-circuiting boolean `and`. `lhs` is a boolean `Ref` and the other operand /// is a block, which is evaluated if `lhs` is `true`. /// Uses the `bool_br` union field. bool_br_and, /// Short-circuiting boolean `or`. `lhs` is a boolean `Ref` and the other operand /// is a block, which is evaluated if `lhs` is `false`. /// Uses the `bool_br` union field. bool_br_or, /// Return a value from a block. /// Uses the `break` union field. /// Uses the source information from previous instruction. @"break", /// Return a value from a block. This instruction is used as the terminator /// of a `block_inline`. It allows using the return value from `Sema.analyzeBody`. /// This instruction may also be used when it is known that there is only one /// break instruction in a block, and the target block is the parent. /// Uses the `break` union field. break_inline, /// Uses the `node` union field. breakpoint, /// Function call with modifier `.auto`. /// Uses `pl_node`. AST node is the function call. Payload is `Call`. call, /// Same as `call` but it also does `ensure_result_used` on the return value. call_chkused, /// Same as `call` but with modifier `.compile_time`. call_compile_time, /// Function call with modifier `.auto`, empty parameter list. /// Uses the `un_node` field. Operand is callee. AST node is the function call. call_none, /// Same as `call_none` but it also does `ensure_result_used` on the return value. call_none_chkused, /// `<` /// Uses the `pl_node` union field. Payload is `Bin`. cmp_lt, /// `<=` /// Uses the `pl_node` union field. Payload is `Bin`. cmp_lte, /// `==` /// Uses the `pl_node` union field. Payload is `Bin`. cmp_eq, /// `>=` /// Uses the `pl_node` union field. Payload is `Bin`. cmp_gte, /// `>` /// Uses the `pl_node` union field. Payload is `Bin`. cmp_gt, /// `!=` /// Uses the `pl_node` union field. Payload is `Bin`. cmp_neq, /// Coerces a result location pointer to a new element type. It is evaluated "backwards"- /// as type coercion from the new element type to the old element type. /// Uses the `bin` union field. /// LHS is destination element type, RHS is result pointer. coerce_result_ptr, /// Emit an error message and fail compilation. /// Uses the `un_node` field. compile_error, /// Log compile time variables and emit an error message. /// Uses the `pl_node` union field. The AST node is the compile log builtin call. /// The payload is `MultiOp`. compile_log, /// Conditional branch. Splits control flow based on a boolean condition value. /// Uses the `pl_node` union field. AST node is an if, while, for, etc. /// Payload is `CondBr`. condbr, /// Same as `condbr`, except the condition is coerced to a comptime value, and /// only the taken branch is analyzed. The then block and else block must /// terminate with an "inline" variant of a noreturn instruction. condbr_inline, /// A struct type definition. Contains references to ZIR instructions for /// the field types, defaults, and alignments. /// Uses the `pl_node` union field. Payload is `StructDecl`. struct_decl, /// Same as `struct_decl`, except has the `packed` layout. struct_decl_packed, /// Same as `struct_decl`, except has the `extern` layout. struct_decl_extern, /// A union type definition. Contains references to ZIR instructions for /// the field types and optional type tag expression. /// Uses the `pl_node` union field. Payload is `UnionDecl`. union_decl, /// An enum type definition. Contains references to ZIR instructions for /// the field value expressions and optional type tag expression. /// Uses the `pl_node` union field. Payload is `EnumDecl`. enum_decl, /// Same as `enum_decl`, except the enum is non-exhaustive. enum_decl_nonexhaustive, /// An opaque type definition. Provides an AST node only. /// Uses the `node` union field. opaque_decl, /// Declares the beginning of a statement. Used for debug info. /// Uses the `node` union field. dbg_stmt_node, /// Represents a pointer to a global decl. /// Uses the `pl_node` union field. `payload_index` is into `decls`. decl_ref, /// Equivalent to a decl_ref followed by load. /// Uses the `pl_node` union field. `payload_index` is into `decls`. decl_val, /// Load the value from a pointer. Assumes `x.*` syntax. /// Uses `un_node` field. AST node is the `x.*` syntax. load, /// Arithmetic division. Asserts no integer overflow. /// Uses the `pl_node` union field. Payload is `Bin`. div, /// Given a pointer to an array, slice, or pointer, returns a pointer to the element at /// the provided index. Uses the `bin` union field. Source location is implied /// to be the same as the previous instruction. elem_ptr, /// Same as `elem_ptr` except also stores a source location node. /// Uses the `pl_node` union field. AST node is a[b] syntax. Payload is `Bin`. elem_ptr_node, /// Given an array, slice, or pointer, returns the element at the provided index. /// Uses the `bin` union field. Source location is implied to be the same /// as the previous instruction. elem_val, /// Same as `elem_val` except also stores a source location node. /// Uses the `pl_node` union field. AST node is a[b] syntax. Payload is `Bin`. elem_val_node, /// This instruction has been deleted late in the astgen phase. It must /// be ignored, and the corresponding `Data` is undefined. elided, /// Emits a compile error if the operand is not `void`. /// Uses the `un_node` field. ensure_result_used, /// Emits a compile error if an error is ignored. /// Uses the `un_node` field. ensure_result_non_error, /// Create a `E!T` type. /// Uses the `pl_node` field with `Bin` payload. error_union_type, /// `error.Foo` syntax. Uses the `str_tok` field of the Data union. error_value, /// Given a pointer to a struct or object that contains virtual fields, returns a pointer /// to the named field. The field name is stored in string_bytes. Used by a.b syntax. /// Uses `pl_node` field. The AST node is the a.b syntax. Payload is Field. field_ptr, /// Given a struct or object that contains virtual fields, returns the named field. /// The field name is stored in string_bytes. Used by a.b syntax. /// This instruction also accepts a pointer. /// Uses `pl_node` field. The AST node is the a.b syntax. Payload is Field. field_val, /// Given a pointer to a struct or object that contains virtual fields, returns a pointer /// to the named field. The field name is a comptime instruction. Used by @field. /// Uses `pl_node` field. The AST node is the builtin call. Payload is FieldNamed. field_ptr_named, /// Given a struct or object that contains virtual fields, returns the named field. /// The field name is a comptime instruction. Used by @field. /// Uses `pl_node` field. The AST node is the builtin call. Payload is FieldNamed. field_val_named, /// Convert a larger float type to any other float type, possibly causing /// a loss of precision. /// Uses the `pl_node` field. AST is the `@floatCast` syntax. /// Payload is `Bin` with lhs as the dest type, rhs the operand. floatcast, /// Returns a function type, assuming unspecified calling convention. /// Uses the `pl_node` union field. `payload_index` points to a `FnType`. fn_type, /// Same as `fn_type` but the function is variadic. fn_type_var_args, /// Returns a function type, with a calling convention instruction operand. /// Uses the `pl_node` union field. `payload_index` points to a `FnTypeCc`. fn_type_cc, /// Same as `fn_type_cc` but the function is variadic. fn_type_cc_var_args, /// `@import(operand)`. /// Uses the `un_node` field. import, /// Integer literal that fits in a u64. Uses the int union value. int, /// A float literal that fits in a f32. Uses the float union value. float, /// A float literal that fits in a f128. Uses the `pl_node` union value. /// Payload is `Float128`. float128, /// Convert an integer value to another integer type, asserting that the destination type /// can hold the same mathematical value. /// Uses the `pl_node` field. AST is the `@intCast` syntax. /// Payload is `Bin` with lhs as the dest type, rhs the operand. intcast, /// Make an integer type out of signedness and bit count. /// Payload is `int_type` int_type, /// Convert an error type to `u16` error_to_int, /// Convert a `u16` to `anyerror` int_to_error, /// Return a boolean false if an optional is null. `x != null` /// Uses the `un_node` field. is_non_null, /// Return a boolean true if an optional is null. `x == null` /// Uses the `un_node` field. is_null, /// Return a boolean false if an optional is null. `x.* != null` /// Uses the `un_node` field. is_non_null_ptr, /// Return a boolean true if an optional is null. `x.* == null` /// Uses the `un_node` field. is_null_ptr, /// Return a boolean true if value is an error /// Uses the `un_node` field. is_err, /// Return a boolean true if dereferenced pointer is an error /// Uses the `un_node` field. is_err_ptr, /// A labeled block of code that loops forever. At the end of the body will have either /// a `repeat` instruction or a `repeat_inline` instruction. /// Uses the `pl_node` field. The AST node is either a for loop or while loop. /// This ZIR instruction is needed because TZIR does not (yet?) match ZIR, and Sema /// needs to emit more than 1 TZIR block for this instruction. /// The payload is `Block`. loop, /// Sends runtime control flow back to the beginning of the current block. /// Uses the `node` field. repeat, /// Sends comptime control flow back to the beginning of the current block. /// Uses the `node` field. repeat_inline, /// Merge two error sets into one, `E1 || E2`. /// Uses the `pl_node` field with payload `Bin`. merge_error_sets, /// Ambiguously remainder division or modulus. If the computation would possibly have /// a different value depending on whether the operation is remainder division or modulus, /// a compile error is emitted. Otherwise the computation is performed. /// Uses the `pl_node` union field. Payload is `Bin`. mod_rem, /// Arithmetic multiplication. Asserts no integer overflow. /// Uses the `pl_node` union field. Payload is `Bin`. mul, /// Twos complement wrapping integer multiplication. /// Uses the `pl_node` union field. Payload is `Bin`. mulwrap, /// Given a reference to a function and a parameter index, returns the /// type of the parameter. The only usage of this instruction is for the /// result location of parameters of function calls. In the case of a function's /// parameter type being `anytype`, it is the type coercion's job to detect this /// scenario and skip the coercion, so that semantic analysis of this instruction /// is not in a position where it must create an invalid type. /// Uses the `param_type` union field. param_type, /// Convert a pointer to a `usize` integer. /// Uses the `un_node` field. The AST node is the builtin fn call node. ptrtoint, /// Turns an R-Value into a const L-Value. In other words, it takes a value, /// stores it in a memory location, and returns a const pointer to it. If the value /// is `comptime`, the memory location is global static constant data. Otherwise, /// the memory location is in the stack frame, local to the scope containing the /// instruction. /// Uses the `un_tok` union field. ref, /// Obtains a pointer to the return value. /// Uses the `node` union field. ret_ptr, /// Obtains the return type of the in-scope function. /// Uses the `node` union field. ret_type, /// Sends control flow back to the function's callee. /// Includes an operand as the return value. /// Includes an AST node source location. /// Uses the `un_node` union field. ret_node, /// Sends control flow back to the function's callee. /// Includes an operand as the return value. /// Includes a token source location. /// Uses the `un_tok` union field. ret_tok, /// Same as `ret_tok` except the operand needs to get coerced to the function's /// return type. ret_coerce, /// Changes the maximum number of backwards branches that compile-time /// code execution can use before giving up and making a compile error. /// Uses the `un_node` union field. set_eval_branch_quota, /// Integer shift-left. Zeroes are shifted in from the right hand side. /// Uses the `pl_node` union field. Payload is `Bin`. shl, /// Integer shift-right. Arithmetic or logical depending on the signedness of the integer type. /// Uses the `pl_node` union field. Payload is `Bin`. shr, /// Create a pointer type that does not have a sentinel, alignment, or bit range specified. /// Uses the `ptr_type_simple` union field. ptr_type_simple, /// Create a pointer type which can have a sentinel, alignment, and/or bit range. /// Uses the `ptr_type` union field. ptr_type, /// Each `store_to_inferred_ptr` puts the type of the stored value into a set, /// and then `resolve_inferred_alloc` triggers peer type resolution on the set. /// The operand is a `alloc_inferred` or `alloc_inferred_mut` instruction, which /// is the allocation that needs to have its type inferred. /// Uses the `un_node` field. The AST node is the var decl. resolve_inferred_alloc, /// Slice operation `lhs[rhs..]`. No sentinel and no end offset. /// Uses the `pl_node` field. AST node is the slice syntax. Payload is `SliceStart`. slice_start, /// Slice operation `array_ptr[start..end]`. No sentinel. /// Uses the `pl_node` field. AST node is the slice syntax. Payload is `SliceEnd`. slice_end, /// Slice operation `array_ptr[start..end:sentinel]`. /// Uses the `pl_node` field. AST node is the slice syntax. Payload is `SliceSentinel`. slice_sentinel, /// Write a value to a pointer. For loading, see `load`. /// Source location is assumed to be same as previous instruction. /// Uses the `bin` union field. store, /// Same as `store` except provides a source location. /// Uses the `pl_node` union field. Payload is `Bin`. store_node, /// Same as `store` but the type of the value being stored will be used to infer /// the block type. The LHS is the pointer to store to. /// Uses the `bin` union field. store_to_block_ptr, /// Same as `store` but the type of the value being stored will be used to infer /// the pointer type. /// Uses the `bin` union field - Astgen.zig depends on the ability to change /// the tag of an instruction from `store_to_block_ptr` to `store_to_inferred_ptr` /// without changing the data. store_to_inferred_ptr, /// String Literal. Makes an anonymous Decl and then takes a pointer to it. /// Uses the `str` union field. str, /// Arithmetic subtraction. Asserts no integer overflow. /// Uses the `pl_node` union field. Payload is `Bin`. sub, /// Twos complement wrapping integer subtraction. /// Uses the `pl_node` union field. Payload is `Bin`. subwrap, /// Arithmetic negation. Asserts no integer overflow. /// Same as sub with a lhs of 0, split into a separate instruction to save memory. /// Uses `un_node`. negate, /// Twos complement wrapping integer negation. /// Same as subwrap with a lhs of 0, split into a separate instruction to save memory. /// Uses `un_node`. negate_wrap, /// Returns the type of a value. /// Uses the `un_tok` field. typeof, /// Given a value which is a pointer, returns the element type. /// Uses the `un_node` field. typeof_elem, /// The builtin `@TypeOf` which returns the type after Peer Type Resolution /// of one or more params. /// Uses the `pl_node` field. AST node is the `@TypeOf` call. Payload is `MultiOp`. typeof_peer, /// Asserts control-flow will not reach this instruction (`unreachable`). /// Uses the `unreachable` union field. @"unreachable", /// Bitwise XOR. `^` /// Uses the `pl_node` union field. Payload is `Bin`. xor, /// Create an optional type '?T' /// Uses the `un_node` field. optional_type, /// Create an optional type '?T'. The operand is a pointer value. The optional type will /// be the type of the pointer element, wrapped in an optional. /// Uses the `un_node` field. optional_type_from_ptr_elem, /// ?T => T with safety. /// Given an optional value, returns the payload value, with a safety check that /// the value is non-null. Used for `orelse`, `if` and `while`. /// Uses the `un_node` field. optional_payload_safe, /// ?T => T without safety. /// Given an optional value, returns the payload value. No safety checks. /// Uses the `un_node` field. optional_payload_unsafe, /// *?T => *T with safety. /// Given a pointer to an optional value, returns a pointer to the payload value, /// with a safety check that the value is non-null. Used for `orelse`, `if` and `while`. /// Uses the `un_node` field. optional_payload_safe_ptr, /// *?T => *T without safety. /// Given a pointer to an optional value, returns a pointer to the payload value. /// No safety checks. /// Uses the `un_node` field. optional_payload_unsafe_ptr, /// E!T => T with safety. /// Given an error union value, returns the payload value, with a safety check /// that the value is not an error. Used for catch, if, and while. /// Uses the `un_node` field. err_union_payload_safe, /// E!T => T without safety. /// Given an error union value, returns the payload value. No safety checks. /// Uses the `un_node` field. err_union_payload_unsafe, /// *E!T => *T with safety. /// Given a pointer to an error union value, returns a pointer to the payload value, /// with a safety check that the value is not an error. Used for catch, if, and while. /// Uses the `un_node` field. err_union_payload_safe_ptr, /// *E!T => *T without safety. /// Given a pointer to a error union value, returns a pointer to the payload value. /// No safety checks. /// Uses the `un_node` field. err_union_payload_unsafe_ptr, /// E!T => E without safety. /// Given an error union value, returns the error code. No safety checks. /// Uses the `un_node` field. err_union_code, /// *E!T => E without safety. /// Given a pointer to an error union value, returns the error code. No safety checks. /// Uses the `un_node` field. err_union_code_ptr, /// Takes a *E!T and raises a compiler error if T != void /// Uses the `un_tok` field. ensure_err_payload_void, /// An enum literal. Uses the `str_tok` union field. enum_literal, /// An enum literal 8 or fewer bytes. No source location. /// Uses the `small_str` field. enum_literal_small, /// A switch expression. Uses the `pl_node` union field. /// AST node is the switch, payload is `SwitchBlock`. /// All prongs of target handled. switch_block, /// Same as switch_block, except one or more prongs have multiple items. switch_block_multi, /// Same as switch_block, except has an else prong. switch_block_else, /// Same as switch_block_else, except one or more prongs have multiple items. switch_block_else_multi, /// Same as switch_block, except has an underscore prong. switch_block_under, /// Same as switch_block, except one or more prongs have multiple items. switch_block_under_multi, /// Same as `switch_block` but the target is a pointer to the value being switched on. switch_block_ref, /// Same as `switch_block_multi` but the target is a pointer to the value being switched on. switch_block_ref_multi, /// Same as `switch_block_else` but the target is a pointer to the value being switched on. switch_block_ref_else, /// Same as `switch_block_else_multi` but the target is a pointer to the /// value being switched on. switch_block_ref_else_multi, /// Same as `switch_block_under` but the target is a pointer to the value /// being switched on. switch_block_ref_under, /// Same as `switch_block_under_multi` but the target is a pointer to /// the value being switched on. switch_block_ref_under_multi, /// Produces the capture value for a switch prong. /// Uses the `switch_capture` field. switch_capture, /// Produces the capture value for a switch prong. /// Result is a pointer to the value. /// Uses the `switch_capture` field. switch_capture_ref, /// Produces the capture value for a switch prong. /// The prong is one of the multi cases. /// Uses the `switch_capture` field. switch_capture_multi, /// Produces the capture value for a switch prong. /// The prong is one of the multi cases. /// Result is a pointer to the value. /// Uses the `switch_capture` field. switch_capture_multi_ref, /// Produces the capture value for the else/'_' switch prong. /// Uses the `switch_capture` field. switch_capture_else, /// Produces the capture value for the else/'_' switch prong. /// Result is a pointer to the value. /// Uses the `switch_capture` field. switch_capture_else_ref, /// Given a set of `field_ptr` instructions, assumes they are all part of a struct /// initialization expression, and emits compile errors for duplicate fields /// as well as missing fields, if applicable. /// This instruction asserts that there is at least one field_ptr instruction, /// because it must use one of them to find out the struct type. /// Uses the `pl_node` field. Payload is `Block`. validate_struct_init_ptr, /// A struct literal with a specified type, with no fields. /// Uses the `un_node` field. struct_init_empty, /// Converts an integer into an enum value. /// Uses `pl_node` with payload `Bin`. `lhs` is enum type, `rhs` is operand. int_to_enum, /// Converts an enum value into an integer. Resulting type will be the tag type /// of the enum. Uses `un_node`. enum_to_int, /// Returns whether the instruction is one of the control flow "noreturn" types. /// Function calls do not count. pub fn isNoReturn(tag: Tag) bool { return switch (tag) { .add, .addwrap, .alloc, .alloc_mut, .alloc_inferred, .alloc_inferred_mut, .array_cat, .array_mul, .array_type, .array_type_sentinel, .indexable_ptr_len, .as, .as_node, .@"asm", .asm_volatile, .bit_and, .bitcast, .bitcast_result_ptr, .bit_or, .block, .block_inline, .loop, .bool_br_and, .bool_br_or, .bool_not, .bool_and, .bool_or, .breakpoint, .call, .call_chkused, .call_compile_time, .call_none, .call_none_chkused, .cmp_lt, .cmp_lte, .cmp_eq, .cmp_gte, .cmp_gt, .cmp_neq, .coerce_result_ptr, .struct_decl, .struct_decl_packed, .struct_decl_extern, .union_decl, .enum_decl, .enum_decl_nonexhaustive, .opaque_decl, .dbg_stmt_node, .decl_ref, .decl_val, .load, .div, .elem_ptr, .elem_val, .elem_ptr_node, .elem_val_node, .ensure_result_used, .ensure_result_non_error, .floatcast, .field_ptr, .field_val, .field_ptr_named, .field_val_named, .fn_type, .fn_type_var_args, .fn_type_cc, .fn_type_cc_var_args, .int, .float, .float128, .intcast, .int_type, .is_non_null, .is_null, .is_non_null_ptr, .is_null_ptr, .is_err, .is_err_ptr, .mod_rem, .mul, .mulwrap, .param_type, .ptrtoint, .ref, .ret_ptr, .ret_type, .shl, .shr, .store, .store_node, .store_to_block_ptr, .store_to_inferred_ptr, .str, .sub, .subwrap, .negate, .negate_wrap, .typeof, .typeof_elem, .xor, .optional_type, .optional_type_from_ptr_elem, .optional_payload_safe, .optional_payload_unsafe, .optional_payload_safe_ptr, .optional_payload_unsafe_ptr, .err_union_payload_safe, .err_union_payload_unsafe, .err_union_payload_safe_ptr, .err_union_payload_unsafe_ptr, .err_union_code, .err_union_code_ptr, .error_to_int, .int_to_error, .ptr_type, .ptr_type_simple, .ensure_err_payload_void, .enum_literal, .enum_literal_small, .merge_error_sets, .error_union_type, .bit_not, .error_value, .slice_start, .slice_end, .slice_sentinel, .import, .typeof_peer, .resolve_inferred_alloc, .set_eval_branch_quota, .compile_log, .elided, .switch_capture, .switch_capture_ref, .switch_capture_multi, .switch_capture_multi_ref, .switch_capture_else, .switch_capture_else_ref, .switch_block, .switch_block_multi, .switch_block_else, .switch_block_else_multi, .switch_block_under, .switch_block_under_multi, .switch_block_ref, .switch_block_ref_multi, .switch_block_ref_else, .switch_block_ref_else_multi, .switch_block_ref_under, .switch_block_ref_under_multi, .validate_struct_init_ptr, .struct_init_empty, .int_to_enum, .enum_to_int, => false, .@"break", .break_inline, .condbr, .condbr_inline, .compile_error, .ret_node, .ret_tok, .ret_coerce, .@"unreachable", .repeat, .repeat_inline, => true, }; } }; /// The position of a ZIR instruction within the `Code` instructions array. pub const Index = u32; /// A reference to a TypedValue, parameter of the current function, /// or ZIR instruction. /// /// If the Ref has a tag in this enum, it refers to a TypedValue which may be /// retrieved with Ref.toTypedValue(). /// /// If the value of a Ref does not have a tag, it referes to either a parameter /// of the current function or a ZIR instruction. /// /// The first values after the the last tag refer to parameters which may be /// derived by subtracting typed_value_map.len. /// /// All further values refer to ZIR instructions which may be derived by /// subtracting typed_value_map.len and the number of parameters. /// /// When adding a tag to this enum, consider adding a corresponding entry to /// `simple_types` in astgen. /// /// The tag type is specified so that it is safe to bitcast between `[]u32` /// and `[]Ref`. pub const Ref = enum(u32) { /// This Ref does not correspond to any ZIR instruction or constant /// value and may instead be used as a sentinel to indicate null. none, u8_type, i8_type, u16_type, i16_type, u32_type, i32_type, u64_type, i64_type, usize_type, isize_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, null_type, undefined_type, fn_noreturn_no_args_type, fn_void_no_args_type, fn_naked_noreturn_no_args_type, fn_ccc_void_no_args_type, single_const_pointer_to_comptime_int_type, const_slice_u8_type, enum_literal_type, /// `undefined` (untyped) undef, /// `0` (comptime_int) zero, /// `1` (comptime_int) one, /// `{}` void_value, /// `unreachable` (noreturn type) unreachable_value, /// `null` (untyped) null_value, /// `true` bool_true, /// `false` bool_false, /// `.{}` (untyped) empty_struct, /// `0` (usize) zero_usize, /// `1` (usize) one_usize, _, pub const typed_value_map = std.enums.directEnumArray(Ref, TypedValue, 0, .{ .none = undefined, .u8_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.u8_type), }, .i8_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.i8_type), }, .u16_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.u16_type), }, .i16_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.i16_type), }, .u32_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.u32_type), }, .i32_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.i32_type), }, .u64_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.u64_type), }, .i64_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.i64_type), }, .usize_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.usize_type), }, .isize_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.isize_type), }, .c_short_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_short_type), }, .c_ushort_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_ushort_type), }, .c_int_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_int_type), }, .c_uint_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_uint_type), }, .c_long_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_long_type), }, .c_ulong_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_ulong_type), }, .c_longlong_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_longlong_type), }, .c_ulonglong_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_ulonglong_type), }, .c_longdouble_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_longdouble_type), }, .f16_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.f16_type), }, .f32_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.f32_type), }, .f64_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.f64_type), }, .f128_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.f128_type), }, .c_void_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.c_void_type), }, .bool_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.bool_type), }, .void_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.void_type), }, .type_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.type_type), }, .anyerror_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.anyerror_type), }, .comptime_int_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.comptime_int_type), }, .comptime_float_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.comptime_float_type), }, .noreturn_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.noreturn_type), }, .null_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.null_type), }, .undefined_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.undefined_type), }, .fn_noreturn_no_args_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.fn_noreturn_no_args_type), }, .fn_void_no_args_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.fn_void_no_args_type), }, .fn_naked_noreturn_no_args_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.fn_naked_noreturn_no_args_type), }, .fn_ccc_void_no_args_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.fn_ccc_void_no_args_type), }, .single_const_pointer_to_comptime_int_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.single_const_pointer_to_comptime_int_type), }, .const_slice_u8_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.const_slice_u8_type), }, .enum_literal_type = .{ .ty = Type.initTag(.type), .val = Value.initTag(.enum_literal_type), }, .undef = .{ .ty = Type.initTag(.@"undefined"), .val = Value.initTag(.undef), }, .zero = .{ .ty = Type.initTag(.comptime_int), .val = Value.initTag(.zero), }, .zero_usize = .{ .ty = Type.initTag(.usize), .val = Value.initTag(.zero), }, .one = .{ .ty = Type.initTag(.comptime_int), .val = Value.initTag(.one), }, .one_usize = .{ .ty = Type.initTag(.usize), .val = Value.initTag(.one), }, .void_value = .{ .ty = Type.initTag(.void), .val = Value.initTag(.void_value), }, .unreachable_value = .{ .ty = Type.initTag(.noreturn), .val = Value.initTag(.unreachable_value), }, .null_value = .{ .ty = Type.initTag(.@"null"), .val = Value.initTag(.null_value), }, .bool_true = .{ .ty = Type.initTag(.bool), .val = Value.initTag(.bool_true), }, .bool_false = .{ .ty = Type.initTag(.bool), .val = Value.initTag(.bool_false), }, .empty_struct = .{ .ty = Type.initTag(.empty_struct_literal), .val = Value.initTag(.empty_struct_value), }, }); }; /// All instructions have an 8-byte payload, which is contained within /// this union. `Tag` determines which union field is active, as well as /// how to interpret the data within. pub const Data = union { /// Used for unary operators, with an AST node source location. un_node: struct { /// Offset from Decl AST node index. src_node: i32, /// The meaning of this operand depends on the corresponding `Tag`. operand: Ref, pub fn src(self: @This()) LazySrcLoc { return .{ .node_offset = self.src_node }; } }, /// Used for unary operators, with a token source location. un_tok: struct { /// Offset from Decl AST token index. src_tok: ast.TokenIndex, /// The meaning of this operand depends on the corresponding `Tag`. operand: Ref, pub fn src(self: @This()) LazySrcLoc { return .{ .token_offset = self.src_tok }; } }, pl_node: struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: i32, /// index into extra. /// `Tag` determines what lives there. payload_index: u32, pub fn src(self: @This()) LazySrcLoc { return .{ .node_offset = self.src_node }; } }, bin: Bin, /// For strings which may contain null bytes. str: struct { /// Offset into `string_bytes`. start: u32, /// Number of bytes in the string. len: u32, pub fn get(self: @This(), code: Code) []const u8 { return code.string_bytes[self.start..][0..self.len]; } }, /// Strings 8 or fewer bytes which may not contain null bytes. small_str: struct { bytes: [8]u8, pub fn get(self: @This()) []const u8 { const end = for (self.bytes) |byte, i| { if (byte == 0) break i; } else self.bytes.len; return self.bytes[0..end]; } }, str_tok: struct { /// Offset into `string_bytes`. Null-terminated. start: u32, /// Offset from Decl AST token index. src_tok: u32, pub fn get(self: @This(), code: Code) [:0]const u8 { return code.nullTerminatedString(self.start); } pub fn src(self: @This()) LazySrcLoc { return .{ .token_offset = self.src_tok }; } }, /// Offset from Decl AST token index. tok: ast.TokenIndex, /// Offset from Decl AST node index. node: i32, int: u64, float: struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: i32, number: f32, pub fn src(self: @This()) LazySrcLoc { return .{ .node_offset = self.src_node }; } }, array_type_sentinel: struct { len: Ref, /// index into extra, points to an `ArrayTypeSentinel` payload_index: u32, }, ptr_type_simple: struct { is_allowzero: bool, is_mutable: bool, is_volatile: bool, size: std.builtin.TypeInfo.Pointer.Size, elem_type: Ref, }, ptr_type: struct { flags: packed struct { is_allowzero: bool, is_mutable: bool, is_volatile: bool, has_sentinel: bool, has_align: bool, has_bit_range: bool, _: u2 = undefined, }, size: std.builtin.TypeInfo.Pointer.Size, /// Index into extra. See `PtrType`. payload_index: u32, }, int_type: struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: i32, signedness: std.builtin.Signedness, bit_count: u16, pub fn src(self: @This()) LazySrcLoc { return .{ .node_offset = self.src_node }; } }, bool_br: struct { lhs: Ref, /// Points to a `Block`. payload_index: u32, }, param_type: struct { callee: Ref, param_index: u32, }, @"unreachable": struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: i32, /// `false`: Not safety checked - the compiler will assume the /// correctness of this instruction. /// `true`: In safety-checked modes, this will generate a call /// to the panic function unless it can be proven unreachable by the compiler. safety: bool, pub fn src(self: @This()) LazySrcLoc { return .{ .node_offset = self.src_node }; } }, @"break": struct { block_inst: Index, operand: Ref, }, switch_capture: struct { switch_inst: Index, prong_index: u32, }, // Make sure we don't accidentally add a field to make this union // bigger than expected. Note that in Debug builds, Zig is allowed // to insert a secret field for safety checks. comptime { if (std.builtin.mode != .Debug) { assert(@sizeOf(Data) == 8); } } }; /// Stored in extra. Trailing is: /// * output_name: u32 // index into string_bytes (null terminated) if output is present /// * arg: Ref // for every args_len. /// * constraint: u32 // index into string_bytes (null terminated) for every args_len. /// * clobber: u32 // index into string_bytes (null terminated) for every clobbers_len. pub const Asm = struct { asm_source: Ref, return_type: Ref, /// May be omitted. output: Ref, args_len: u32, clobbers_len: u32, }; /// This data is stored inside extra, with trailing parameter type indexes /// according to `param_types_len`. /// Each param type is a `Ref`. pub const FnTypeCc = struct { return_type: Ref, cc: Ref, param_types_len: u32, }; /// This data is stored inside extra, with trailing parameter type indexes /// according to `param_types_len`. /// Each param type is a `Ref`. pub const FnType = struct { return_type: Ref, param_types_len: u32, }; /// This data is stored inside extra, with trailing operands according to `operands_len`. /// Each operand is a `Ref`. pub const MultiOp = struct { operands_len: u32, }; /// This data is stored inside extra, with trailing operands according to `body_len`. /// Each operand is an `Index`. pub const Block = struct { body_len: u32, }; /// Stored inside extra, with trailing arguments according to `args_len`. /// Each argument is a `Ref`. pub const Call = struct { callee: Ref, args_len: u32, }; /// This data is stored inside extra, with two sets of trailing `Ref`: /// * 0. the then body, according to `then_body_len`. /// * 1. the else body, according to `else_body_len`. pub const CondBr = struct { condition: Ref, then_body_len: u32, else_body_len: u32, }; /// Stored in extra. Depending on the flags in Data, there will be up to 4 /// trailing Ref fields: /// 0. sentinel: Ref // if `has_sentinel` flag is set /// 1. align: Ref // if `has_align` flag is set /// 2. bit_start: Ref // if `has_bit_range` flag is set /// 3. bit_end: Ref // if `has_bit_range` flag is set pub const PtrType = struct { elem_type: Ref, }; pub const ArrayTypeSentinel = struct { sentinel: Ref, elem_type: Ref, }; pub const SliceStart = struct { lhs: Ref, start: Ref, }; pub const SliceEnd = struct { lhs: Ref, start: Ref, end: Ref, }; pub const SliceSentinel = struct { lhs: Ref, start: Ref, end: Ref, sentinel: Ref, }; /// The meaning of these operands depends on the corresponding `Tag`. pub const Bin = struct { lhs: Ref, rhs: Ref, }; /// This form is supported when there are no ranges, and exactly 1 item per block. /// Depending on zir tag and len fields, extra fields trail /// this one in the extra array. /// 0. else_body { // If the tag has "_else" or "_under" in it. /// body_len: u32, /// body member Index for every body_len /// } /// 1. cases: { /// item: Ref, /// body_len: u32, /// body member Index for every body_len /// } for every cases_len pub const SwitchBlock = struct { operand: Ref, cases_len: u32, }; /// This form is required when there exists a block which has more than one item, /// or a range. /// Depending on zir tag and len fields, extra fields trail /// this one in the extra array. /// 0. else_body { // If the tag has "_else" or "_under" in it. /// body_len: u32, /// body member Index for every body_len /// } /// 1. scalar_cases: { // for every scalar_cases_len /// item: Ref, /// body_len: u32, /// body member Index for every body_len /// } /// 2. multi_cases: { // for every multi_cases_len /// items_len: u32, /// ranges_len: u32, /// body_len: u32, /// item: Ref // for every items_len /// ranges: { // for every ranges_len /// item_first: Ref, /// item_last: Ref, /// } /// body member Index for every body_len /// } pub const SwitchBlockMulti = struct { operand: Ref, scalar_cases_len: u32, multi_cases_len: u32, }; pub const Field = struct { lhs: Ref, /// Offset into `string_bytes`. field_name_start: u32, }; pub const FieldNamed = struct { lhs: Ref, field_name: Ref, }; pub const As = struct { dest_type: Ref, operand: Ref, }; /// Trailing: /// 0. has_bits: u32 // for every 16 fields /// - sets of 2 bits: /// 0b0X: whether corresponding field has an align expression /// 0bX0: whether corresponding field has a default expression /// 1. fields: { // for every fields_len /// field_name: u32, /// field_type: Ref, /// align: Ref, // if corresponding bit is set /// default_value: Ref, // if corresponding bit is set /// } pub const StructDecl = struct { fields_len: u32, }; /// Trailing: /// 0. has_bits: u32 // for every 32 fields /// - the bit is whether corresponding field has an value expression /// 1. field_name: u32 // for every field: null terminated string index /// 2. value: Ref // for every field for which corresponding bit is set pub const EnumDecl = struct { /// Can be `Ref.none`. tag_type: Ref, fields_len: u32, }; /// Trailing: /// 0. has_bits: u32 // for every 10 fields (+1) /// - first bit is special: set if and only if auto enum tag is enabled. /// - sets of 3 bits: /// 0b00X: whether corresponding field has a type expression /// 0b0X0: whether corresponding field has a align expression /// 0bX00: whether corresponding field has a tag value expression /// 1. field_name: u32 // for every field: null terminated string index /// 2. opt_exprs // Ref for every field for which corresponding bit is set /// - interleaved. type if present, align if present, tag value if present. pub const UnionDecl = struct { /// Can be `Ref.none`. tag_type: Ref, fields_len: u32, }; /// A f128 value, broken up into 4 u32 parts. pub const Float128 = struct { piece0: u32, piece1: u32, piece2: u32, piece3: u32, pub fn get(self: Float128) f128 { const int_bits = @as(u128, self.piece0) | (@as(u128, self.piece1) << 32) | (@as(u128, self.piece2) << 64) | (@as(u128, self.piece3) << 96); return @bitCast(f128, int_bits); } }; }; pub const SpecialProng = enum { none, @"else", under }; const Writer = struct { gpa: *Allocator, arena: *Allocator, scope: *Module.Scope, code: Code, indent: usize, param_count: usize, fn writeInstToStream( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const tags = self.code.instructions.items(.tag); const tag = tags[inst]; try stream.print("= {s}(", .{@tagName(tags[inst])}); switch (tag) { .array_type, .as, .coerce_result_ptr, .elem_ptr, .elem_val, .intcast, .store, .store_to_block_ptr, .store_to_inferred_ptr, => try self.writeBin(stream, inst), .alloc, .alloc_mut, .indexable_ptr_len, .bit_not, .bool_not, .negate, .negate_wrap, .call_none, .call_none_chkused, .compile_error, .load, .ensure_result_used, .ensure_result_non_error, .import, .ptrtoint, .ret_node, .set_eval_branch_quota, .resolve_inferred_alloc, .optional_type, .optional_type_from_ptr_elem, .optional_payload_safe, .optional_payload_unsafe, .optional_payload_safe_ptr, .optional_payload_unsafe_ptr, .err_union_payload_safe, .err_union_payload_unsafe, .err_union_payload_safe_ptr, .err_union_payload_unsafe_ptr, .err_union_code, .err_union_code_ptr, .int_to_error, .error_to_int, .is_non_null, .is_null, .is_non_null_ptr, .is_null_ptr, .is_err, .is_err_ptr, .typeof, .typeof_elem, .struct_init_empty, .enum_to_int, => try self.writeUnNode(stream, inst), .ref, .ret_tok, .ret_coerce, .ensure_err_payload_void, => try self.writeUnTok(stream, inst), .bool_br_and, .bool_br_or, => try self.writeBoolBr(stream, inst), .array_type_sentinel => try self.writeArrayTypeSentinel(stream, inst), .param_type => try self.writeParamType(stream, inst), .ptr_type_simple => try self.writePtrTypeSimple(stream, inst), .ptr_type => try self.writePtrType(stream, inst), .int => try self.writeInt(stream, inst), .float => try self.writeFloat(stream, inst), .float128 => try self.writeFloat128(stream, inst), .str => try self.writeStr(stream, inst), .elided => try stream.writeAll(")"), .int_type => try self.writeIntType(stream, inst), .@"break", .break_inline, => try self.writeBreak(stream, inst), .@"asm", .asm_volatile, .elem_ptr_node, .elem_val_node, .field_ptr_named, .field_val_named, .floatcast, .slice_start, .slice_end, .slice_sentinel, .union_decl, .enum_decl, .enum_decl_nonexhaustive, => try self.writePlNode(stream, inst), .add, .addwrap, .array_cat, .array_mul, .mul, .mulwrap, .sub, .subwrap, .bool_and, .bool_or, .cmp_lt, .cmp_lte, .cmp_eq, .cmp_gte, .cmp_gt, .cmp_neq, .div, .mod_rem, .shl, .shr, .xor, .store_node, .error_union_type, .merge_error_sets, .bit_and, .bit_or, .int_to_enum, => try self.writePlNodeBin(stream, inst), .call, .call_chkused, .call_compile_time, => try self.writePlNodeCall(stream, inst), .block, .block_inline, .loop, .validate_struct_init_ptr, => try self.writePlNodeBlock(stream, inst), .condbr, .condbr_inline, => try self.writePlNodeCondBr(stream, inst), .struct_decl, .struct_decl_packed, .struct_decl_extern, => try self.writeStructDecl(stream, inst), .switch_block => try self.writePlNodeSwitchBr(stream, inst, .none), .switch_block_else => try self.writePlNodeSwitchBr(stream, inst, .@"else"), .switch_block_under => try self.writePlNodeSwitchBr(stream, inst, .under), .switch_block_ref => try self.writePlNodeSwitchBr(stream, inst, .none), .switch_block_ref_else => try self.writePlNodeSwitchBr(stream, inst, .@"else"), .switch_block_ref_under => try self.writePlNodeSwitchBr(stream, inst, .under), .switch_block_multi => try self.writePlNodeSwitchBlockMulti(stream, inst, .none), .switch_block_else_multi => try self.writePlNodeSwitchBlockMulti(stream, inst, .@"else"), .switch_block_under_multi => try self.writePlNodeSwitchBlockMulti(stream, inst, .under), .switch_block_ref_multi => try self.writePlNodeSwitchBlockMulti(stream, inst, .none), .switch_block_ref_else_multi => try self.writePlNodeSwitchBlockMulti(stream, inst, .@"else"), .switch_block_ref_under_multi => try self.writePlNodeSwitchBlockMulti(stream, inst, .under), .compile_log, .typeof_peer, => try self.writePlNodeMultiOp(stream, inst), .decl_ref, .decl_val, => try self.writePlNodeDecl(stream, inst), .field_ptr, .field_val, => try self.writePlNodeField(stream, inst), .as_node => try self.writeAs(stream, inst), .breakpoint, .opaque_decl, .dbg_stmt_node, .ret_ptr, .ret_type, .repeat, .repeat_inline, .alloc_inferred, .alloc_inferred_mut, => try self.writeNode(stream, inst), .error_value, .enum_literal, => try self.writeStrTok(stream, inst), .fn_type => try self.writeFnType(stream, inst, false), .fn_type_cc => try self.writeFnTypeCc(stream, inst, false), .fn_type_var_args => try self.writeFnType(stream, inst, true), .fn_type_cc_var_args => try self.writeFnTypeCc(stream, inst, true), .@"unreachable" => try self.writeUnreachable(stream, inst), .enum_literal_small => try self.writeSmallStr(stream, inst), .switch_capture, .switch_capture_ref, .switch_capture_multi, .switch_capture_multi_ref, .switch_capture_else, .switch_capture_else_ref, => try self.writeSwitchCapture(stream, inst), .bitcast, .bitcast_result_ptr, => try stream.writeAll("TODO)"), } } fn writeBin(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].bin; try self.writeInstRef(stream, inst_data.lhs); try stream.writeAll(", "); try self.writeInstRef(stream, inst_data.rhs); try stream.writeByte(')'); } fn writeUnNode( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].un_node; try self.writeInstRef(stream, inst_data.operand); try stream.writeAll(") "); try self.writeSrc(stream, inst_data.src()); } fn writeUnTok( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].un_tok; try self.writeInstRef(stream, inst_data.operand); try stream.writeAll(") "); try self.writeSrc(stream, inst_data.src()); } fn writeArrayTypeSentinel( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].array_type_sentinel; try stream.writeAll("TODO)"); } fn writeParamType( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].param_type; try self.writeInstRef(stream, inst_data.callee); try stream.print(", {d})", .{inst_data.param_index}); } fn writePtrTypeSimple( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].ptr_type_simple; try stream.writeAll("TODO)"); } fn writePtrType( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].ptr_type; try stream.writeAll("TODO)"); } fn writeInt( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].int; try stream.print("{d})", .{inst_data}); } fn writeFloat(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].float; const src = inst_data.src(); try stream.print("{d}) ", .{inst_data.number}); try self.writeSrc(stream, src); } fn writeFloat128(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.Float128, inst_data.payload_index).data; const src = inst_data.src(); const number = extra.get(); // TODO improve std.format to be able to print f128 values try stream.print("{d}) ", .{@floatCast(f64, number)}); try self.writeSrc(stream, src); } fn writeStr( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].str; const str = inst_data.get(self.code); try stream.print("\"{}\")", .{std.zig.fmtEscapes(str)}); } fn writePlNode( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; try stream.writeAll("TODO) "); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeBin(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.Bin, inst_data.payload_index).data; try self.writeInstRef(stream, extra.lhs); try stream.writeAll(", "); try self.writeInstRef(stream, extra.rhs); try stream.writeAll(") "); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeCall(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.Call, inst_data.payload_index); const args = self.code.refSlice(extra.end, extra.data.args_len); try self.writeInstRef(stream, extra.data.callee); try stream.writeAll(", ["); for (args) |arg, i| { if (i != 0) try stream.writeAll(", "); try self.writeInstRef(stream, arg); } try stream.writeAll("]) "); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeBlock(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.Block, inst_data.payload_index); const body = self.code.extra[extra.end..][0..extra.data.body_len]; try stream.writeAll("{\n"); self.indent += 2; try self.writeBody(stream, body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}) "); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeCondBr(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.CondBr, inst_data.payload_index); const then_body = self.code.extra[extra.end..][0..extra.data.then_body_len]; const else_body = self.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; try self.writeInstRef(stream, extra.data.condition); try stream.writeAll(", {\n"); self.indent += 2; try self.writeBody(stream, then_body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}, {\n"); self.indent += 2; try self.writeBody(stream, else_body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}) "); try self.writeSrc(stream, inst_data.src()); } fn writeStructDecl(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.StructDecl, inst_data.payload_index); const fields_len = extra.data.fields_len; const bit_bags_count = std.math.divCeil(usize, fields_len, 16) catch unreachable; try stream.writeAll("{\n"); self.indent += 2; var field_index: usize = extra.end + bit_bags_count; var bit_bag_index: usize = extra.end; var cur_bit_bag: u32 = undefined; var field_i: u32 = 0; while (field_i < fields_len) : (field_i += 1) { if (field_i % 16 == 0) { cur_bit_bag = self.code.extra[bit_bag_index]; bit_bag_index += 1; } const has_align = @truncate(u1, cur_bit_bag) != 0; cur_bit_bag >>= 1; const has_default = @truncate(u1, cur_bit_bag) != 0; cur_bit_bag >>= 1; const field_name = self.code.nullTerminatedString(self.code.extra[field_index]); field_index += 1; const field_type = @intToEnum(Inst.Ref, self.code.extra[field_index]); field_index += 1; try stream.writeByteNTimes(' ', self.indent); try stream.print("{}: ", .{std.zig.fmtId(field_name)}); try self.writeInstRef(stream, field_type); if (has_align) { const align_ref = @intToEnum(Inst.Ref, self.code.extra[field_index]); field_index += 1; try stream.writeAll(" align("); try self.writeInstRef(stream, align_ref); try stream.writeAll(")"); } if (has_default) { const default_ref = @intToEnum(Inst.Ref, self.code.extra[field_index]); field_index += 1; try stream.writeAll(" = "); try self.writeInstRef(stream, default_ref); } try stream.writeAll(",\n"); } self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}) "); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeSwitchBr( self: *Writer, stream: anytype, inst: Inst.Index, special_prong: SpecialProng, ) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.SwitchBlock, inst_data.payload_index); const special: struct { body: []const Inst.Index, end: usize, } = switch (special_prong) { .none => .{ .body = &.{}, .end = extra.end }, .under, .@"else" => blk: { const body_len = self.code.extra[extra.end]; const extra_body_start = extra.end + 1; break :blk .{ .body = self.code.extra[extra_body_start..][0..body_len], .end = extra_body_start + body_len, }; }, }; try self.writeInstRef(stream, extra.data.operand); if (special.body.len != 0) { const prong_name = switch (special_prong) { .@"else" => "else", .under => "_", else => unreachable, }; try stream.print(", {s} => {{\n", .{prong_name}); self.indent += 2; try self.writeBody(stream, special.body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}"); } var extra_index: usize = special.end; { var scalar_i: usize = 0; while (scalar_i < extra.data.cases_len) : (scalar_i += 1) { const item_ref = @intToEnum(Inst.Ref, self.code.extra[extra_index]); extra_index += 1; const body_len = self.code.extra[extra_index]; extra_index += 1; const body = self.code.extra[extra_index..][0..body_len]; extra_index += body_len; try stream.writeAll(", "); try self.writeInstRef(stream, item_ref); try stream.writeAll(" => {\n"); self.indent += 2; try self.writeBody(stream, body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}"); } } try stream.writeAll(") "); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeSwitchBlockMulti( self: *Writer, stream: anytype, inst: Inst.Index, special_prong: SpecialProng, ) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.SwitchBlockMulti, inst_data.payload_index); const special: struct { body: []const Inst.Index, end: usize, } = switch (special_prong) { .none => .{ .body = &.{}, .end = extra.end }, .under, .@"else" => blk: { const body_len = self.code.extra[extra.end]; const extra_body_start = extra.end + 1; break :blk .{ .body = self.code.extra[extra_body_start..][0..body_len], .end = extra_body_start + body_len, }; }, }; try self.writeInstRef(stream, extra.data.operand); if (special.body.len != 0) { const prong_name = switch (special_prong) { .@"else" => "else", .under => "_", else => unreachable, }; try stream.print(", {s} => {{\n", .{prong_name}); self.indent += 2; try self.writeBody(stream, special.body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}"); } var extra_index: usize = special.end; { var scalar_i: usize = 0; while (scalar_i < extra.data.scalar_cases_len) : (scalar_i += 1) { const item_ref = @intToEnum(Inst.Ref, self.code.extra[extra_index]); extra_index += 1; const body_len = self.code.extra[extra_index]; extra_index += 1; const body = self.code.extra[extra_index..][0..body_len]; extra_index += body_len; try stream.writeAll(", "); try self.writeInstRef(stream, item_ref); try stream.writeAll(" => {\n"); self.indent += 2; try self.writeBody(stream, body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}"); } } { var multi_i: usize = 0; while (multi_i < extra.data.multi_cases_len) : (multi_i += 1) { const items_len = self.code.extra[extra_index]; extra_index += 1; const ranges_len = self.code.extra[extra_index]; extra_index += 1; const body_len = self.code.extra[extra_index]; extra_index += 1; const items = self.code.refSlice(extra_index, items_len); extra_index += items_len; for (items) |item_ref| { try stream.writeAll(", "); try self.writeInstRef(stream, item_ref); } var range_i: usize = 0; while (range_i < ranges_len) : (range_i += 1) { const item_first = @intToEnum(Inst.Ref, self.code.extra[extra_index]); extra_index += 1; const item_last = @intToEnum(Inst.Ref, self.code.extra[extra_index]); extra_index += 1; try stream.writeAll(", "); try self.writeInstRef(stream, item_first); try stream.writeAll("..."); try self.writeInstRef(stream, item_last); } const body = self.code.extra[extra_index..][0..body_len]; extra_index += body_len; try stream.writeAll(" => {\n"); self.indent += 2; try self.writeBody(stream, body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("}"); } } try stream.writeAll(") "); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeMultiOp(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.MultiOp, inst_data.payload_index); const operands = self.code.refSlice(extra.end, extra.data.operands_len); for (operands) |operand, i| { if (i != 0) try stream.writeAll(", "); try self.writeInstRef(stream, operand); } try stream.writeAll(") "); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeDecl(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const owner_decl = self.scope.ownerDecl().?; const decl = owner_decl.dependencies.entries.items[inst_data.payload_index].key; try stream.print("{s}) ", .{decl.name}); try self.writeSrc(stream, inst_data.src()); } fn writePlNodeField(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.Field, inst_data.payload_index).data; const name = self.code.nullTerminatedString(extra.field_name_start); try self.writeInstRef(stream, extra.lhs); try stream.print(", \"{}\") ", .{std.zig.fmtEscapes(name)}); try self.writeSrc(stream, inst_data.src()); } fn writeAs(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const extra = self.code.extraData(Inst.As, inst_data.payload_index).data; try self.writeInstRef(stream, extra.dest_type); try stream.writeAll(", "); try self.writeInstRef(stream, extra.operand); try stream.writeAll(") "); try self.writeSrc(stream, inst_data.src()); } fn writeNode( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const src_node = self.code.instructions.items(.data)[inst].node; const src: LazySrcLoc = .{ .node_offset = src_node }; try stream.writeAll(") "); try self.writeSrc(stream, src); } fn writeStrTok( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].str_tok; const str = inst_data.get(self.code); try stream.print("\"{}\") ", .{std.zig.fmtEscapes(str)}); try self.writeSrc(stream, inst_data.src()); } fn writeFnType( self: *Writer, stream: anytype, inst: Inst.Index, var_args: bool, ) !void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); const extra = self.code.extraData(Inst.FnType, inst_data.payload_index); const param_types = self.code.refSlice(extra.end, extra.data.param_types_len); return self.writeFnTypeCommon(stream, param_types, extra.data.return_type, var_args, .none, src); } fn writeFnTypeCc( self: *Writer, stream: anytype, inst: Inst.Index, var_args: bool, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); const extra = self.code.extraData(Inst.FnTypeCc, inst_data.payload_index); const param_types = self.code.refSlice(extra.end, extra.data.param_types_len); const cc = extra.data.cc; return self.writeFnTypeCommon(stream, param_types, extra.data.return_type, var_args, cc, src); } fn writeBoolBr(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].bool_br; const extra = self.code.extraData(Inst.Block, inst_data.payload_index); const body = self.code.extra[extra.end..][0..extra.data.body_len]; try self.writeInstRef(stream, inst_data.lhs); try stream.writeAll(", {\n"); self.indent += 2; try self.writeBody(stream, body); self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("})"); } fn writeIntType(self: *Writer, stream: anytype, inst: Inst.Index) !void { const int_type = self.code.instructions.items(.data)[inst].int_type; const prefix: u8 = switch (int_type.signedness) { .signed => 'i', .unsigned => 'u', }; try stream.print("{c}{d}) ", .{ prefix, int_type.bit_count }); try self.writeSrc(stream, int_type.src()); } fn writeBreak(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].@"break"; try self.writeInstIndex(stream, inst_data.block_inst); try stream.writeAll(", "); try self.writeInstRef(stream, inst_data.operand); try stream.writeAll(")"); } fn writeUnreachable(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].@"unreachable"; const safety_str = if (inst_data.safety) "safe" else "unsafe"; try stream.print("{s}) ", .{safety_str}); try self.writeSrc(stream, inst_data.src()); } fn writeFnTypeCommon( self: *Writer, stream: anytype, param_types: []const Inst.Ref, ret_ty: Inst.Ref, var_args: bool, cc: Inst.Ref, src: LazySrcLoc, ) !void { try stream.writeAll("["); for (param_types) |param_type, i| { if (i != 0) try stream.writeAll(", "); try self.writeInstRef(stream, param_type); } try stream.writeAll("], "); try self.writeInstRef(stream, ret_ty); try self.writeOptionalInstRef(stream, ", cc=", cc); try self.writeFlag(stream, ", var_args", var_args); try stream.writeAll(") "); try self.writeSrc(stream, src); } fn writeSmallStr( self: *Writer, stream: anytype, inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const str = self.code.instructions.items(.data)[inst].small_str.get(); try stream.print("\"{}\")", .{std.zig.fmtEscapes(str)}); } fn writeSwitchCapture(self: *Writer, stream: anytype, inst: Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].switch_capture; try self.writeInstIndex(stream, inst_data.switch_inst); try stream.print(", {d})", .{inst_data.prong_index}); } fn writeInstRef(self: *Writer, stream: anytype, ref: Inst.Ref) !void { var i: usize = @enumToInt(ref); if (i < Inst.Ref.typed_value_map.len) { return stream.print("@{}", .{ref}); } i -= Inst.Ref.typed_value_map.len; if (i < self.param_count) { return stream.print("${d}", .{i}); } i -= self.param_count; return self.writeInstIndex(stream, @intCast(Inst.Index, i)); } fn writeInstIndex(self: *Writer, stream: anytype, inst: Inst.Index) !void { return stream.print("%{d}", .{inst}); } fn writeOptionalInstRef( self: *Writer, stream: anytype, prefix: []const u8, inst: Inst.Ref, ) !void { if (inst == .none) return; try stream.writeAll(prefix); try self.writeInstRef(stream, inst); } fn writeFlag( self: *Writer, stream: anytype, name: []const u8, flag: bool, ) !void { if (!flag) return; try stream.writeAll(name); } fn writeSrc(self: *Writer, stream: anytype, src: LazySrcLoc) !void { const tree = self.scope.tree(); const src_loc = src.toSrcLoc(self.scope); const abs_byte_off = try src_loc.byteOffset(); const delta_line = std.zig.findLineColumn(tree.source, abs_byte_off); try stream.print("{s}:{d}:{d}", .{ @tagName(src), delta_line.line + 1, delta_line.column + 1, }); } fn writeBody(self: *Writer, stream: anytype, body: []const Inst.Index) !void { for (body) |inst| { try stream.writeByteNTimes(' ', self.indent); try stream.print("%{d} ", .{inst}); try self.writeInstToStream(stream, inst); try stream.writeByte('\n'); } } };
src/zir.zig
const std = @import("std"); const lex = @import("zua").lex; // Tests for comparing the tokens of Zua's lexer with Lua's. // Expects @import("build_options").fuzzed_lex_inputs_dir to be a path to // a directory containing a corpus of inputs to test and // @import("build_options").fuzzed_lex_outputs_dir to be a path to a // directory containing the tokens obtained by running the input // through the Lua lexer (in a specific format). // // A usable corpus/outputs pair can be obtained from // https://github.com/squeek502/fuzzing-lua const verboseTestPrinting = false; const printTokenBounds = false; const printErrorContextDifferences = false; const build_options = @import("build_options"); const inputs_dir_path = build_options.fuzzed_lex_inputs_dir; const outputs_dir_path = build_options.fuzzed_lex_outputs_dir; test "fuzz_llex input/output pairs" { const allocator = std.testing.allocator; var inputs_dir = try std.fs.cwd().openDir(inputs_dir_path, .{ .iterate = true }); defer inputs_dir.close(); var outputs_dir = try std.fs.cwd().openDir(outputs_dir_path, .{}); defer outputs_dir.close(); var result_buffer: [1024 * 1024]u8 = undefined; var n: usize = 0; var inputs_iterator = inputs_dir.iterate(); while (try inputs_iterator.next()) |entry| { if (entry.kind != .File) continue; if (verboseTestPrinting) { std.debug.print("\n{s}\n", .{entry.name}); } const contents = try inputs_dir.readFileAlloc(allocator, entry.name, std.math.maxInt(usize)); defer allocator.free(contents); const expectedContents = try outputs_dir.readFileAlloc(allocator, entry.name, std.math.maxInt(usize)); defer allocator.free(expectedContents); // ignore this error for now, see long_str_nesting_compat TODO if (std.mem.indexOf(u8, expectedContents, "nesting of [[...]]") != null) { continue; } var result_stream = std.io.fixedBufferStream(&result_buffer); const result_writer = result_stream.writer(); var lexer = lex.Lexer.init(contents, "fuzz"); while (true) { const token = lexer.next() catch |e| { if (verboseTestPrinting) { std.debug.print("\n{s}\n", .{e}); } try result_writer.writeByte('\n'); const err_msg = try lexer.renderErrorAlloc(allocator); defer allocator.free(err_msg); try result_writer.writeAll(err_msg); break; }; if (verboseTestPrinting) { if (printTokenBounds) { std.debug.print("{d}:{s}:{d}", .{ token.start, token.nameForDisplay(), token.end }); } else { std.debug.print("{s}", .{token.nameForDisplay()}); } } try result_writer.writeAll(token.nameForDisplay()); if (token.id == lex.Token.Id.eof) { break; } else { if (verboseTestPrinting) { std.debug.print(" ", .{}); } try result_writer.print(" ", .{}); } } if (verboseTestPrinting) { std.debug.print("\nexpected\n{s}\n", .{expectedContents}); } var nearIndex = std.mem.lastIndexOf(u8, expectedContents, " near '"); if (nearIndex) |i| { try std.testing.expectEqualStrings(expectedContents[0..i], result_stream.getWritten()[0..i]); if (printErrorContextDifferences) { var lastLineEnding = std.mem.lastIndexOf(u8, expectedContents, "\n").? + 1; const expectedError = expectedContents[lastLineEnding..]; const actualError = result_stream.getWritten()[lastLineEnding..]; if (!std.mem.eql(u8, expectedError, actualError)) { std.debug.print("\n{s}\nexpected: {s}\nactual: {s}\n", .{ entry.name, expectedContents[lastLineEnding..], result_stream.getWritten()[lastLineEnding..] }); } } } else { try std.testing.expectEqualStrings(expectedContents, result_stream.getWritten()); } n += 1; } std.debug.print("\n{d} input/output pairs checked\n", .{n}); }
test/fuzzed_lex.zig