code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const mem = std.mem; const GraphemeLink = @This(); allocator: *mem.Allocator, array: []bool, lo: u21 = 2381, hi: u21 = 73111, pub fn init(allocator: *mem.Allocator) !GraphemeLink { var instance = GraphemeLink{ .allocator = allocator, .array = try allocator.alloc(bool, 70731), }; mem.set(bool, instance.array, false); var index: u21 = 0; instance.array[0] = true; instance.array[128] = true; instance.array[256] = true; instance.array[384] = true; instance.array[512] = true; instance.array[640] = true; instance.array[768] = true; instance.array[896] = true; index = 1006; while (index <= 1007) : (index += 1) { instance.array[index] = true; } instance.array[1024] = true; instance.array[1149] = true; instance.array[1261] = true; instance.array[1389] = true; instance.array[1591] = true; index = 1772; while (index <= 1773) : (index += 1) { instance.array[index] = true; } instance.array[3527] = true; instance.array[3559] = true; instance.array[3717] = true; instance.array[4371] = true; instance.array[4599] = true; instance.array[4701] = true; instance.array[4702] = true; index = 4773; while (index <= 4774) : (index += 1) { instance.array[index] = true; } instance.array[9266] = true; instance.array[40633] = true; instance.array[40671] = true; instance.array[40823] = true; instance.array[40966] = true; instance.array[41075] = true; instance.array[41385] = true; instance.array[41632] = true; instance.array[65778] = true; instance.array[67321] = true; instance.array[67378] = true; instance.array[67436] = true; index = 67558; while (index <= 67559) : (index += 1) { instance.array[index] = true; } instance.array[67699] = true; instance.array[67816] = true; instance.array[67997] = true; instance.array[68096] = true; instance.array[68341] = true; instance.array[68469] = true; instance.array[68722] = true; instance.array[68850] = true; instance.array[68969] = true; instance.array[69086] = true; instance.array[69356] = true; instance.array[69616] = true; instance.array[69617] = true; instance.array[69779] = true; instance.array[69863] = true; instance.array[69882] = true; instance.array[69964] = true; instance.array[70386] = true; index = 70647; while (index <= 70648) : (index += 1) { instance.array[index] = true; } instance.array[70730] = true; // Placeholder: 0. Struct name, 1. Code point kind return instance; } pub fn deinit(self: *GraphemeLink) void { self.allocator.free(self.array); } // isGraphemeLink checks if cp is of the kind Grapheme_Link. pub fn isGraphemeLink(self: GraphemeLink, cp: u21) bool { if (cp < self.lo or cp > self.hi) return false; const index = cp - self.lo; return if (index >= self.array.len) false else self.array[index]; }
src/components/autogen/DerivedCoreProperties/GraphemeLink.zig
const std = @import("../index.zig"); const builtin = @import("builtin"); const os = std.os; const mem = std.mem; const math = std.math; const assert = std.debug.assert; const posix = os.posix; const windows = os.windows; const Os = builtin.Os; const is_posix = builtin.os != builtin.Os.windows; const is_windows = builtin.os == builtin.Os.windows; pub const File = struct { /// The OS-specific file descriptor or file handle. handle: os.FileHandle, const OpenError = os.WindowsOpenError || os.PosixOpenError; /// `path` needs to be copied in memory to add a null terminating byte, hence the allocator. /// Call close to clean up. pub fn openRead(allocator: &mem.Allocator, path: []const u8) OpenError!File { if (is_posix) { const flags = posix.O_LARGEFILE|posix.O_RDONLY; const fd = try os.posixOpen(allocator, path, flags, 0); return openHandle(fd); } else if (is_windows) { const handle = try os.windowsOpen(allocator, path, windows.GENERIC_READ, windows.FILE_SHARE_READ, windows.OPEN_EXISTING, windows.FILE_ATTRIBUTE_NORMAL); return openHandle(handle); } else { @compileError("TODO implement openRead for this OS"); } } /// Calls `openWriteMode` with os.default_file_mode for the mode. pub fn openWrite(allocator: &mem.Allocator, path: []const u8) OpenError!File { return openWriteMode(allocator, path, os.default_file_mode); } /// If the path does not exist it will be created. /// If a file already exists in the destination it will be truncated. /// `path` needs to be copied in memory to add a null terminating byte, hence the allocator. /// Call close to clean up. pub fn openWriteMode(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) OpenError!File { if (is_posix) { const flags = posix.O_LARGEFILE|posix.O_WRONLY|posix.O_CREAT|posix.O_CLOEXEC|posix.O_TRUNC; const fd = try os.posixOpen(allocator, path, flags, file_mode); return openHandle(fd); } else if (is_windows) { const handle = try os.windowsOpen(allocator, path, windows.GENERIC_WRITE, windows.FILE_SHARE_WRITE|windows.FILE_SHARE_READ|windows.FILE_SHARE_DELETE, windows.CREATE_ALWAYS, windows.FILE_ATTRIBUTE_NORMAL); return openHandle(handle); } else { @compileError("TODO implement openWriteMode for this OS"); } } /// If the path does not exist it will be created. /// If a file already exists in the destination this returns OpenError.PathAlreadyExists /// `path` needs to be copied in memory to add a null terminating byte, hence the allocator. /// Call close to clean up. pub fn openWriteNoClobber(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) OpenError!File { if (is_posix) { const flags = posix.O_LARGEFILE|posix.O_WRONLY|posix.O_CREAT|posix.O_CLOEXEC|posix.O_EXCL; const fd = try os.posixOpen(allocator, path, flags, file_mode); return openHandle(fd); } else if (is_windows) { const handle = try os.windowsOpen(allocator, path, windows.GENERIC_WRITE, windows.FILE_SHARE_WRITE|windows.FILE_SHARE_READ|windows.FILE_SHARE_DELETE, windows.CREATE_NEW, windows.FILE_ATTRIBUTE_NORMAL); return openHandle(handle); } else { @compileError("TODO implement openWriteMode for this OS"); } } pub fn openHandle(handle: os.FileHandle) File { return File { .handle = handle, }; } pub fn access(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) !bool { const path_with_null = try std.cstr.addNullByte(allocator, path); defer allocator.free(path_with_null); if (is_posix) { // mode is ignored and is always F_OK for now const result = posix.access(path_with_null.ptr, posix.F_OK); const err = posix.getErrno(result); if (err > 0) { return switch (err) { posix.EACCES => error.PermissionDenied, posix.EROFS => error.PermissionDenied, posix.ELOOP => error.PermissionDenied, posix.ETXTBSY => error.PermissionDenied, posix.ENOTDIR => error.NotFound, posix.ENOENT => error.NotFound, posix.ENAMETOOLONG => error.NameTooLong, posix.EINVAL => error.BadMode, posix.EFAULT => error.BadPathName, posix.EIO => error.Io, posix.ENOMEM => error.SystemResources, else => os.unexpectedErrorPosix(err), }; } return true; } else if (is_windows) { if (os.windows.PathFileExists(path_with_null.ptr) == os.windows.TRUE) { return true; } const err = windows.GetLastError(); return switch (err) { windows.ERROR.FILE_NOT_FOUND => error.NotFound, windows.ERROR.ACCESS_DENIED => error.PermissionDenied, else => os.unexpectedErrorWindows(err), }; } else { @compileError("TODO implement access for this OS"); } } /// Upon success, the stream is in an uninitialized state. To continue using it, /// you must use the open() function. pub fn close(self: &File) void { os.close(self.handle); self.handle = undefined; } /// Calls `os.isTty` on `self.handle`. pub fn isTty(self: &File) bool { return os.isTty(self.handle); } pub fn seekForward(self: &File, amount: isize) !void { switch (builtin.os) { Os.linux, Os.macosx, Os.ios => { const result = posix.lseek(self.handle, amount, posix.SEEK_CUR); const err = posix.getErrno(result); if (err > 0) { return switch (err) { posix.EBADF => error.BadFd, posix.EINVAL => error.Unseekable, posix.EOVERFLOW => error.Unseekable, posix.ESPIPE => error.Unseekable, posix.ENXIO => error.Unseekable, else => os.unexpectedErrorPosix(err), }; } }, Os.windows => { if (windows.SetFilePointerEx(self.handle, amount, null, windows.FILE_CURRENT) == 0) { const err = windows.GetLastError(); return switch (err) { windows.ERROR.INVALID_PARAMETER => error.BadFd, else => os.unexpectedErrorWindows(err), }; } }, else => @compileError("unsupported OS"), } } pub fn seekTo(self: &File, pos: usize) !void { switch (builtin.os) { Os.linux, Os.macosx, Os.ios => { const ipos = try math.cast(isize, pos); const result = posix.lseek(self.handle, ipos, posix.SEEK_SET); const err = posix.getErrno(result); if (err > 0) { return switch (err) { posix.EBADF => error.BadFd, posix.EINVAL => error.Unseekable, posix.EOVERFLOW => error.Unseekable, posix.ESPIPE => error.Unseekable, posix.ENXIO => error.Unseekable, else => os.unexpectedErrorPosix(err), }; } }, Os.windows => { const ipos = try math.cast(isize, pos); if (windows.SetFilePointerEx(self.handle, ipos, null, windows.FILE_BEGIN) == 0) { const err = windows.GetLastError(); return switch (err) { windows.ERROR.INVALID_PARAMETER => error.BadFd, else => os.unexpectedErrorWindows(err), }; } }, else => @compileError("unsupported OS: " ++ @tagName(builtin.os)), } } pub fn getPos(self: &File) !usize { switch (builtin.os) { Os.linux, Os.macosx, Os.ios => { const result = posix.lseek(self.handle, 0, posix.SEEK_CUR); const err = posix.getErrno(result); if (err > 0) { return switch (err) { posix.EBADF => error.BadFd, posix.EINVAL => error.Unseekable, posix.EOVERFLOW => error.Unseekable, posix.ESPIPE => error.Unseekable, posix.ENXIO => error.Unseekable, else => os.unexpectedErrorPosix(err), }; } return result; }, Os.windows => { var pos : windows.LARGE_INTEGER = undefined; if (windows.SetFilePointerEx(self.handle, 0, &pos, windows.FILE_CURRENT) == 0) { const err = windows.GetLastError(); return switch (err) { windows.ERROR.INVALID_PARAMETER => error.BadFd, else => os.unexpectedErrorWindows(err), }; } assert(pos >= 0); if (@sizeOf(@typeOf(pos)) > @sizeOf(usize)) { if (pos > @maxValue(usize)) { return error.FilePosLargerThanPointerRange; } } return usize(pos); }, else => @compileError("unsupported OS"), } } pub fn getEndPos(self: &File) !usize { if (is_posix) { var stat: posix.Stat = undefined; const err = posix.getErrno(posix.fstat(self.handle, &stat)); if (err > 0) { return switch (err) { posix.EBADF => error.BadFd, posix.ENOMEM => error.SystemResources, else => os.unexpectedErrorPosix(err), }; } return usize(stat.size); } else if (is_windows) { var file_size: windows.LARGE_INTEGER = undefined; if (windows.GetFileSizeEx(self.handle, &file_size) == 0) { const err = windows.GetLastError(); return switch (err) { else => os.unexpectedErrorWindows(err), }; } if (file_size < 0) return error.Overflow; return math.cast(usize, u64(file_size)); } else { @compileError("TODO support getEndPos on this OS"); } } pub const ModeError = error { BadFd, SystemResources, Unexpected, }; fn mode(self: &File) ModeError!os.FileMode { if (is_posix) { var stat: posix.Stat = undefined; const err = posix.getErrno(posix.fstat(self.handle, &stat)); if (err > 0) { return switch (err) { posix.EBADF => error.BadFd, posix.ENOMEM => error.SystemResources, else => os.unexpectedErrorPosix(err), }; } // TODO: we should be able to cast u16 to ModeError!u32, making this // explicit cast not necessary return os.FileMode(stat.mode); } else if (is_windows) { return {}; } else { @compileError("TODO support file mode on this OS"); } } pub const ReadError = error {}; pub fn read(self: &File, buffer: []u8) !usize { if (is_posix) { var index: usize = 0; while (index < buffer.len) { const amt_read = posix.read(self.handle, &buffer[index], buffer.len - index); const read_err = posix.getErrno(amt_read); if (read_err > 0) { switch (read_err) { posix.EINTR => continue, posix.EINVAL => unreachable, posix.EFAULT => unreachable, posix.EBADF => return error.BadFd, posix.EIO => return error.Io, else => return os.unexpectedErrorPosix(read_err), } } if (amt_read == 0) return index; index += amt_read; } return index; } else if (is_windows) { var index: usize = 0; while (index < buffer.len) { const want_read_count = windows.DWORD(math.min(windows.DWORD(@maxValue(windows.DWORD)), buffer.len - index)); var amt_read: windows.DWORD = undefined; if (windows.ReadFile(self.handle, @ptrCast(&c_void, &buffer[index]), want_read_count, &amt_read, null) == 0) { const err = windows.GetLastError(); return switch (err) { windows.ERROR.OPERATION_ABORTED => continue, windows.ERROR.BROKEN_PIPE => return index, else => os.unexpectedErrorWindows(err), }; } if (amt_read == 0) return index; index += amt_read; } return index; } else { unreachable; } } pub const WriteError = os.WindowsWriteError || os.PosixWriteError; fn write(self: &File, bytes: []const u8) WriteError!void { if (is_posix) { try os.posixWrite(self.handle, bytes); } else if (is_windows) { try os.windowsWrite(self.handle, bytes); } else { @compileError("Unsupported OS"); } } };
std/os/file.zig
const std = @import("std"); const util = @import("util"); const Wire = enum(u8) { a = 1 << 0, b = 1 << 1, c = 1 << 2, d = 1 << 3, e = 1 << 4, f = 1 << 5, g = 1 << 6, const Self = @This(); fn fromString(wires: []const u8) u8 { var res: u8 = 0; for (wires) |wire| { res |= @enumToInt(std.meta.stringToEnum(Self, &[_]u8{wire}).?); } return res; } fn toString(wires: u8, out: []u8) void { for ("abcdefg") |wire, i| { const mask = @enumToInt(std.meta.stringToEnum(Self, &[_]u8{wire}).?); if ((wires & mask) > 0) { out[i] = wire; } else { out[i] = 0; } } } }; fn isUniqueSignal(num: usize) bool { return num == 2 or num == 3 or num == 4 or num == 7; } pub fn part1(input: []const u8) !u64 { var count: u64 = 0; var lines = std.mem.split(u8, std.mem.trimRight(u8, input, "\n"), "\n"); while (lines.next()) |line| { var parts = std.mem.split(u8, line, " | "); _ = parts.next().?; var outputs = std.mem.split(u8, parts.next().?, " "); while (outputs.next()) |output| { if (isUniqueSignal(output.len)) { count += 1; } } } return count; } pub fn part2(input: []const u8) !u64 { const alloc = std.heap.page_allocator; var total: u64 = 0; var lines = std.mem.split(u8, std.mem.trimRight(u8, input, "\n"), "\n"); while (lines.next()) |line| { var parts = std.mem.split(u8, line, " | "); var inputs = std.mem.split(u8, parts.next().?, " "); var outputs = std.mem.split(u8, parts.next().?, " "); var wire_to_segment = std.AutoHashMap(Wire, Wire).init(alloc); defer wire_to_segment.deinit(); var remaining_signals = std.ArrayList(u8).init(alloc); defer remaining_signals.deinit(); var pattern_to_digit = std.AutoHashMap(u8, u8).init(alloc); defer pattern_to_digit.deinit(); var digit_to_pattern = std.AutoHashMap(u8, u8).init(alloc); defer digit_to_pattern.deinit(); while (inputs.next()) |signals| { // 0 - six segments, abcefg // 1 - two segments, cv // 2 - five segments, acdeg // 3 - five segments, acdfg // 4 - four segments, bcdf // 5 - five segments, abdfg // 6 - six segments, abdefg // 7 - three segments, acf // 8 - seven segments, abcdefg // 9 - six segments, abcdfg const pattern = Wire.fromString(signals); if (isUniqueSignal(signals.len)) { const digit: u8 = switch (signals.len) { 2 => 1, 3 => 7, 4 => 4, 7 => 8, else => unreachable, }; try pattern_to_digit.put(pattern, digit); try digit_to_pattern.put(digit, pattern); } else { try remaining_signals.append(pattern); } } const one = digit_to_pattern.get(1).?; const four = digit_to_pattern.get(4).?; while (remaining_signals.items.len > 0) { const pattern = remaining_signals.orderedRemove(0); const six = digit_to_pattern.get(6); if (@popCount(u8, pattern) == 5) { // We need to know the pattern for six to // correctly identify the following patterns. // If we dont have the pattern for six yet move // this pattern back to the end. if (six == null) { try remaining_signals.append(pattern); continue; } // Test if pattern represents a three if ((pattern & one) == one) { try digit_to_pattern.put(3, pattern); try pattern_to_digit.put(pattern, 3); } // Test if pattern is a five else if ((pattern & six.?) == pattern) { try digit_to_pattern.put(5, pattern); try pattern_to_digit.put(pattern, 5); } // Otherwise it's a two else { try digit_to_pattern.put(2, pattern); try pattern_to_digit.put(pattern, 2); } } else if (@popCount(u8, pattern) == 6) { // Test if pattern represent a six if (@popCount(u8, pattern & one) == 1) { try digit_to_pattern.put(6, pattern); try pattern_to_digit.put(pattern, 6); } // Test if pattern represent a nine else if ((pattern & four) == four) { try digit_to_pattern.put(9, pattern); try pattern_to_digit.put(pattern, 9); } // Otherwise it's a zero else { try digit_to_pattern.put(0, pattern); try pattern_to_digit.put(pattern, 0); } } } var i: u64 = 10000; while (outputs.next()) |output| { i = @divExact(i, 10); const pattern = Wire.fromString(output); const digit = pattern_to_digit.get(pattern).?; total += i * digit; } } return total; } test "day 8 part 1" { const test_input = \\be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe \\edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc \\fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg \\fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb \\aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea \\fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb \\dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe \\bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef \\egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb \\gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce ; try std.testing.expectEqual(part1(test_input), 26); } test "day 8 part 2" { const test_input = \\be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe \\edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc \\fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg \\fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb \\aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea \\fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb \\dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe \\bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef \\egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb \\gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce ; try std.testing.expectEqual(part2(test_input), 61229); }
zig/src/day8.zig
const sf = @import("../sfml_import.zig"); pub fn Vector2(comptime T: type) type { return struct { const Self = @This(); /// The CSFML vector type equivalent const CsfmlEquivalent = switch (T) { u32 => sf.c.sfVector2u, i32 => sf.c.sfVector2i, f32 => sf.c.sfVector2f, else => void, }; /// Makes a CSFML vector with this vector (only if the corresponding type exists) /// This is mainly for the inner workings of this wrapper pub fn toCSFML(self: Self) CsfmlEquivalent { if (CsfmlEquivalent == void) @compileError("This vector type doesn't have a CSFML equivalent."); return CsfmlEquivalent{ .x = self.x, .y = self.y }; } /// Creates a vector from a CSFML one (only if the corresponding type exists) /// This is mainly for the inner workings of this wrapper pub fn fromCSFML(vec: CsfmlEquivalent) Self { if (CsfmlEquivalent == void) @compileError("This vector type doesn't have a CSFML equivalent."); return Self{ .x = vec.x, .y = vec.y }; } /// Adds two vectors pub fn add(self: Self, other: Self) Self { return Self{ .x = self.x + other.x, .y = self.y + other.y }; } /// Substracts two vectors pub fn substract(self: Self, other: Self) Self { return Self{ .x = self.x - other.x, .y = self.y - other.y }; } /// Scales a vector pub fn scale(self: Self, factor: T) Self { return Self{ .x = self.x * factor, .y = self.y * factor }; } /// x component of the vector x: T, /// y component of the vector y: T }; } // Common vector types pub const Vector2u = Vector2(u32); pub const Vector2i = Vector2(i32); pub const Vector2f = Vector2(f32); pub const Vector3f = struct { const Self = @This(); /// Makes a CSFML vector with this vector (only if the corresponding type exists) /// This is mainly for the inner workings of this wrapper pub fn toCSFML(self: Self) sf.c.sfVector3f { return sf.c.sfVector3f{ .x = self.x, .y = self.y, .z = self.z }; } /// Creates a vector from a CSFML one (only if the corresponding type exists) /// This is mainly for the inner workings of this wrapper pub fn fromCSFML(vec: sf.c.sfVector3f) Self { return Self{ .x = vec.x, .y = vec.y, .z = vec.z }; } /// x component of the vector x: f32, /// y component of the vector y: f32, /// z component of the vector z: f32, };
src/sfml/system/vector.zig
const fmt = @import("std").fmt; const io = @import("std").io; const BIOS = @import("bios.zig").BIOS; pub const Debug = struct { const PrintContext = packed struct { request: u16, bank: u16, get: u16, put: u16, }; const DebugStream = struct { streamWritten: usize, const Self = @This(); pub fn init() Self { return Self{ .streamWritten = 0, }; } pub fn write(self: *Self, bytes: []const u8) !usize { var remaining = AGB_BUFFER_SIZE - self.streamWritten; if (remaining < bytes.len) { var index: usize = 0; while (index < remaining) : (index += 1) { printChar(bytes[index]); } return error.BufferTooSmall; } var written: usize = 0; for (bytes) |char| { printChar(char); self.streamWritten += 1; written += 1; } return written; } pub fn outStream(self: *Self) io.Writer(*Self, error{BufferTooSmall}, Self.write) { return .{ .context = self }; } }; const AGB_PRINT_PROTECT = @intToPtr(*volatile u16, 0x09FE2FFE); const AGB_PRINT_CONTEXT = @intToPtr(*volatile PrintContext, 0x09FE20F8); const AGB_PRINT_BUFFER = @intToPtr([*]volatile u16, 0x09FD0000); const AGB_BUFFER_SIZE = 0x100; pub fn init() void { AGB_PRINT_PROTECT.* = 0x20; AGB_PRINT_CONTEXT.request = 0x00; AGB_PRINT_CONTEXT.get = 0x00; AGB_PRINT_CONTEXT.put = 0x00; AGB_PRINT_CONTEXT.bank = 0xFD; AGB_PRINT_PROTECT.* = 0x00; } pub fn print(comptime formatString: []const u8, args: anytype) !void { lockPrint(); defer unlockPrint(); defer BIOS.debugFlush(); var debugStream = DebugStream.init(); try fmt.format(debugStream.outStream(), formatString, args); } pub fn write(message: []const u8) !void { lockPrint(); defer unlockPrint(); defer BIOS.debugFlush(); if (message.len >= AGB_BUFFER_SIZE) { var index: usize = 0; while (index < AGB_BUFFER_SIZE) : (index += 1) { printChar(message[index]); } return error.BufferTooSmall; } for (message) |char| { printChar(char); } } fn lockPrint() callconv(.Inline) void { AGB_PRINT_PROTECT.* = 0x20; } fn unlockPrint() callconv(.Inline) void { AGB_PRINT_PROTECT.* = 0x00; } fn printChar(value: u8) void { var data: u16 = AGB_PRINT_BUFFER[AGB_PRINT_CONTEXT.put >> 1]; if ((AGB_PRINT_CONTEXT.put & 1) == 1) { data = (@intCast(u16, value) << 8) | (data & 0xFF); } else { data = (data & 0xFF00) | value; } AGB_PRINT_BUFFER[AGB_PRINT_CONTEXT.put >> 1] = data; AGB_PRINT_CONTEXT.put += 1; } };
GBA/debug.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ShaderConfig = @import("shaderconfig.zig").ShaderConfig; const Jazbz = @import("jabz.zig").Jazbz(f64); const Srgb = @import("jabz.zig").Srgb(u8); const unitbounds = @import("unitbounds.zig"); pub fn SsaaShader(width: usize, height: usize, ssaa: usize, comptime T: type) type { const mixVectors = makeMixVectors(width, height, ssaa); const meanFactor = 1.0 / @intToFloat(f64, mixVectors.len); const ub = unitbounds.PosUTo01.forCenter(width, height); return struct { const Self = @This(); chain: T, pub fn init(allocator: *Allocator, config: ShaderConfig) !Self { return Self{ .chain = try T.init(allocator, config), }; } pub fn deinit(self: *const Self, allocator: *Allocator) void { self.chain.deinit(allocator); } pub fn shade(self: *const Self, x: usize, y: usize) Srgb { const pos = ub.toPos01(x, y); var jab = Jazbz{}; for (mixVectors) |mv| { jab = Jazbz.JazbzField.add(jab, self.chain.shade(pos.x + mv.x, pos.y + mv.y)); } jab.j *= meanFactor; jab.azbz.az *= meanFactor; jab.azbz.bz *= meanFactor; return jab.toSrgb(u8); } }; } const MixVector = struct { x: f64, y: f64 }; fn makeMixVectors(width: usize, height: usize, comptime n: usize) [n * n]MixVector { const nf = @intToFloat(f64, n); const xScale = 1 / (nf * @intToFloat(f64, width)); const yScale = 1 / (nf * @intToFloat(f64, height)); var result: [n * n]MixVector = undefined; var y: usize = 0; while (y < n) : (y += 1) { const yf = @intToFloat(f64, y); var x: usize = 0; while (x < n) : (x += 1) { const xf = @intToFloat(f64, x); result[y * n + x] = .{ .x = xf * xScale, .y = yf * yScale, }; } } return result; }
lib/ssaashader.zig
const std = @import("std"); const root = @import("root"); const os = std.os; const builtin = @import("builtin"); pub const PollOptions = packed struct { read: bool = false, write: bool = false, }; pub const CallOptions = packed struct { read: bool = false, write: bool = false, }; pub const WakeOptions = packed struct { notify: bool = false, shutdown: bool = false, read_ready: bool = false, write_ready: bool = false, }; const has_epoll = @hasDecl(os.linux, "epoll_create1") and @hasDecl(os.linux, "epoll_ctl") and @hasDecl(os.linux, "epoll_event"); const has_kqueue = @hasDecl(os.system, "kqueue") and @hasDecl(os.system, "kevent") and @hasDecl(os, "Kevent"); // Export asynchronous frame dispatcher and user scope (Task). pub const Task = if (@hasDecl(root, "pike_task")) root.pike_task else struct { next: ?*Task = null, frame: anyframe, pub inline fn init(frame: anyframe) Task { return .{ .frame = frame }; } }; pub const Batch = if (@hasDecl(root, "pike_batch")) root.pike_batch else struct { head: ?*Task = null, tail: *Task = undefined, pub fn from(batchable: anytype) Batch { if (@TypeOf(batchable) == Batch) return batchable; if (@TypeOf(batchable) == *Task) { batchable.next = null; return Batch{ .head = batchable, .tail = batchable, }; } if (@TypeOf(batchable) == ?*Task) { const task: *Task = batchable orelse return Batch{}; return Batch.from(task); } @compileError(@typeName(@TypeOf(batchable)) ++ " cannot be converted into a " ++ @typeName(Batch)); } pub fn push(self: *Batch, entity: anytype) void { const other = Batch.from(entity); if (self.head == null) { self.* = other; } else { self.tail.next = other.head; self.tail = other.tail; } } pub fn pop(self: *Batch) ?*Task { const task = self.head orelse return null; self.head = task.next; return task; } }; pub const dispatch: fn (anytype, anytype) void = if (@hasDecl(root, "pike_dispatch")) root.pike_dispatch else struct { fn default(batchable: anytype, args: anytype) void { var batch = Batch.from(batchable); _ = args; while (batch.pop()) |task| { resume task.frame; } } }.default; // Export 'Notifier' and 'Handle'. pub usingnamespace if (@hasDecl(root, "notifier")) root.notifier else if (has_epoll) @import("notifier_epoll.zig") else if (has_kqueue) @import("notifier_kqueue.zig") else if (builtin.os.tag == .windows) @import("notifier_iocp.zig") else @compileError("pike: unable to figure out a 'Notifier'/'Handle' implementation to use for the build target"); // Export 'SocketOptionType', 'SocketOption', and 'Socket'. pub usingnamespace if (builtin.os.tag == .windows) @import("socket_windows.zig") else @import("socket_posix.zig"); // Export 'SignalType', and 'Signal'. pub usingnamespace if (has_epoll or has_kqueue) @import("signal_posix.zig") else if (builtin.os.tag == .windows) @import("signal_windows.zig") else @compileError("pike: unable to figure out a 'Signal' implementation to use for the build target"); // Export 'Event'. pub usingnamespace if (has_epoll) @import("event_epoll.zig") else if (has_kqueue) @import("event_kqueue.zig") else if (builtin.os.tag == .windows) @import("event_iocp.zig") else @compileError("pike: unable to figure out a 'Event' implementation to use for the build target"); // Export 'Waker' and 'PackedWaker'. pub usingnamespace @import("waker.zig");
pike.zig
const std = @import("std"); const fs = std.fs; const mem = std.mem; const Builder = std.build.Builder; const FileSource = std.build.FileSource; const Pkg = std.build.Pkg; const nanovg_build = @import("deps/nanovg-zig/build.zig"); const win32 = Pkg{ .name = "win32", .path = FileSource.relative("deps/zigwin32/win32.zig") }; const nfd = Pkg{ .name = "nfd", .path = FileSource.relative("deps/nfd-zig/src/lib.zig") }; const nanovg = Pkg{ .name = "nanovg", .path = FileSource.relative("deps/nanovg-zig/src/nanovg.zig") }; const s2s = Pkg{ .name = "s2s", .path = FileSource.relative("deps/s2s/s2s.zig") }; const gui = Pkg{ .name = "gui", .path = FileSource.relative("src/gui/gui.zig"), .dependencies = &.{nanovg} }; fn printError(str: []const u8) void { var stderr = std.io.getStdErr(); var stderr_writer = stderr.writer(); var tty_config = std.debug.detectTTYConfig(); tty_config.setColor(stderr_writer, .Red); _ = stderr_writer.write("ERROR: ") catch {}; tty_config.setColor(stderr_writer, .Reset); _ = stderr_writer.write(str) catch {}; } fn installPalFiles(b: *Builder) void { const pals = [_][]const u8{ "arne16.pal", "arne32.pal", "db32.pal", "default.pal", "famicube.pal", "pico-8.pal" }; inline for (pals) |pal| { b.installBinFile("data/palettes/" ++ pal, "palettes/" ++ pal); } } pub fn build(b: *Builder) !void { const target = b.standardTargetOptions(.{}); const mode = b.standardReleaseOptions(); const exe = b.addExecutable("minipixel", "src/main.zig"); exe.setBuildMode(mode); exe.setTarget(target); // exe.addIncludeDir("lib/nanovg/src"); exe.addIncludeDir("lib/gl2/include"); if (exe.target.isWindows()) { exe.addVcpkgPaths(.dynamic) catch @panic("vcpkg not installed"); if (exe.vcpkg_bin_path) |bin_path| { for (&[_][]const u8{ "SDL2.dll", "libpng16.dll", "zlib1.dll" }) |dll| { const src_dll = try std.fs.path.join(b.allocator, &.{ bin_path, dll }); b.installBinFile(src_dll, dll); } } exe.subsystem = .Windows; exe.linkSystemLibrary("shell32"); std.fs.cwd().access("minipixel.o", .{}) catch { printError("minipixel.o not found. Please use VS Developer Prompt and run\n\n" ++ "\trc /fo minipixel.o minipixel.rc\n\nbefore continuing\n"); return error.FileNotFound; }; exe.addObjectFile("minipixel.o"); // add icon exe.want_lto = false; // workaround for https://github.com/ziglang/zig/issues/8531 } else if (exe.target.isDarwin()) { exe.addCSourceFile("src/c/sdl_hacks.m", &.{}); } const c_flags: []const []const u8 = if (mode == .Debug) &.{ "-std=c99", "-D_CRT_SECURE_NO_WARNINGS", "-O0", "-g" } else &.{ "-std=c99", "-D_CRT_SECURE_NO_WARNINGS" }; exe.addCSourceFile("src/c/png_image.c", &.{"-std=c99"}); exe.addCSourceFile("lib/gl2/src/glad.c", c_flags); // exe.addCSourceFile("lib/nanovg/src/nanovg.c", c_flags); // exe.addCSourceFile("deps/nanovg/src/c/nanovg_gl2_impl.c", c_flags); exe.addPackage(win32); exe.addPackage(nfd); // exe.addPackage(nanovg); nanovg_build.addNanoVGPackage(exe); exe.addPackage(s2s); exe.addPackage(gui); const nfd_lib = try @import("deps/nfd-zig/build.zig").makeLib(b, mode, target, "deps/nfd-zig/"); exe.linkLibrary(nfd_lib); exe.linkSystemLibrary("SDL2"); if (exe.target.isWindows()) { // Workaround for CI: Zig detects pkg-config and resolves -lpng16 which doesn't exist exe.linkSystemLibraryName("libpng16"); } else { exe.linkSystemLibrary("libpng16"); } if (exe.target.isDarwin()) { const frameworks = .{ "AppKit", "AudioToolbox", "Carbon", "Cocoa", "CoreAudio", "CoreHaptics", "ForceFeedback", "GameController", "IOKit", "Metal", "OpenGL", "QuartzCore", }; inline for (frameworks) |framework| { exe.linkFramework(framework); } exe.linkSystemLibrary("iconv"); } else if (exe.target.isWindows()) { exe.linkSystemLibrary("opengl32"); } else if (exe.target.isLinux()) { exe.linkSystemLibrary("gl"); exe.linkSystemLibrary("X11"); } exe.linkLibC(); if (b.is_release) exe.strip = true; exe.install(); installPalFiles(b); const test_cmd = b.addTest("src/tests.zig"); test_cmd.setBuildMode(mode); const test_step = b.step("test", "Run tests"); test_step.dependOn(&test_cmd.step); const run_cmd = exe.run(); run_cmd.step.dependOn(b.getInstallStep()); const run_step = b.step("run", "Run Mini Pixel"); run_step.dependOn(&run_cmd.step); }
build.zig
const std = @import("std"); const expectEqual = @import("std").testing.expectEqual; test "math" { // std.debug.print("\n{}\n", .{math("a", .{ .a = @as(i8, 7) })}); try expectEqual(@as(i8, 5), math("a", .{ .a = @as(i8, 5) })); try expectEqual(@as(i8, 15), math("a + a + a", .{ .a = @as(i8, 5) })); // std.debug.print("\n{}\n", .{math("a + b", .{ // .a = @as(i8, 7), // .b = @as(i8, 2), // })}); try expectEqual(15, math("a - b", .{ .a = 20, .b = 5 })); // std.debug.print("\n{}\n", .{math("a - b", .{ .a = 1000000, .b = 5 })}); // std.debug.print("\n{}\n", .{math("(-a) + a + (a+a+a", .{ .a = 10 })}); } // Using an allocator (even just a fixed buffer) doesn't work during comptime yet. // Instead just allocate something on the stack at the entry point, and work // from there. If we could use a real allocator, it'd be better for ast to // contain pointer to concrete types, instead of concrete types pointing to asts. // This would more efficiently pack memory. However this way is much simpler given // the constraints. const StupidAlloc = struct { asts: [100]Ast, index: isize, fn next(comptime self: *StupidAlloc) *Ast { var r = &self.asts[self.index]; self.index += 1; return r; } }; pub fn math(comptime eq: [:0]const u8, args: anytype) ReturnType(eq, @TypeOf(args)) { comptime var parser = comptime Parser.init(eq, @TypeOf(args)); comptime var root = parser.parse(); return root.eval(args); } fn ReturnType(comptime eq: [:0]const u8, argsType: type) type { comptime @setEvalBranchQuota(10000); comptime var parser = comptime Parser.init(eq, argsType); comptime var root = parser.parse(); return root.ReturnType(); } const BlockTerm = enum { eof, rParen, // fn name(self: BlockTerm) [:0]const u8 { // switch (self) { // .eof => "end of equation", // .closeParen => "close parentheses", // } // } }; const Parser = struct { alloc: StupidAlloc, argsType: type, tokenizer: Tokenizer, // Careful: StupidAlloc is large, and pointers to it's allocations will change // when it's moved. fn init(eq: [:0]const u8, comptime argsType: type) Parser { return Parser{ .alloc = StupidAlloc{ .asts = undefined, .index = 0, }, .argsType = argsType, .tokenizer = Tokenizer.init(eq), }; } fn parse(comptime self: *Parser) *Ast { // parse should only be called once, but it's easy to fix that not working, // so why not? self.tokenizer.index = 0; return self.parseStatement(BlockTerm.eof); } fn parseStatement(comptime self: *Parser, expectedBlockTerm: BlockTerm) *Ast { var lhs = switch (self.parseElement()) { .operand => |op| { var rhs = switch (self.parseElement()) { .operand => @compileError("Two operands in a row."), .value => |rhs| rhs, .blockTerm => { @compileError("Unexpected end of block"); }, }; switch (self.parseElement()) { .operand => @compileError("Operand after unary operation"), .value => @compileError("Value after unary operation"), .blockTerm => |blockTerm| { if (expectedBlockTerm == blockTerm) { return UnaryOp.init(&self.alloc, op, rhs); } @compileError("Incorrect termination of a statement."); }, } }, .value => |lhs| lhs, .blockTerm => { @compileError("Empty block"); }, }; var firstOp: ?Token.Tag = null; while (true) { var op = switch (self.parseElement()) { .operand => |op| op, .value => { @compileError("Multiple values in a row"); }, .blockTerm => |blockTerm| { if (expectedBlockTerm == blockTerm) { return lhs; } @compileError("Incorrect termination of a statement."); }, }; if (firstOp) |correctOp| { if (op != correctOp) { @compileError("Mismatching operations"); } } else { firstOp = op; } var rhs = switch (self.parseElement()) { .operand => @compileError("Unexpected double operand"), .value => |rhs| rhs, .blockTerm => @compileError("Unexpected block termination"), }; lhs = makeBinaryOp(&self.alloc, lhs, op, rhs); } } const Element = union(enum) { operand: Token.Tag, value: *Ast, blockTerm: BlockTerm, }; fn parseElement(comptime self: *Parser) Element { var token = self.tokenizer.next(); switch (token.tag) { .invalid => @compileError("Invalid equation"), .eof => { return Element{ .blockTerm = BlockTerm.eof }; }, .lParen => { return Element{ .value = self.parseStatement(BlockTerm.rParen) }; }, .rParen => { return Element{ .blockTerm = BlockTerm.rParen }; }, .plus, .minus, .asterisk, .slash => { return Element{ .operand = token.tag }; }, .identifier => { return Element{ .value = Identifier.init(&self.alloc, self.tokenizer.source(token), self.argsType) }; }, } } }; const Ast = union(enum) { identifier: Identifier, scalerBinaryOp: ScalerBinaryOp, fnBinaryOp: FnBinaryOp, unaryOp: UnaryOp, fn eval(comptime ast: *Ast, args: anytype) ast.ReturnType() { return switch (ast.*) { .identifier => |v| v.eval(args), .scalerBinaryOp => |v| v.eval(args), .fnBinaryOp => |v| v.eval(args), .unaryOp => |v| v.eval(args), }; } fn ReturnType(comptime ast: *Ast) type { return switch (ast.*) { .identifier => |v| v.ReturnType, .scalerBinaryOp => |v| v.ReturnType, .fnBinaryOp => |v| v.ReturnType, .unaryOp => |v| v.ReturnType, }; } }; const Identifier = struct { name: []const u8, ReturnType: type, fn init(comptime alloc: *StupidAlloc, name: []const u8, comptime argsType: type) *Ast { comptime var S = switch (@typeInfo(argsType)) { .Struct => |v| v, else => @compileError("math args must be a struct or touple."), }; for (S.fields) |field| { if (std.mem.eql(u8, name, field.name)) { var r = alloc.next(); r.* = Ast{ .identifier = Identifier{ .name = name, .ReturnType = field.field_type, }, }; return r; } } else { @compileError("Identifier in equation not found in passed info: " ++ name); } } fn eval(comptime ident: *const Identifier, args: anytype) ident.ReturnType { return @field(args, ident.name); } }; fn makeBinaryOp(comptime alloc: *StupidAlloc, lhs: *Ast, opToken: Token.Tag, rhs: *Ast) *Ast { const r = alloc.next(); const Lhs = lhs.ReturnType(); const Rhs = rhs.ReturnType(); if (isBuiltinScalar(Lhs) and Lhs == Rhs) { const op = switch (opToken) { .plus => ScalerBinaryOp.Op.addErr, .minus => ScalerBinaryOp.Op.subErr, .asterisk => ScalerBinaryOp.Op.mulErr, else => @compileError("Invalid binary operator for scaler value"), }; r.* = Ast{ .scalerBinaryOp = ScalerBinaryOp{ .lhs = lhs, .op = op, .rhs = rhs, .ReturnType = Lhs, }, }; return r; } const opName = switch (opToken) { .plus => "add", .minus => "sub", .asterisk => "mul", .slash => "div", else => @compileError("Invalid binary operator for method call"), }; if (CheckTypeForBinaryMethod(opName, Lhs, Lhs, Rhs)) |T| { r.* = Ast{ .fnBinaryOp = FnBinaryOp{ .CallType = Lhs, .lhs = lhs, .op = opName, .rhs = rhs, .ReturnType = T, } }; return r; } if (CheckTypeForBinaryMethod(opName, Rhs, Lhs, Rhs)) |T| { r.* = Ast{ .fnBinaryOp = FnBinaryOp{ .CallType = Rhs, .lhs = rhs, .op = opName, .rhs = lhs, .ReturnType = T, } }; return r; } @compileError(@typeName(Lhs) ++ " and " ++ @typeName(Rhs) ++ " are incompatible for " ++ opName ++ "."); } // If A has a method named opName, which takes B, return the return type. Otherwise null. fn CheckTypeForBinaryMethod(comptime opName: [:0]const u8, comptime C: type, comptime A: type, comptime B: type) ?type { if (isBuiltinScalar(C)) { return null; } if (!@hasDecl(C, opName)) { return null; } const declInfo = std.meta.declarationInfo(C, opName); const FnType = switch (declInfo.data) { .Type => return null, .Var => return null, .Fn => |f| f.fn_type, }; const fnTypeInfo = switch (@typeInfo(FnType)) { .Fn => |f| f, else => unreachable, }; if (fnTypeInfo.args.len == 2 and fnTypeInfo.args[0].arg_type == A and fnTypeInfo.args[1].arg_type == B) { return fnTypeInfo.return_type; } const fnName = opName ++ "ReturnType"; if (@hasDecl(C, fnName)) { const R = @field(C, fnName)(A, B); if (R != void) { return R; } } return null; } const ScalerBinaryOp = struct { lhs: *Ast, op: Op, rhs: *Ast, ReturnType: type, const Op = enum { addErr, subErr, mulErr, }; fn eval(comptime self: *const ScalerBinaryOp, args: anytype) self.ReturnType { const lhs = self.lhs.eval(args); const rhs = self.rhs.eval(args); return switch (self.op) { .addErr => lhs + rhs, .subErr => lhs - rhs, .mulErr => lhs * rhs, }; } }; const FnBinaryOp = struct { CallType: type, lhs: *Ast, op: [:0]const u8, rhs: *Ast, ReturnType: type, fn eval(comptime self: *const FnBinaryOp, args: anytype) self.ReturnType { const lhs = self.lhs.eval(args); const rhs = self.rhs.eval(args); return @field(self.CallType, self.op)(lhs, rhs); } }; const UnaryOp = struct { op: Op, rhs: *Ast, ReturnType: type, const Op = enum { negate, }; fn init(comptime alloc: *StupidAlloc, opToken: Token.Tag, rhs: *Ast) *Ast { var op = switch (opToken) { .minus => Op.negate, else => @compileError("Invalid unary operator"), }; var r = alloc.next(); r.* = Ast{ .unaryOp = UnaryOp{ .op = op, .rhs = rhs, .ReturnType = rhs.ReturnType(), } }; return r; } fn eval(comptime self: *const UnaryOp, args: anytype) self.ReturnType { return switch (self.op) { .negate => { return -self.rhs.eval(args); }, }; } }; // fn parseInt(comptime str: []const u8) comptime_int { // var r: comptime_int = 0; // // todo: non-base 10 integers? // for (str) |chr| { // switch (chr) { // '0' => r = r * 10, // '1' => r = r * 10 + 1, // '2' => r = r * 10 + 2, // '3' => r = r * 10 + 3, // '4' => r = r * 10 + 4, // '5' => r = r * 10 + 5, // '6' => r = r * 10 + 6, // '7' => r = r * 10 + 7, // '8' => r = r * 10 + 8, // '9' => r = r * 10 + 9, // else => @compileError("invalid integer"), // } // } // return r; // } // test "parse integer" { // try expectEqual(0, parseInt("0")); // try expectEqual(10, parseInt("010")); // try expectEqual(9876543210, parseInt("9876543210")); // } fn isBuiltinScalar(comptime v: type) bool { return switch (@typeInfo(v)) { .Int => true, .Float => true, .ComptimeFloat => true, .ComptimeInt => true, else => false, }; } // fn InvalidCombo(comptime a: type, comptime b: type, comptime op: []const u8) noreturn { // @compileError("Invalid combination of " ++ @typeName(a) ++ " and " ++ @typeName(b) ++ " for operation " ++ op ++ "."); // } // fn logStruct(s: anytype) void { // comptime var T = @TypeOf(s); // @compileLog(T); // @compileLog(s); // comptime var S = switch (@typeInfo(T)) { // .Struct => |v| v, // else => @compileError("log struct only takes structs."), // }; // inline for (S.fields) |field| { // @compileLog(field.name); // } // } const Token = struct { tag: Tag, start: usize, end: usize, const Tag = enum { invalid, eof, identifier, plus, minus, asterisk, slash, lParen, rParen, }; }; const Tokenizer = struct { buffer: [:0]const u8, index: usize, fn init(buffer: [:0]const u8) Tokenizer { return Tokenizer{ .buffer = buffer, .index = 0, }; } const State = enum { start, identifier, // plus, }; fn next(self: *Tokenizer) Token { var state = State.start; var r = Token{ .tag = .eof, .start = self.index, .end = undefined, }; outer: while (true) : (self.index += 1) { const c = if (self.index < self.buffer.len) self.buffer[self.index] else 0; switch (state) { .start => switch (c) { 0 => { break :outer; }, ' ' => { r.start = self.index + 1; }, 'a'...'z', 'A'...'Z', '_' => { state = .identifier; }, '+' => { r.tag = .plus; self.index += 1; break :outer; }, '-' => { r.tag = .minus; self.index += 1; break :outer; }, '*' => { r.tag = .asterisk; self.index += 1; break :outer; }, '/' => { r.tag = .slash; self.index += 1; break :outer; }, '(' => { r.tag = .lParen; self.index += 1; break :outer; }, ')' => { r.tag = .rParen; self.index += 1; break :outer; }, else => { r.tag = .invalid; break :outer; }, }, .identifier => switch (c) { 'a'...'z', 'A'...'Z', '_' => {}, else => { r.tag = .identifier; break :outer; }, }, } } r.end = self.index; return r; } fn source(self: *Tokenizer, token: Token) []const u8 { return self.buffer[token.start..token.end]; } };
src/math.zig
const std = @import("std"); const debug = std.debug; const mem = std.mem; const testing = std.testing; const unicode = std.unicode; const sbp = @import("../ziglyph.zig").sentence_break_property; const CodePoint = @import("CodePoint.zig"); const CodePointIterator = CodePoint.CodePointIterator; pub const Sentence = @This(); bytes: []const u8, offset: usize, /// `eql` compares `str` with the bytes of this sentence for equality. pub fn eql(self: Sentence, str: []const u8) bool { return mem.eql(u8, self.bytes, str); } const Type = enum { aterm, close, cr, extend, format, lf, lower, numeric, oletter, scontinue, sep, sp, sterm, upper, any, fn get(cp: CodePoint) Type { var ty: Type = .any; if (0x000D == cp.scalar) ty = .cr; if (0x000A == cp.scalar) ty = .lf; if (sbp.isLower(cp.scalar)) ty = .lower; if (sbp.isUpper(cp.scalar)) ty = .upper; if (sbp.isOletter(cp.scalar)) ty = .oletter; if (sbp.isNumeric(cp.scalar)) ty = .numeric; if (sbp.isSep(cp.scalar)) ty = .sep; if (sbp.isSp(cp.scalar)) ty = .sp; if (sbp.isClose(cp.scalar)) ty = .close; if (sbp.isAterm(cp.scalar)) ty = .aterm; if (sbp.isSterm(cp.scalar)) ty = .sterm; if (sbp.isScontinue(cp.scalar)) ty = .scontinue; if (sbp.isExtend(cp.scalar)) ty = .extend; if (sbp.isFormat(cp.scalar)) ty = .format; return ty; } }; const Token = struct { ty: Type, code_point: CodePoint, offset: usize = 0, fn is(self: Token, ty: Type) bool { return self.ty == ty; } }; const TokenList = std.ArrayList(Token); /// `SentenceIterator` iterates a string one sentence at-a-time. pub const SentenceIterator = struct { bytes: []const u8, i: ?usize = null, start: ?Token = null, tokens: TokenList, const Self = @This(); pub fn init(allocator: mem.Allocator, str: []const u8) !Self { if (!unicode.utf8ValidateSlice(str)) return error.InvalidUtf8; var self = Self{ .bytes = str, .tokens = TokenList.init(allocator), }; try self.lex(); if (self.tokens.items.len == 0) return error.NoTokens; self.start = self.tokens.items[0]; // Set token offsets. for (self.tokens.items) |*token, i| { token.offset = i; } return self; } pub fn deinit(self: *Self) void { self.tokens.deinit(); } fn lex(self: *Self) !void { var iter = CodePointIterator{ .bytes = self.bytes, .i = 0, }; while (iter.next()) |cp| { try self.tokens.append(.{ .ty = Type.get(cp), .code_point = cp, }); } } // Main API. pub fn next(self: *Self) ?Sentence { no_break: while (self.advance()) |current_token| { if (isParaSep(current_token)) { var end = current_token; if (current_token.is(.cr)) { if (self.peek()) |p| { if (p.is(.lf)) { _ = self.advance(); end = self.current(); } } } const start = self.start.?; self.start = self.peek(); return self.emit(start, end); } if (current_token.is(.aterm)) { var end = self.current(); if (self.peek()) |p| { if (isUpper(p)) { // self.i may not be the same as current token's offset due to ignorable skipping. const original_i = self.i; self.i = current_token.offset; defer self.i = original_i; if (self.prevAfterSkip(isIgnorable)) |v| { if (isUpperLower(v)) continue :no_break; } } else if (isParaSep(p) or isLower(p) or isNumeric(p) or isSContinue(p)) { continue :no_break; } else if (isSpace(p)) { // ATerm Sp* self.run(isSpace); end = self.current(); // Possible lower case after. if (self.peek()) |pp| { if (isLower(pp)) continue :no_break; } } else if (isClose(p)) { // ATerm Close* self.run(isClose); if (self.peek()) |pp| { // Possible ParaSep after. if (isParaSep(pp)) { _ = self.advance(); end = self.current(); const start = self.start.?; self.start = self.peek(); return self.emit(start, end); } // Possible spaces after. if (isSpace(pp)) { // ATerm Close* Sp* self.run(isSpace); if (self.peek()) |ppp| { // Possible lower after. if (isLower(ppp)) continue :no_break; // Possible lower after some allowed code points. if (isAllowedBeforeLower(ppp)) { if (self.peekAfterSkip(isAllowedBeforeLower)) |pppp| { // ATerm Close* Sp* !(Unallowed) Lower if (isLower(pppp)) continue :no_break; } } } } } end = self.current(); } else if (isSATerm(p)) { self.run(isSATerm); end = self.current(); } } const start = self.start.?; self.start = self.peek(); return self.emit(start, end); } if (current_token.is(.sterm)) { var end = self.current(); if (self.peek()) |p| { if (isParaSep(p) or isSATerm(p) or isSContinue(p)) { _ = self.advance(); end = self.current(); } else if (isSpace(p)) { self.run(isSpace); end = self.current(); } else if (isClose(p)) { // STerm Close* self.run(isClose); if (self.peek()) |pp| { if (isSpace(pp)) { // STerm Close* Sp* self.run(isSpace); } } end = self.current(); } } const start = self.start.?; self.start = self.peek(); return self.emit(start, end); } } return if (self.start) |start| self.emit(start, self.last()) else null; } // Token array movement. fn forward(self: *Self) bool { if (self.i) |*index| { index.* += 1; if (index.* >= self.tokens.items.len) return false; } else { self.i = 0; } return true; } // Token array movement. fn getRelative(self: Self, n: isize) ?Token { var index: usize = self.i orelse 0; if (n < 0) { if (index == 0 or -%n > index) return null; index -= @intCast(usize, -%n); } else { const un = @intCast(usize, n); if (index + un >= self.tokens.items.len) return null; index += un; } return self.tokens.items[index]; } fn prevAfterSkip(self: *Self, predicate: TokenPredicate) ?Token { if (self.i == null or self.i.? == 0) return null; var i: isize = 1; while (self.getRelative(-i)) |token| : (i += 1) { if (!predicate(token)) return token; } return null; } fn current(self: Self) Token { // Assumes self.i is not null. return self.tokens.items[self.i.?]; } fn last(self: Self) Token { return self.tokens.items[self.tokens.items.len - 1]; } fn peek(self: Self) ?Token { return self.getRelative(1); } fn peekAfterSkip(self: *Self, predicate: TokenPredicate) ?Token { var i: isize = 1; while (self.getRelative(i)) |token| : (i += 1) { if (!predicate(token)) return token; } return null; } fn advance(self: *Self) ?Token { const token = if (self.forward()) self.current() else return null; if (!isParaSep(token)) _ = self.skipIgnorables(token); return token; } fn run(self: *Self, predicate: TokenPredicate) void { while (self.peek()) |token| { if (!predicate(token)) break; _ = self.advance(); } } fn skipIgnorables(self: *Self, end: Token) Token { if (self.peek()) |p| { if (isIgnorable(p)) { self.run(isIgnorable); return self.current(); } } return end; } // Production. fn emit(self: Self, start_token: Token, end_token: Token) Sentence { const start = start_token.code_point.offset; const end = end_token.code_point.end(); return .{ .bytes = self.bytes[start..end], .offset = start, }; } }; // Predicates const TokenPredicate = fn (Token) bool; fn isNumeric(token: Token) bool { return token.ty == .numeric; } fn isLower(token: Token) bool { return token.ty == .lower; } fn isUpper(token: Token) bool { return token.ty == .upper; } fn isUpperLower(token: Token) bool { return isUpper(token) or isLower(token); } fn isIgnorable(token: Token) bool { return token.ty == .extend or token.ty == .format; } fn isClose(token: Token) bool { return token.ty == .close; } fn isSpace(token: Token) bool { return token.ty == .sp; } fn isParaSep(token: Token) bool { return token.ty == .cr or token.ty == .lf or token.ty == .sep; } fn isSATerm(token: Token) bool { return token.ty == .aterm or token.ty == .sterm; } fn isSContinue(token: Token) bool { return token.ty == .scontinue; } fn isUnallowedBeforeLower(token: Token) bool { return token.ty == .oletter or isUpperLower(token) or isSATerm(token) or isParaSep(token); } fn isAllowedBeforeLower(token: Token) bool { return !isUnallowedBeforeLower(token); } test "Segmentation SentenceIterator" { var path_buf: [1024]u8 = undefined; var path = try std.fs.cwd().realpath(".", &path_buf); // Check if testing in this library path. if (!mem.endsWith(u8, path, "ziglyph")) return; var allocator = std.testing.allocator; var file = try std.fs.cwd().openFile("src/data/ucd/SentenceBreakTest.txt", .{}); defer file.close(); var buf_reader = std.io.bufferedReader(file.reader()); var input_stream = buf_reader.reader(); var buf: [4096]u8 = undefined; var line_no: usize = 1; while (try input_stream.readUntilDelimiterOrEof(&buf, '\n')) |raw| : (line_no += 1) { // Skip comments or empty lines. if (raw.len == 0 or raw[0] == '#' or raw[0] == '@') continue; // Clean up. var line = mem.trimLeft(u8, raw, "÷ "); if (mem.indexOf(u8, line, " ÷\t#")) |octo| { line = line[0..octo]; } //debug.print("\nline {}: {s}\n", .{ line_no, line }); // Iterate over fields. var want = std.ArrayList(Sentence).init(allocator); defer { for (want.items) |snt| { allocator.free(snt.bytes); } want.deinit(); } var all_bytes = std.ArrayList(u8).init(allocator); defer all_bytes.deinit(); var sentences = mem.split(u8, line, " ÷ "); var bytes_index: usize = 0; while (sentences.next()) |field| { var code_points = mem.split(u8, field, " "); var cp_buf: [4]u8 = undefined; var cp_index: usize = 0; var first: u21 = undefined; var cp_bytes = std.ArrayList(u8).init(allocator); defer cp_bytes.deinit(); while (code_points.next()) |code_point| { if (mem.eql(u8, code_point, "×")) continue; const cp: u21 = try std.fmt.parseInt(u21, code_point, 16); if (cp_index == 0) first = cp; const len = try unicode.utf8Encode(cp, &cp_buf); try all_bytes.appendSlice(cp_buf[0..len]); try cp_bytes.appendSlice(cp_buf[0..len]); cp_index += len; } try want.append(Sentence{ .bytes = cp_bytes.toOwnedSlice(), .offset = bytes_index, }); bytes_index += cp_index; } //debug.print("\nline {}: {s}\n", .{ line_no, all_bytes.items }); var iter = try SentenceIterator.init(allocator, all_bytes.items); defer iter.deinit(); // Chaeck. for (want.items) |w| { const g = (iter.next()).?; //debug.print("\n", .{}); //for (w.bytes) |b| { // debug.print("line {}: w:({x})\n", .{ line_no, b }); //} //for (g.bytes) |b| { // debug.print("line {}: g:({x})\n", .{ line_no, b }); //} //debug.print("line {}: w:({s}), g:({s})\n", .{ line_no, w.bytes, g.bytes }); try testing.expectEqualStrings(w.bytes, g.bytes); try testing.expectEqual(w.offset, g.offset); } } } // Comptime fn getTokens(comptime str: []const u8, comptime n: usize) [n]Token { var i: usize = 0; var cp_iter = CodePointIterator{ .bytes = str }; var tokens: [n]Token = undefined; while (cp_iter.next()) |cp| : (i += 1) { tokens[i] = .{ .ty = Type.get(cp), .code_point = cp, .offset = i, }; } return tokens; } /// `ComptimeSentenceIterator` is like `SentenceIterator` but requires a string literal to do its work at compile time. pub fn ComptimeSentenceIterator(comptime str: []const u8) type { const cp_count: usize = unicode.utf8CountCodepoints(str) catch @compileError("Invalid UTF-8."); if (cp_count == 0) @compileError("No code points?"); const tokens = getTokens(str, cp_count); return struct { bytes: []const u8 = str, i: ?usize = null, start: ?Token = tokens[0], tokens: [cp_count]Token = tokens, const Self = @This(); // Main API. pub fn next(self: *Self) ?Sentence { no_break: while (self.advance()) |current_token| { if (isParaSep(current_token)) { var end = current_token; if (current_token.is(.cr)) { if (self.peek()) |p| { if (p.is(.lf)) { _ = self.advance(); end = self.current(); } } } const start = self.start.?; self.start = self.peek(); return self.emit(start, end); } if (current_token.is(.aterm)) { var end = self.current(); if (self.peek()) |p| { if (isUpper(p)) { // self.i may not be the same as current token's offset due to ignorable skipping. const original_i = self.i; self.i = current_token.offset; defer self.i = original_i; if (self.prevAfterSkip(isIgnorable)) |v| { if (isUpperLower(v)) continue :no_break; } } else if (isParaSep(p) or isLower(p) or isNumeric(p) or isSContinue(p)) { continue :no_break; } else if (isSpace(p)) { // ATerm Sp* self.run(isSpace); end = self.current(); // Possible lower case after. if (self.peek()) |pp| { if (isLower(pp)) continue :no_break; } } else if (isClose(p)) { // ATerm Close* self.run(isClose); if (self.peek()) |pp| { // Possible ParaSep after. if (isParaSep(pp)) { _ = self.advance(); end = self.current(); const start = self.start.?; self.start = self.peek(); return self.emit(start, end); } // Possible spaces after. if (isSpace(pp)) { // ATerm Close* Sp* self.run(isSpace); if (self.peek()) |ppp| { // Possible lower after. if (isLower(ppp)) continue :no_break; // Possible lower after some allowed code points. if (isAllowedBeforeLower(ppp)) { if (self.peekAfterSkip(isAllowedBeforeLower)) |pppp| { // ATerm Close* Sp* !(Unallowed) Lower if (isLower(pppp)) continue :no_break; } } } } } end = self.current(); } else if (isSATerm(p)) { self.run(isSATerm); end = self.current(); } } const start = self.start.?; self.start = self.peek(); return self.emit(start, end); } if (current_token.is(.sterm)) { var end = self.current(); if (self.peek()) |p| { if (isParaSep(p) or isSATerm(p) or isSContinue(p)) { _ = self.advance(); end = self.current(); } else if (isSpace(p)) { self.run(isSpace); end = self.current(); } else if (isClose(p)) { // STerm Close* self.run(isClose); if (self.peek()) |pp| { if (isSpace(pp)) { // STerm Close* Sp* self.run(isSpace); } } end = self.current(); } } const start = self.start.?; self.start = self.peek(); return self.emit(start, end); } } return if (self.start) |start| self.emit(start, self.last()) else null; } // Token array movement. fn forward(self: *Self) bool { if (self.i) |*index| { index.* += 1; if (index.* >= self.tokens.len) return false; } else { self.i = 0; } return true; } pub fn count(self: *Self) usize { const original_i = self.i; const original_start = self.start; defer { self.i = original_i; self.start = original_start; } self.rewind(); var i: usize = 0; while (self.next()) |_| : (i += 1) {} return i; } // Token array movement. pub fn rewind(self: *Self) void { self.i = null; self.start = self.tokens[0]; } fn getRelative(self: Self, n: isize) ?Token { var index: usize = self.i orelse 0; if (n < 0) { if (index == 0 or -%n > index) return null; index -= @intCast(usize, -%n); } else { const un = @intCast(usize, n); if (index + un >= self.tokens.len) return null; index += un; } return self.tokens[index]; } fn prevAfterSkip(self: *Self, predicate: TokenPredicate) ?Token { if (self.i == null or self.i.? == 0) return null; var i: isize = 1; while (self.getRelative(-i)) |token| : (i += 1) { if (!predicate(token)) return token; } return null; } fn current(self: Self) Token { // Assumes self.i is not null. return self.tokens[self.i.?]; } fn last(self: Self) Token { return self.tokens[self.tokens.len - 1]; } fn peek(self: Self) ?Token { return self.getRelative(1); } fn peekAfterSkip(self: *Self, predicate: TokenPredicate) ?Token { var i: isize = 1; while (self.getRelative(i)) |token| : (i += 1) { if (!predicate(token)) return token; } return null; } fn advance(self: *Self) ?Token { const token = if (self.forward()) self.current() else return null; if (!isParaSep(token)) _ = self.skipIgnorables(token); return token; } fn run(self: *Self, predicate: TokenPredicate) void { while (self.peek()) |token| { if (!predicate(token)) break; _ = self.advance(); } } fn skipIgnorables(self: *Self, end: Token) Token { if (self.peek()) |p| { if (isIgnorable(p)) { self.run(isIgnorable); return self.current(); } } return end; } // Production. fn emit(self: Self, start_token: Token, end_token: Token) Sentence { const start = start_token.code_point.offset; const end = end_token.code_point.end(); return .{ .bytes = self.bytes[start..end], .offset = start, }; } }; } test "Segmentation ComptimeSentenceIterator" { @setEvalBranchQuota(2_000); const input = \\("Go.") ("He said.") ; comptime var ct_iter = ComptimeSentenceIterator(input){}; const n = comptime ct_iter.count(); var sentences: [n]Sentence = undefined; comptime { var i: usize = 0; while (ct_iter.next()) |sentence| : (i += 1) { sentences[i] = sentence; } } const s1 = \\("Go.") ; const s2 = \\("He said.") ; const want = &[_][]const u8{ s1, s2 }; for (sentences) |sentence, i| { try testing.expect(sentence.eql(want[i])); } }
src/segmenter/Sentence.zig
const std = @import("std"); const upaya = @import("upaya_cli.zig"); const Texture = @import("texture.zig").Texture; /// Image is a CPU side array of color data with some helper methods that can be used to prep data /// before creating a Texture pub const Image = struct { w: usize = 0, h: usize = 0, pixels: []u32, pub fn init(width: usize, height: usize) Image { return .{ .w = width, .h = height, .pixels = upaya.mem.allocator.alloc(u32, width * height) catch unreachable }; } pub fn initFromFile(file: []const u8) Image { const image_contents = upaya.fs.read(upaya.mem.tmp_allocator, file) catch unreachable; var w: c_int = undefined; var h: c_int = undefined; var channels: c_int = undefined; const load_res = upaya.stb.stbi_load_from_memory(image_contents.ptr, @intCast(c_int, image_contents.len), &w, &h, &channels, 4); if (load_res == null) unreachable; defer upaya.stb.stbi_image_free(load_res); var img = init(@intCast(usize, w), @intCast(usize, h)); var pixels = std.mem.bytesAsSlice(u32, load_res[0..@intCast(usize, w * h * channels)]); for (pixels) |p, i| { img.pixels[i] = p; } return img; } pub fn deinit(self: Image) void { upaya.mem.allocator.free(self.pixels); } pub fn fillRect(self: *Image, rect: upaya.math.RectI, color: upaya.math.Color) void { const x = @intCast(usize, rect.x); var y = @intCast(usize, rect.y); const w = @intCast(usize, rect.w); var h = @intCast(usize, rect.h); var data = self.pixels[x + y * self.w ..]; while (h > 0) : (h -= 1) { var i: usize = 0; while (i < w) : (i += 1) { data[i] = color.value; } y += 1; data = self.pixels[x + y * self.w ..]; } } pub fn blit(self: *Image, src: Image, x: usize, y: usize) void { var yy = y; var h = src.h; var data = self.pixels[x + yy * self.w ..]; var src_y: usize = 0; while (h > 0) : (h -= 1) { const src_row = src.pixels[src_y * src.w .. (src_y * src.w) + src.w]; std.mem.copy(u32, data, src_row); // next row and move our slice to it as well src_y += 1; yy += 1; data = self.pixels[x + yy * self.w ..]; } } pub fn asTexture(self: Image, filter: Texture.Filter) Texture { return Texture.initWithColorData(self.pixels, @intCast(i32, self.w), @intCast(i32, self.h), filter); } pub fn save(self: Image, file: []const u8) void { var c_file = std.cstr.addNullByte(upaya.mem.tmp_allocator, file) catch unreachable; var bytes = std.mem.sliceAsBytes(self.pixels); _ = upaya.stb.stbi_write_png(c_file.ptr, @intCast(c_int, self.w), @intCast(c_int, self.h), 4, bytes.ptr, @intCast(c_int, self.w * 4)); } /// returns true if the image was loaded successfully pub fn getTextureSize(file: []const u8, w: *c_int, h: *c_int) bool { const image_contents = upaya.fs.read(upaya.mem.tmp_allocator, file) catch unreachable; var comp: c_int = undefined; if (upaya.stb.stbi_info_from_memory(image_contents.ptr, @intCast(c_int, image_contents.len), w, h, &comp) == 1) { return true; } return false; } };
src/image.zig
const c = @import("c.zig"); pub usingnamespace c; pub const XID = c_ulong; pub const Mask = c_ulong; pub const Atom = c_ulong; pub const VisualID = c_ulong; pub const Time = c_ulong; pub const Window = XID; pub const Drawable = XID; pub const Font = XID; pub const Pixmap = XID; pub const Cursor = XID; pub const Colormap = XID; pub const GContext = XID; pub const KeySym = XID; pub const KeyCode = u8; pub const X_PROTOCOL = @as(c_int, 11); pub const X_PROTOCOL_REVISION = @as(c_int, 0); pub const _XTYPEDEF_XID = ""; pub const _XTYPEDEF_MASK = ""; pub const _XTYPEDEF_ATOM = ""; pub const _XTYPEDEF_FONT = ""; pub const None = @as(c_long, 0); pub const ParentRelative = @as(c_long, 1); pub const CopyFromParent = @as(c_long, 0); pub const PointerWindow = @as(c_long, 0); pub const InputFocus = @as(c_long, 1); pub const PointerRoot = @as(c_long, 1); pub const AnyPropertyType = @as(c_long, 0); pub const AnyKey = @as(c_long, 0); pub const AnyButton = @as(c_long, 0); pub const AllTemporary = @as(c_long, 0); pub const CurrentTime = @as(c_long, 0); pub const NoSymbol = @as(c_long, 0); pub const NoEventMask = @as(c_long, 0); pub const KeyPressMask = @as(c_long, 1) << @as(c_int, 0); pub const KeyReleaseMask = @as(c_long, 1) << @as(c_int, 1); pub const ButtonPressMask = @as(c_long, 1) << @as(c_int, 2); pub const ButtonReleaseMask = @as(c_long, 1) << @as(c_int, 3); pub const EnterWindowMask = @as(c_long, 1) << @as(c_int, 4); pub const LeaveWindowMask = @as(c_long, 1) << @as(c_int, 5); pub const PointerMotionMask = @as(c_long, 1) << @as(c_int, 6); pub const PointerMotionHintMask = @as(c_long, 1) << @as(c_int, 7); pub const Button1MotionMask = @as(c_long, 1) << @as(c_int, 8); pub const Button2MotionMask = @as(c_long, 1) << @as(c_int, 9); pub const Button3MotionMask = @as(c_long, 1) << @as(c_int, 10); pub const Button4MotionMask = @as(c_long, 1) << @as(c_int, 11); pub const Button5MotionMask = @as(c_long, 1) << @as(c_int, 12); pub const ButtonMotionMask = @as(c_long, 1) << @as(c_int, 13); pub const KeymapStateMask = @as(c_long, 1) << @as(c_int, 14); pub const ExposureMask = @as(c_long, 1) << @as(c_int, 15); pub const VisibilityChangeMask = @as(c_long, 1) << @as(c_int, 16); pub const StructureNotifyMask = @as(c_long, 1) << @as(c_int, 17); pub const ResizeRedirectMask = @as(c_long, 1) << @as(c_int, 18); pub const SubstructureNotifyMask = @as(c_long, 1) << @as(c_int, 19); pub const SubstructureRedirectMask = @as(c_long, 1) << @as(c_int, 20); pub const FocusChangeMask = @as(c_long, 1) << @as(c_int, 21); pub const PropertyChangeMask = @as(c_long, 1) << @as(c_int, 22); pub const ColormapChangeMask = @as(c_long, 1) << @as(c_int, 23); pub const OwnerGrabButtonMask = @as(c_long, 1) << @as(c_int, 24); pub const KeyPress = @as(c_int, 2); pub const KeyRelease = @as(c_int, 3); pub const ButtonPress = @as(c_int, 4); pub const ButtonRelease = @as(c_int, 5); pub const MotionNotify = @as(c_int, 6); pub const EnterNotify = @as(c_int, 7); pub const LeaveNotify = @as(c_int, 8); pub const FocusIn = @as(c_int, 9); pub const FocusOut = @as(c_int, 10); pub const KeymapNotify = @as(c_int, 11); pub const Expose = @as(c_int, 12); pub const GraphicsExpose = @as(c_int, 13); pub const NoExpose = @as(c_int, 14); pub const VisibilityNotify = @as(c_int, 15); pub const CreateNotify = @as(c_int, 16); pub const DestroyNotify = @as(c_int, 17); pub const UnmapNotify = @as(c_int, 18); pub const MapNotify = @as(c_int, 19); pub const MapRequest = @as(c_int, 20); pub const ReparentNotify = @as(c_int, 21); pub const ConfigureNotify = @as(c_int, 22); pub const ConfigureRequest = @as(c_int, 23); pub const GravityNotify = @as(c_int, 24); pub const ResizeRequest = @as(c_int, 25); pub const CirculateNotify = @as(c_int, 26); pub const CirculateRequest = @as(c_int, 27); pub const PropertyNotify = @as(c_int, 28); pub const SelectionClear = @as(c_int, 29); pub const SelectionRequest = @as(c_int, 30); pub const SelectionNotify = @as(c_int, 31); pub const ColormapNotify = @as(c_int, 32); pub const ClientMessage = @as(c_int, 33); pub const MappingNotify = @as(c_int, 34); pub const GenericEvent = @as(c_int, 35); pub const LASTEvent = @as(c_int, 36); pub const ShiftMask = @as(c_int, 1) << @as(c_int, 0); pub const LockMask = @as(c_int, 1) << @as(c_int, 1); pub const ControlMask = @as(c_int, 1) << @as(c_int, 2); pub const Mod1Mask = @as(c_int, 1) << @as(c_int, 3); pub const Mod2Mask = @as(c_int, 1) << @as(c_int, 4); pub const Mod3Mask = @as(c_int, 1) << @as(c_int, 5); pub const Mod4Mask = @as(c_int, 1) << @as(c_int, 6); pub const Mod5Mask = @as(c_int, 1) << @as(c_int, 7); pub const ShiftMapIndex = @as(c_int, 0); pub const LockMapIndex = @as(c_int, 1); pub const ControlMapIndex = @as(c_int, 2); pub const Mod1MapIndex = @as(c_int, 3); pub const Mod2MapIndex = @as(c_int, 4); pub const Mod3MapIndex = @as(c_int, 5); pub const Mod4MapIndex = @as(c_int, 6); pub const Mod5MapIndex = @as(c_int, 7); pub const Button1Mask = @as(c_int, 1) << @as(c_int, 8); pub const Button2Mask = @as(c_int, 1) << @as(c_int, 9); pub const Button3Mask = @as(c_int, 1) << @as(c_int, 10); pub const Button4Mask = @as(c_int, 1) << @as(c_int, 11); pub const Button5Mask = @as(c_int, 1) << @as(c_int, 12); pub const AnyModifier = @as(c_int, 1) << @as(c_int, 15); pub const Button1 = @as(c_int, 1); pub const Button2 = @as(c_int, 2); pub const Button3 = @as(c_int, 3); pub const Button4 = @as(c_int, 4); pub const Button5 = @as(c_int, 5); pub const NotifyNormal = @as(c_int, 0); pub const NotifyGrab = @as(c_int, 1); pub const NotifyUngrab = @as(c_int, 2); pub const NotifyWhileGrabbed = @as(c_int, 3); pub const NotifyHint = @as(c_int, 1); pub const NotifyAncestor = @as(c_int, 0); pub const NotifyVirtual = @as(c_int, 1); pub const NotifyInferior = @as(c_int, 2); pub const NotifyNonlinear = @as(c_int, 3); pub const NotifyNonlinearVirtual = @as(c_int, 4); pub const NotifyPointer = @as(c_int, 5); pub const NotifyPointerRoot = @as(c_int, 6); pub const NotifyDetailNone = @as(c_int, 7); pub const VisibilityUnobscured = @as(c_int, 0); pub const VisibilityPartiallyObscured = @as(c_int, 1); pub const VisibilityFullyObscured = @as(c_int, 2); pub const PlaceOnTop = @as(c_int, 0); pub const PlaceOnBottom = @as(c_int, 1); pub const FamilyInternet = @as(c_int, 0); pub const FamilyDECnet = @as(c_int, 1); pub const FamilyChaos = @as(c_int, 2); pub const FamilyInternet6 = @as(c_int, 6); pub const FamilyServerInterpreted = @as(c_int, 5); pub const PropertyNewValue = @as(c_int, 0); pub const PropertyDelete = @as(c_int, 1); pub const ColormapUninstalled = @as(c_int, 0); pub const ColormapInstalled = @as(c_int, 1); pub const GrabModeSync = @as(c_int, 0); pub const GrabModeAsync = @as(c_int, 1); pub const GrabSuccess = @as(c_int, 0); pub const AlreadyGrabbed = @as(c_int, 1); pub const GrabInvalidTime = @as(c_int, 2); pub const GrabNotViewable = @as(c_int, 3); pub const GrabFrozen = @as(c_int, 4); pub const AsyncPointer = @as(c_int, 0); pub const SyncPointer = @as(c_int, 1); pub const ReplayPointer = @as(c_int, 2); pub const AsyncKeyboard = @as(c_int, 3); pub const SyncKeyboard = @as(c_int, 4); pub const ReplayKeyboard = @as(c_int, 5); pub const AsyncBoth = @as(c_int, 6); pub const SyncBoth = @as(c_int, 7); pub const RevertToNone = @import("std").zig.c_translation.cast(c_int, None); pub const RevertToPointerRoot = @import("std").zig.c_translation.cast(c_int, PointerRoot); pub const RevertToParent = @as(c_int, 2); pub const Success = @as(c_int, 0); pub const BadRequest = @as(c_int, 1); pub const BadValue = @as(c_int, 2); pub const BadWindow = @as(c_int, 3); pub const BadPixmap = @as(c_int, 4); pub const BadAtom = @as(c_int, 5); pub const BadCursor = @as(c_int, 6); pub const BadFont = @as(c_int, 7); pub const BadMatch = @as(c_int, 8); pub const BadDrawable = @as(c_int, 9); pub const BadAccess = @as(c_int, 10); pub const BadAlloc = @as(c_int, 11); pub const BadColor = @as(c_int, 12); pub const BadGC = @as(c_int, 13); pub const BadIDChoice = @as(c_int, 14); pub const BadName = @as(c_int, 15); pub const BadLength = @as(c_int, 16); pub const BadImplementation = @as(c_int, 17); pub const FirstExtensionError = @as(c_int, 128); pub const LastExtensionError = @as(c_int, 255); pub const InputOutput = @as(c_int, 1); pub const InputOnly = @as(c_int, 2); pub const CWBackPixmap = @as(c_long, 1) << @as(c_int, 0); pub const CWBackPixel = @as(c_long, 1) << @as(c_int, 1); pub const CWBorderPixmap = @as(c_long, 1) << @as(c_int, 2); pub const CWBorderPixel = @as(c_long, 1) << @as(c_int, 3); pub const CWBitGravity = @as(c_long, 1) << @as(c_int, 4); pub const CWWinGravity = @as(c_long, 1) << @as(c_int, 5); pub const CWBackingStore = @as(c_long, 1) << @as(c_int, 6); pub const CWBackingPlanes = @as(c_long, 1) << @as(c_int, 7); pub const CWBackingPixel = @as(c_long, 1) << @as(c_int, 8); pub const CWOverrideRedirect = @as(c_long, 1) << @as(c_int, 9); pub const CWSaveUnder = @as(c_long, 1) << @as(c_int, 10); pub const CWEventMask = @as(c_long, 1) << @as(c_int, 11); pub const CWDontPropagate = @as(c_long, 1) << @as(c_int, 12); pub const CWColormap = @as(c_long, 1) << @as(c_int, 13); pub const CWCursor = @as(c_long, 1) << @as(c_int, 14); pub const CWX = @as(c_int, 1) << @as(c_int, 0); pub const CWY = @as(c_int, 1) << @as(c_int, 1); pub const CWWidth = @as(c_int, 1) << @as(c_int, 2); pub const CWHeight = @as(c_int, 1) << @as(c_int, 3); pub const CWBorderWidth = @as(c_int, 1) << @as(c_int, 4); pub const CWSibling = @as(c_int, 1) << @as(c_int, 5); pub const CWStackMode = @as(c_int, 1) << @as(c_int, 6); pub const ForgetGravity = @as(c_int, 0); pub const NorthWestGravity = @as(c_int, 1); pub const NorthGravity = @as(c_int, 2); pub const NorthEastGravity = @as(c_int, 3); pub const WestGravity = @as(c_int, 4); pub const CenterGravity = @as(c_int, 5); pub const EastGravity = @as(c_int, 6); pub const SouthWestGravity = @as(c_int, 7); pub const SouthGravity = @as(c_int, 8); pub const SouthEastGravity = @as(c_int, 9); pub const StaticGravity = @as(c_int, 10); pub const UnmapGravity = @as(c_int, 0); pub const NotUseful = @as(c_int, 0); pub const WhenMapped = @as(c_int, 1); pub const Always = @as(c_int, 2); pub const IsUnmapped = @as(c_int, 0); pub const IsUnviewable = @as(c_int, 1); pub const IsViewable = @as(c_int, 2); pub const SetModeInsert = @as(c_int, 0); pub const SetModeDelete = @as(c_int, 1); pub const DestroyAll = @as(c_int, 0); pub const RetainPermanent = @as(c_int, 1); pub const RetainTemporary = @as(c_int, 2); pub const Above = @as(c_int, 0); pub const Below = @as(c_int, 1); pub const TopIf = @as(c_int, 2); pub const BottomIf = @as(c_int, 3); pub const Opposite = @as(c_int, 4); pub const RaiseLowest = @as(c_int, 0); pub const LowerHighest = @as(c_int, 1); pub const PropModeReplace = @as(c_int, 0); pub const PropModePrepend = @as(c_int, 1); pub const PropModeAppend = @as(c_int, 2); pub const GXclear = @as(c_int, 0x0); pub const GXand = @as(c_int, 0x1); pub const GXandReverse = @as(c_int, 0x2); pub const GXcopy = @as(c_int, 0x3); pub const GXandInverted = @as(c_int, 0x4); pub const GXnoop = @as(c_int, 0x5); pub const GXxor = @as(c_int, 0x6); pub const GXor = @as(c_int, 0x7); pub const GXnor = @as(c_int, 0x8); pub const GXequiv = @as(c_int, 0x9); pub const GXinvert = @as(c_int, 0xa); pub const GXorReverse = @as(c_int, 0xb); pub const GXcopyInverted = @as(c_int, 0xc); pub const GXorInverted = @as(c_int, 0xd); pub const GXnand = @as(c_int, 0xe); pub const GXset = @as(c_int, 0xf); pub const LineSolid = @as(c_int, 0); pub const LineOnOffDash = @as(c_int, 1); pub const LineDoubleDash = @as(c_int, 2); pub const CapNotLast = @as(c_int, 0); pub const CapButt = @as(c_int, 1); pub const CapRound = @as(c_int, 2); pub const CapProjecting = @as(c_int, 3); pub const JoinMiter = @as(c_int, 0); pub const JoinRound = @as(c_int, 1); pub const JoinBevel = @as(c_int, 2); pub const FillSolid = @as(c_int, 0); pub const FillTiled = @as(c_int, 1); pub const FillStippled = @as(c_int, 2); pub const FillOpaqueStippled = @as(c_int, 3); pub const EvenOddRule = @as(c_int, 0); pub const WindingRule = @as(c_int, 1); pub const ClipByChildren = @as(c_int, 0); pub const IncludeInferiors = @as(c_int, 1); pub const Unsorted = @as(c_int, 0); pub const YSorted = @as(c_int, 1); pub const YXSorted = @as(c_int, 2); pub const YXBanded = @as(c_int, 3); pub const CoordModeOrigin = @as(c_int, 0); pub const CoordModePrevious = @as(c_int, 1); pub const Complex = @as(c_int, 0); pub const Nonconvex = @as(c_int, 1); pub const Convex = @as(c_int, 2); pub const ArcChord = @as(c_int, 0); pub const ArcPieSlice = @as(c_int, 1); pub const GCFunction = @as(c_long, 1) << @as(c_int, 0); pub const GCPlaneMask = @as(c_long, 1) << @as(c_int, 1); pub const GCForeground = @as(c_long, 1) << @as(c_int, 2); pub const GCBackground = @as(c_long, 1) << @as(c_int, 3); pub const GCLineWidth = @as(c_long, 1) << @as(c_int, 4); pub const GCLineStyle = @as(c_long, 1) << @as(c_int, 5); pub const GCCapStyle = @as(c_long, 1) << @as(c_int, 6); pub const GCJoinStyle = @as(c_long, 1) << @as(c_int, 7); pub const GCFillStyle = @as(c_long, 1) << @as(c_int, 8); pub const GCFillRule = @as(c_long, 1) << @as(c_int, 9); pub const GCTile = @as(c_long, 1) << @as(c_int, 10); pub const GCStipple = @as(c_long, 1) << @as(c_int, 11); pub const GCTileStipXOrigin = @as(c_long, 1) << @as(c_int, 12); pub const GCTileStipYOrigin = @as(c_long, 1) << @as(c_int, 13); pub const GCFont = @as(c_long, 1) << @as(c_int, 14); pub const GCSubwindowMode = @as(c_long, 1) << @as(c_int, 15); pub const GCGraphicsExposures = @as(c_long, 1) << @as(c_int, 16); pub const GCClipXOrigin = @as(c_long, 1) << @as(c_int, 17); pub const GCClipYOrigin = @as(c_long, 1) << @as(c_int, 18); pub const GCClipMask = @as(c_long, 1) << @as(c_int, 19); pub const GCDashOffset = @as(c_long, 1) << @as(c_int, 20); pub const GCDashList = @as(c_long, 1) << @as(c_int, 21); pub const GCArcMode = @as(c_long, 1) << @as(c_int, 22); pub const GCLastBit = @as(c_int, 22); pub const FontLeftToRight = @as(c_int, 0); pub const FontRightToLeft = @as(c_int, 1); pub const FontChange = @as(c_int, 255); pub const XYBitmap = @as(c_int, 0); pub const XYPixmap = @as(c_int, 1); pub const ZPixmap = @as(c_int, 2); pub const AllocNone = @as(c_int, 0); pub const AllocAll = @as(c_int, 1); pub const DoRed = @as(c_int, 1) << @as(c_int, 0); pub const DoGreen = @as(c_int, 1) << @as(c_int, 1); pub const DoBlue = @as(c_int, 1) << @as(c_int, 2); pub const CursorShape = @as(c_int, 0); pub const TileShape = @as(c_int, 1); pub const StippleShape = @as(c_int, 2); pub const AutoRepeatModeOff = @as(c_int, 0); pub const AutoRepeatModeOn = @as(c_int, 1); pub const AutoRepeatModeDefault = @as(c_int, 2); pub const LedModeOff = @as(c_int, 0); pub const LedModeOn = @as(c_int, 1); pub const KBKeyClickPercent = @as(c_long, 1) << @as(c_int, 0); pub const KBBellPercent = @as(c_long, 1) << @as(c_int, 1); pub const KBBellPitch = @as(c_long, 1) << @as(c_int, 2); pub const KBBellDuration = @as(c_long, 1) << @as(c_int, 3); pub const KBLed = @as(c_long, 1) << @as(c_int, 4); pub const KBLedMode = @as(c_long, 1) << @as(c_int, 5); pub const KBKey = @as(c_long, 1) << @as(c_int, 6); pub const KBAutoRepeatMode = @as(c_long, 1) << @as(c_int, 7); pub const MappingSuccess = @as(c_int, 0); pub const MappingBusy = @as(c_int, 1); pub const MappingFailed = @as(c_int, 2); pub const MappingModifier = @as(c_int, 0); pub const MappingKeyboard = @as(c_int, 1); pub const MappingPointer = @as(c_int, 2); pub const DontPreferBlanking = @as(c_int, 0); pub const PreferBlanking = @as(c_int, 1); pub const DefaultBlanking = @as(c_int, 2); pub const DisableScreenSaver = @as(c_int, 0); pub const DisableScreenInterval = @as(c_int, 0); pub const DontAllowExposures = @as(c_int, 0); pub const AllowExposures = @as(c_int, 1); pub const DefaultExposures = @as(c_int, 2); pub const ScreenSaverReset = @as(c_int, 0); pub const ScreenSaverActive = @as(c_int, 1); pub const HostInsert = @as(c_int, 0); pub const HostDelete = @as(c_int, 1); pub const EnableAccess = @as(c_int, 1); pub const DisableAccess = @as(c_int, 0); pub const StaticGray = @as(c_int, 0); pub const GrayScale = @as(c_int, 1); pub const StaticColor = @as(c_int, 2); pub const PseudoColor = @as(c_int, 3); pub const TrueColor = @as(c_int, 4); pub const DirectColor = @as(c_int, 5); pub const LSBFirst = @as(c_int, 0); pub const MSBFirst = @as(c_int, 1);
modules/platform/src/linux/X11/X.zig
const std = @import("std"); const pr = @import("private.zig"); /// opengl library pub const gl = @import("core/gl.zig"); /// file system library pub const fs = @import("core/fs.zig"); /// utf8 library pub const utf8 = @import("core/utf8.zig"); /// utils library pub const utils = @import("core/utils.zig"); /// audio library pub const audio = @import("core/audio/audio.zig"); /// ecs library pub const ecs = @import("core/ecs.zig"); /// math library pub const math = @import("core/math/math.zig"); /// glfw library pub const glfw = @import("core/glfw.zig"); /// input library pub const input = @import("core/input.zig"); /// std.log implementation pub const log = @import("core/log.zig"); /// primitive renderer library pub const renderer = @import("core/renderer.zig"); /// single window management library pub const window = @import("core/window.zig"); /// GUI library pub const gui = @import("gui.zig"); const m = math; const alog = std.log.scoped(.alka); /// Error set pub const Error = pr.Error; pub const max_quad = pr.max_quad; pub const Vertex2D = pr.Vertex2D; pub const Batch2DQuad = pr.Batch2DQuad; pub const Colour = pr.Colour; // error: inferring error set of return type valid only for function definitions // var pupdateproc: ?fn (deltatime: f32) !void = null; // ^ pub const Callbacks = pr.Callbacks; pub const Batch = pr.Batch; pub const AssetManager = pr.AssetManager; var pengineready: bool = false; var p: *pr.Private = undefined; /// Initializes the engine pub fn init(alloc: *std.mem.Allocator, callbacks: Callbacks, width: i32, height: i32, title: []const u8, fpslimit: u32, resizable: bool) Error!void { if (pengineready) return Error.EngineIsInitialized; p = try alloc.create(pr.Private); p.* = pr.Private{}; pr.setstruct(p); p.alloc = alloc; try glfw.init(); try glfw.windowHint(glfw.WindowHint.Resizable, if (resizable) 1 else 0); gl.setProfile(); p.input.clearBindings(); p.win.size.width = width; p.win.size.height = height; p.win.minsize = if (resizable) .{ .width = 100, .height = 100 } else p.win.size; p.win.maxsize = if (resizable) .{ .width = 10000, .height = 10000 } else p.win.size; p.win.title = title; p.win.callbacks.close = pr.closeCallback; p.win.callbacks.resize = pr.resizeCallback; p.win.callbacks.keyinp = pr.keyboardCallback; p.win.callbacks.mouseinp = pr.mousebuttonCallback; p.win.callbacks.mousepos = pr.mousePosCallback; setCallbacks(callbacks); if (fpslimit != 0) p.targetfps = 1.0 / @intToFloat(f32, fpslimit); try p.win.create(false, true); try glfw.makeContextCurrent(p.win.handle); gl.init(); gl.setBlending(true); if (fpslimit == 0) { try glfw.swapInterval(1); } else { try glfw.swapInterval(0); } //p.layers = try utils.UniqueList(pr.Private.Layer).init(p.alloc, 1); p.defaults.cam2d = m.Camera2D{}; p.defaults.cam2d.ortho = m.Mat4x4f.ortho(0, @intToFloat(f32, p.win.size.width), @intToFloat(f32, p.win.size.height), 0, -1, 1); p.assetmanager.alloc = p.alloc; try p.assetmanager.init(); try p.assetmanager.loadShader(pr.embed.default_shader.id, pr.embed.default_shader.vertex_shader, pr.embed.default_shader.fragment_shader); { var c = [_]renderer.UColour{ .{ .r = 255, .g = 255, .b = 255, .a = 255 }, }; const wtexture = renderer.Texture.createFromColour(&c, 1, 1); try p.assetmanager.loadTexturePro(pr.embed.white_texture_id, wtexture); } popCamera2D(); pengineready = true; alog.info("fully initialized!", .{}); } /// Deinitializes the engine pub fn deinit() Error!void { if (!pengineready) return Error.EngineIsNotInitialized; // Destroy all the batchs if (p.batch_counter > 0) { var i: usize = 0; while (i < p.batch_counter) : (i += 1) { if (p.batchs[i].state != pr.PrivateBatchState.unknown) { pr.destroyPrivateBatch(i); alog.notice("batch(id: {}) destroyed!", .{i}); } } p.alloc.free(p.batchs); } //p.layers.deinit(); p.assetmanager.deinit(); try p.win.destroy(); gl.deinit(); try glfw.terminate(); p.alloc.destroy(p); pengineready = false; alog.info("fully deinitialized!", .{}); } /// Opens the window pub fn open() Error!void { if (!pengineready) return Error.EngineIsNotInitialized; p.winrun = true; } /// Closes the window pub fn close() Error!void { if (!pengineready) return Error.EngineIsNotInitialized; p.winrun = false; } /// Updates the engine /// can return `anyerror` pub fn update() !void { if (!pengineready) return Error.EngineIsNotInitialized; // Source: https://gafferongames.com/post/fix_your_timestep/ var last: f64 = try glfw.getTime(); var accumulator: f64 = 0; var dt: f64 = 0.01; while (p.winrun) { if (p.callbacks.update) |fun| { try fun(@floatCast(f32, p.frametime.delta)); } try p.frametime.start(); var ftime: f64 = p.frametime.current - last; if (ftime > 0.25) { ftime = 0.25; } last = p.frametime.current; accumulator += ftime; if (p.callbacks.fixed) |fun| { while (accumulator >= dt) : (accumulator -= dt) { try fun(@floatCast(f32, dt)); } } p.input.handle(); gl.clearBuffers(gl.BufferBit.colour); if (p.callbacks.draw) |fun| { try fun(); } popCamera2D(); // Render all the batches try renderAllBatchs(); try glfw.swapBuffers(p.win.handle); try glfw.pollEvents(); // Clean all the batches cleanAllBatchs(); try p.frametime.stop(); try p.frametime.sleep(p.targetfps); p.fps = p.fps.calculate(p.frametime); } if (p.win.callbacks.close != null) pr.closeCallback(p.win.handle); } /// Returns the p.alloc pub fn getAllocator() *std.mem.Allocator { return p.alloc; } /// Returns the fps pub fn getFps() u32 { return p.fps.fps; } /// Returns the debug information /// Warning: you have to manually free the buffer pub fn getDebug() ![]u8 { if (!pengineready) return Error.EngineIsNotInitialized; var buffer: []u8 = try p.alloc.alloc(u8, 255); buffer = try std.fmt.bufPrintZ(buffer, "update: {d:.4}\tdraw: {d:.4}\tdelta: {d:.4}\tfps: {}", .{ p.frametime.update, p.frametime.draw, p.frametime.delta, p.fps.fps }); return buffer; } /// Returns the window pub fn getWindow() *window.Info { return &p.win; } /// Returns the input pub fn getInput() *input.Info { return &p.input; } /// Returns the mouse pos pub fn getMousePosition() m.Vec2f { return p.mousep; } /// Returns the ptr to assetmanager pub fn getAssetManager() *AssetManager { return &p.assetmanager; } /// Returns the ptr to default camera2d pub fn getCamera2DPtr() *m.Camera2D { return &p.defaults.cam2d; } /// Returns the read-only default camera2d pub fn getCamera2D() m.Camera2D { return p.defaults.cam2d; } /// Returns the ptr to pushed camera2d pub fn getCamera2DPushedPtr() *m.Camera2D { return &p.force_camera2d; } /// Returns the read-only pushed camera2d pub fn getCamera2DPushed() m.Camera2D { return p.force_camera2d; } /// Returns the requested batch with given attribs /// Note: updating every frame is the way to go pub fn getBatch(mode: gl.DrawMode, sh_id: u64, texture_id: u64) Error!Batch { const sh = try p.assetmanager.getShader(sh_id); const texture = try p.assetmanager.getTexture(texture_id); var i: usize = 0; while (i < p.batch_counter) : (i += 1) { if (p.batchs[i].state == pr.PrivateBatchState.active and p.batchs[i].mode == mode and p.batchs[i].shader == sh and p.batchs[i].texture.id == texture.id) return Batch{ .id = @intCast(i32, i), .mode = p.batchs[i].mode, .shader = p.batchs[i].shader, .texture = p.batchs[i].texture, .cam2d = &p.batchs[i].cam2d, .subcounter = &p.batchs[i].data.submission_counter, }; } return Error.InvalidBatch; } /// Returns the requested batch with given attribs /// Note: updating every frame is the way to go /// usefull when using non-assetmanager loaded shaders and textures pub fn getBatchNoID(mode: gl.DrawMode, sh: u32, texture: renderer.Texture) Error!Batch { var i: usize = 0; while (i < p.batch_counter) : (i += 1) { if (p.batchs[i].state == pr.PrivateBatchState.active and p.batchs[i].mode == mode and p.batchs[i].shader == sh and p.batchs[i].texture.id == texture.id) return Batch{ .id = @intCast(i32, i), .mode = p.batchs[i].mode, .shader = p.batchs[i].shader, .texture = p.batchs[i].texture, .cam2d = &p.batchs[i].cam2d, .subcounter = &p.batchs[i].data.submission_counter, }; } return Error.InvalidBatch; } /// Creates a batch with given attribs /// Note: updating every frame is the way to go pub fn createBatch(mode: gl.DrawMode, sh_id: u64, texture_id: u64) Error!Batch { const i = pr.findPrivateBatch() catch |err| { if (err == Error.FailedToFindPrivateBatch) { try pr.createPrivateBatch(); return createBatch(mode, sh_id, texture_id); } else return err; }; var b = &p.batchs[i]; b.state = pr.PrivateBatchState.active; b.mode = mode; b.shader = try p.assetmanager.getShader(sh_id); b.texture = try p.assetmanager.getTexture(texture_id); b.cam2d = p.force_camera2d; return Batch{ .id = @intCast(i32, i), .mode = b.mode, .shader = b.shader, .texture = b.texture, .cam2d = &b.cam2d, .subcounter = &b.data.submission_counter, }; } /// Creates a batch with given attribs /// Note: updating every frame is the way to go /// usefull when using non-assetmanager loaded shaders and textures pub fn createBatchNoID(mode: gl.DrawMode, sh: u32, texture: renderer.Texture) Error!Batch { const i = pr.findPrivateBatch() catch |err| { if (err == Error.FailedToFindPrivateBatch) { try pr.createPrivateBatch(); return createBatchNoID(mode, sh, texture); } else return err; }; var b = &p.batchs[i]; b.state = pr.PrivateBatchState.active; b.mode = mode; b.shader = sh; b.texture = texture; b.cam2d = p.force_camera2d; return Batch{ .id = @intCast(i32, i), .mode = b.mode, .shader = b.shader, .texture = b.texture, .cam2d = &b.cam2d, .subcounter = &b.data.submission_counter, }; } /// Sets the batch drawfun /// use this after `batch.drawfun = fun` pub fn setBatchFun(batch: Batch) void { var b = &p.batchs[@intCast(usize, batch.id)]; b.drawfun = batch.drawfun; } /// Sets the batch layer pub fn setBatchLayer(layer: i64) void { @compileError("This functionality does not implemented."); } /// Sets the callbacks pub fn setCallbacks(calls: Callbacks) void { p.callbacks = calls; } /// Sets the background colour pub fn setBackgroundColour(r: f32, g: f32, b: f32) void { gl.clearColour(r, g, b, 1); } /// Automatically resizes/strecthes the view/camera /// Recommended to use after initializing the engine and `resize` callback pub fn autoResize(virtualwidth: i32, virtualheight: i32, screenwidth: i32, screenheight: i32) void { var cam = &p.force_camera2d; const aspect: f32 = @intToFloat(f32, virtualwidth) / @intToFloat(f32, virtualheight); var width = screenwidth; var height = @floatToInt(i32, @intToFloat(f32, screenheight) / aspect + 0.5); if (height > screenheight) { height = screenheight; width = @floatToInt(i32, @intToFloat(f32, screenheight) * aspect + 0.5); } const vx = @divTrunc(screenwidth, 2) - @divTrunc(width, 2); const vy = @divTrunc(screenheight, 2) - @divTrunc(height, 2); const scalex = @intToFloat(f32, screenwidth) / @intToFloat(f32, virtualwidth); const scaley = @intToFloat(f32, screenheight) / @intToFloat(f32, virtualheight); gl.viewport(vx, vy, width, height); gl.ortho(0, @intToFloat(f32, screenwidth), @intToFloat(f32, screenheight), 0, -1, 1); cam.ortho = m.Mat4x4f.ortho(0, @intToFloat(f32, screenwidth), @intToFloat(f32, screenheight), 0, -1, 1); cam.zoom.x = scalex; cam.zoom.y = scaley; } /// Renders the given batch pub fn renderBatch(batch: Batch) Error!void { const i = @intCast(usize, batch.id); return pr.drawPrivateBatch(i); } /// Cleans the batch pub fn cleanBatch(batch: Batch) void { const i = @intCast(usize, batch.id); return pr.cleanPrivateBatch(i); } /// Renders all the batchs pub fn renderAllBatchs() Error!void { var i: usize = 0; while (i < p.batch_counter) : (i += 1) { try pr.renderPrivateBatch(i); } } /// Cleans all the batchs pub fn cleanAllBatchs() void { var i: usize = 0; while (i < p.batch_counter) : (i += 1) { pr.cleanPrivateBatch(i); } } /// Pushes the given camera2D pub fn pushCamera2D(cam: m.Camera2D) void { p.force_camera2d = cam; } /// Pops the camera2D pub fn popCamera2D() void { p.force_camera2d = getCamera2D(); } /// Forces to use the given shader /// in draw calls pub fn pushShader(sh: u64) Error!void { if (p.force_batch != null) return Error.CustomBatchInUse; p.force_shader = sh; } /// Pops the force use shader pub fn popShader() void { p.force_shader = null; } /// Forces to use the given batch /// in draw calls pub fn pushBatch(batch: Batch) Error!void { if (p.force_shader != null) return Error.CustomShaderInUse; p.force_batch = @intCast(usize, batch.id); } /// Pops the force use batch pub fn popBatch() void { p.force_batch = null; } /// Draws a pixel /// Draw mode: points pub fn drawPixel(pos: m.Vec2f, colour: Colour) Error!void { const i = try identifyBatchID(.points, pr.embed.default_shader.id, pr.embed.white_texture_id); const vx = [Batch2DQuad.max_vertex_count]Vertex2D{ .{ .position = pos, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, }; p.batchs[i].data.submitDrawable(vx) catch |err| { if (err == Error.ObjectOverflow) { try pr.drawPrivateBatch(i); pr.cleanPrivateBatch(i); //alog.notice("batch(id: {}) flushed!", .{i}); return p.batchs[i].data.submitDrawable(vx); } else return err; }; } /// Draws a line /// Draw mode: lines pub fn drawLine(start: m.Vec2f, end: m.Vec2f, thickness: f32, colour: Colour) Error!void { const i = try identifyBatchID(.lines, pr.embed.default_shader.id, pr.embed.white_texture_id); const pos0 = m.Vec2f{ .x = start.x, .y = start.y }; const pos1 = m.Vec2f{ .x = end.x, .y = end.y }; const pos2 = m.Vec2f{ .x = start.x + thickness, .y = start.y + thickness }; const pos3 = m.Vec2f{ .x = end.x + thickness, .y = end.y + thickness }; const vx = [Batch2DQuad.max_vertex_count]Vertex2D{ .{ .position = pos0, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos1, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos2, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos3, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, }; p.batchs[i].data.submitDrawable(vx) catch |err| { if (err == Error.ObjectOverflow) { try pr.drawPrivateBatch(i); pr.cleanPrivateBatch(i); //alog.notice("batch(id: {}) flushed!", .{i}); return p.batchs[i].data.submitDrawable(vx); } else return err; }; } /// Draws a circle lines, 16 segments by default /// Draw mode: triangles pub fn drawCircle(position: m.Vec2f, radius: f32, colour: Colour) Error!void { return drawCircleAdv(position, radius, 0, 360, 16, colour); } // Source: https://github.com/raysan5/raylib/blob/f1ed8be5d7e2d966d577a3fd28e53447a398b3b6/src/shapes.c#L209 /// Draws a circle /// Draw mode: triangles pub fn drawCircleAdv(center: m.Vec2f, radius: f32, segments: i32, startangle: i32, endangle: i32, colour: Colour) Error!void { const batch_id = try identifyBatchID(.triangles, pr.embed.default_shader.id, pr.embed.white_texture_id); const SMOOTH_CIRCLE_ERROR_RATE = comptime 0.5; var iradius = radius; var istartangle = startangle; var iendangle = endangle; var isegments = segments; if (iradius <= 0.0) iradius = 0.1; // Avoid div by zero // Function expects (endangle > startangle) if (iendangle < istartangle) { // Swap values const tmp = istartangle; istartangle = iendangle; iendangle = tmp; } if (isegments < 4) { // Calculate the maximum angle between segments based on the error rate (usually 0.5f) const th: f32 = std.math.acos(2 * std.math.pow(f32, 1 - SMOOTH_CIRCLE_ERROR_RATE / iradius, 2) - 1); isegments = @floatToInt(i32, (@intToFloat(f32, (iendangle - istartangle)) * @ceil(2 * m.PI / th) / 360)); if (isegments <= 0) isegments = 4; } const steplen: f32 = @intToFloat(f32, iendangle - istartangle) / @intToFloat(f32, isegments); var angle: f32 = @intToFloat(f32, istartangle); // NOTE: Every QUAD actually represents two segments var i: i32 = 0; while (i < @divTrunc(isegments, 2)) : (i += 1) { const pos0 = m.Vec2f{ .x = center.x, .y = center.y }; const pos1 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle)) * iradius, .y = center.y + @cos(m.deg2radf(angle)) * iradius, }; const pos2 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle + steplen)) * iradius, .y = center.y + @cos(m.deg2radf(angle + steplen)) * iradius, }; const pos3 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle + steplen * 2)) * iradius, .y = center.y + @cos(m.deg2radf(angle + steplen * 2)) * iradius, }; angle += steplen * 2; const vx = [Batch2DQuad.max_vertex_count]Vertex2D{ .{ .position = pos0, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos1, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos2, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos3, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, }; p.batchs[batch_id].data.submitDrawable(vx) catch |err| { if (err == Error.ObjectOverflow) { try pr.drawPrivateBatch(batch_id); pr.cleanPrivateBatch(batch_id); //alog.notice("batch(id: {}) flushed!", .{i}); return p.batchs[batch_id].data.submitDrawable(vx); } else return err; }; } // NOTE: In case number of segments is odd, we add one last piece to the cake if (@mod(isegments, 2) != 0) { const pos0 = m.Vec2f{ .x = center.x, .y = center.y }; const pos1 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle)) * iradius, .y = center.y + @cos(m.deg2radf(angle)) * iradius, }; const pos2 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle + steplen)) * iradius, .y = center.y + @cos(m.deg2radf(angle + steplen)) * iradius, }; const pos3 = m.Vec2f{ .x = center.x, .y = center.y }; const vx = [Batch2DQuad.max_vertex_count]Vertex2D{ .{ .position = pos0, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos1, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos2, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos3, .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, }; p.batchs[batch_id].data.submitDrawable(vx) catch |err| { if (err == Error.ObjectOverflow) { try pr.drawPrivateBatch(batch_id); pr.cleanPrivateBatch(batch_id); //alog.notice("batch(id: {}) flushed!", .{i}); return p.batchs[batch_id].data.submitDrawable(vx); } else return err; }; } } /// Draws a circle lines, 16 segments by default /// Draw mode: lines pub fn drawCircleLines(position: m.Vec2f, radius: f32, colour: Colour) Error!void { return drawCircleLinesAdv(position, radius, 16, 0, 360, colour); } // source: https://github.com/raysan5/raylib/blob/f1ed8be5d7e2d966d577a3fd28e53447a398b3b6/src/shapes.c#L298 /// Draws a circle lines /// Draw mode: lines pub fn drawCircleLinesAdv(center: m.Vec2f, radius: f32, segments: i32, startangle: i32, endangle: i32, colour: Colour) Error!void { const SMOOTH_CIRCLE_ERROR_RATE = comptime 0.5; var isegments: i32 = segments; var istartangle: i32 = startangle; var iendangle: i32 = endangle; var iradius = radius; if (iradius <= 0.0) iradius = 0.1; // Avoid div by zero // Function expects (endangle > startangle) if (iendangle < istartangle) { // Swap values const tmp = istartangle; istartangle = iendangle; iendangle = tmp; } if (isegments < 4) { // Calculate the maximum angle between segments based on the error rate (usually 0.5f) const th: f32 = std.math.acos(2 * std.math.pow(f32, 1 - SMOOTH_CIRCLE_ERROR_RATE / iradius, 2) - 1); isegments = @floatToInt(i32, (@intToFloat(f32, (iendangle - istartangle)) * @ceil(2 * m.PI / th) / 360)); if (isegments <= 0) isegments = 4; } const steplen: f32 = @intToFloat(f32, iendangle - istartangle) / @intToFloat(f32, isegments); var angle: f32 = @intToFloat(f32, istartangle); // Hide the cap lines when the circle is full var showcaplines: bool = true; if (@mod(iendangle - istartangle, 360) == 0) { showcaplines = false; } if (showcaplines) { const pos0 = m.Vec2f{ .x = center.x, .y = center.y }; const pos1 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle)) * iradius, .y = center.y + @cos(m.deg2radf(angle)) * iradius, }; try drawLine(pos0, pos1, 1, colour); } var i: i32 = 0; while (i < isegments) : (i += 1) { const pos1 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle)) * iradius, .y = center.y + @cos(m.deg2radf(angle)) * iradius, }; const pos2 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle + steplen)) * iradius, .y = center.y + @cos(m.deg2radf(angle + steplen)) * iradius, }; try drawLine(pos1, pos2, 1, colour); angle += steplen; } if (showcaplines) { const pos0 = m.Vec2f{ .x = center.x, .y = center.y }; const pos1 = m.Vec2f{ .x = center.x + @sin(m.deg2radf(angle)) * iradius, .y = center.y + @cos(m.deg2radf(angle)) * iradius, }; try drawLine(pos0, pos1, 1, colour); } } /// Draws a basic rectangle /// Draw mode: triangles pub fn drawRectangle(rect: m.Rectangle, colour: Colour) Error!void { const i = try identifyBatchID(.triangles, pr.embed.default_shader.id, pr.embed.white_texture_id); const pos = createQuadPositions(rect); const vx = [Batch2DQuad.max_vertex_count]Vertex2D{ .{ .position = pos[0], .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos[1], .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos[2], .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos[3], .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, }; p.batchs[i].data.submitDrawable(vx) catch |err| { if (err == Error.ObjectOverflow) { try pr.drawPrivateBatch(i); pr.cleanPrivateBatch(i); //alog.notice("batch(id: {}) flushed!", .{i}); return p.batchs[i].data.submitDrawable(vx); } else return err; }; } /// Draws a basic rectangle lines /// Draw mode: lines pub fn drawRectangleLines(rect: m.Rectangle, colour: Colour) Error!void { const pos = createQuadPositions(rect); try drawLine(pos[0], pos[1], 1, colour); try drawLine(pos[1], pos[2], 1, colour); try drawLine(pos[2], pos[3], 1, colour); try drawLine(pos[0], pos[3], 1, colour); } /// Draws a rectangle, angle should be in radians /// Draw mode: triangles pub fn drawRectangleAdv(rect: m.Rectangle, origin: m.Vec2f, angle: f32, colour: Colour) Error!void { const i = try identifyBatchID(.triangles, pr.embed.default_shader.id, pr.embed.white_texture_id); const pos = createQuadPositionsMVP(rect, origin, angle); const vx = [Batch2DQuad.max_vertex_count]Vertex2D{ .{ .position = pos[0], .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos[1], .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos[2], .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, .{ .position = pos[3], .texcoord = m.Vec2f{ .x = 0, .y = 0 }, .colour = colour }, }; p.batchs[i].data.submitDrawable(vx) catch |err| { if (err == Error.ObjectOverflow) { try pr.drawPrivateBatch(i); pr.cleanPrivateBatch(i); //alog.notice("batch(id: {}) flushed!", .{i}); return p.batchs[i].data.submitDrawable(vx); } else return err; }; } /// Draws a rectangle line, angle should be in radians /// Draw mode: lines pub fn drawRectangleLinesAdv(rect: m.Rectangle, origin: m.Vec2f, angle: f32, colour: Colour) Error!void { const pos = createQuadPositionsMVP(rect, origin, angle); try drawLine(pos[0], pos[1], 1, colour); try drawLine(pos[1], pos[2], 1, colour); try drawLine(pos[2], pos[3], 1, colour); try drawLine(pos[0], pos[3], 1, colour); } /// Draws a texture /// Draw mode: triangles pub fn drawTexture(texture_id: u64, rect: m.Rectangle, srect: m.Rectangle, colour: Colour) Error!void { const i: usize = try identifyBatchID(.triangles, pr.embed.default_shader.id, texture_id); const pos = createQuadPositions(rect); return pr.submitTextureQuad(i, pos[0], pos[1], pos[2], pos[3], srect, colour); } /// Draws a texture, angle should be in radians /// Draw mode: triangles pub fn drawTextureAdv(texture_id: u64, rect: m.Rectangle, srect: m.Rectangle, origin: m.Vec2f, angle: f32, colour: Colour) Error!void { const i = try identifyBatchID(.triangles, pr.embed.default_shader.id, texture_id); const pos = createQuadPositionsMVP(rect, origin, angle); return pr.submitTextureQuad(i, pos[0], pos[1], pos[2], pos[3], srect, colour); } /// Draws a given codepoint from the font /// Draw mode: triangles pub fn drawTextPoint(font_id: u64, codepoint: i32, position: m.Vec2f, psize: f32, colour: Colour) Error!void { const font = try p.assetmanager.getFont(font_id); const i = try identifyBatchIDWithNoID(.triangles, pr.embed.default_shader.id, font.texture); return pr.submitFontPointQuad(i, font_id, codepoint, position, psize, colour); } /// Draws the given string from the font /// Draw mode: triangles pub fn drawText(font_id: u64, string: []const u8, position: m.Vec2f, psize: f32, colour: Colour) Error!void { const spacing: f32 = 1; const font = try p.assetmanager.getFont(font_id); var offx: f32 = 0; var offy: f32 = 0; const scale_factor: f32 = psize / @intToFloat(f32, font.base_size); var i: usize = 0; while (i < string.len) { var codepointbytec: i32 = 0; var codepoint: i32 = utf8.nextCodepoint(string[i..], &codepointbytec); const index: usize = @intCast(usize, font.glyphIndex(codepoint)); if (codepoint == 0x3f) codepointbytec = 1; if (codepoint == '\n') { offy += @intToFloat(f32, (font.base_size + @divTrunc(font.base_size, 2))) * scale_factor; offx = 0; } else { if ((codepoint != ' ') and (codepoint != '\t')) { try drawTextPoint(font_id, codepoint, m.Vec2f{ .x = position.x + offx, .y = position.y + offy }, psize, colour); } if (font.glyphs[index].advance == 0) { offx += font.rects[index].size.x * scale_factor + spacing; } else offx += @intToFloat(f32, font.glyphs[index].advance) * scale_factor + spacing; } i += @intCast(usize, codepointbytec); } } fn createQuadPositions(rect: m.Rectangle) [4]m.Vec2f { return [4]m.Vec2f{ m.Vec2f{ .x = rect.position.x, .y = rect.position.y }, m.Vec2f{ .x = rect.position.x + rect.size.x, .y = rect.position.y }, m.Vec2f{ .x = rect.position.x + rect.size.x, .y = rect.position.y + rect.size.y }, m.Vec2f{ .x = rect.position.x, .y = rect.position.y + rect.size.y }, }; } fn createQuadPositionsMVP(rect: m.Rectangle, origin: m.Vec2f, rad: f32) [4]m.Vec2f { var model = m.ModelMatrix{}; model.translate(rect.position.x, rect.position.y, 0); model.translate(origin.x, origin.y, 0); model.rotate(0, 0, 1, rad); model.translate(-origin.x, -origin.y, 0); const mvp = model.model; const r0 = m.Vec3f.transform(.{ .x = 0, .y = 0 }, mvp); const r1 = m.Vec3f.transform(.{ .x = rect.size.x, .y = 0 }, mvp); const r2 = m.Vec3f.transform(.{ .x = rect.size.x, .y = rect.size.y }, mvp); const r3 = m.Vec3f.transform(.{ .x = 0, .y = rect.size.y }, mvp); return [4]m.Vec2f{ m.Vec2f{ .x = rect.position.x + r0.x, .y = rect.position.y + r0.y }, m.Vec2f{ .x = rect.position.x + r1.x, .y = rect.position.y + r1.y }, m.Vec2f{ .x = rect.position.x + r2.x, .y = rect.position.y + r2.y }, m.Vec2f{ .x = rect.position.x + r3.x, .y = rect.position.y + r3.y }, }; } fn identifyBatchID(mode: gl.DrawMode, sshader: u64, texture: u64) Error!usize { if (p.force_batch) |id| { return id; } else { var shader = sshader; if (p.force_shader) |shaa| { shader = shaa; } const batch = getBatch(mode, shader, texture) catch |err| { if (err == Error.InvalidBatch) { _ = try createBatch(mode, shader, texture); return identifyBatchID(mode, sshader, texture); } else return err; }; return @intCast(usize, batch.id); } return Error.FailedToFindBatch; } fn identifyBatchIDWithNoID(mode: gl.DrawMode, sshader: u64, texture: renderer.Texture) Error!usize { if (p.force_batch) |id| { return id; } else { var shader = sshader; if (p.force_shader) |shaa| { shader = shaa; } const sh = try p.assetmanager.getShader(shader); const batch = getBatchNoID(mode, sh, texture) catch |err| { if (err == Error.InvalidBatch) { _ = try createBatchNoID(mode, sh, texture); return identifyBatchIDWithNoID(mode, sshader, texture); } else return err; }; return @intCast(usize, batch.id); } return Error.FailedToFindBatch; }
src/alka.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const bindings = @import("bindings.zig"); const c = bindings.c; const Gl = bindings.Gl; const Context = @import("context.zig").Context; // currently using old style opengl for compatability // not that I understand opengl pub const BasicContext = struct { pixel_buffer: PixelBuffer, pub fn init(parent_context: *Context(false)) !BasicContext { try Gl.viewport(.{ 0, 0, 256 * 3, 240 * 3 }); try Gl.enable(.{c.GL_TEXTURE_2D}); try Gl.matrixMode(.{c.GL_PROJECTION}); try Gl.loadIdentity(); var self = BasicContext{ .pixel_buffer = try PixelBuffer.init(parent_context.allocator, 256, 240), }; self.pixel_buffer.scale = 3; return self; } pub fn deinit(self: BasicContext, allocator: *Allocator) void { self.pixel_buffer.deinit(allocator); } pub fn getGamePixelBuffer(self: *BasicContext) *PixelBuffer { return &self.pixel_buffer; } pub fn handleEvent(_: *BasicContext, event: c.SDL_Event) bool { switch (event.type) { c.SDL_KEYUP => switch (event.key.keysym.sym) { c.SDLK_q => return false, else => {}, }, c.SDL_QUIT => return false, else => {}, } return true; } pub fn draw(self: BasicContext) !void { try Gl.pushClientAttrib(.{c.GL_CLIENT_ALL_ATTRIB_BITS}); try Gl.pushMatrix(); try Gl.enableClientState(.{c.GL_VERTEX_ARRAY}); try Gl.enableClientState(.{c.GL_TEXTURE_COORD_ARRAY}); try Gl.loadIdentity(); try Gl.ortho(.{ 0, 256 * 3, 240 * 3, 0, 0, 1 }); try self.pixel_buffer.drawRaw(); try Gl.bindTexture(.{ c.GL_TEXTURE_2D, 0 }); try Gl.disableClientState(.{c.GL_VERTEX_ARRAY}); try Gl.disableClientState(.{c.GL_TEXTURE_COORD_ARRAY}); try Gl.popMatrix(); try Gl.popClientAttrib(); } }; pub const PixelBuffer = struct { pixels: []u32 = null, width: usize, height: usize, scale: usize = 1, texture: c.GLuint, pub fn init(allocator: *Allocator, width: usize, height: usize) !PixelBuffer { var texture: c.GLuint = undefined; try Gl.genTextures(.{ 1, &texture }); try Gl.bindTexture(.{ c.GL_TEXTURE_2D, texture }); try Gl.texParameteri(.{ c.GL_TEXTURE_2D, c.GL_TEXTURE_BASE_LEVEL, 0 }); try Gl.texParameteri(.{ c.GL_TEXTURE_2D, c.GL_TEXTURE_MAX_LEVEL, 0 }); try Gl.texParameteri(.{ c.GL_TEXTURE_2D, c.GL_TEXTURE_MAG_FILTER, c.GL_NEAREST }); try Gl.texParameteri(.{ c.GL_TEXTURE_2D, c.GL_TEXTURE_MIN_FILTER, c.GL_NEAREST }); try Gl.bindTexture(.{ c.GL_TEXTURE_2D, 0 }); return PixelBuffer{ .pixels = try allocator.alloc(u32, width * height), .texture = texture, .width = width, .height = height, }; } pub fn deinit(self: PixelBuffer, allocator: *Allocator) void { allocator.free(self.pixels); Gl.deleteTextures(.{ 1, &self.texture }) catch {}; } pub fn putPixel(self: PixelBuffer, x: usize, y: usize, pixel: u32) void { self.pixels[x + y * self.width] = pixel; } /// Copies pixels into internal texture /// Does not call bindTexture, caller must take care of it pub fn copyTextureInternal(self: PixelBuffer) !void { try Gl.texImage2D(.{ c.GL_TEXTURE_2D, 0, c.GL_RGBA8, @intCast(c_int, self.width), @intCast(c_int, self.height), 0, c.GL_RGBA, c.GL_UNSIGNED_INT_8_8_8_8, @ptrCast(*const c_void, self.pixels), }); } /// Draws directly to the current opengl fbo (probably the screen) pub fn drawRaw(self: PixelBuffer) !void { const vertex_positions = [8]c_int{ 0, 0, @intCast(c_int, self.width * self.scale), 0, @intCast(c_int, self.width * self.scale), @intCast(c_int, self.height * self.scale), 0, @intCast(c_int, self.height * self.scale), }; const tex_coords = [8]c_int{ 0, 0, 1, 0, 1, 1, 0, 1, }; try Gl.bindTexture(.{ c.GL_TEXTURE_2D, self.texture }); try self.copyTextureInternal(); try Gl.vertexPointer(.{ 2, c.GL_INT, 0, &vertex_positions }); try Gl.texCoordPointer(.{ 2, c.GL_INT, 0, &tex_coords }); try Gl.drawArrays(.{ c.GL_QUADS, 0, 4 }); try Gl.bindTexture(.{ c.GL_TEXTURE_2D, 0 }); } };
src/sdl/basic_video.zig
// SPDX-License-Identifier: MIT // This file is part of the Termelot project under the MIT license. const std = @import("std"); pub const style = @import("style.zig"); usingnamespace style; pub const event = @import("event.zig"); pub const Backend = @import("backend.zig").backend.Backend; pub const Buffer = @import("buffer.zig").Buffer; pub const Rune = @import("rune.zig").Rune; pub const Config = struct { raw_mode: bool, alternate_screen: bool, }; pub const SupportedFeatures = struct { color_types: struct { Named16: bool, Bit8: bool, Bit24: bool, }, decorations: Decorations, }; pub const Size = packed struct { rows: u16, cols: u16, }; pub const Position = packed struct { row: u16, col: u16, }; pub const Cell = struct { rune: Rune, style: Style, }; pub const Termelot = struct { config: Config, supported_features: SupportedFeatures, allocator: *std.mem.Allocator, key_callbacks: std.ArrayList(event.key.Callback), mouse_callbacks: std.ArrayList(event.mouse.Callback), cursor_position: Position, cursor_visible: bool, screen_size: Size, screen_buffer: Buffer, backend: Backend, const Self = @This(); /// This function should be called *after* declaring a `Termelot` struct: /// var termelot: Termelot = undefined; OR /// var termelot = @as(Termelot, undefined); pub fn init( self: *Self, allocator: *std.mem.Allocator, config: Config, initial_buffer_size: ?Size, ) !void { self.key_callbacks = std.ArrayList(event.key.Callback).init(allocator); errdefer self.key_callbacks.deinit(); self.mouse_callbacks = std.ArrayList(event.mouse.Callback).init(allocator); errdefer self.mouse_callbacks.deinit(); self.backend = try Backend.init(self, allocator, config); errdefer self.backend.deinit(); self.config = config; if (config.raw_mode) { try self.backend.setRawMode(true); } if (config.alternate_screen) { try self.backend.setAlternateScreen(true); } self.supported_features = try self.backend.getSupportedFeatures(); self.cursor_position = try self.backend.getCursorPosition(); self.cursor_visible = try self.backend.getCursorVisibility(); self.screen_size = try self.backend.getScreenSize(); self.screen_buffer = try Buffer.init( &self.backend, allocator, initial_buffer_size, ); errdefer self.screen_buffer.deinit(); try self.backend.start(); } pub fn deinit(self: *Self) void { if (self.config.alternate_screen) { self.backend.setAlternateScreen(false) catch {}; } if (self.config.raw_mode) { self.backend.setRawMode(false) catch {}; } self.backend.stop(); self.screen_buffer.deinit(); self.backend.deinit(); self.key_callbacks.deinit(); self.mouse_callbacks.deinit(); } /// Set the Termelot-aware screen size. This does NOT resize the physical /// terminal screen, and should not be called by users in most cases. This /// is intended for use primarily by the backend. pub fn setScreenSize(self: *Self, screen_size: Size) void { self.screen_size = screen_size; } pub fn callKeyCallbacks(self: Self) void {} pub fn registerKeyCallback( self: *Self, key_callback: event.key.Callback, ) !void { for (self.key_callbacks.items) |callback| { if (std.meta.eql(callback, key_callback)) { return; } } try self.key_callbacks.append(key_callback); } pub fn deregisterKeyCallback( self: *Self, key_callback: event.key.Callback, ) void { var remove_index: usize = self.key_callbacks.items.len; for (self.key_callbacks.items) |callback, index| { if (std.meta.eql(callback, key_callback)) { remove_index = index; break; } } if (remove_index < self.key_callbacks.items.len) { _ = self.key_callbacks.orderedRemove(remove_index); } } pub fn callMouseCallbacks(self: Self) void {} pub fn registerMouseCallback( self: *Self, mouse_callback: event.mouse.Callback, ) !void { for (self.mouse_callbacks.items) |callback| { if (std.meta.eql(callback, mouse_callback)) { return; } } try self.mouse_callbacks.append(mouse_callback); } pub fn deregisterMouseCallback( self: *Self, mouse_callback: event.mouse.Callback, ) void { var remove_index: usize = self.mouse_callbacks.items.len; for (self.mouse_callbacks.items) |callback, index| { if (std.meta.eql(callback, mouse_callback)) { remove_index = index; break; } } if (remove_index < self.mouse_callbacks.items.len) { _ = self.mouse_callbacks.orderedRemove(remove_index); } } pub fn setTitle(self: *Self, title: []const Rune) !void { try self.backend.setTitle(title); } pub fn setCursorPosition(self: *Self, position: Position) !void { try self.backend.setCursorPosition(position); self.cursor_position = position; } pub fn setCursorVisibility(self: *Self, visible: bool) !void { try self.backend.setCursorVisibility(visible); self.cursor_visible = visible; } pub fn drawScreen(self: *Self) !void { const orig_cursor_position = self.cursor_position; try self.screen_buffer.draw(self.screen_size); try self.setCursorPosition(orig_cursor_position); } pub fn clearScreen(self: *Self) !void { const orig_cursor_position = self.cursor_position; self.screen_buffer.clear(); try self.setCursorPosition(orig_cursor_position); } pub fn getCell(self: Self, position: Position) ?Cell { return self.screen_buffer.getCell(position); } pub fn getCells( self: Self, position: Position, length: u16, result: *[length]Cell, ) ?u16 { return self.screen_buffer.getCells(position, length, result); } pub fn setCell(self: *Self, position: Position, new_cell: Cell) void { self.screen_buffer.setCell(position, new_cell); } pub fn setCells(self: *Self, position: Position, new_cells: []Cell) void { self.screen_buffer.setCells(position, new_cells); } pub fn fillCells( self: *Self, position: Position, length: u16, new_cell: Cell, ) void { self.screen_buffer.fillCells(position, length, new_cell); } };
src/termelot.zig
const std = @import("std"); const assert = std.debug.assert; pub const Header = extern struct { comptime { assert(@sizeOf(Header) == 128); } /// A checksum covering only the rest of this header starting from `checksum_body`. /// This allows the header to be trusted without having to recv() or read() the associated body. /// This checksum is enough to uniquely identify a network message or journal entry. checksum: u128 = 0, /// A checksum covering only the associated body after this header. checksum_body: u128 = 0, /// A backpointer to the checksum of the previous prepare if this header is for a prepare. hash_chain: u128 = 0, /// The checksum of the message to which this message refers, or a unique recovery nonce: /// We use this nonce in various ways, for example: /// * A prepare sets nonce to the checksum of the request. /// * A reply sets nonce to the checksum of the prepare so client can assert against the request. /// * A prepare_ok sets nonce to the checksum of the prepare it wants to ack. /// * A commit sets nonce to the checksum of the latest committed op. /// This enables cryptographic assertions beyond the request, op, and commit numbers, which may /// otherwise easily collide in the presence of any correctness bugs. nonce: u128 = 0, /// Each client records its own client ID and a current request number. A client is allowed to /// have just one outstanding request at a time. client: u128 = 0, /// Each request is given a number by the client and later requests must have larger numbers /// than earlier ones. The request number is used by the replicas to avoid running requests more /// than once; it is also used by the client to discard duplicate responses to its requests. request: u32 = 0, /// The cluster number binds intention into the header, so that a client or replica can indicate /// which cluster it thinks it's speaking to, instead of accidentally talking to the wrong /// cluster (for example, staging vs production). cluster: u32, /// The cluster reconfiguration epoch number (for future use): epoch: u32 = 0, /// Every message sent from one replica to another contains the sending replica's current view. /// A u32 allows for a minimum lifetime of 136 years at a rate of one view change per second. view: u32 = 0, /// The op number. op: u64 = 0, /// The commit number. commit: u64 = 0, /// The journal offset to which this message relates. /// This enables direct access to a prepare, without requiring previous variable-length entries. /// While we use fixed-size data structures, a batch will contain a variable amount of them. offset: u64 = 0, /// The size of this message header and any associated body. /// This must be 0 for an empty header with command == .reserved. size: u32 = @sizeOf(Header), /// The index of the replica in the cluster configuration array that originated this message. /// This identifies the ultimate author because messages may be forwarded amongst replicas. replica: u8 = 0, /// The Viewstamped Replication protocol command for this message. command: u8, /// The state machine operation to apply. operation: u8 = 0, /// The version of the protocol implementation that originated this message. version: u8 = 0, }; test "size" { std.debug.print("\nHeader={}\n", .{@sizeOf(Header)}); }
docs/header.zig
const std = @import("std"); const vec4 = std.meta.Vector(4, f64); fn vec1to4(f: f64) vec4 { return @splat(4, f); } fn baseIdx(i: vec4) vec4 { @setFloatMode(.Optimized); return i * (i + vec1to4(1)) * vec1to4(0.5) + vec1to4(1); } fn multAvGeneric(comptime transpose: bool, dst: []vec4, src: []const vec4) void { @setFloatMode(.Optimized); const srcVals = std.mem.bytesAsSlice(f64, std.mem.sliceAsBytes(src)); var ti = if (transpose) vec4{ 1, 2, 3, 4 } else vec4{ 0, 1, 2, 3 }; for (dst) |*res| { var idx = if (transpose) baseIdx(ti - vec1to4(1)) else baseIdx(ti) + ti; var sum = vec1to4(0); for (srcVals) |u, j| { sum += vec1to4(u) / idx; idx += ti + vec1to4(@intToFloat(f64, j + 1)); } res.* = sum; ti += vec1to4(4); } } fn multAv(dst: []vec4, src: []const vec4) void { return multAvGeneric(false, dst, src); } fn multAtv(dst: []vec4, src: []const vec4) void { return multAvGeneric(true, dst, src); } fn multAtAv(dest: []vec4, src: []const vec4, temp: []vec4) void { std.debug.assert(dest.len == src.len and src.len == temp.len); multAv(temp, src); multAtv(dest, temp); } fn aggregateResults(u: []const vec4, v: []const vec4) f64 { @setFloatMode(.Optimized); var vbv = vec1to4(0); var vv = vec1to4(0); for (v) |f, i| { vbv += u[i] * f; vv += f * f; } return std.math.sqrt(@reduce(.Add, vbv) / @reduce(.Add, vv)); } pub fn main() !void { const n = try get_n(); const len = n / @typeInfo(vec4).Vector.len; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); var u = try allocator.alloc(vec4, len); defer allocator.free(u); for (u) |*i| i.* = vec1to4(1); var v = try allocator.alloc(vec4, len); defer allocator.free(v); for (v) |*i| i.* = vec1to4(1); var temp = try allocator.alloc(vec4, len); defer allocator.free(temp); const task_count = try std.Thread.getCpuCount(); const tasks = try allocator.alloc(std.Thread, task_count - 1); defer allocator.free(tasks); var times: usize = 0; while (times < 10) : (times += 1) { multAtAv(v, u, temp); multAtAv(u, v, temp); } const res = aggregateResults(u, v); const stdout = std.io.getStdOut().writer(); try stdout.print("{d:.9}\n", .{res}); } fn get_n() !usize { var arg_it = std.process.args(); _ = arg_it.skip(); const arg = arg_it.nextPosix() orelse return 100; return try std.fmt.parseInt(usize, arg, 10); }
bench/algorithm/spectral-norm/2.zig
const std = @import("std"); const mem = std.mem; const fs = std.fs; const math = std.math; const process = std.process; const md = @import("md/markdown.zig").Markdown; const log = @import("md/log.zig"); const webview = @import("webview/webview.zig"); var DEBUG = false; var LOG_LEVEL = log.logger.Level.Error; var LOG_DATESTAMP = true; const Cmd = enum { view, }; /// Translates markdown input_files into html, returns a slice. Caller ows the memory. fn translate(allocator: *mem.Allocator, input_files: *std.ArrayList([]const u8)) ![]const u8 { var str = std.ArrayList(u8).init(allocator); defer str.deinit(); const cwd = fs.cwd(); for (input_files.items) |input_file| { const source = try cwd.readFileAlloc(allocator, input_file, math.maxInt(usize)); // try stdout.print("File: {}\nSource:\n````\n{}````\n", .{ input_file, source }); try md.renderToHtml( allocator, source, str.outStream(), ); } return str.toOwnedSlice(); } pub fn main() anyerror!void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = &arena.allocator; const args = try process.argsAlloc(allocator); var arg_i: usize = 1; var maybe_cmd: ?Cmd = null; var input_files = std.ArrayList([]const u8).init(allocator); log.config(LOG_LEVEL, LOG_DATESTAMP); while (arg_i < args.len) : (arg_i += 1) { const full_arg = args[arg_i]; if (mem.startsWith(u8, full_arg, "--")) { const arg = full_arg[2..]; if (mem.eql(u8, arg, "help")) { try dumpUsage(std.io.getStdOut()); return; } else if (mem.eql(u8, arg, "debug")) { DEBUG = true; LOG_LEVEL = log.logger.Level.Debug; log.config(LOG_LEVEL, LOG_DATESTAMP); } else { log.Errorf("Invalid parameter: {}\n", .{full_arg}); dumpStdErrUsageAndExit(); } } else if (mem.startsWith(u8, full_arg, "-")) { const arg = full_arg[1..]; if (mem.eql(u8, arg, "h")) { try dumpUsage(std.io.getStdOut()); return; } } else { inline for (std.meta.fields(Cmd)) |field| { log.Debugf("full_arg: {} field: {}\n", .{ full_arg, field }); if (mem.eql(u8, full_arg, field.name)) { maybe_cmd = @field(Cmd, field.name); log.Infof("Have command: {}\n", .{field.name}); break; // } else { // std.debug.warn("Invalid command: {}\n", .{full_arg}); // dumpStdErrUsageAndExit(); // } } else { _ = try input_files.append(full_arg); } } } } if (args.len <= 1) { log.Error("No arguments given!\n"); dumpStdErrUsageAndExit(); } if (input_files.items.len == 0) { log.Error("No input files were given!\n"); dumpStdErrUsageAndExit(); } var html = try std.ArrayListSentineled(u8, 0).init(allocator, ""); defer html.deinit(); const translated: []const u8 = try translate(allocator, &input_files); defer allocator.free(translated); const yava_script = \\ window.onload = function() { \\ }; ; try std.fmt.format(html.outStream(), \\ data:text/html, \\ <!doctype html> \\ <html> \\ <body> \\ {} \\ </body> \\ <script> \\ {} \\ </script> \\ </html> , .{ translated, yava_script }); const final_doc = mem.span(@ptrCast([*c]const u8, html.span())); log.Debugf("final_doc: {} type: {}\n", .{ final_doc, @typeInfo(@TypeOf(final_doc)) }); if (maybe_cmd) |cmd| { switch (cmd) { .view => { var handle = webview.webview_create(1, null); webview.webview_set_size(handle, 1240, 1400, webview.WEBVIEW_HINT_MIN); webview.webview_set_title(handle, "Zig Markdown Viewer"); webview.webview_navigate(handle, final_doc); webview.webview_run(handle); return; }, else => {}, } } } fn dumpStdErrUsageAndExit() noreturn { dumpUsage(std.io.getStdErr()) catch {}; process.exit(1); } fn dumpUsage(file: fs.File) !void { _ = try file.write( \\Usage: mdcf [command] [options] <input> \\ \\If no commands are specified, the html translated markdown is dumped to stdout. \\ \\Commands: \\ view Show the translated markdown in webview. \\ \\Options: \\ -h, --help Dump this help text to stdout. \\ --debug Show debug output. \\ ); }
src/main.zig
const reduce = @import("./reduce.zig"); const bs = @import("./bitstream.zig"); const hamlet = @embedFile("../fixtures/hamlet.txt"); const std = @import("std"); const allocator = std.testing.allocator; const assert = std.debug.assert; const expect = std.testing.expect; const mem = std.mem; // // $ curl -O http://cd.textfiles.com/originalsw/25/pkz092.exe // $ dosbox -c "mount c ." -c "c:" -c "pkz092" -c "exit" // $ dd if=hamlet.txt of=a bs=1 count=2K // $ dosbox -c "mount c ." -c "c:" -c "pkzip -ea4 a.zip a" -c "exit" // $ xxd -i -s 31 -l $(expr $(find A.ZIP -printf %s) - 100) A.ZIP // const hamlet_2048: [1285]u8 = [_]u8{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x58, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x0f, 0x06, 0x11, 0x31, 0x21, 0x1f, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x99, 0x00, 0x00, 0x00, 0x00, 0x20, 0x80, 0xbc, 0x01, 0xc4, 0x5d, 0x1a, 0x5a, 0x98, 0x50, 0x06, 0x49, 0xcc, 0xb9, 0xd1, 0x91, 0x11, 0x65, 0x20, 0x68, 0x73, 0x04, 0x08, 0x24, 0x5d, 0x19, 0x51, 0x06, 0x02, 0x99, 0x06, 0x08, 0x6c, 0x61, 0x84, 0x9c, 0x5b, 0x1d, 0x1d, 0x02, 0xf9, 0x76, 0x46, 0x36, 0x46, 0x57, 0x96, 0x26, 0x40, 0x86, 0x11, 0x65, 0x61, 0x90, 0x6c, 0x00, 0x40, 0xb8, 0xd1, 0xcd, 0xd5, 0x09, 0x61, 0x65, 0x02, 0x64, 0x9d, 0xf0, 0x06, 0x42, 0x40, 0xca, 0xb9, 0x81, 0x10, 0x20, 0x90, 0x69, 0x65, 0x04, 0x24, 0xdd, 0x1b, 0x9a, 0x50, 0xa6, 0x4e, 0xc8, 0xd1, 0xb9, 0xcd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xe9, 0x22, 0x50, 0x11, 0x11, 0x20, 0x68, 0x52, 0x49, 0x80, 0x40, 0x15, 0x04, 0x00, 0x80, 0xf0, 0x26, 0x04, 0x08, 0x61, 0x41, 0x02, 0x24, 0x08, 0x00, 0x08, 0x4f, 0x45, 0x00, 0x20, 0x48, 0x39, 0x09, 0x61, 0x45, 0x02, 0x1a, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x02, 0xa4, 0x1b, 0x00, 0x00, 0x80, 0x00, 0xd2, 0x00, 0x08, 0x20, 0x90, 0x80, 0xa0, 0x22, 0x0e, 0x00, 0x01, 0x24, 0x00, 0x00, 0x00, 0x00, 0x20, 0x77, 0x61, 0x53, 0x6f, 0x50, 0x45, 0x90, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x28, 0x00, 0x80, 0x00, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xbb, 0xbf, 0x0d, 0x28, 0xf7, 0xad, 0x5a, 0xd9, 0x31, 0xe9, 0x51, 0x1d, 0xc1, 0x62, 0xe8, 0x59, 0x10, 0x2d, 0xf4, 0xf6, 0xed, 0x1a, 0x88, 0x35, 0x33, 0xd2, 0xb0, 0x6d, 0xd9, 0x90, 0x2e, 0x0b, 0xc5, 0xe6, 0xf1, 0x2a, 0x2d, 0x9b, 0xa7, 0x0d, 0xdb, 0x16, 0x84, 0xd0, 0xb8, 0x56, 0x76, 0x2e, 0xdc, 0xb2, 0x61, 0xc0, 0x06, 0x36, 0x90, 0x4a, 0xd3, 0x88, 0x65, 0xf0, 0x97, 0x34, 0xa2, 0x19, 0x50, 0x3a, 0xea, 0x75, 0x30, 0xc0, 0x27, 0x8c, 0xf3, 0x14, 0x03, 0x0c, 0xee, 0xa8, 0xe0, 0x69, 0x00, 0xef, 0xa8, 0xea, 0xe6, 0x42, 0x32, 0x10, 0xdd, 0x30, 0xe1, 0x1c, 0x84, 0xb6, 0x81, 0x6d, 0xdf, 0xce, 0x51, 0x66, 0x2a, 0xb9, 0x48, 0x67, 0x01, 0x1f, 0x24, 0x20, 0xbd, 0xfb, 0x86, 0x6c, 0xc9, 0x20, 0x52, 0x37, 0x09, 0x72, 0x0c, 0x30, 0x12, 0x46, 0x03, 0x48, 0x0c, 0x22, 0xd9, 0xe8, 0x33, 0xca, 0x06, 0xca, 0xe1, 0x1c, 0xcb, 0xf9, 0x98, 0xa6, 0x7d, 0xd3, 0x39, 0x00, 0x91, 0xbf, 0x2d, 0x6b, 0x87, 0xba, 0x10, 0x64, 0xd6, 0x1b, 0x83, 0x6c, 0x73, 0x1e, 0xc7, 0x18, 0x6e, 0x1e, 0xd3, 0x94, 0x85, 0x67, 0xd3, 0xda, 0xe1, 0x69, 0x92, 0xbc, 0xf3, 0x3c, 0x0c, 0x2a, 0x87, 0x2d, 0x90, 0xb0, 0x9a, 0xa6, 0x0d, 0xac, 0x93, 0x19, 0x07, 0x7a, 0xe9, 0xa0, 0x6d, 0x50, 0x20, 0x24, 0x03, 0x74, 0x30, 0x4d, 0x3b, 0xb6, 0x8c, 0x00, 0x34, 0x6e, 0x98, 0x6d, 0x9d, 0x8d, 0x04, 0x8f, 0x74, 0x9c, 0xc6, 0x0d, 0x70, 0x22, 0xe1, 0x0d, 0x32, 0x65, 0x9b, 0x16, 0x12, 0xf4, 0xe9, 0x04, 0x40, 0x97, 0x67, 0xac, 0xd0, 0x72, 0xf9, 0x86, 0x67, 0x5d, 0x08, 0x32, 0xc9, 0xcc, 0x79, 0x32, 0x88, 0x00, 0xee, 0x26, 0x56, 0xb6, 0x6f, 0xc7, 0x86, 0x85, 0xb4, 0x08, 0xc8, 0x13, 0x1f, 0x0d, 0x50, 0x03, 0x24, 0x8b, 0xa0, 0x22, 0xb0, 0x39, 0x48, 0x34, 0xda, 0xe1, 0x74, 0xdf, 0x82, 0x1c, 0xb3, 0xc7, 0xae, 0x41, 0x96, 0x40, 0xcb, 0xa6, 0x77, 0x21, 0x5b, 0xac, 0x8c, 0x91, 0xd2, 0x72, 0xf3, 0xe0, 0x13, 0x6b, 0x79, 0x72, 0x03, 0x00, 0x18, 0xe4, 0x02, 0x2e, 0x31, 0x9a, 0x01, 0x9a, 0x66, 0x1a, 0x08, 0x6f, 0x05, 0x59, 0x56, 0xec, 0xdb, 0xb7, 0x6b, 0x2e, 0x21, 0xad, 0x18, 0xb2, 0x44, 0x72, 0x9a, 0xb2, 0xa1, 0x8e, 0x29, 0xe4, 0x21, 0x4d, 0x3b, 0xa8, 0x8e, 0xfc, 0x86, 0x3a, 0xb2, 0x41, 0xbe, 0xd4, 0xb2, 0x6c, 0x18, 0x66, 0x3b, 0x11, 0x42, 0x1d, 0x3a, 0xd1, 0x8e, 0x6d, 0xc5, 0x90, 0xc6, 0xe4, 0xe4, 0xe0, 0x80, 0xdc, 0x82, 0x3c, 0x12, 0x34, 0x12, 0x53, 0x23, 0x43, 0xd3, 0xd5, 0x40, 0x26, 0x4c, 0xad, 0x0a, 0x97, 0x4c, 0x40, 0xae, 0x03, 0x95, 0x85, 0x4b, 0x17, 0xf2, 0xc0, 0xca, 0x4c, 0x18, 0x16, 0xca, 0xc0, 0xc4, 0xe4, 0x40, 0x2a, 0x52, 0x26, 0x48, 0x0e, 0x7b, 0xb6, 0xac, 0x0e, 0xda, 0x8d, 0xb2, 0x4d, 0x63, 0xb4, 0x90, 0xda, 0x35, 0x04, 0x18, 0x76, 0x4c, 0x90, 0xce, 0x39, 0x9d, 0x96, 0x11, 0x99, 0x8c, 0xa0, 0x3a, 0xac, 0xa2, 0x51, 0x0b, 0x0e, 0xa4, 0xfa, 0xa9, 0x40, 0x10, 0xa2, 0x1a, 0x24, 0x05, 0x3e, 0x19, 0x81, 0xa4, 0x8a, 0x34, 0x69, 0x0a, 0x04, 0xa5, 0x3e, 0x29, 0x15, 0x1d, 0x12, 0x8f, 0xaa, 0x58, 0xa4, 0x45, 0x3c, 0x02, 0xd1, 0x42, 0x4f, 0x4f, 0x4b, 0x46, 0x1a, 0xd4, 0xc4, 0xb4, 0x28, 0x15, 0xaa, 0x40, 0x48, 0x82, 0x87, 0x2c, 0xa2, 0x4b, 0x87, 0x78, 0x74, 0x02, 0x1b, 0x5e, 0x0e, 0xe1, 0x04, 0x0d, 0x25, 0x8f, 0x44, 0xd3, 0x86, 0xb1, 0x1b, 0xbb, 0x50, 0xd9, 0x30, 0x42, 0x8a, 0x0f, 0xaa, 0x48, 0x06, 0x49, 0x45, 0x8f, 0x8a, 0x12, 0xcd, 0x82, 0x04, 0x35, 0xc8, 0x03, 0x4d, 0x2c, 0xa0, 0xd4, 0x24, 0xa7, 0x43, 0x8b, 0x42, 0x02, 0x1f, 0x91, 0x6e, 0x0a, 0x92, 0xba, 0xc4, 0x8a, 0xa6, 0x06, 0xf8, 0x83, 0x30, 0xc3, 0x83, 0x91, 0xa1, 0x6f, 0x52, 0x50, 0xad, 0x12, 0x6e, 0x87, 0xc4, 0xa4, 0x06, 0x4e, 0x8d, 0x2d, 0x23, 0x7b, 0x92, 0x0b, 0x9a, 0xed, 0xdc, 0x34, 0x08, 0xd0, 0x85, 0x41, 0x20, 0x8e, 0xd4, 0x0c, 0x6c, 0x63, 0x05, 0x31, 0x24, 0x8e, 0x1d, 0x1a, 0x66, 0x66, 0x43, 0x97, 0x90, 0x14, 0x03, 0x99, 0x41, 0x46, 0xee, 0xdb, 0xb7, 0x6d, 0xa0, 0xf0, 0x9c, 0xb0, 0x0c, 0x6b, 0xf2, 0x42, 0x1e, 0x98, 0xe1, 0x81, 0x4c, 0x12, 0x24, 0xa5, 0xa4, 0x21, 0x08, 0xbe, 0x65, 0xfb, 0x26, 0x37, 0x8a, 0xc3, 0x1c, 0xa2, 0x7d, 0x23, 0x14, 0x81, 0xcb, 0x4a, 0x52, 0x49, 0xd0, 0x21, 0x24, 0xd5, 0xb5, 0x02, 0x3a, 0xdb, 0xd0, 0x2b, 0x39, 0x6c, 0xfb, 0x66, 0xa0, 0x4c, 0x2f, 0xe4, 0x1a, 0x5e, 0x48, 0x0a, 0x85, 0x4c, 0xc0, 0x0d, 0x39, 0xa1, 0x1b, 0x52, 0x28, 0xec, 0xac, 0xf0, 0x13, 0x52, 0x06, 0xa4, 0x42, 0x0a, 0xc1, 0x14, 0x24, 0x17, 0x7c, 0x04, 0x81, 0x44, 0x23, 0x9b, 0x29, 0x07, 0x20, 0x2c, 0x0f, 0x42, 0x90, 0xd0, 0xee, 0x06, 0x87, 0x96, 0x42, 0x8a, 0x42, 0x4a, 0x2b, 0x64, 0x63, 0x12, 0x52, 0x14, 0x84, 0x9c, 0x71, 0x0a, 0x29, 0x11, 0x27, 0x94, 0x68, 0x84, 0x43, 0xd3, 0x00, 0xa3, 0xd4, 0x88, 0x96, 0x71, 0x9b, 0x20, 0x82, 0x43, 0xb6, 0x58, 0x85, 0xec, 0x02, 0x33, 0xc1, 0x8a, 0x15, 0x42, 0x71, 0x69, 0x85, 0x3c, 0xfc, 0x42, 0x1e, 0xa9, 0x86, 0xbc, 0xf1, 0x30, 0xe6, 0x75, 0xe5, 0x8e, 0x79, 0xde, 0x30, 0x24, 0x13, 0x4b, 0x6c, 0x42, 0x0e, 0x3b, 0x96, 0xa8, 0xdc, 0xb0, 0x6d, 0x6a, 0x1a, 0x81, 0x65, 0x3a, 0xf7, 0x4d, 0x87, 0x4d, 0x21, 0x87, 0xc5, 0x83, 0x6c, 0x13, 0x28, 0x67, 0x20, 0x8a, 0x6d, 0xe3, 0xc1, 0xfb, 0x50, 0x26, 0xab, 0x9c, 0x54, 0x75, 0x8a, 0x85, 0x4b, 0x0c, 0x62, 0x87, 0x7c, 0xb0, 0xc1, 0x62, 0xb2, 0xd1, 0x90, 0x45, 0xc4, 0x15, 0xa2, 0xcc, 0x0f, 0xa4, 0x62, 0x1f, 0x21, 0x31, 0x45, 0x15, 0x72, 0x59, 0xba, 0x6c, 0xc4, 0x98, 0xb5, 0x34, 0x10, 0x15, 0xba, 0x34, 0x1b, 0x16, 0x72, 0x58, 0x4f, 0x17, 0x79, 0x54, 0x04, 0x5c, 0xa5, 0x59, 0x2c, 0x66, 0x54, 0xdd, 0xb2, 0x65, 0x84, 0x0a, 0xaf, 0xda, 0x28, 0xf6, 0x98, 0x85, 0x6e, 0xf2, 0x2e, 0x08, 0xa8, 0x59, 0xc8, 0x72, 0x13, 0x86, 0xb2, 0x69, 0x9d, 0x69, 0x74, 0x11, 0x9f, 0x98, 0x3e, 0x39, 0x85, 0x74, 0x4e, 0xa6, 0x6f, 0x48, 0x86, 0x43, 0x10, 0x72, 0xd4, 0x0d, 0xa4, 0xd1, 0xba, 0x48, 0x26, 0x8b, 0x60, 0xd1, 0x29, 0x16, 0xe8, 0x4d, 0x30, 0x2a, 0x1d, 0x72, 0xcd, 0xa4, 0x8b, 0x7c, 0x82, 0x42, 0x32, 0xd3, 0xa4, 0x20, 0x16, 0x12, 0xb1, 0xee, 0x59, 0xb4, 0x90, 0xa3, 0x26, 0x20, 0x2f, 0x7c, 0x20, 0x21, 0x25, 0x95, 0x9f, 0x58, 0x68, 0x24, 0xe7, 0x65, 0x34, 0x0d, 0x7b, 0xc2, 0xb9, 0xbe, 0x2e, 0xd2, 0xe8, 0x49, 0x0a, 0x3b, 0x29, 0xe5, 0x14, 0xe4, 0x0c, 0x18, 0x27, 0x00, }; test "expand_hamlet2048" { var dst: [2048]u8 = undefined; var src_used: usize = 0; try expect(reduce.hwexpand( &hamlet_2048, hamlet_2048.len, 2048, 4, &src_used, &dst, ) == reduce.expand_stat_t.HWEXPAND_OK); try expect(src_used == hamlet_2048.len); try expect(mem.eql(u8, dst[0..2048], hamlet[0..2048])); } // // Put some text first to make PKZIP actually use Reduce compression. // Target the code path which copies a zero when dist > current position. // // $ curl -O http://cd.textfiles.com/originalsw/25/pkz092.exe // $ dosbox -c "mount c ." -c "c:" -c "pkz092" -c "exit" // $ dd if=hamlet.txt bs=1 count=2048 > a // $ dd if=/dev/zero bs=1 count=1024 >> a // $ dosbox -c "mount c ." -c "c:" -c "pkzip -ea4 a.zip a" -c "exit" // $ xxd -i -s 31 -l $(expr $(find A.ZIP -printf %s) - 100) A.ZIP // const zeros_reduced = [_]u8{ 0xc2, 0x3f, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x58, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x0f, 0x06, 0x11, 0x31, 0x21, 0x1f, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x99, 0x00, 0x00, 0x00, 0x00, 0x20, 0x80, 0xbc, 0x01, 0xc4, 0x5d, 0x1a, 0x5a, 0x98, 0x50, 0x06, 0x49, 0xcc, 0xb9, 0xd1, 0x91, 0x11, 0x65, 0x20, 0x68, 0x73, 0x04, 0x08, 0x24, 0x5d, 0x19, 0x51, 0x06, 0x02, 0x99, 0x06, 0x08, 0x6c, 0x61, 0x84, 0x9c, 0x5b, 0x1d, 0x1d, 0x02, 0xf9, 0x76, 0x46, 0x36, 0x46, 0x57, 0x96, 0x26, 0x40, 0x86, 0x11, 0x65, 0x61, 0x90, 0x6c, 0x00, 0x40, 0xb8, 0xd1, 0xcd, 0xd5, 0x09, 0x61, 0x65, 0x02, 0x64, 0x9d, 0xf0, 0x06, 0x42, 0x40, 0xca, 0xb9, 0x81, 0x10, 0x20, 0x90, 0x69, 0x65, 0x04, 0x24, 0xdd, 0x1b, 0x9a, 0x50, 0xa6, 0x4e, 0xc8, 0xd1, 0xb9, 0xcd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xe9, 0x22, 0x50, 0x11, 0x11, 0x20, 0x68, 0x52, 0x49, 0x80, 0x40, 0x15, 0x04, 0x00, 0x80, 0xf0, 0x26, 0x04, 0x08, 0x61, 0x41, 0x02, 0x24, 0x08, 0x00, 0x08, 0x4f, 0x45, 0x00, 0x20, 0x48, 0x39, 0x09, 0x61, 0x45, 0x02, 0x1a, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x02, 0xa4, 0x1b, 0x00, 0x00, 0x80, 0x00, 0xd2, 0x00, 0x08, 0x20, 0x90, 0x80, 0xa0, 0x22, 0x0e, 0x00, 0x01, 0x24, 0x00, 0x00, 0x00, 0x00, 0x20, 0x77, 0x61, 0x53, 0x6f, 0x50, 0x45, 0x90, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x28, 0x00, 0x80, 0x00, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xbb, 0xbf, 0x0d, 0x28, 0xf7, 0xad, 0x5a, 0xd9, 0x31, 0xe9, 0x51, 0x1d, 0xc1, 0x62, 0xe8, 0x59, 0x10, 0x2d, 0xf4, 0xf6, 0xed, 0x1a, 0x88, 0x35, 0x33, 0xd2, 0xb0, 0x6d, 0xd9, 0x90, 0x2e, 0x0b, 0xc5, 0xe6, 0xf1, 0x2a, 0x2d, 0x9b, 0xa7, 0x0d, 0xdb, 0x16, 0x84, 0xd0, 0xb8, 0x56, 0x76, 0x2e, 0xdc, 0xb2, 0x61, 0xc0, 0x06, 0x36, 0x90, 0x4a, 0xd3, 0x88, 0x65, 0xf0, 0x97, 0x34, 0xa2, 0x19, 0x50, 0x3a, 0xea, 0x75, 0x30, 0xc0, 0x27, 0x8c, 0xf3, 0x14, 0x03, 0x0c, 0xee, 0xa8, 0xe0, 0x69, 0x00, 0xef, 0xa8, 0xea, 0xe6, 0x42, 0x32, 0x10, 0xdd, 0x30, 0xe1, 0x1c, 0x84, 0xb6, 0x81, 0x6d, 0xdf, 0xce, 0x51, 0x66, 0x2a, 0xb9, 0x48, 0x67, 0x01, 0x1f, 0x24, 0x20, 0xbd, 0xfb, 0x86, 0x6c, 0xc9, 0x20, 0x52, 0x37, 0x09, 0x72, 0x0c, 0x30, 0x12, 0x46, 0x03, 0x48, 0x0c, 0x22, 0xd9, 0xe8, 0x33, 0xca, 0x06, 0xca, 0xe1, 0x1c, 0xcb, 0xf9, 0x98, 0xa6, 0x7d, 0xd3, 0x39, 0x00, 0x91, 0xbf, 0x2d, 0x6b, 0x87, 0xba, 0x10, 0x64, 0xd6, 0x1b, 0x83, 0x6c, 0x73, 0x1e, 0xc7, 0x18, 0x6e, 0x1e, 0xd3, 0x94, 0x85, 0x67, 0xd3, 0xda, 0xe1, 0x69, 0x92, 0xbc, 0xf3, 0x3c, 0x0c, 0x2a, 0x87, 0x2d, 0x90, 0xb0, 0x9a, 0xa6, 0x0d, 0xac, 0x93, 0x19, 0x07, 0x7a, 0xe9, 0xa0, 0x6d, 0x50, 0x20, 0x24, 0x03, 0x74, 0x30, 0x4d, 0x3b, 0xb6, 0x8c, 0x00, 0x34, 0x6e, 0x98, 0x6d, 0x9d, 0x8d, 0x04, 0x8f, 0x74, 0x9c, 0xc6, 0x0d, 0x70, 0x22, 0xe1, 0x0d, 0x32, 0x65, 0x9b, 0x16, 0x12, 0xf4, 0xe9, 0x04, 0x40, 0x97, 0x67, 0xac, 0xd0, 0x72, 0xf9, 0x86, 0x67, 0x5d, 0x08, 0x32, 0xc9, 0xcc, 0x79, 0x32, 0x88, 0x00, 0xee, 0x26, 0x56, 0xb6, 0x6f, 0xc7, 0x86, 0x85, 0xb4, 0x08, 0xc8, 0x13, 0x1f, 0x0d, 0x50, 0x03, 0x24, 0x8b, 0xa0, 0x22, 0xb0, 0x39, 0x48, 0x34, 0xda, 0xe1, 0x74, 0xdf, 0x82, 0x1c, 0xb3, 0xc7, 0xae, 0x41, 0x96, 0x40, 0xcb, 0xa6, 0x77, 0x21, 0x5b, 0xac, 0x8c, 0x91, 0xd2, 0x72, 0xf3, 0xe0, 0x13, 0x6b, 0x79, 0x72, 0x03, 0x00, 0x18, 0xe4, 0x02, 0x2e, 0x31, 0x9a, 0x01, 0x9a, 0x66, 0x1a, 0x08, 0x6f, 0x05, 0x59, 0x56, 0xec, 0xdb, 0xb7, 0x6b, 0x2e, 0x21, 0xad, 0x18, 0xb2, 0x44, 0x72, 0x9a, 0xb2, 0xa1, 0x8e, 0x29, 0xe4, 0x21, 0x4d, 0x3b, 0xa8, 0x8e, 0xfc, 0x86, 0x3a, 0xb2, 0x41, 0xbe, 0xd4, 0xb2, 0x6c, 0x18, 0x66, 0x3b, 0x11, 0x42, 0x1d, 0x3a, 0xd1, 0x8e, 0x6d, 0xc5, 0x90, 0xc6, 0xe4, 0xe4, 0xe0, 0x80, 0xdc, 0x82, 0x3c, 0x12, 0x34, 0x12, 0x53, 0x23, 0x43, 0xd3, 0xd5, 0x40, 0x26, 0x4c, 0xad, 0x0a, 0x97, 0x4c, 0x40, 0xae, 0x03, 0x95, 0x85, 0x4b, 0x17, 0xf2, 0xc0, 0xca, 0x4c, 0x18, 0x16, 0xca, 0xc0, 0xc4, 0xe4, 0x40, 0x2a, 0x52, 0x26, 0x48, 0x0e, 0x7b, 0xb6, 0xac, 0x0e, 0xda, 0x8d, 0xb2, 0x4d, 0x63, 0xb4, 0x90, 0xda, 0x35, 0x04, 0x18, 0x76, 0x4c, 0x90, 0xce, 0x39, 0x9d, 0x96, 0x11, 0x99, 0x8c, 0xa0, 0x3a, 0xac, 0xa2, 0x51, 0x0b, 0x0e, 0xa4, 0xfa, 0xa9, 0x40, 0x10, 0xa2, 0x1a, 0x24, 0x05, 0x3e, 0x19, 0x81, 0xa4, 0x8a, 0x34, 0x69, 0x0a, 0x04, 0xa5, 0x3e, 0x29, 0x15, 0x1d, 0x12, 0x8f, 0xaa, 0x58, 0xa4, 0x45, 0x3c, 0x02, 0xd1, 0x42, 0x4f, 0x4f, 0x4b, 0x46, 0x1a, 0xd4, 0xc4, 0xb4, 0x28, 0x15, 0xaa, 0x40, 0x48, 0x82, 0x87, 0x2c, 0xa2, 0x4b, 0x87, 0x78, 0x74, 0x02, 0x1b, 0x5e, 0x0e, 0xe1, 0x04, 0x0d, 0x25, 0x8f, 0x44, 0xd3, 0x86, 0xb1, 0x1b, 0xbb, 0x50, 0xd9, 0x30, 0x42, 0x8a, 0x0f, 0xaa, 0x48, 0x06, 0x49, 0x45, 0x8f, 0x8a, 0x12, 0xcd, 0x82, 0x04, 0x35, 0xc8, 0x03, 0x4d, 0x2c, 0xa0, 0xd4, 0x24, 0xa7, 0x43, 0x8b, 0x42, 0x02, 0x1f, 0x91, 0x6e, 0x0a, 0x92, 0xba, 0xc4, 0x8a, 0xa6, 0x06, 0xf8, 0x83, 0x30, 0xc3, 0x83, 0x91, 0xa1, 0x6f, 0x52, 0x50, 0xad, 0x12, 0x6e, 0x87, 0xc4, 0xa4, 0x06, 0x4e, 0x8d, 0x2d, 0x23, 0x7b, 0x92, 0x0b, 0x9a, 0xed, 0xdc, 0x34, 0x08, 0xd0, 0x85, 0x41, 0x20, 0x8e, 0xd4, 0x0c, 0x6c, 0x63, 0x05, 0x31, 0x24, 0x8e, 0x1d, 0x1a, 0x66, 0x66, 0x43, 0x97, 0x90, 0x14, 0x03, 0x99, 0x41, 0x46, 0xee, 0xdb, 0xb7, 0x6d, 0xa0, 0xf0, 0x9c, 0xb0, 0x0c, 0x6b, 0xf2, 0x42, 0x1e, 0x98, 0xe1, 0x81, 0x4c, 0x12, 0x24, 0xa5, 0xa4, 0x21, 0x08, 0xbe, 0x65, 0xfb, 0x26, 0x37, 0x8a, 0xc3, 0x1c, 0xa2, 0x7d, 0x23, 0x14, 0x81, 0xcb, 0x4a, 0x52, 0x49, 0xd0, 0x21, 0x24, 0xd5, 0xb5, 0x02, 0x3a, 0xdb, 0xd0, 0x2b, 0x39, 0x6c, 0xfb, 0x66, 0xa0, 0x4c, 0x2f, 0xe4, 0x1a, 0x5e, 0x48, 0x0a, 0x85, 0x4c, 0xc0, 0x0d, 0x39, 0xa1, 0x1b, 0x52, 0x28, 0xec, 0xac, 0xf0, 0x13, 0x52, 0x06, 0xa4, 0x42, 0x0a, 0xc1, 0x14, 0x24, 0x17, 0x7c, 0x04, 0x81, 0x44, 0x23, 0x9b, 0x29, 0x07, 0x20, 0x2c, 0x0f, 0x42, 0x90, 0xd0, 0xee, 0x06, 0x87, 0x96, 0x42, 0x8a, 0x42, 0x4a, 0x2b, 0x64, 0x63, 0x12, 0x52, 0x14, 0x84, 0x9c, 0x71, 0x0a, 0x29, 0x11, 0x27, 0x94, 0x68, 0x84, 0x43, 0xd3, 0x00, 0xa3, 0xd4, 0x88, 0x96, 0x71, 0x9b, 0x20, 0x82, 0x43, 0xb6, 0x58, 0x85, 0xec, 0x02, 0x33, 0xc1, 0x8a, 0x15, 0x42, 0x71, 0x69, 0x85, 0x3c, 0xfc, 0x42, 0x1e, 0xa9, 0x86, 0xbc, 0xf1, 0x30, 0xe6, 0x75, 0xe5, 0x8e, 0x79, 0xde, 0x30, 0x24, 0x13, 0x4b, 0x6c, 0x42, 0x0e, 0x3b, 0x96, 0xa8, 0xdc, 0xb0, 0x6d, 0x6a, 0x1a, 0x81, 0x65, 0x3a, 0xf7, 0x4d, 0x87, 0x4d, 0x21, 0x87, 0xc5, 0x83, 0x6c, 0x13, 0x28, 0x67, 0x20, 0x8a, 0x6d, 0xe3, 0xc1, 0xfb, 0x50, 0x26, 0xab, 0x9c, 0x54, 0x75, 0x8a, 0x85, 0x4b, 0x0c, 0x62, 0x87, 0x7c, 0xb0, 0xc1, 0x62, 0xb2, 0xd1, 0x90, 0x45, 0xc4, 0x15, 0xa2, 0xcc, 0x0f, 0xa4, 0x62, 0x1f, 0x21, 0x31, 0x45, 0x15, 0x72, 0x59, 0xba, 0x6c, 0xc4, 0x98, 0xb5, 0x34, 0x10, 0x15, 0xba, 0x34, 0x1b, 0x16, 0x72, 0x58, 0x4f, 0x17, 0x79, 0x54, 0x04, 0x5c, 0xa5, 0x59, 0x2c, 0x66, 0x54, 0xdd, 0xb2, 0x65, 0x84, 0x0a, 0xaf, 0xda, 0x28, 0xf6, 0x98, 0x85, 0x6e, 0xf2, 0x2e, 0x08, 0xa8, 0x59, 0xc8, 0x72, 0x13, 0x86, 0xb2, 0x69, 0x9d, 0x69, 0x74, 0x11, 0x9f, 0x98, 0x3e, 0x39, 0x85, 0x74, 0x4e, 0xa6, 0x6f, 0x48, 0x86, 0x43, 0x10, 0x72, 0xd4, 0x0d, 0xa4, 0xd1, 0xba, 0x48, 0x26, 0x8b, 0x60, 0xd1, 0x29, 0x16, 0xe8, 0x4d, 0x30, 0x2a, 0x1d, 0x72, 0xcd, 0xa4, 0x8b, 0x7c, 0x82, 0x42, 0x32, 0xd3, 0xa4, 0x20, 0x16, 0x12, 0xb1, 0xee, 0x59, 0xb4, 0x90, 0xa3, 0x26, 0x20, 0x2f, 0x7c, 0x20, 0x21, 0x25, 0x95, 0x9f, 0x58, 0x68, 0x24, 0xe7, 0x65, 0x34, 0x0d, 0x7b, 0xc2, 0xb9, 0xbe, 0x2e, 0xd2, 0xe8, 0x49, 0x0a, 0x3b, 0x29, 0xe5, 0x14, 0xe4, 0x0c, 0x18, 0x27, 0x42, 0xfe, 0x07, 0xff, 0x83, 0xff, 0xc1, 0xff, 0x77, 0xff, 0x01, }; test "expand_zeros" { var dst: [2048 + 1024]u8 = undefined; var src_used: usize = 0; var i: usize = 0; try expect(reduce.hwexpand( &zeros_reduced, zeros_reduced.len, dst.len, 4, &src_used, &dst, ) == reduce.expand_stat_t.HWEXPAND_OK); try expect(src_used == zeros_reduced.len); try expect(mem.eql(u8, dst[0..2048], hamlet[0..2048])); i = 0; while (i < 1024) : (i += 1) { try expect(dst[2048 + i] == 0); } } const DLE_BYTE = 144; test "expand_overlap" { // PKZIP's Reduce does not appear to emit overlapping back references, // so we don't emit them either. However, the spec does seem to allow // them, so be generous in the input we accept. var compressed: [1024]u8 = undefined; var decompressed: [1042]u8 = undefined; var compressed_sz: usize = 0; var comp_used: usize = 0; var os: bs.ostream_t = undefined; var i: usize = 0; bs.ostream_init(&os, &compressed, compressed.len); // Empty follower sets. i = 0; while (i < 256) : (i += 1) { _ = bs.ostream_write(&os, 0, 6); } // "fa-la-l" _ = bs.ostream_write(&os, 'f', 8); _ = bs.ostream_write(&os, 'a', 8); _ = bs.ostream_write(&os, '-', 8); _ = bs.ostream_write(&os, 'l', 8); _ = bs.ostream_write(&os, 'a', 8); _ = bs.ostream_write(&os, '-', 8); _ = bs.ostream_write(&os, 'l', 8); // Backref dist: 6, len: 7 -- "a-la-la" _ = bs.ostream_write(&os, DLE_BYTE, 8); _ = bs.ostream_write(&os, 7 - 3, 8); _ = bs.ostream_write(&os, 6 - 1, 8); // "!" _ = bs.ostream_write(&os, '!', 8); compressed_sz = bs.ostream_bytes_written(&os); try expect(reduce.hwexpand( &compressed, compressed_sz, 15, 4, &comp_used, &decompressed, ) == reduce.expand_stat_t.HWEXPAND_OK); try expect(mem.eql(u8, decompressed[0..15], "fa-la-la-la-la!")); } test "expand_too_short" { var dst: [2048]u8 = undefined; var src_used: usize = 0; var i: usize = 0; // Not enough input. i = 0; while (i < 500) : (i += 1) { assert(i < hamlet_2048.len); try expect(reduce.hwexpand( &hamlet_2048, i, 2048, 4, &src_used, &dst, ) == reduce.expand_stat_t.HWEXPAND_ERR); } } test "expand_too_short2" { // Test not enough input to read the "extra len" byte // in a back reference. var compressed: [1024]u8 = undefined; var decompressed: [1042]u8 = undefined; var compressed_sz: usize = 0; var comp_used: usize = 0; var os: bs.ostream_t = undefined; var i: usize = 0; bs.ostream_init(&os, &compressed, compressed.len); // Empty follower sets. i = 0; while (i < 256) : (i += 1) { _ = bs.ostream_write(&os, 0, 6); } // Some bytes. i = 0; while (i < 30) : (i += 1) { _ = bs.ostream_write(&os, 42, 8); } // Backref; dist: 30, len: 24 _ = bs.ostream_write(&os, DLE_BYTE, 8); _ = bs.ostream_write(&os, 15, 8); // Comp. level 4 => 4 len bits in v. _ = bs.ostream_write(&os, (24 - 3 - 15), 8); // Extra length byte. _ = bs.ostream_write(&os, (30 - 1), 8); // Dist byte. compressed_sz = bs.ostream_bytes_written(&os); try expect(reduce.hwexpand( &compressed, compressed_sz, 54, 4, &comp_used, &decompressed, ) == reduce.expand_stat_t.HWEXPAND_OK); i = 0; while (i < 54) : (i += 1) { try expect(decompressed[i] == 42); } // Not enough input. i = 0; while (i < compressed_sz) : (i += 1) { try expect(reduce.hwexpand( &compressed, i, 54, 4, &comp_used, &decompressed, ) == reduce.expand_stat_t.HWEXPAND_ERR); } // Back reference would yield longer than expected output. try expect(reduce.hwexpand( &compressed, compressed_sz, 54 - 1, 4, &comp_used, &decompressed, ) == reduce.expand_stat_t.HWEXPAND_ERR); } fn roundtrip(src: [*]const u8, src_len: usize, comp_factor: u3) !void { var compressed: [*]u8 = undefined; var uncompressed: [*]u8 = undefined; var compressed_cap: usize = 0; var compressed_size: usize = 0; var compressed_used: usize = 0; assert(comp_factor >= 1 and comp_factor <= 4); compressed_cap = src_len * 2 + 500; var compressed_mem = try allocator.alloc(u8, compressed_cap); compressed = compressed_mem.ptr; var uncompressed_mem = try allocator.alloc(u8, src_len); uncompressed = uncompressed_mem.ptr; try expect(reduce.hwreduce( src, src_len, comp_factor, compressed, compressed_cap, &compressed_size, )); try expect(reduce.hwexpand( compressed, compressed_size, src_len, comp_factor, &compressed_used, uncompressed, ) == reduce.expand_stat_t.HWEXPAND_OK); try expect(compressed_used == compressed_size); try expect(mem.eql(u8, uncompressed[0..src_len], src[0..src_len])); allocator.free(compressed_mem); allocator.free(uncompressed_mem); } test "reduce_roundtrip_empty" { var comp_factor: u3 = 0; const src: [1]u8 = [1]u8{0x00}; comp_factor = 1; while (comp_factor <= 4) : (comp_factor += 1) { try roundtrip( @intToPtr([*]u8, @ptrToInt(&src[0]) + 8), // pointer to outside allowed memory, expecting no one reads it 0, comp_factor, ); } } test "reduce_roundtrip_dle" { const src = [_]u8{144}; var comp_factor: u3 = 0; comp_factor = 1; while (comp_factor <= 4) : (comp_factor += 1) { try roundtrip(&src, src.len, comp_factor); } } test "reduce_roundtrip_hamlet" { var comp_factor: u3 = 0; comp_factor = 1; while (comp_factor <= 4) : (comp_factor += 1) { try roundtrip(hamlet, hamlet.len, comp_factor); } } test "reduce_hamlet_size" { var compressed: [1024 * 512]u8 = undefined; var compressed_sz: usize = 0; // Update the expected sizes if compression improves. // Compression factor 1. try expect(reduce.hwreduce(hamlet, hamlet.len, 1, &compressed, compressed.len, &compressed_sz)); try expect(compressed_sz == 111878); // PKZIP 0.92 -ea1: 111694 // Compression factor 2. try expect(reduce.hwreduce(hamlet, hamlet.len, 2, &compressed, compressed.len, &compressed_sz)); try expect(compressed_sz == 108347); // PKZIP 0.92 -ea2: 108623 // Compression factor 3. try expect(reduce.hwreduce(hamlet, hamlet.len, 3, &compressed, compressed.len, &compressed_sz)); try expect(compressed_sz == 105060); // PKZIP 0.92 -ea3: 106162 // Compression factor 4. try expect(reduce.hwreduce(hamlet, hamlet.len, 4, &compressed, compressed.len, &compressed_sz)); try expect(compressed_sz == 101872); // PKZIP 0.92 -ea4: 102973 } test "reduce_too_short" { var comp_factor: u3 = 4; var compressed: [1024 * 512]u8 = undefined; var compressed_sz: usize = 0; var tmp: usize = 0; var i: usize = 0; // Check trying to compress Hamlet into a destination buffer of various too small sizes. try expect(reduce.hwreduce(hamlet, hamlet.len, comp_factor, &compressed, compressed.len, &compressed_sz)); i = compressed_sz - 100; while (i < compressed_sz) : (i += 1) { try expect(!reduce.hwreduce(hamlet, hamlet.len, comp_factor, &compressed, i, &tmp)); } // Check trying to compress something small, so it fits in the raw bytes // buffer which cannot be flushed due to the too small dst buffer. try expect(reduce.hwreduce("foo", 3, comp_factor, &compressed, compressed.len, &compressed_sz)); i = 0; while (i < compressed_sz) : (i += 1) { try expect(!reduce.hwreduce("foo", 3, comp_factor, &compressed, i, &tmp)); } } test "reduce_implicit_zero_follower" { var compressed: [512]u8 = undefined; var decompressed: [1]u8 = undefined; var compressed_sz: usize = 0; var comp_used: usize = 0; var os: bs.ostream_t = undefined; var i: i32 = 0; bs.ostream_init(&os, &compressed, compressed.len); // Bytes 255--1 have no followers. i = 255; while (i > 0) : (i -= 1) { _ = bs.ostream_write(&os, 0, 6); } // Byte 0 has 1 follower: 'a'. _ = bs.ostream_write(&os, 1, 6); _ = bs.ostream_write(&os, 'a', 8); // LSB-first 0 indicates use follower, 0 is the follower index. _ = bs.ostream_write(&os, 0, 2); compressed_sz = bs.ostream_bytes_written(&os); // Decompression starts with 0 as implicit last byte. Check that using // a follower of that directly works. try expect(reduce.hwexpand( &compressed, compressed_sz, 1, 4, &comp_used, &decompressed, ) == reduce.expand_stat_t.HWEXPAND_OK); try expect(decompressed[0] == 'a'); } test "reduce_bad_follower_index" { var compressed: [512]u8 = undefined; var decompressed: [1]u8 = undefined; var compressed_sz: usize = 0; var comp_used: usize = 0; var os: bs.ostream_t = undefined; var i: u32 = 0; bs.ostream_init(&os, &compressed, compressed.len); // All bytes have one follower: 'x'. i = 0; while (i < 256) : (i += 1) { _ = bs.ostream_write(&os, 1, 6); _ = bs.ostream_write(&os, 'x', 8); } // LSB-first 0 indicates use follower, 1 is the bad follower index. _ = bs.ostream_write(&os, 0x1 << 1, 2); compressed_sz = bs.ostream_bytes_written(&os); // Decompression starts with 0 as implicit last byte. // Should fail due to the too high follower index. try expect(reduce.hwexpand( &compressed, compressed_sz, 1, 4, &comp_used, &decompressed, ) == reduce.expand_stat_t.HWEXPAND_ERR); } test "reduce_max_follower_set_size" { var compressed: [512]u8 = undefined; var decompressed: [1]u8 = undefined; var compressed_sz: usize = 0; var comp_used: usize = 0; var os: bs.ostream_t = undefined; var i: i32 = 0; // Bytes 255--1 have no followers. bs.ostream_init(&os, &compressed, compressed.len); i = 255; while (i > 0) : (i -= 1) { _ = bs.ostream_write(&os, 0, 6); } // Byte 0 has 32 followers. _ = bs.ostream_write(&os, 32, 6); i = 0; while (i < 32) : (i += 1) { _ = bs.ostream_write(&os, @intCast(u8, i), 8); } _ = bs.ostream_write(&os, 0, 1); // Use follower. _ = bs.ostream_write(&os, 31, 5); // Follower idx 31. compressed_sz = bs.ostream_bytes_written(&os); // Decompression starts with 0 as implicit last byte. // Should use the follower. try expect(reduce.hwexpand( &compressed, compressed_sz, 1, 4, &comp_used, &decompressed, ) == reduce.expand_stat_t.HWEXPAND_OK); try expect(decompressed[0] == 31); // Now try having 33 followers. That should fail. // Bytes 255--1 have no followers. bs.ostream_init(&os, &compressed, compressed.len); i = 255; while (i > 0) : (i -= 1) { _ = bs.ostream_write(&os, 0, 6); } // Byte 0 has 33 followers. _ = bs.ostream_write(&os, 33, 6); i = 0; while (i < 33) : (i += 1) { _ = bs.ostream_write(&os, @intCast(u8, i), 8); } compressed_sz = bs.ostream_bytes_written(&os); try expect(reduce.hwexpand( &compressed, compressed_sz, 0, 4, &comp_used, &decompressed, ) == reduce.expand_stat_t.HWEXPAND_ERR); }
src/reduce_test.zig
const std = @import("std"); const thread = @import("./thread.zig"); const allocator = std.heap.c_allocator; const config = @import("./config.zig"); const util = @import("./util.zig"); const warn = std.debug.print; const c = @cImport({ @cInclude("unistd.h"); @cInclude("pthread.h"); @cInclude("curl/curl.h"); }); const NetError = error{ JSONparse, Curl, CurlInit, DNS }; pub fn go(data: ?*anyopaque) callconv(.C) ?*anyopaque { var data8 = @alignCast(@alignOf(thread.Actor), data); var actor = @ptrCast(*thread.Actor, data8); //warn("net thread start {*} {}\n", actor, actor); // setup for the callback var command = allocator.create(thread.Command) catch unreachable; command.id = 1; //var verb = allocator.create(thread.CommandVerb) catch unreachable; command.verb = actor.payload; if (httpget(actor.payload.http)) |body| { //const maxlen = if (body.len > 400) 400 else body.len; warn("net http body len {}\n{}", .{ body.len, actor.payload.http.content_type }); actor.payload.http.body = body; if (body.len > 0 and (actor.payload.http.content_type.len == 0 or std.mem.eql(u8, actor.payload.http.content_type, "application/json; charset=utf-8"))) { //warn("{}\n", body); // json dump var json_parser = std.json.Parser.init(allocator, false); if (json_parser.parse(body)) |value_tree| { actor.payload.http.tree = value_tree; } else |err| { warn("net json err {}\n", .{err}); actor.payload.http.response_code = 1000; } } } else |err| { warn("net thread http err {}\n", .{err}); } thread.signal(actor, command); return null; } pub fn httpget(req: *config.HttpInfo) ![]const u8 { warn("http {} {} {}\n", .{ req.verb, req.url, if (req.token) @as([]const u8, "token") else @as([]const u8, "") }); _ = c.curl_global_init(0); var curl = c.curl_easy_init(); if (curl != null) { var cstr = std.cstr.addNullByte(allocator, req.url) catch unreachable; _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_URL, cstr.ptr); var zero: c_long = 0; var seconds: c_long = 30; _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_CONNECTTIMEOUT, seconds); _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_SSL_VERIFYPEER, zero); _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_SSL_VERIFYHOST, zero); _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_WRITEFUNCTION, curl_write); var body_buffer = try std.ArrayListSentineled(u8, 0).initSize(allocator, 0); _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_WRITEDATA, &body_buffer); //var slist: ?[*c]c.curl_slist = null; var slist = @intToPtr([*c]c.curl_slist, 0); // 0= new list slist = c.curl_slist_append(slist, "Accept: application/json"); if (req.token) |token| { warn("Authorization: {}\n", .{token}); var authbuf = allocator.alloc(u8, 256) catch unreachable; var authstr = std.fmt.bufPrint(authbuf, "Authorization: bearer {}", .{token}) catch unreachable; var cauthstr = util.sliceToCstr(allocator, authstr); slist = c.curl_slist_append(slist, cauthstr); } _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_HTTPHEADER, slist); switch (req.verb) { .get => _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_HTTPGET, @as(c_long, 1)), .post => { _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_POST, @as(c_long, 1)); const post_body_c: [*c]const u8 = util.sliceToCstr(allocator, req.post_body); _ = c.curl_easy_setopt(curl, c.CURLoption.CURLOPT_POSTFIELDS, post_body_c); warn("post body: {}\n", .{req.post_body}); }, } var res = c.curl_easy_perform(curl); if (res == c.CURLcode.CURLE_OK) { _ = c.curl_easy_getinfo(curl, c.CURLINFO.CURLINFO_RESPONSE_CODE, &req.response_code); var ccontent_type: [*c]const u8 = undefined; _ = c.curl_easy_getinfo(curl, c.CURLINFO.CURLINFO_CONTENT_TYPE, &ccontent_type); req.content_type = util.cstrToSliceCopy(allocator, ccontent_type); warn("net curl OK {} {}\n", .{ req.response_code, req.content_type }); return body_buffer.toOwnedSlice(); } else if (res == c.CURLcode.CURLE_OPERATION_TIMEDOUT) { req.response_code = 2200; return NetError.Curl; } else { const err_cstr = c.curl_easy_strerror(res); warn("curl ERR {} {}\n", .{ res, util.cstrToSliceCopy(allocator, err_cstr) }); if (res == c.CURLcode.CURLE_COULDNT_RESOLVE_HOST) { req.response_code = 2100; return NetError.DNS; } else { req.response_code = 2000; return NetError.Curl; } } c.curl_easy_cleanup(curl); } else { warn("net curl easy init fail\n", .{}); return NetError.CurlInit; } } pub fn curl_write(ptr: [*c]const u8, size: usize, nmemb: usize, userdata: *anyopaque) usize { _ = size; var buf = @ptrCast(*std.ArrayListSentineled(u8, 0), @alignCast(8, userdata)); var body_part: []const u8 = ptr[0..nmemb]; buf.appendSlice(body_part) catch |err| { warn("curl_write append fail {}\n", .{err}); }; return nmemb; }
src/net.zig
const std = @import("std"); const builtin = @import("builtin"); const os = std.os; const Allocator = std.mem.Allocator; const assert = std.debug.assert; const log = std.log.scoped(.storage); const IO = @import("io.zig").IO; const config = @import("config.zig"); const vsr = @import("vsr.zig"); pub const Storage = struct { /// See usage in Journal.write_sectors() for details. pub const synchronicity: enum { always_synchronous, always_asynchronous, } = .always_asynchronous; pub const Read = struct { completion: IO.Completion, callback: fn (read: *Storage.Read) void, /// The buffer to read into, re-sliced and re-assigned as we go, e.g. after partial reads. buffer: []u8, /// The position into the file descriptor from where we should read, also adjusted as we go. offset: u64, /// The maximum amount of bytes to read per syscall. We use this to subdivide troublesome /// reads into smaller reads to work around latent sector errors (LSEs). target_max: u64, /// Returns a target slice into `buffer` to read into, capped by `target_max`. /// If the previous read was a partial read of physical sectors (e.g. 512 bytes) less than /// our logical sector size (e.g. 4 KiB), so that the remainder of the buffer is no longer /// aligned to a logical sector, then we further cap the slice to get back onto a logical /// sector boundary. fn target(read: *Read) []u8 { // A worked example of a partial read that leaves the rest of the buffer unaligned: // This could happen for non-Advanced Format disks with a physical sector of 512 bytes. // We want to read 8 KiB: // buffer.ptr = 0 // buffer.len = 8192 // ... and then experience a partial read of only 512 bytes: // buffer.ptr = 512 // buffer.len = 7680 // We can now see that `buffer.len` is no longer a sector multiple of 4 KiB and further // that we have 3584 bytes left of the partial sector read. If we subtract this amount // from our logical sector size of 4 KiB we get 512 bytes, which is the alignment error // that we need to subtract from `target_max` to get back onto the boundary. var max = read.target_max; const partial_sector_read_remainder = read.buffer.len % config.sector_size; if (partial_sector_read_remainder != 0) { // TODO log.debug() because this is interesting, and to ensure fuzz test coverage. const partial_sector_read = config.sector_size - partial_sector_read_remainder; max -= partial_sector_read; } return read.buffer[0..std.math.min(read.buffer.len, max)]; } }; pub const Write = struct { completion: IO.Completion, callback: fn (write: *Storage.Write) void, buffer: []const u8, offset: u64, }; size: u64, fd: os.fd_t, io: *IO, pub fn init(size: u64, fd: os.fd_t, io: *IO) !Storage { return Storage{ .size = size, .fd = fd, .io = io, }; } pub fn deinit() void {} pub fn read_sectors( self: *Storage, callback: fn (read: *Storage.Read) void, read: *Storage.Read, buffer: []u8, offset: u64, ) void { assert_alignment(buffer, offset); read.* = .{ .completion = undefined, .callback = callback, .buffer = buffer, .offset = offset, .target_max = buffer.len, }; self.start_read(read, 0); } fn start_read(self: *Storage, read: *Storage.Read, bytes_read: usize) void { assert(bytes_read <= read.target().len); read.offset += bytes_read; read.buffer = read.buffer[bytes_read..]; const target = read.target(); if (target.len == 0) { read.callback(read); return; } self.assert_bounds(target, read.offset); self.io.read( *Storage, self, on_read, &read.completion, self.fd, target, read.offset, ); } fn on_read(self: *Storage, completion: *IO.Completion, result: IO.ReadError!usize) void { const read = @fieldParentPtr(Storage.Read, "completion", completion); const bytes_read = result catch |err| switch (err) { error.InputOutput => { // The disk was unable to read some sectors (an internal CRC or hardware failure): // We may also have already experienced a partial unaligned read, reading less // physical sectors than the logical sector size, so we cannot expect `target.len` // to be an exact logical sector multiple. const target = read.target(); if (target.len > config.sector_size) { // We tried to read more than a logical sector and failed. log.err("latent sector error: offset={}, subdividing read...", .{read.offset}); // Divide the buffer in half and try to read each half separately: // This creates a recursive binary search for the sector(s) causing the error. // This is considerably slower than doing a single bulk read and by now we might // also have experienced the disk's read retry timeout (in seconds). // TODO Our docs must instruct on why and how to reduce disk firmware timeouts. // These lines both implement ceiling division e.g. `((3 - 1) / 2) + 1 == 2` and // require that the numerator is always greater than zero: assert(target.len > 0); const target_sectors = @divFloor(target.len - 1, config.sector_size) + 1; assert(target_sectors > 0); read.target_max = (@divFloor(target_sectors - 1, 2) + 1) * config.sector_size; assert(read.target_max >= config.sector_size); // Pass 0 for `bytes_read`, we want to retry the read with smaller `target_max`: self.start_read(read, 0); return; } else { // We tried to read at (or less than) logical sector granularity and failed. log.err("latent sector error: offset={}, zeroing sector...", .{read.offset}); // Zero this logical sector which can't be read: // We will treat these EIO errors the same as a checksum failure. // TODO This could be an interesting avenue to explore further, whether // temporary or permanent EIO errors should be conflated with checksum failures. assert(target.len > 0); std.mem.set(u8, target, 0); // We could set `read.target_max` to `vsr.sector_ceil(read.buffer.len)` here // in order to restart our pseudo-binary search on the rest of the sectors to be // read, optimistically assuming that this is the last failing sector. // However, data corruption that causes EIO errors often has spacial locality. // Therefore, restarting our pseudo-binary search here might give us abysmal // performance in the (not uncommon) case of many successive failing sectors. self.start_read(read, target.len); return; } }, error.WouldBlock, error.NotOpenForReading, error.ConnectionResetByPeer, error.Alignment, error.IsDir, error.SystemResources, error.Unseekable, error.Unexpected, => { log.err( "impossible read: offset={} buffer.len={} error={s}", .{ read.offset, read.buffer.len, @errorName(err) }, ); @panic("impossible read"); }, }; if (bytes_read == 0) { // We tried to read more than there really is available to read. // In other words, we thought we could read beyond the end of the file descriptor. // This can happen if the data file inode `size` was truncated or corrupted. log.err( "short read: buffer.len={} offset={} bytes_read={}", .{ read.offset, read.buffer.len, bytes_read }, ); @panic("data file inode size was truncated or corrupted"); } // If our target was limited to a single sector, perhaps because of a latent sector error, // then increase `target_max` according to AIMD now that we have read successfully and // hopefully cleared the faulty zone. // We assume that `target_max` may exceed `read.buffer.len` at any time. if (read.target_max == config.sector_size) { // TODO Add log.debug because this is interesting. read.target_max += config.sector_size; } self.start_read(read, bytes_read); } pub fn write_sectors( self: *Storage, callback: fn (write: *Storage.Write) void, write: *Storage.Write, buffer: []const u8, offset: u64, ) void { assert_alignment(buffer, offset); write.* = .{ .completion = undefined, .callback = callback, .buffer = buffer, .offset = offset, }; self.start_write(write); } fn start_write(self: *Storage, write: *Storage.Write) void { self.assert_bounds(write.buffer, write.offset); self.io.write( *Storage, self, on_write, &write.completion, self.fd, write.buffer, write.offset, ); } fn on_write(self: *Storage, completion: *IO.Completion, result: IO.WriteError!usize) void { const write = @fieldParentPtr(Storage.Write, "completion", completion); const bytes_written = result catch |err| switch (err) { // We assume that the disk will attempt to reallocate a spare sector for any LSE. // TODO What if we receive a temporary EIO error because of a faulty cable? error.InputOutput => @panic("latent sector error: no spare sectors to reallocate"), // TODO: It seems like it might be possible for some filesystems to return ETIMEDOUT // here. Consider handling this without panicking. else => { log.err( "impossible write: offset={} buffer.len={} error={s}", .{ write.offset, write.buffer.len, @errorName(err) }, ); @panic("impossible write"); }, }; if (bytes_written == 0) { // This should never happen if the kernel and filesystem are well behaved. // However, block devices are known to exhibit this behavior in the wild. // TODO: Consider retrying with a timeout if this panic proves problematic, and be // careful to avoid logging in a busy loop. Perhaps a better approach might be to // return wrote = null here and let the protocol retry at a higher layer where there is // more context available to decide on how important this is or whether to cancel. @panic("write operation returned 0 bytes written"); } write.offset += bytes_written; write.buffer = write.buffer[bytes_written..]; if (write.buffer.len == 0) { write.callback(write); return; } self.start_write(write); } /// Ensures that the read or write is aligned correctly for Direct I/O. /// If this is not the case, then the underlying syscall will return EINVAL. /// We check this only at the start of a read or write because the physical sector size may be /// less than our logical sector size so that partial IOs then leave us no longer aligned. fn assert_alignment(buffer: []const u8, offset: u64) void { assert(@ptrToInt(buffer.ptr) % config.sector_size == 0); assert(buffer.len % config.sector_size == 0); assert(offset % config.sector_size == 0); } /// Ensures that the read or write is within bounds and intends to read or write some bytes. fn assert_bounds(self: *Storage, buffer: []const u8, offset: u64) void { assert(buffer.len > 0); assert(offset + buffer.len <= self.size); } };
src/storage.zig
const std = @import("std"); const date_module = @import("date.zig"); const Date = date_module.Date; const notes_module = @import("notes.zig"); const Notes = notes_module.Notes; const Allocator = std.mem.Allocator; const json = std.json; const dict_module = @import("dict.zig"); const DictArrayUnmanaged = dict_module.DictArrayUnmanaged; const logger = std.log.scoped(.ft); const util = @import("util.zig"); pub const Person = struct { id: Id, name: Name = .{}, alternative_names: NameList = .{}, surname: Surname = .{}, alternative_surnames: SurnameList = .{}, patronymic: Patronymic = .{}, sex: ?Sex = null, birth_date: ?Date = null, death_date: ?Date = null, notes: Notes = .{}, pub const Id = i64; pub fn deinit(this: *Person, ator: Allocator) void { logger.debug("Person.deinit() w/ id={d}, w/ ator.vtable={*}", .{this.id, ator.vtable}); inline for (@typeInfo(Person).Struct.fields) |field| { switch (field.field_type) { Id, ?Sex, ?Date => {}, else => { @field(this, field.name).deinit(ator); }, } } } pub const FromJsonError = error { bad_type, bad_field, }; pub fn readFromJson( this: *Person, json_person: *json.Value, allocator: anytype, comptime options: util.StrMgmt, ) !void { util.AOCheck(allocator, options); logger.debug("Person.readFromJson() w/ id={d}, options={s}", .{this.id, options.asText()}); switch (json_person.*) { json.Value.Object => |*map| { inline for (@typeInfo(Person).Struct.fields) |field| { if (map.getPtr(field.name)) |val_ptr| { switch (field.field_type) { Id => { switch (val_ptr.*) { json.Value.Integer => |int| { this.id = int; }, else => { logger.err( "in Person.readFromJson()" ++ " j_person.get(\"id\")" ++ " is not of type {s}" , .{"json.Integer"} ); return FromJsonError.bad_field; }, } }, ?Date, ?Sex => { switch (val_ptr.*) { json.Value.Null => { @field(this, field.name) = null; }, else => { if (null == @field(this, field.name)) { @field(this, field.name) = .{}; errdefer @field(this, field.name) = null; try @field(this, field.name).? .readFromJson(val_ptr.*); } else { try @field(this, field.name).? .readFromJson(val_ptr.*); } }, } }, else => { try @field(this, field.name) .readFromJson(val_ptr, allocator, options.asEnumLiteral()); }, } } } }, else => { logger.err( "in Person.readFromJson() j_person is not of type {s}", .{"json.ObjectMap"}, ); return FromJsonError.bad_type; }, } } /// for testing purposes pub fn readFromJsonSourceStr( this: *Person, source_str: []const u8, ator: Allocator, comptime options: util.StrMgmt, ) !void { // TODO should only .copy be allowed??? var parser = json.Parser.init(ator, false); // strings are copied in readFromJson defer parser.deinit(); var tree = try parser.parse(source_str); defer tree.deinit(); try this.readFromJson(&tree.root, ator, options); } pub fn toJson( self: Person, ator: Allocator, comptime settings: util.ToJsonSettings, ) util.ToJsonError!util.ToJsonResult { return util.toJson( self, ator, .{.allow_overload=false, .apply_arena=settings.apply_arena}, ); } // pub fn rename( // this: *Person, // new_name_ptr: anytype, // comptime allocator: ?Allocator, // comptime options: util.StrMgmt, // ) !void { // util.AOCheck(allocator, options); // logger.debug("Person.rename(): {s} -> {s}", .{this.name.getSome(), new_name_ptr.getSome()}); // switch (options) { // .copy => { // if (allocator) |ator| { // var copy = try new_name_ptr.copy(ator); // defer copy.deinit(ator); // this.name.swap(&copy); // } else { // unreachable; // util.AOCheck() // } // }, // .move => { // this.name = new_name_ptr.move(); // }, // .weak => { // this.name = new_name_ptr.*; // }, // } // } pub fn setDate(this: *Person, date: Date, which: enum { birth, death, }) !void { logger.debug( "Person.setDate() /w person.id={d} for event '{s}'", .{ this.id, switch (which) { .birth => "birth", .death => "death", }, }, ); try date.validate(); switch (which) { .birth => { this.birth_date = date; }, .death => { this.death_date = date; }, } } }; pub const Name = struct { normal_form: []const u8 = "", short_form: []const u8 = "", full_form: []const u8 = "", patronymic_male_form: []const u8 = "", patronymic_female_form: []const u8 = "", pub fn deinit(this: *Name, ator: Allocator) void { logger.debug("Name.deinit() w/ name={s}, ator={*}", .{this.getSome(), ator.vtable}); inline for (@typeInfo(Name).Struct.fields) |field| { switch (field.field_type) { []const u8 => { ator.free(@field(this, field.name)); }, else => { @compileError("Name.deinit() nonexhaustive field_type switch"); }, } } } pub const FromJsonError = error { bad_type, bad_field, }; pub fn readFromJson( this: *Name, json_name: *json.Value, allocator: anytype, comptime options: util.StrMgmt, ) !void { util.AOCheck(allocator, options); logger.debug("Name.readFromJson() w/ options={s}", .{options.asText()}); switch (json_name.*) { json.Value.Object => |*map| { switch (options) { .copy => { if (util.allocatorCapture(allocator)) |ator| { try this.deepCopyFromJsonObj(map.*, ator); } else { unreachable; // util.AOCheck() } }, .move => { try this.moveFromJsonObj(map); }, .weak => { try this.weakCopyFromJsonObj(map.*); }, } }, json.Value.String => |*str| { switch (options) { .copy => { if (util.allocatorCapture(allocator)) |ator| { this.normal_form = try util.strCopyAlloc(str.*, ator); } else { unreachable; // util.AOCheck() } }, .move => { this.normal_form = str.*; str.* = ""; }, .weak => { this.normal_form = str.*; }, } }, else => { logger.err( "in Name.readFromJson() j_name is of neither type {s} nor {s}" , .{"json.ObjectMap", "json.String"} ); return FromJsonError.bad_type; }, } } fn deepCopyFromJsonObj(this: *Name, map: json.ObjectMap, ator: Allocator) !void { inline for (@typeInfo(Name).Struct.fields) |field| { if (map.get(field.name)) |val| { switch (field.field_type) { []const u8 => { switch (val) { json.Value.String, json.Value.NumberString => |str| { @field(this, field.name) = try util.strCopyAlloc(str, ator); }, else => { logger.err( "in Name.readFromJson() j_name.get(\"{s}\")" ++ " is not of type {s}" , .{field.name, "json.String"} ); return FromJsonError.bad_field; }, } }, else => { @compileError("Name.readFromJson() nonexhaustive switch on field_type"); }, } } } } fn weakCopyFromJsonObj(this: *Name, map: json.ObjectMap) !void { inline for (@typeInfo(Name).Struct.fields) |field| { if (map.get(field.name)) |*val| { switch (field.field_type) { []const u8 => { switch (val.*) { json.Value.String, json.Value.NumberString => |str| { @field(this, field.name) = str; }, else => { logger.err( "in Name.readFromJson() j_name.get(\"{s}\")" ++ " is not of type {s}" , .{field.name, "json.String"} ); return FromJsonError.bad_field; }, } }, else => { @compileError("Name.readFromJson() nonexhaustive switch on field_type"); }, } } } } fn moveFromJsonObj(this: *Name, map: *json.ObjectMap) !void { inline for (@typeInfo(Name).Struct.fields) |field| { if (map.getPtr(field.name)) |val_ptr| { switch (field.field_type) { []const u8 => { switch (val_ptr.*) { json.Value.String, json.Value.NumberString => |*str| { @field(this, field.name) = str.*; str.* = ""; }, else => { logger.err( \\in Name.readFromJson() j_name.get("{s}") \\ is not of type {s} , .{field.name, "json.String"} ); return FromJsonError.bad_field; }, } }, else => { @compileError("Name.readFromJson() nonexhaustive switch on field_type"); }, } } } } pub fn getSome(self: Name) []const u8 { if (self.normal_form.len > 0) { return self.normal_form; } else if (self.full_form.len > 0) { return self.full_form; } else if (self.short_form.len > 0) { return self.short_form; } else { return ""; } } }; pub const NameList = struct { data: DictArrayUnmanaged(Name) = .{}, pub fn deinit(this: *NameList, ator: Allocator) void { logger.debug("NameList.deinit() w/ ator={*}", .{ator.vtable}); var v_it = this.data.valueIterator(); while (v_it.next()) |val_ptr| { val_ptr.deinit(ator); } this.data.deinit(ator); } pub const FromJsonError = error { bad_type, bad_field, // bad_field is required by Name allocator_required, }; pub fn readFromJson( this: *NameList, json_name_list: *json.Value, allocator: anytype, comptime options: util.StrMgmt, ) (dict_module.DictError||FromJsonError) ! void { if (util.allocatorCapture(allocator)) |ator| { // can't check allocator at comptime logger.debug( "NameList.readFromJson() w/ ator={*}, options={s}" , .{ator.vtable, options.asText()} ); var last_read_name: ?Name = null; switch (json_name_list.*) { json.Value.Object => |*obj| { try this.data.data.ensureUnusedCapacity(ator, obj.count()); errdefer this.data.data.shrinkAndFree(ator, this.data.data.count()); var e_it = obj.iterator(); while (e_it.next()) |entry| { var name = Name{}; errdefer { switch (options) { .copy, .move => { name.deinit(ator); }, .weak => {}, } } name.readFromJson( entry.value_ptr, ator, options, ) catch |err| { if (last_read_name) |lrn| { logger.err( "in NameList.readFromJson()" ++ " last successfully read name is {s}" , .{lrn.getSome()} ); } else { logger.err( "in NameList.readFromJson()" ++ " no name could be read" , .{} ); } return err; }; last_read_name = name; try this.data.putAssumeCapacity( entry.key_ptr.*, name, ator, .{.kopy = (options == .copy)}, ); switch (options) { .move => { entry.key_ptr.* = ""; }, .copy, .weak => {}, } } }, else => { logger.err( "in NameList.readFromJson()" ++ " j_name_list is not of type {s}" , .{"json.ObjectMap"} ); return FromJsonError.bad_type; }, } } else { logger.err("in NameList.readFromJson() allocator required", .{}); return FromJsonError.allocator_required; } } pub fn toJson( self: NameList, ator: Allocator, comptime settings: util.ToJsonSettings, ) util.ToJsonError!util.ToJsonResult { return util.toJson(self.data, ator, settings); } }; pub const Surname = struct { male_form: []const u8 = "", female_form: []const u8 = "", pub fn deinit(this: *Surname, ator: Allocator) void { logger.debug("Surname.deinit() w/ surname={s}, ator={*}", .{this.getSome(), ator.vtable}); inline for (@typeInfo(Surname).Struct.fields) |field| { switch (field.field_type) { []const u8 => { ator.free(@field(this, field.name)); }, else => { @compileError("Surname.deinit() nonexhaustive switch on field_type"); }, } } } pub const FromJsonError = error { bad_type, bad_field, }; pub fn readFromJson( this: *Surname, json_surname: *json.Value, allocator: anytype, comptime options: util.StrMgmt, ) !void { util.AOCheck(allocator, options); logger.debug("Surname.readFromJson() w/ options={s}", .{options.asText()}); switch (json_surname.*) { json.Value.Object => |*map| { switch (options) { .copy => { if (util.allocatorCapture(allocator)) |ator| { try this.deepCopyFromJsonObj(map.*, ator); } else { unreachable; // util.AOCheck() } }, .move => { try this.moveFromJsonObj(map); }, .weak => { // if (util.allocatorCapture(allocator)) |ator| { // try this.weakCopyFromJsonObj(map.*, ator); // } else { // unreachable; // util.AOCheck() // } try this.weakCopyFromJsonObj(map.*); }, } }, json.Value.String => |*str| { switch (options) { .copy => { if (util.allocatorCapture(allocator)) |ator| { this.male_form = try util.strCopyAlloc(str.*, ator); } else { unreachable; // util.AOCheck() } }, .move => { this.male_form = str.*; str.* = ""; }, .weak => { this.male_form = str.*; }, } }, else => { logger.err( "in Surname.readFromJson() j_surname is of neither type {s} nor {s}" , .{"json.ObjectMap", "json.String"} ); return FromJsonError.bad_type; }, } } fn deepCopyFromJsonObj(this: *Surname, map: json.ObjectMap, ator: Allocator) !void { inline for (@typeInfo(Surname).Struct.fields) |field| { if (map.get(field.name)) |*val| { switch (field.field_type) { []const u8 => { switch (val.*) { json.Value.String, json.Value.NumberString => |*str| { @field(this, field.name) = try util.strCopyAlloc(str.*, ator); }, else => { logger.err( "in Surname.readFromJson() j_surname.get(\"{s}\")" ++ " is not of type {s}" , .{field.name, "json.String"} ); return FromJsonError.bad_field; }, } }, else => { @compileError("Surname.readFromJson() nonexhaustive switch on field_type"); }, } } } } fn weakCopyFromJsonObj(this: *Surname, map: json.ObjectMap) !void { inline for (@typeInfo(Surname).Struct.fields) |field| { if (map.get(field.name)) |*val| { switch (field.field_type) { []const u8 => { switch (val.*) { json.Value.String, json.Value.NumberString => |str| { @field(this, field.name) = str; }, else => { logger.err( "in Surname.readFromJson() j_surname.get(\"{s}\")" ++ " is not of type {s}" , .{field.name, "json.String"} ); return FromJsonError.bad_field; }, } }, else => { @compileError("Surname.readFromJson() nonexhaustive switch on field_type"); }, } } } } fn moveFromJsonObj(this: *Surname, map: *json.ObjectMap) !void { inline for (@typeInfo(Surname).Struct.fields) |field| { if (map.getPtr(field.name)) |val_ptr| { switch (field.field_type) { []const u8 => { switch (val_ptr.*) { json.Value.String, json.Value.NumberString => |*str| { @field(this, field.name) = str.*; str.* = ""; }, else => { logger.err( "in Surname.readFromJson() j_surname.get(\"{s}\")" ++ " is not of type {s}" , .{field.name, "json.String"} ); return FromJsonError.bad_field; }, } }, else => { @compileError("Surname.readFromJson() nonexhaustive switch on field_type"); }, } } } } pub fn getSome(self: Surname) []const u8 { if (self.male_form.len > 0) { return self.male_form; } else if (self.female_form.len > 0) { return self.female_form; } else { return ""; } } }; pub const SurnameList = struct { data: DictArrayUnmanaged(Surname) = .{}, pub fn deinit(this: *SurnameList, ator: Allocator) void { logger.debug("SurnameList.deinit() w/ ator={*}", .{ator.vtable}); var v_it = this.data.valueIterator(); while (v_it.next()) |val_ptr| { val_ptr.deinit(ator); } this.data.deinit(ator); } pub const FromJsonError = error { bad_type, bad_field, // bad_field is required by Name allocator_required, }; pub fn readFromJson( this: *SurnameList, json_surname_list: *json.Value, allocator: anytype, comptime options: util.StrMgmt, ) (dict_module.DictError||FromJsonError) ! void { if (util.allocatorCapture(allocator)) |ator| { logger.debug( "Person.readFromJson() w/ ator={*}, options={s}" , .{ator.vtable, options.asText()} ); var last_read_surname: ?Surname = null; switch (json_surname_list.*) { json.Value.Object => |*obj| { try this.data.data.ensureUnusedCapacity(ator, obj.count()); errdefer this.data.data.shrinkAndFree(ator, this.data.count()); var e_it = obj.iterator(); while (e_it.next()) |entry| { var surname = Surname{}; errdefer { switch (options) { .copy, .move => { surname.deinit(ator); }, .weak => {}, } } surname.readFromJson( entry.value_ptr, ator, options, ) catch |err| { if (last_read_surname) |lrs| { logger.err( "in SurnameList.readFromJson()" ++ " last successfully read surname is {s}" , .{lrs.getSome()} ); } else { logger.err( "in SurnameList.readFromJson()" ++ " no surname could be read" , .{} ); } return err; }; last_read_surname = surname; try this.data.putAssumeCapacity( entry.key_ptr.*, surname, ator, .{.kopy = (options == .copy)}, ); switch (options) { .move => { entry.key_ptr.* = ""; }, .copy, .weak => {}, } } }, else => { logger.err( "in SurnameList.fromJsonError() j_surname_list" ++ " is not of type {s}" , .{"json.ObjectMap"} ); return FromJsonError.bad_type; }, } } else { logger.err("in SurnameList.fromJsonError() allocator required", .{}); return FromJsonError.allocator_required; } } pub fn toJson( self: SurnameList, ator: Allocator, comptime settings: util.ToJsonSettings, ) util.ToJsonError!util.ToJsonResult { return util.toJson(self.data, ator, settings); } }; pub const Patronymic = WrappedString("Patronymic"); fn WrappedString(comptime type_name: []const u8) type { return struct { data: []const u8 = "", pub fn deinit(this: *@This(), ator: Allocator) void { ator.free(this.data); } pub const FromJsonError = error { bad_type, }; pub fn readFromJson( this: *@This(), json_patronymic: *json.Value, allocator: anytype, comptime options: util.StrMgmt, ) (dict_module.DictError||FromJsonError) ! void { util.AOCheck(allocator, options); logger.debug("{s}.readFromJson() w/ options={s}", .{type_name, options.asText()}); switch (json_patronymic.*) { json.Value.String, json.Value.NumberString => |*str| { switch (options) { .copy => { if (util.allocatorCapture(allocator)) |ator| { this.data = try util.strCopyAlloc(str.*, ator); } else { unreachable; // util.AOCheck() } }, .move => { this.data = str.*; str.* = ""; }, .weak => { this.data = str.*; }, } }, // huge json{"date": {"date": {"date": ...}}} could cause stack overflow // json.Value.Object => |map| { // if (map.get("data")) |*j_data| { // try this.readFromJson(j_data, allocator, options); // } else { // this.data = ""; // } // }, else => { logger.err( "in {s}.readFromJson() j_{s} is not of type {s}" , .{type_name, "wrapped_string", "json.String"} ); return FromJsonError.bad_type; }, } } pub fn toJson( self: @This(), ator: Allocator, comptime settings: util.ToJsonSettings, ) util.ToJsonError!util.ToJsonResult { return util.toJson(self.data, ator, settings); } }; } pub const Sex = struct { data: UnderlyingEnum = .male, const UnderlyingInt = u1; pub const UnderlyingEnum = enum(UnderlyingInt) { male = 1, female = 0, }; pub fn asChar(self: Sex) u8 { return switch (self.data) { .male => '1', .female => '0', }; } pub fn asNum(self: Sex) UnderlyingInt { return switch (self.data) { .male => 1, .female => 0, }; } pub fn asText(self: Sex) []const u8 { return switch (self.data) { .male => "male", .female => "female", }; } pub const FromJsonError = error { bad_type, bad_field, }; pub fn readFromJson(this: *Sex, json_sex: json.Value) !void { logger.debug("Sex.readFromJson()", .{}); switch (json_sex) { json.Value.String => |str| { if (util.strEqual("male", str)) { this.data = .male; } else if (util.strEqual("female", str)) { this.data = .female; } else { logger.err( "in Sex.readFromJson() j_sex_str" ++ " is neither \"male\" nor \"female\"" , .{} ); return FromJsonError.bad_field; } }, json.Value.Bool => |is_male| { if (is_male) { this.data = .male; } else { this.data = .female; } }, json.Value.Integer => |int| { if (int == 1) { this.data = .male; } else if (int == 0) { this.data = .female; } else { logger.err( "in Sex.readFromJson() j_sex_int" ++ " is neither 1 nor 0" , .{} ); return FromJsonError.bad_field; } }, else => { logger.err( "in Sex.readFromJson() j_sex is of neither type {s}, {s} nor {s}" , .{"json.String", "json.Bool", "json.Integer"} ); return FromJsonError.bad_type; }, } } pub fn toJson( self: Sex, ator: Allocator, comptime settings: util.ToJsonSettings, ) util.ToJsonError!util.ToJsonResult { return util.toJson(self.asText(), ator, settings); } pub fn equal( self: Sex, other: Sex, comptime settings: util.EqualSettings, ) bool { _ = settings; return self.data == other.data; } }; const testing = std.testing; const expect = testing.expect; const expectEqual = testing.expectEqual; const expectError = testing.expectError; const tator = testing.allocator; const human_full_source = \\{ \\ "id": 1, \\ "name": {"normal_form": "Human", "short_form": "Hum"}, \\ "surname": {"male_form": "Ivanov", "female_form": "Ivanova"}, \\ "patronymic": "Fathersson", \\ "sex": "male", \\ "birth_date": {"day": 3, "month": 2, "year": 2000}, \\ "death_date": null, \\ "notes": "" \\} ; const human_short_source = \\{ \\ "id": 2, \\ "name": "Human", \\ "surname": "Ivanov", \\ "patronymic": "Fathersson", \\ "sex": "male", \\ "birth_date": {"day": 3, "month": 2, "year": 2000}, \\ "death_date": null, \\ "notes": "" \\} ; const mysterious_source = \\{ \\ "id": 3, \\ "name": "", \\ "surname": "", \\ "patronymic": "", \\ "sex": null, \\ "notes": "" \\} ; fn testId(src: []const u8, expected_id: Person.Id) !void { var human = Person{.id = undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(src, tator, .copy); try expectEqual(human.id, expected_id); } test "id" { try testId(human_full_source, 1); try testId(human_short_source, 2); try testId(mysterious_source, 3); } fn testName(src: []const u8, expected_name: Name) !void { var human = Person{.id = undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(src, tator, .copy); inline for (@typeInfo(Name).Struct.fields) |field| { try expect(util.strEqual( @field(human.name, field.name), @field(expected_name, field.name), )); } } test "name" { try testName(human_full_source, Name{.normal_form="Human", .short_form="Hum"}); try testName(human_short_source, Name{.normal_form="Human"}); try testName(mysterious_source, Name{}); } fn testSurname(src: []const u8, expected_surname: Surname) !void { var human = Person{.id = undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(src, tator, .copy); inline for (@typeInfo(Surname).Struct.fields) |field| { try expect(util.strEqual( @field(human.surname, field.name), @field(expected_surname, field.name), )); } } test "surname" { try testSurname(human_full_source, Surname{.male_form="Ivanov", .female_form="Ivanova"}); try testSurname(human_short_source, Surname{.male_form="Ivanov"}); try testSurname(mysterious_source, Surname{}); } fn testPatronymic(src: []const u8, expected_patronymic: Patronymic) !void { var human = Person{.id=undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(src, tator, .copy); try expect(util.strEqual(expected_patronymic.data, human.patronymic.data)); } test "patronymic" { try testPatronymic(human_full_source, Patronymic{.data="Fathersson"}); try testPatronymic(human_short_source, Patronymic{.data="Fathersson"}); try testPatronymic(mysterious_source, Patronymic{.data=""}); } fn testSex(src: []const u8, expected_sex: ?Sex) !void { var human = Person{.id=undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(src, tator, .copy); if (expected_sex) |es| { try expectEqual(es.data, human.sex.?.data); } else { try expectEqual(human.sex, null); } } test "sex" { try testSex(human_full_source, Sex{.data=.male}); try testSex(human_short_source, Sex{.data=.male}); try testSex(mysterious_source, null); } fn testDate(src: []const u8, expected_date: ?Date, comptime which: @TypeOf(.enum_literal)) !void { var human = Person{.id=undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(src, tator, .copy); switch (which) { .birth => { if (expected_date) |ed| { inline for (@typeInfo(Date).Struct.fields) |field| { try expectEqual( @field(ed, field.name), @field(human.birth_date.?, field.name), ); } } else { try expectEqual(human.birth_date, null); } }, .death => { if (expected_date) |ed| { inline for (@typeInfo(Date).Struct.fields) |field| { try expectEqual( @field(ed, field.name), @field(human.death_date.?, field.name), ); } } else { try expectEqual(human.death_date, null); } }, else => { @compileError("testDate() nonexhaustive switch on which date"); }, } } test "date" { try testDate(human_full_source, Date{.day=3, .month=2, .year=2000}, .birth); try testDate(human_full_source, null, .death); try testDate(human_short_source, Date{.day=3, .month=2, .year=2000}, .birth); try testDate(human_short_source, null, .death); try testDate(mysterious_source, null, .birth); try testDate(mysterious_source, null, .death); } test "notes" { { var human = Person{.id=undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(human_full_source, tator, .copy); try expect(util.strEqual("", human.notes.text)); try expectEqual(@as(usize,0), human.notes.child_nodes.count()); } { var human = Person{.id=undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(human_short_source, tator, .copy); try expect(util.strEqual("", human.notes.text)); try expectEqual(@as(usize,0), human.notes.child_nodes.count()); } { var human = Person{.id=undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(mysterious_source, tator, .copy); try expect(util.strEqual("", human.notes.text)); try expectEqual(@as(usize,0), human.notes.child_nodes.count()); } } test "set date" { { var human = Person{.id=undefined}; defer human.deinit(tator); try human.readFromJsonSourceStr(mysterious_source, tator, .copy); try human.setDate(Date{.day=2, .month=3, .year=2}, .birth); try human.setDate(Date{.day=1, .month=1, .year=-1}, .death); try expectEqual(human.birth_date.?.day.?, 2); try expectEqual(human.birth_date.?.month.?, 3); try expectEqual(human.birth_date.?.year.?, 2); try expectEqual(human.death_date.?.day.?, 1); try expectEqual(human.death_date.?.month.?, 1); try expectEqual(human.death_date.?.year.?, -1); } } fn testError(src: []const u8, expected_error: anyerror) !void { var human = Person{.id=undefined}; defer human.deinit(tator); try expectError(expected_error, human.readFromJsonSourceStr(src, tator, .copy)); } const bad_type_src_self = \\"asdf" ; const bad_type_src_name = \\{ \\ "name": 1 \\} ; const bad_type_src_surname = \\{ \\ "surname": 1 \\} ; const bad_type_src_name_list = \\{ \\ "alternative_names": 2 \\} ; const bad_type_src_surname_list = \\{ \\ "alternative_surnames": ["a", "b", "c"] \\} ; const bad_type_src_date = \\{ \\ "birth_date": "today" \\} ; const bad_type_src_sex = \\{ \\ "sex": [1, 2, 3] \\} ; const bad_type_src_patronymic = \\{ \\ "patronymic": 2 \\} ; const bad_type_src_notes = \\{ \\ "notes": 2 \\} ; const bad_type_sources = [_][]const u8{ bad_type_src_self, bad_type_src_name, bad_type_src_name_list, bad_type_src_surname, bad_type_src_surname_list, bad_type_src_date, bad_type_src_sex, bad_type_src_patronymic, bad_type_src_notes, }; const bad_field_src_id = \\{ \\ "id": "asdf" \\} ; const bad_field_src_name = \\{ \\ "name": { \\ "normal_form": 1 \\ } \\} ; const bad_field_src_name_list = \\{ \\ "alternative_names": { \\ "name": { \\ "normal_form": 1 \\ } \\ } \\} ; const bad_field_src_surname = \\{ \\ "surname": { \\ "male_form": 1 \\ } \\} ; const bad_field_src_surname_list = \\{ \\ "alternative_surnames": { \\ "surname": { \\ "male_form": 1 \\ } \\ } \\} ; const bad_field_src_date = \\{ \\ "birth_date": { \\ "day": "today" \\ } \\} ; const bad_field_src_sex = \\{ \\ "sex": 2 \\} ; const bad_field_src_notes = \\{ \\ "notes": { \\ "text": "text", \\ "child_nodes": 2 \\ } \\} ; const bad_field_sources = [_][]const u8{ bad_field_src_id, bad_field_src_name, bad_field_src_name_list, bad_field_src_surname, bad_field_src_surname_list, bad_field_src_date, bad_field_src_sex, bad_field_src_notes, }; fn testAllocatorRequired(src: []const u8) !void { var parser = json.Parser.init(tator, false); // strings are copied in readFromJson defer parser.deinit(); var tree = try parser.parse(src); defer tree.deinit(); var hum = Person{.id=undefined}; defer hum.deinit(tator); try expectError(anyerror.allocator_required, hum.readFromJson(&tree.root, null, .weak)); } const allocator_required_src_name_list = \\{ \\ "alternative_names": {} \\} ; const allocator_required_src_surname_list = \\{ \\ "alternative_surnames": {} \\} ; const allocator_required_src_notes = \\{ \\ "notes": { \\ "child_nodes": {} \\ } \\} ; const allocator_required_sources = [_][]const u8{ allocator_required_src_name_list, allocator_required_src_surname_list, allocator_required_src_notes, }; test "errors" { for (bad_type_sources) |bt_src| { try testError(bt_src, anyerror.bad_type); } for (bad_field_sources) |bf_src| { try testError(bf_src, anyerror.bad_field); } for (allocator_required_sources) |ar_src| { try testAllocatorRequired(ar_src); } } test "to json" { var person = Person{.id = undefined}; defer person.deinit(tator); try person.readFromJsonSourceStr(human_full_source , tator, .copy); var j_person = try person.toJson(tator, .{}); defer j_person.deinit(); var nosrep = Person{.id = undefined}; defer nosrep.deinit(tator); try nosrep.readFromJson(&j_person.value, tator, .copy); try expect(util.equal(person, nosrep, .{})); }
src/person.zig
//! Lock may be held only once. If the same thread tries to acquire //! the same mutex twice, it deadlocks. This type supports static //! initialization and is at most `@sizeOf(usize)` in size. When an //! application is built in single threaded release mode, all the //! functions are no-ops. In single threaded debug mode, there is //! deadlock detection. //! //! Example usage: //! var m = Mutex{}; //! //! const lock = m.acquire(); //! defer lock.release(); //! ... critical code //! //! Non-blocking: //! if (m.tryAcquire) |lock| { //! defer lock.release(); //! // ... critical section //! } else { //! // ... lock not acquired //! } impl: Impl = .{}, const Mutex = @This(); const std = @import("../std.zig"); const builtin = std.builtin; const os = std.os; const assert = std.debug.assert; const windows = os.windows; const linux = os.linux; const testing = std.testing; const StaticResetEvent = std.thread.StaticResetEvent; /// Try to acquire the mutex without blocking. Returns `null` if the mutex is /// unavailable. Otherwise returns `Held`. Call `release` on `Held`. pub fn tryAcquire(m: *Mutex) ?Impl.Held { return m.impl.tryAcquire(); } /// Acquire the mutex. Deadlocks if the mutex is already /// held by the calling thread. pub fn acquire(m: *Mutex) Impl.Held { return m.impl.acquire(); } /// This is required to get AtomicCondition to work properly /// but isn't meant to be called from user code pub fn force_release_internal(m: *Mutex) void { if(Impl == AtomicMutex){ var releaser = AtomicMutex.Held {.mutex = m.impl}; releaser.release(); } } const Impl = if (builtin.single_threaded) Dummy else if (builtin.os.tag == .windows) WindowsMutex else if (std.Thread.use_pthreads) PthreadMutex else AtomicMutex; pub const AtomicMutex = struct { state: State = .unlocked, const State = enum(i32) { unlocked, locked, waiting, }; pub const Held = struct { mutex: *AtomicMutex, pub fn release(held: Held) void { switch (@atomicRmw(State, &held.mutex.state, .Xchg, .unlocked, .Release)) { .unlocked => unreachable, .locked => {}, .waiting => held.mutex.unlockSlow(), } } }; pub fn tryAcquire(m: *AtomicMutex) ?Held { if (@cmpxchgStrong( State, &m.state, .unlocked, .locked, .Acquire, .Monotonic, ) == null) { return Held{ .mutex = m }; } else { return null; } } pub fn acquire(m: *AtomicMutex) Held { switch (@atomicRmw(State, &m.state, .Xchg, .locked, .Acquire)) { .unlocked => {}, else => |s| m.lockSlow(s), } return Held{ .mutex = m }; } fn lockSlow(m: *AtomicMutex, current_state: State) void { @setCold(true); var new_state = current_state; var spin: u8 = 0; while (spin < 100) : (spin += 1) { const state = @cmpxchgWeak( State, &m.state, .unlocked, new_state, .Acquire, .Monotonic, ) orelse return; switch (state) { .unlocked => {}, .locked => {}, .waiting => break, } var iter = std.math.min(32, spin + 1); while (iter > 0) : (iter -= 1) std.atomic.spinLoopHint(); } new_state = .waiting; while (true) { switch (@atomicRmw(State, &m.state, .Xchg, new_state, .Acquire)) { .unlocked => return, else => {}, } switch (std.Target.current.os.tag) { .linux => { switch (linux.getErrno(linux.futex_wait( @ptrCast(*const i32, &m.state), linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT, @enumToInt(new_state), null, ))) { 0 => {}, std.os.EINTR => {}, std.os.EAGAIN => {}, else => unreachable, } }, else => std.atomic.spinLoopHint(), } } } fn unlockSlow(m: *AtomicMutex) void { @setCold(true); switch (std.Target.current.os.tag) { .linux => { switch (linux.getErrno(linux.futex_wake( @ptrCast(*const i32, &m.state), linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE, 1, ))) { 0 => {}, std.os.EFAULT => {}, else => unreachable, } }, else => {}, } } }; pub const PthreadMutex = struct { pthread_mutex: std.c.pthread_mutex_t = .{}, pub const Held = struct { mutex: *PthreadMutex, pub fn release(held: Held) void { switch (std.c.pthread_mutex_unlock(&held.mutex.pthread_mutex)) { 0 => return, std.c.EINVAL => unreachable, std.c.EAGAIN => unreachable, std.c.EPERM => unreachable, else => unreachable, } } }; /// Try to acquire the mutex without blocking. Returns null if /// the mutex is unavailable. Otherwise returns Held. Call /// release on Held. pub fn tryAcquire(m: *PthreadMutex) ?Held { if (std.c.pthread_mutex_trylock(&m.pthread_mutex) == 0) { return Held{ .mutex = m }; } else { return null; } } /// Acquire the mutex. Will deadlock if the mutex is already /// held by the calling thread. pub fn acquire(m: *PthreadMutex) Held { switch (std.c.pthread_mutex_lock(&m.pthread_mutex)) { 0 => return Held{ .mutex = m }, std.c.EINVAL => unreachable, std.c.EBUSY => unreachable, std.c.EAGAIN => unreachable, std.c.EDEADLK => unreachable, std.c.EPERM => unreachable, else => unreachable, } } }; /// This has the sematics as `Mutex`, however it does not actually do any /// synchronization. Operations are safety-checked no-ops. pub const Dummy = struct { lock: @TypeOf(lock_init) = lock_init, const lock_init = if (std.debug.runtime_safety) false else {}; pub const Held = struct { mutex: *Dummy, pub fn release(held: Held) void { if (std.debug.runtime_safety) { held.mutex.lock = false; } } }; /// Try to acquire the mutex without blocking. Returns null if /// the mutex is unavailable. Otherwise returns Held. Call /// release on Held. pub fn tryAcquire(m: *Dummy) ?Held { if (std.debug.runtime_safety) { if (m.lock) return null; m.lock = true; } return Held{ .mutex = m }; } /// Acquire the mutex. Will deadlock if the mutex is already /// held by the calling thread. pub fn acquire(m: *Dummy) Held { return m.tryAcquire() orelse @panic("deadlock detected"); } }; const WindowsMutex = struct { srwlock: windows.SRWLOCK = windows.SRWLOCK_INIT, pub const Held = struct { mutex: *WindowsMutex, pub fn release(held: Held) void { windows.kernel32.ReleaseSRWLockExclusive(&held.mutex.srwlock); } }; pub fn tryAcquire(m: *WindowsMutex) ?Held { if (windows.kernel32.TryAcquireSRWLockExclusive(&m.srwlock) != windows.FALSE) { return Held{ .mutex = m }; } else { return null; } } pub fn acquire(m: *WindowsMutex) Held { windows.kernel32.AcquireSRWLockExclusive(&m.srwlock); return Held{ .mutex = m }; } }; const TestContext = struct { mutex: *Mutex, data: i128, const incr_count = 10000; }; test "basic usage" { var mutex = Mutex{}; var context = TestContext{ .mutex = &mutex, .data = 0, }; if (builtin.single_threaded) { worker(&context); try testing.expect(context.data == TestContext.incr_count); } else { const thread_count = 10; var threads: [thread_count]std.Thread = undefined; for (threads) |*t| { t.* = try std.Thread.spawn(.{}, worker, .{&context}); } for (threads) |t| t.join(); try testing.expect(context.data == thread_count * TestContext.incr_count); } } fn worker(ctx: *TestContext) void { var i: usize = 0; while (i != TestContext.incr_count) : (i += 1) { const held = ctx.mutex.acquire(); defer held.release(); ctx.data += 1; } }
lib/std/Thread/Mutex.zig
const std = @import("std"); const utils = @import("utils"); const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const print = utils.print; fn readInput(arena: *ArenaAllocator, lines_it: *utils.FileLineIterator) anyerror![]i32 { var numbers = try std.ArrayList(i32).initCapacity(&arena.allocator, 4096); var line = lines_it.next().?; var num_it = std.mem.tokenize(u8, line, ","); while (num_it.next()) |num| { const i = try std.fmt.parseInt(i32, num, 10); try numbers.append(i); } print("File ok :) Number of inputs: {d}", .{numbers.items.len}); return numbers.items; } fn part1(arena: *ArenaAllocator, positions: []i32) anyerror!i32 { var max: i32 = positions[0]; for (positions) |position| { max = std.math.max(max, position); } var count_by_position = try arena.allocator.alloc(i32, @intCast(usize, max + 1)); std.mem.set(i32, count_by_position, 0); for (positions) |pos| { count_by_position[@intCast(usize, pos)] += 1; } var spent_by_pos = try arena.allocator.alloc(i32, @intCast(usize, max + 1)); std.mem.set(i32, spent_by_pos, 0); var i: usize = 0; var count_from_left: i32 = 0; var count_from_right: i32 = 0; var spent_left: i32 = 0; var spent_right: i32 = 0; while (i < spent_by_pos.len) : (i += 1) { spent_left += count_from_left; spent_right += count_from_right; spent_by_pos[i] += spent_left; spent_by_pos[spent_by_pos.len - i - 1] += spent_right; count_from_left += count_by_position[i]; count_from_right += count_by_position[count_by_position.len - i - 1]; } var best_position: usize = 0; for (spent_by_pos) |spent, position| { if (spent < spent_by_pos[best_position]) { best_position = position; } } return spent_by_pos[best_position]; } fn part2(arena: *ArenaAllocator, positions: []i32) anyerror!i32 { var max: i32 = positions[0]; for (positions) |position| { max = std.math.max(max, position); } var count_by_position = try arena.allocator.alloc(i32, @intCast(usize, max + 1)); std.mem.set(i32, count_by_position, 0); for (positions) |pos| { count_by_position[@intCast(usize, pos)] += 1; } var spent_by_pos = try arena.allocator.alloc(i32, @intCast(usize, max + 1)); std.mem.set(i32, spent_by_pos, 0); var i: usize = 0; var count_from_left: i32 = 0; var count_from_right: i32 = 0; var count_from_left2: i32 = 0; var count_from_right2: i32 = 0; var spent_left: i32 = 0; var spent_right: i32 = 0; while (i < spent_by_pos.len) : (i += 1) { spent_left += count_from_left; spent_right += count_from_right; spent_by_pos[i] += spent_left; spent_by_pos[spent_by_pos.len - i - 1] += spent_right; count_from_left += count_from_left2 + count_by_position[i]; count_from_right += count_from_right2 + count_by_position[count_by_position.len - i - 1]; count_from_left2 += count_by_position[i]; count_from_right2 += count_by_position[count_by_position.len - i - 1]; } var best_position: usize = 0; for (spent_by_pos) |spent, position| { if (spent < spent_by_pos[best_position]) { best_position = position; } } return spent_by_pos[best_position]; } pub fn main() anyerror!void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); var lines_it = try utils.iterateLinesInFile(&arena.allocator, "input.txt"); defer lines_it.deinit(); const input = try readInput(&arena, &lines_it); const part1_result = try part1(&arena, input); print("Part 1: {d}", .{part1_result}); const part2_result = try part2(&arena, input); print("Part 2: {d}", .{part2_result}); }
day7/src/main.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const testing = std.testing; // BitSet is a naive bitset implementation with an iterator attached. pub const BitSet = struct { const Self = @This(); const wordBits = @bitSizeOf(u64); alloc: *Allocator, bits: ?[]u64 = null, pub fn init(allocator: *Allocator) Self { return Self{ .alloc = allocator }; } pub fn deinit(self: *Self) void { if (self.bits != null) self.alloc.free(self.bits.?); } pub fn reserve(self: *Self, bits: u64) !void { const needCap = @intCast(usize, bits / wordBits) + 1; if (self.bits != null and self.bits.?.len >= needCap) return; var p = try self.alloc.alloc(u64, needCap); if (self.bits) |o| { mem.copy(u64, p, o); mem.set(u64, p[o.len..], 0); self.alloc.free(o); } else { mem.set(u64, p, 0); } self.bits = p; } pub fn zero(self: *Self) void { if (self.bits == null) return; mem.set(u64, self.bits.?, 0); } pub fn invert(self: *Self) void { if (self.bits == null) return; for (self.bits.?) |*i| i.* = ~i.*; } pub fn set(self: *Self, bit: u64, v: bool) !void { try self.reserve(bit); const off: u6 = @intCast(u6, bit % wordBits); const i: usize = @intCast(usize, (bit - off) / wordBits); const w: u64 = self.bits.?[i]; const m: u64 = @intCast(u64, 1) << off; self.bits.?[i] = if (v) (w | m) else (w & ~m); } pub fn get(self: Self, bit: u64) bool { const i = @intCast(usize, bit / wordBits); if (self.bits.?.len <= i) return false; const m: u64 = @intCast(u64, 1) << @intCast(u6, bit % wordBits); return (self.bits.?[i] & m) == m; } pub fn getWord(self: Self, bit: u64) u64 { const i = bit / wordBits; if (self.bits.?.len <= i) return 0; return self.bits.?[i]; } pub fn count(self: Self) usize { if (self.bits == null) return 0; var n: usize = 0; for (self.bits.?) |i| n += @popCount(u64, i); return n; } pub fn iter(self: *const Self) Iter { return Iter{ .p = self, .word = if (self.bits) |p| p[0] else 0, }; } const Iter = struct { word: u64 = 0, p: *const Self, i: usize = 0, pub fn next(self: *Iter) ?u64 { if (self.p.bits == null) return null; const bits = self.p.bits.?; if (self.i >= bits.len) return null; if (self.word == 0) { self.i += 1; while (self.i < bits.len and bits[self.i] == 0) self.i += 1; if (self.i >= bits.len) return null; self.word = bits[self.i]; } // Note: because of the self.word == 0 check above, this will never // be never be 64. const bit = @truncate(u6, @ctz(u64, self.word)); self.word &= ~(@intCast(u64, 1) << bit); return self.i * 64 + bit; } }; }; test "BitSet usage" { const expect = testing.expect; const expectEqual = testing.expectEqual; var bits = BitSet.init(std.testing.allocator); defer bits.deinit(); try bits.set(0, true); expect(bits.get(0)); expect(!bits.get(1)); try bits.set(1, true); expect(bits.get(1)); expect(!bits.get(1000)); try bits.set(1000, true); expect(bits.get(1000)); var wantBits = [_]u64{ 0, 1, 1000 }; expectEqual(wantBits.len, bits.count()); var nth: usize = 0; var iter = bits.iter(); while (iter.next()) |i| { expectEqual(wantBits[nth], i); nth += 1; } bits.zero(); expectEqual(@intCast(usize, 0), bits.count()); }
lib/nil/bits.zig
const std = @import("std"); const with_trace = true; const assert = std.debug.assert; fn trace(comptime fmt: []const u8, args: anytype) void { if (with_trace) std.debug.print(fmt, args); } const maxpackets = 29; const Result = struct { qe: u64, s0: u32, }; const Candidate = struct { rem0: u16, rem1: u16, rem2: u16, qe: u64, packets: u8, groups: [4]u8, storage: [maxpackets]u8 = undefined, next: usize = undefined, }; const Agenda = struct { pool: [100000]Candidate, count: usize, first: usize, free: usize, const none: usize = 0xFFFFFFFF; }; fn is_better(a: Candidate, b: Candidate) bool { if (a.rem0 < b.rem0) return true; if (a.rem0 > b.rem0) return false; if (a.groups[0] < b.groups[0]) return true; if (a.groups[0] > b.groups[0]) return true; if (a.qe < b.qe) return true; if (a.qe > b.qe) return false; if (a.rem1 < b.rem1) return true; if (a.rem1 > b.rem1) return false; if (a.rem2 < b.rem2) return true; if (a.rem2 > b.rem2) return false; return false; } fn agenda_insert(a: *Agenda, candidate: Candidate) void { var place = &a.first; while (place.* != Agenda.none and is_better(a.pool[place.*], candidate)) { place = &a.pool[place.*].next; } const newidx = a.free; const new = &a.pool[newidx]; a.free = new.next; new.* = candidate; new.next = place.*; place.* = newidx; a.count += 1; } fn agenda_pop(a: *Agenda) ?Candidate { if (a.first == Agenda.none) return null; const idx = a.first; const c = a.pool[idx]; a.first = a.pool[idx].next; a.pool[idx].next = a.free; a.free = idx; a.count -= 1; return c; } fn agenda_init(a: *Agenda) void { for (a.pool) |*it, i| { it.next = i + 1; } a.pool[a.pool.len - 1].next = Agenda.none; a.first = Agenda.none; a.free = 0; a.count = 0; } fn bfs(a: *Agenda, curbest: *Result) void { var bestrem0: u16 = 9999; var bestrem1: u16 = 9999; var bestrem2: u16 = 9999; var iter: u32 = 0; while (agenda_pop(a)) |candidate| { const rem0 = candidate.rem0; const rem1 = candidate.rem1; const rem2 = candidate.rem2; const qe = candidate.qe; const packets = candidate.storage[0..candidate.packets]; const groups = [4][]const u8{ candidate.storage[candidate.packets .. candidate.packets + candidate.groups[0]], candidate.storage[candidate.packets + candidate.groups[0] .. candidate.packets + candidate.groups[0] + candidate.groups[1]], candidate.storage[candidate.packets + candidate.groups[0] + candidate.groups[1] .. candidate.packets + candidate.groups[0] + candidate.groups[1] + candidate.groups[2]], candidate.storage[candidate.packets + candidate.groups[0] + candidate.groups[1] + candidate.groups[2] .. candidate.packets + candidate.groups[0] + candidate.groups[1] + candidate.groups[2] + candidate.groups[3]], }; { var s0 = @intCast(u32, groups[0].len); if (s0 > curbest.s0 or (s0 == curbest.s0 and qe >= curbest.qe)) continue; } iter += 1; if (rem0 < bestrem0 or rem1 < bestrem1 or rem2 < bestrem2) { bestrem0 = rem0; bestrem1 = rem1; bestrem2 = rem2; trace("progress.. rems={},{},{}, qe={} agenda={}, iter={}\n", rem0, rem1, rem2, qe, a.count, iter); trace("cur candidate:\n"); for (groups) |g, i| { trace(" group{} = [", i); for (g) |p| { trace("{}, ", p); } trace("]\n"); } } var newcandidate: Candidate = undefined; if (rem0 > 0) { const g = groups[0]; if (g.len >= curbest.s0) continue; for (packets) |p, i| { if (p > rem0) continue; newcandidate.rem0 = rem0 - p; newcandidate.rem1 = rem1; newcandidate.rem2 = rem2; newcandidate.qe = qe * p; newcandidate.packets = candidate.packets - 1; newcandidate.groups[0] = candidate.groups[0] + 1; newcandidate.groups[1] = candidate.groups[1]; newcandidate.groups[2] = candidate.groups[2]; newcandidate.groups[3] = candidate.groups[3]; const newpackets = newcandidate.storage[0..newcandidate.packets]; std.mem.copy(u8, newpackets[0..i], packets[0..i]); std.mem.copy(u8, newpackets[i..], packets[i + 1 ..]); const newgroups = [4][]u8{ newcandidate.storage[newcandidate.packets .. newcandidate.packets + newcandidate.groups[0]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2] + newcandidate.groups[3]], }; std.mem.copy(u8, newgroups[0][1 .. g.len + 1], g); newgroups[0][0] = p; std.mem.copy(u8, newgroups[1], groups[1]); std.mem.copy(u8, newgroups[2], groups[2]); std.mem.copy(u8, newgroups[3], groups[3]); agenda_insert(a, newcandidate); } continue; } if (rem1 > 0) { const g = groups[1]; for (packets) |p, i| { if (p > rem1) continue; newcandidate.rem0 = rem0; newcandidate.rem1 = rem1 - p; newcandidate.rem2 = rem2; newcandidate.qe = qe; newcandidate.packets = candidate.packets - 1; newcandidate.groups[0] = candidate.groups[0]; newcandidate.groups[1] = candidate.groups[1] + 1; newcandidate.groups[2] = candidate.groups[2]; newcandidate.groups[3] = candidate.groups[3]; const newpackets = newcandidate.storage[0..newcandidate.packets]; std.mem.copy(u8, newpackets[0..i], packets[0..i]); std.mem.copy(u8, newpackets[i..], packets[i + 1 ..]); const newgroups = [4][]u8{ newcandidate.storage[newcandidate.packets .. newcandidate.packets + newcandidate.groups[0]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2] + newcandidate.groups[3]], }; std.mem.copy(u8, newgroups[0], groups[0]); std.mem.copy(u8, newgroups[1][1 .. g.len + 1], g); newgroups[1][0] = p; std.mem.copy(u8, newgroups[2], groups[2]); std.mem.copy(u8, newgroups[3], groups[3]); agenda_insert(a, newcandidate); } continue; } if (rem2 > 0) { const g = groups[2]; for (packets) |p, i| { if (p > rem2) continue; newcandidate.rem0 = rem0; newcandidate.rem1 = rem1; newcandidate.rem2 = rem2 - p; newcandidate.qe = qe; newcandidate.packets = candidate.packets - 1; newcandidate.groups[0] = candidate.groups[0]; newcandidate.groups[1] = candidate.groups[1]; newcandidate.groups[2] = candidate.groups[2] + 1; newcandidate.groups[3] = candidate.groups[3]; const newpackets = newcandidate.storage[0..newcandidate.packets]; std.mem.copy(u8, newpackets[0..i], packets[0..i]); std.mem.copy(u8, newpackets[i..], packets[i + 1 ..]); const newgroups = [4][]u8{ newcandidate.storage[newcandidate.packets .. newcandidate.packets + newcandidate.groups[0]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2]], newcandidate.storage[newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2] .. newcandidate.packets + newcandidate.groups[0] + newcandidate.groups[1] + newcandidate.groups[2] + newcandidate.groups[3]], }; std.mem.copy(u8, newgroups[0], groups[0]); std.mem.copy(u8, newgroups[1], groups[1]); std.mem.copy(u8, newgroups[2][1 .. g.len + 1], g); newgroups[2][0] = p; std.mem.copy(u8, newgroups[3], groups[3]); agenda_insert(a, newcandidate); } continue; } { const newgroups = [4][]const u8{ groups[0], groups[1], groups[2], packets }; var m = [4]u32{ 0, 0, 0, 0 }; for (newgroups) |g, i| { for (g) |p| { m[i] += p; } } assert(m[0] == m[1] and m[0] == m[2] and m[0] == m[3]); var s0 = @intCast(u32, newgroups[0].len); if (s0 < curbest.s0 or (s0 == curbest.s0 and qe < curbest.qe)) { curbest.qe = qe; curbest.s0 = s0; trace("new best: {}\n", curbest.*); for (newgroups) |g, i| { trace(" group{} = [", i); for (g) |p| { trace("{}, ", p); } trace("]\n"); } } } } } pub fn main() anyerror!void { 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, "day24.txt", limit); //const packets = [_]u8{1,2,3,4,5,7,8,9,10,11}; //const packets = [_]u8{11,10,9,8,7,5,4,3,2,1}; const packets = [_]u8{ 113, 109, 107, 103, 101, 97, 89, 83, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 23, 19, 17, 13, 11, 7, 3, 2, 1 }; const totalmass = blk: { var m: u16 = 0; for (packets) |p| { m += p; } break :blk m; }; assert(totalmass % 3 == 0 and totalmass % 4 == 0); const targetmass = comptime totalmass / 4; var agenda = try allocator.create(Agenda); agenda_init(agenda); const c0 = Candidate{ .rem0 = targetmass, .rem1 = targetmass, .rem2 = targetmass, .qe = 1, .packets = @intCast(u8, packets.len), .groups = [4]u8{ 0, 0, 0, 0 }, .storage = packets, }; agenda_insert(agenda, c0); var res = Result{ .qe = 99999999999999, .s0 = 99 }; bfs(agenda, &res); const out = std.io.getStdOut().writer(); try out.print("res: {} \n", res); // return error.SolutionNotFound; }
2015/day24.zig
const std = @import("std"); const debug = std.debug; const assert = debug.assert; const assertError = debug.assertError; const warn = debug.warn; const ArrayList = std.ArrayList; const parse_args = @import("parse_args.zig"); const ArgIter = parse_args.ArgIter; const ArgRec = parse_args.ArgRec; const ArgUnionFields = parse_args.ArgUnionFields; const ArgUnion = parse_args.ArgUnion; const parseArgs = parse_args.parseArgs; const parsers = @import("parsers.zig"); const ParseNumber = parsers.ParseNumber; const globals = @import("modules/globals.zig"); fn d(bit: usize) bool { return globals.debug_bits.r(globals.dbg_offset_parse_args + bit) == 1; } fn dbgw(bit: usize, value: usize) void { globals.debug_bits.w(globals.dbg_offset_parse_args + bit, value); } pub fn main() !void { // Initialize the debug bits dbgw(0, 1); dbgw(1, 1); warn("\n"); var arg_list = ArrayList(ArgRec).init(debug.global_allocator); try arg_list.append(ArgRec{ .leader = "", .name = "count", .value_default_set = true, .value_set = false, .arg_union = ArgUnionFields{ .argU32 = ArgUnion(u32){ .parser = ParseNumber(u32).parse, .value_default = 32, .value = 0, }, }, }); // Initialize the os ArgRec Iterator var arg_iter = ArgIter.initOsArgIter(); // Parse the arguments var positional_args = try parseArgs(debug.global_allocator, &arg_iter, arg_list); // Display the positional arguments for (positional_args.toSlice()) |arg, i| { warn("positional_args[{}]={}\n", i, arg); } // Display the options for (arg_list.toSlice()) |arg, i| { warn("arg_list[{}]: name={} value_set={} arg.value=", i, arg.name, arg.value_set); switch (arg.arg_union) { ArgUnionFields.argU32 => warn("{}", arg.arg_union.argU32.value), ArgUnionFields.argI32 => warn("{}", arg.arg_union.argI32.value), ArgUnionFields.argU64 => warn("{}", arg.arg_union.argU64.value), ArgUnionFields.argI64 => warn("{}", arg.arg_union.argI64.value), ArgUnionFields.argU128 => warn("0x{x}", arg.arg_union.argU128.value), ArgUnionFields.argI128 => warn("{}", arg.arg_union.argI128.value), ArgUnionFields.argF32 => warn("{}", arg.arg_union.argF32.value), ArgUnionFields.argF64 => warn("{}", arg.arg_union.argF64.value), ArgUnionFields.argAlloced => { warn("{} &value[0]={*}", arg.arg_union.argAlloced.value, &arg.arg_union.argAlloced.value[0]); }, } warn("\n"); } // Free data any allocated data of ArgUnionFields.argAlloced for (arg_list.toSlice()) |arg, i| { switch (arg.arg_union) { ArgUnionFields.argAlloced => { if (arg.value_set) { warn("free arg_list[{}]: name={} value_set={} arg.value={}\n", i, arg.name, arg.value_set, arg.arg_union.argAlloced.value); debug.global_allocator.free(arg.arg_union.argAlloced.value); } }, else => {}, } } debug.global_allocator.free(arg_list.items); }
test_app.zig
pub const MKSYS_URLMONIKER = @as(u32, 6); pub const URL_MK_LEGACY = @as(u32, 0); pub const URL_MK_UNIFORM = @as(u32, 1); pub const URL_MK_NO_CANONICALIZE = @as(u32, 2); pub const FIEF_FLAG_FORCE_JITUI = @as(u32, 1); pub const FIEF_FLAG_PEEK = @as(u32, 2); pub const FIEF_FLAG_SKIP_INSTALLED_VERSION_CHECK = @as(u32, 4); pub const FIEF_FLAG_RESERVED_0 = @as(u32, 8); pub const FMFD_DEFAULT = @as(u32, 0); pub const FMFD_URLASFILENAME = @as(u32, 1); pub const FMFD_ENABLEMIMESNIFFING = @as(u32, 2); pub const FMFD_IGNOREMIMETEXTPLAIN = @as(u32, 4); pub const FMFD_SERVERMIME = @as(u32, 8); pub const FMFD_RESPECTTEXTPLAIN = @as(u32, 16); pub const FMFD_RETURNUPDATEDIMGMIMES = @as(u32, 32); pub const FMFD_RESERVED_1 = @as(u32, 64); pub const FMFD_RESERVED_2 = @as(u32, 128); pub const UAS_EXACTLEGACY = @as(u32, 4096); pub const URLMON_OPTION_USERAGENT = @as(u32, 268435457); pub const URLMON_OPTION_USERAGENT_REFRESH = @as(u32, 268435458); pub const URLMON_OPTION_URL_ENCODING = @as(u32, 268435460); pub const URLMON_OPTION_USE_BINDSTRINGCREDS = @as(u32, 268435464); pub const URLMON_OPTION_USE_BROWSERAPPSDOCUMENTS = @as(u32, 268435472); pub const CF_NULL = @as(u32, 0); pub const MK_S_ASYNCHRONOUS = @import("../../zig.zig").typedConst(HRESULT, @as(i32, 262632)); pub const S_ASYNCHRONOUS = @as(i32, 262632); pub const E_PENDING = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2147483638)); pub const INET_E_INVALID_URL = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697214)); pub const INET_E_NO_SESSION = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697213)); pub const INET_E_CANNOT_CONNECT = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697212)); pub const INET_E_RESOURCE_NOT_FOUND = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697211)); pub const INET_E_OBJECT_NOT_FOUND = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697210)); pub const INET_E_DATA_NOT_AVAILABLE = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697209)); pub const INET_E_DOWNLOAD_FAILURE = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697208)); pub const INET_E_AUTHENTICATION_REQUIRED = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697207)); pub const INET_E_NO_VALID_MEDIA = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697206)); pub const INET_E_CONNECTION_TIMEOUT = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697205)); pub const INET_E_INVALID_REQUEST = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697204)); pub const INET_E_UNKNOWN_PROTOCOL = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697203)); pub const INET_E_SECURITY_PROBLEM = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697202)); pub const INET_E_CANNOT_LOAD_DATA = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697201)); pub const INET_E_CANNOT_INSTANTIATE_OBJECT = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697200)); pub const INET_E_INVALID_CERTIFICATE = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697191)); pub const INET_E_REDIRECT_FAILED = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697196)); pub const INET_E_REDIRECT_TO_DIR = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697195)); pub const INET_E_CANNOT_LOCK_REQUEST = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697194)); pub const INET_E_USE_EXTEND_BINDING = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697193)); pub const INET_E_TERMINATED_BIND = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697192)); pub const INET_E_RESERVED_1 = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697190)); pub const INET_E_BLOCKED_REDIRECT_XSECURITYID = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697189)); pub const INET_E_DOMINJECTIONVALIDATION = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697188)); pub const INET_E_VTAB_SWITCH_FORCE_ENGINE = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697187)); pub const INET_E_HSTS_CERTIFICATE_ERROR = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697186)); pub const INET_E_RESERVED_2 = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697185)); pub const INET_E_RESERVED_3 = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697184)); pub const INET_E_RESERVED_4 = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697183)); pub const INET_E_RESERVED_5 = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697182)); pub const INET_E_ERROR_FIRST = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697214)); pub const INET_E_CODE_DOWNLOAD_DECLINED = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146696960)); pub const INET_E_RESULT_DISPATCHED = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146696704)); pub const INET_E_CANNOT_REPLACE_SFP_FILE = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146696448)); pub const INET_E_CODE_INSTALL_SUPPRESSED = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146696192)); pub const INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695936)); pub const INET_E_DOWNLOAD_BLOCKED_BY_INPRIVATE = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695935)); pub const INET_E_CODE_INSTALL_BLOCKED_IMMERSIVE = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695934)); pub const INET_E_FORBIDFRAMING = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695933)); pub const INET_E_CODE_INSTALL_BLOCKED_ARM = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695932)); pub const INET_E_BLOCKED_PLUGGABLE_PROTOCOL = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695931)); pub const INET_E_BLOCKED_ENHANCEDPROTECTEDMODE = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695930)); pub const INET_E_CODE_INSTALL_BLOCKED_BITNESS = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695929)); pub const INET_E_DOWNLOAD_BLOCKED_BY_CSP = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146695928)); pub const INET_E_ERROR_LAST = @as(i32, -2146695928); pub const Uri_DISPLAY_NO_FRAGMENT = @as(u32, 1); pub const Uri_PUNYCODE_IDN_HOST = @as(u32, 2); pub const Uri_DISPLAY_IDN_HOST = @as(u32, 4); pub const Uri_DISPLAY_NO_PUNYCODE = @as(u32, 8); pub const Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8 = @as(u32, 1); pub const Uri_ENCODING_USER_INFO_AND_PATH_IS_CP = @as(u32, 2); pub const Uri_ENCODING_HOST_IS_IDN = @as(u32, 4); pub const Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8 = @as(u32, 8); pub const Uri_ENCODING_HOST_IS_PERCENT_ENCODED_CP = @as(u32, 16); pub const Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8 = @as(u32, 32); pub const Uri_ENCODING_QUERY_AND_FRAGMENT_IS_CP = @as(u32, 64); pub const UriBuilder_USE_ORIGINAL_FLAGS = @as(u32, 1); pub const WININETINFO_OPTION_LOCK_HANDLE = @as(u32, 65534); pub const URLOSTRM_USECACHEDCOPY_ONLY = @as(u32, 1); pub const URLOSTRM_USECACHEDCOPY = @as(u32, 2); pub const URLOSTRM_GETNEWESTVERSION = @as(u32, 3); pub const SET_FEATURE_ON_THREAD = @as(u32, 1); pub const SET_FEATURE_ON_PROCESS = @as(u32, 2); pub const SET_FEATURE_IN_REGISTRY = @as(u32, 4); pub const SET_FEATURE_ON_THREAD_LOCALMACHINE = @as(u32, 8); pub const SET_FEATURE_ON_THREAD_INTRANET = @as(u32, 16); pub const SET_FEATURE_ON_THREAD_TRUSTED = @as(u32, 32); pub const SET_FEATURE_ON_THREAD_INTERNET = @as(u32, 64); pub const SET_FEATURE_ON_THREAD_RESTRICTED = @as(u32, 128); pub const GET_FEATURE_FROM_THREAD = @as(u32, 1); pub const GET_FEATURE_FROM_PROCESS = @as(u32, 2); pub const GET_FEATURE_FROM_REGISTRY = @as(u32, 4); pub const GET_FEATURE_FROM_THREAD_LOCALMACHINE = @as(u32, 8); pub const GET_FEATURE_FROM_THREAD_INTRANET = @as(u32, 16); pub const GET_FEATURE_FROM_THREAD_TRUSTED = @as(u32, 32); pub const GET_FEATURE_FROM_THREAD_INTERNET = @as(u32, 64); pub const GET_FEATURE_FROM_THREAD_RESTRICTED = @as(u32, 128); pub const INET_E_USE_DEFAULT_PROTOCOLHANDLER = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697199)); pub const INET_E_USE_DEFAULT_SETTING = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697198)); pub const INET_E_DEFAULT_ACTION = @as(i32, -2146697199); pub const INET_E_QUERYOPTION_UNKNOWN = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697197)); pub const INET_E_REDIRECTING = @import("../../zig.zig").typedConst(HRESULT, @as(i32, -2146697196)); pub const PROTOCOLFLAG_NO_PICS_CHECK = @as(u32, 1); pub const MUTZ_NOSAVEDFILECHECK = @as(u32, 1); pub const MUTZ_ISFILE = @as(u32, 2); pub const MUTZ_ACCEPT_WILDCARD_SCHEME = @as(u32, 128); pub const MUTZ_ENFORCERESTRICTED = @as(u32, 256); pub const MUTZ_RESERVED = @as(u32, 512); pub const MUTZ_REQUIRESAVEDFILECHECK = @as(u32, 1024); pub const MUTZ_DONT_UNESCAPE = @as(u32, 2048); pub const MUTZ_DONT_USE_CACHE = @as(u32, 4096); pub const MUTZ_FORCE_INTRANET_FLAGS = @as(u32, 8192); pub const MUTZ_IGNORE_ZONE_MAPPINGS = @as(u32, 16384); pub const MAX_SIZE_SECURITY_ID = @as(u32, 512); pub const URLACTION_MIN = @as(u32, 4096); pub const URLACTION_DOWNLOAD_MIN = @as(u32, 4096); pub const URLACTION_DOWNLOAD_SIGNED_ACTIVEX = @as(u32, 4097); pub const URLACTION_DOWNLOAD_UNSIGNED_ACTIVEX = @as(u32, 4100); pub const URLACTION_DOWNLOAD_CURR_MAX = @as(u32, 4100); pub const URLACTION_DOWNLOAD_MAX = @as(u32, 4607); pub const URLACTION_ACTIVEX_MIN = @as(u32, 4608); pub const URLACTION_ACTIVEX_RUN = @as(u32, 4608); pub const URLPOLICY_ACTIVEX_CHECK_LIST = @as(u32, 65536); pub const URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY = @as(u32, 4609); pub const URLACTION_ACTIVEX_OVERRIDE_DATA_SAFETY = @as(u32, 4610); pub const URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY = @as(u32, 4611); pub const URLACTION_SCRIPT_OVERRIDE_SAFETY = @as(u32, 5121); pub const URLACTION_ACTIVEX_CONFIRM_NOOBJECTSAFETY = @as(u32, 4612); pub const URLACTION_ACTIVEX_TREATASUNTRUSTED = @as(u32, 4613); pub const URLACTION_ACTIVEX_NO_WEBOC_SCRIPT = @as(u32, 4614); pub const URLACTION_ACTIVEX_OVERRIDE_REPURPOSEDETECTION = @as(u32, 4615); pub const URLACTION_ACTIVEX_OVERRIDE_OPTIN = @as(u32, 4616); pub const URLACTION_ACTIVEX_SCRIPTLET_RUN = @as(u32, 4617); pub const URLACTION_ACTIVEX_DYNSRC_VIDEO_AND_ANIMATION = @as(u32, 4618); pub const URLACTION_ACTIVEX_OVERRIDE_DOMAINLIST = @as(u32, 4619); pub const URLACTION_ACTIVEX_ALLOW_TDC = @as(u32, 4620); pub const URLACTION_ACTIVEX_CURR_MAX = @as(u32, 4620); pub const URLACTION_ACTIVEX_MAX = @as(u32, 5119); pub const URLACTION_SCRIPT_MIN = @as(u32, 5120); pub const URLACTION_SCRIPT_RUN = @as(u32, 5120); pub const URLACTION_SCRIPT_JAVA_USE = @as(u32, 5122); pub const URLACTION_SCRIPT_SAFE_ACTIVEX = @as(u32, 5125); pub const URLACTION_CROSS_DOMAIN_DATA = @as(u32, 5126); pub const URLACTION_SCRIPT_PASTE = @as(u32, 5127); pub const URLACTION_ALLOW_XDOMAIN_SUBFRAME_RESIZE = @as(u32, 5128); pub const URLACTION_SCRIPT_XSSFILTER = @as(u32, 5129); pub const URLACTION_SCRIPT_NAVIGATE = @as(u32, 5130); pub const URLACTION_PLUGGABLE_PROTOCOL_XHR = @as(u32, 5131); pub const URLACTION_ALLOW_VBSCRIPT_IE = @as(u32, 5132); pub const URLACTION_ALLOW_JSCRIPT_IE = @as(u32, 5133); pub const URLACTION_SCRIPT_CURR_MAX = @as(u32, 5133); pub const URLACTION_SCRIPT_MAX = @as(u32, 5631); pub const URLACTION_HTML_MIN = @as(u32, 5632); pub const URLACTION_HTML_SUBMIT_FORMS = @as(u32, 5633); pub const URLACTION_HTML_SUBMIT_FORMS_FROM = @as(u32, 5634); pub const URLACTION_HTML_SUBMIT_FORMS_TO = @as(u32, 5635); pub const URLACTION_HTML_FONT_DOWNLOAD = @as(u32, 5636); pub const URLACTION_HTML_JAVA_RUN = @as(u32, 5637); pub const URLACTION_HTML_USERDATA_SAVE = @as(u32, 5638); pub const URLACTION_HTML_SUBFRAME_NAVIGATE = @as(u32, 5639); pub const URLACTION_HTML_META_REFRESH = @as(u32, 5640); pub const URLACTION_HTML_MIXED_CONTENT = @as(u32, 5641); pub const URLACTION_HTML_INCLUDE_FILE_PATH = @as(u32, 5642); pub const URLACTION_HTML_ALLOW_INJECTED_DYNAMIC_HTML = @as(u32, 5643); pub const URLACTION_HTML_REQUIRE_UTF8_DOCUMENT_CODEPAGE = @as(u32, 5644); pub const URLACTION_HTML_ALLOW_CROSS_DOMAIN_CANVAS = @as(u32, 5645); pub const URLACTION_HTML_ALLOW_WINDOW_CLOSE = @as(u32, 5646); pub const URLACTION_HTML_ALLOW_CROSS_DOMAIN_WEBWORKER = @as(u32, 5647); pub const URLACTION_HTML_ALLOW_CROSS_DOMAIN_TEXTTRACK = @as(u32, 5648); pub const URLACTION_HTML_ALLOW_INDEXEDDB = @as(u32, 5649); pub const URLACTION_HTML_MAX = @as(u32, 6143); pub const URLACTION_SHELL_MIN = @as(u32, 6144); pub const URLACTION_SHELL_INSTALL_DTITEMS = @as(u32, 6144); pub const URLACTION_SHELL_MOVE_OR_COPY = @as(u32, 6146); pub const URLACTION_SHELL_FILE_DOWNLOAD = @as(u32, 6147); pub const URLACTION_SHELL_VERB = @as(u32, 6148); pub const URLACTION_SHELL_WEBVIEW_VERB = @as(u32, 6149); pub const URLACTION_SHELL_SHELLEXECUTE = @as(u32, 6150); pub const URLACTION_SHELL_EXECUTE_HIGHRISK = @as(u32, 6150); pub const URLACTION_SHELL_EXECUTE_MODRISK = @as(u32, 6151); pub const URLACTION_SHELL_EXECUTE_LOWRISK = @as(u32, 6152); pub const URLACTION_SHELL_POPUPMGR = @as(u32, 6153); pub const URLACTION_SHELL_RTF_OBJECTS_LOAD = @as(u32, 6154); pub const URLACTION_SHELL_ENHANCED_DRAGDROP_SECURITY = @as(u32, 6155); pub const URLACTION_SHELL_EXTENSIONSECURITY = @as(u32, 6156); pub const URLACTION_SHELL_SECURE_DRAGSOURCE = @as(u32, 6157); pub const URLACTION_SHELL_REMOTEQUERY = @as(u32, 6158); pub const URLACTION_SHELL_PREVIEW = @as(u32, 6159); pub const URLACTION_SHELL_SHARE = @as(u32, 6160); pub const URLACTION_SHELL_ALLOW_CROSS_SITE_SHARE = @as(u32, 6161); pub const URLACTION_SHELL_TOCTOU_RISK = @as(u32, 6162); pub const URLACTION_SHELL_CURR_MAX = @as(u32, 6162); pub const URLACTION_SHELL_MAX = @as(u32, 6655); pub const URLACTION_NETWORK_MIN = @as(u32, 6656); pub const URLACTION_CREDENTIALS_USE = @as(u32, 6656); pub const URLPOLICY_CREDENTIALS_SILENT_LOGON_OK = @as(u32, 0); pub const URLPOLICY_CREDENTIALS_MUST_PROMPT_USER = @as(u32, 65536); pub const URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT = @as(u32, 131072); pub const URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY = @as(u32, 196608); pub const URLACTION_AUTHENTICATE_CLIENT = @as(u32, 6657); pub const URLPOLICY_AUTHENTICATE_CLEARTEXT_OK = @as(u32, 0); pub const URLPOLICY_AUTHENTICATE_CHALLENGE_RESPONSE = @as(u32, 65536); pub const URLPOLICY_AUTHENTICATE_MUTUAL_ONLY = @as(u32, 196608); pub const URLACTION_COOKIES = @as(u32, 6658); pub const URLACTION_COOKIES_SESSION = @as(u32, 6659); pub const URLACTION_CLIENT_CERT_PROMPT = @as(u32, 6660); pub const URLACTION_COOKIES_THIRD_PARTY = @as(u32, 6661); pub const URLACTION_COOKIES_SESSION_THIRD_PARTY = @as(u32, 6662); pub const URLACTION_COOKIES_ENABLED = @as(u32, 6672); pub const URLACTION_NETWORK_CURR_MAX = @as(u32, 6672); pub const URLACTION_NETWORK_MAX = @as(u32, 7167); pub const URLACTION_JAVA_MIN = @as(u32, 7168); pub const URLACTION_JAVA_PERMISSIONS = @as(u32, 7168); pub const URLPOLICY_JAVA_PROHIBIT = @as(u32, 0); pub const URLPOLICY_JAVA_HIGH = @as(u32, 65536); pub const URLPOLICY_JAVA_MEDIUM = @as(u32, 131072); pub const URLPOLICY_JAVA_LOW = @as(u32, 196608); pub const URLPOLICY_JAVA_CUSTOM = @as(u32, 8388608); pub const URLACTION_JAVA_CURR_MAX = @as(u32, 7168); pub const URLACTION_JAVA_MAX = @as(u32, 7423); pub const URLACTION_INFODELIVERY_MIN = @as(u32, 7424); pub const URLACTION_INFODELIVERY_NO_ADDING_CHANNELS = @as(u32, 7424); pub const URLACTION_INFODELIVERY_NO_EDITING_CHANNELS = @as(u32, 7425); pub const URLACTION_INFODELIVERY_NO_REMOVING_CHANNELS = @as(u32, 7426); pub const URLACTION_INFODELIVERY_NO_ADDING_SUBSCRIPTIONS = @as(u32, 7427); pub const URLACTION_INFODELIVERY_NO_EDITING_SUBSCRIPTIONS = @as(u32, 7428); pub const URLACTION_INFODELIVERY_NO_REMOVING_SUBSCRIPTIONS = @as(u32, 7429); pub const URLACTION_INFODELIVERY_NO_CHANNEL_LOGGING = @as(u32, 7430); pub const URLACTION_INFODELIVERY_CURR_MAX = @as(u32, 7430); pub const URLACTION_INFODELIVERY_MAX = @as(u32, 7679); pub const URLACTION_CHANNEL_SOFTDIST_MIN = @as(u32, 7680); pub const URLACTION_CHANNEL_SOFTDIST_PERMISSIONS = @as(u32, 7685); pub const URLPOLICY_CHANNEL_SOFTDIST_PROHIBIT = @as(u32, 65536); pub const URLPOLICY_CHANNEL_SOFTDIST_PRECACHE = @as(u32, 131072); pub const URLPOLICY_CHANNEL_SOFTDIST_AUTOINSTALL = @as(u32, 196608); pub const URLACTION_CHANNEL_SOFTDIST_MAX = @as(u32, 7935); pub const URLACTION_DOTNET_USERCONTROLS = @as(u32, 8197); pub const URLACTION_BEHAVIOR_MIN = @as(u32, 8192); pub const URLACTION_BEHAVIOR_RUN = @as(u32, 8192); pub const URLPOLICY_BEHAVIOR_CHECK_LIST = @as(u32, 65536); pub const URLACTION_FEATURE_MIN = @as(u32, 8448); pub const URLACTION_FEATURE_MIME_SNIFFING = @as(u32, 8448); pub const URLACTION_FEATURE_ZONE_ELEVATION = @as(u32, 8449); pub const URLACTION_FEATURE_WINDOW_RESTRICTIONS = @as(u32, 8450); pub const URLACTION_FEATURE_SCRIPT_STATUS_BAR = @as(u32, 8451); pub const URLACTION_FEATURE_FORCE_ADDR_AND_STATUS = @as(u32, 8452); pub const URLACTION_FEATURE_BLOCK_INPUT_PROMPTS = @as(u32, 8453); pub const URLACTION_FEATURE_DATA_BINDING = @as(u32, 8454); pub const URLACTION_FEATURE_CROSSDOMAIN_FOCUS_CHANGE = @as(u32, 8455); pub const URLACTION_AUTOMATIC_DOWNLOAD_UI_MIN = @as(u32, 8704); pub const URLACTION_AUTOMATIC_DOWNLOAD_UI = @as(u32, 8704); pub const URLACTION_AUTOMATIC_ACTIVEX_UI = @as(u32, 8705); pub const URLACTION_ALLOW_RESTRICTEDPROTOCOLS = @as(u32, 8960); pub const URLACTION_ALLOW_APEVALUATION = @as(u32, 8961); pub const URLACTION_ALLOW_XHR_EVALUATION = @as(u32, 8962); pub const URLACTION_WINDOWS_BROWSER_APPLICATIONS = @as(u32, 9216); pub const URLACTION_XPS_DOCUMENTS = @as(u32, 9217); pub const URLACTION_LOOSE_XAML = @as(u32, 9218); pub const URLACTION_LOWRIGHTS = @as(u32, 9472); pub const URLACTION_WINFX_SETUP = @as(u32, 9728); pub const URLACTION_INPRIVATE_BLOCKING = @as(u32, 9984); pub const URLACTION_ALLOW_AUDIO_VIDEO = @as(u32, 9985); pub const URLACTION_ALLOW_ACTIVEX_FILTERING = @as(u32, 9986); pub const URLACTION_ALLOW_STRUCTURED_STORAGE_SNIFFING = @as(u32, 9987); pub const URLACTION_ALLOW_AUDIO_VIDEO_PLUGINS = @as(u32, 9988); pub const URLACTION_ALLOW_ZONE_ELEVATION_VIA_OPT_OUT = @as(u32, 9989); pub const URLACTION_ALLOW_ZONE_ELEVATION_OPT_OUT_ADDITION = @as(u32, 9990); pub const URLACTION_ALLOW_CROSSDOMAIN_DROP_WITHIN_WINDOW = @as(u32, 9992); pub const URLACTION_ALLOW_CROSSDOMAIN_DROP_ACROSS_WINDOWS = @as(u32, 9993); pub const URLACTION_ALLOW_CROSSDOMAIN_APPCACHE_MANIFEST = @as(u32, 9994); pub const URLACTION_ALLOW_RENDER_LEGACY_DXTFILTERS = @as(u32, 9995); pub const URLACTION_ALLOW_ANTIMALWARE_SCANNING_OF_ACTIVEX = @as(u32, 9996); pub const URLACTION_ALLOW_CSS_EXPRESSIONS = @as(u32, 9997); pub const URLPOLICY_ALLOW = @as(u32, 0); pub const URLPOLICY_QUERY = @as(u32, 1); pub const URLPOLICY_DISALLOW = @as(u32, 3); pub const URLPOLICY_NOTIFY_ON_ALLOW = @as(u32, 16); pub const URLPOLICY_NOTIFY_ON_DISALLOW = @as(u32, 32); pub const URLPOLICY_LOG_ON_ALLOW = @as(u32, 64); pub const URLPOLICY_LOG_ON_DISALLOW = @as(u32, 128); pub const URLPOLICY_MASK_PERMISSIONS = @as(u32, 15); pub const URLPOLICY_DONTCHECKDLGBOX = @as(u32, 256); pub const URLZONE_ESC_FLAG = @as(u32, 256); pub const SECURITY_IE_STATE_GREEN = @as(u32, 0); pub const SECURITY_IE_STATE_RED = @as(u32, 1); pub const SOFTDIST_FLAG_USAGE_EMAIL = @as(u32, 1); pub const SOFTDIST_FLAG_USAGE_PRECACHE = @as(u32, 2); pub const SOFTDIST_FLAG_USAGE_AUTOINSTALL = @as(u32, 4); pub const SOFTDIST_FLAG_DELETE_SUBSCRIPTION = @as(u32, 8); pub const SOFTDIST_ADSTATE_NONE = @as(u32, 0); pub const SOFTDIST_ADSTATE_AVAILABLE = @as(u32, 1); pub const SOFTDIST_ADSTATE_DOWNLOADED = @as(u32, 2); pub const SOFTDIST_ADSTATE_INSTALLED = @as(u32, 3); pub const CONFIRMSAFETYACTION_LOADOBJECT = @as(u32, 1); //-------------------------------------------------------------------------------- // Section: Types (88) //-------------------------------------------------------------------------------- pub const IEObjectType = enum(i32) { EVENT = 0, MUTEX = 1, SEMAPHORE = 2, SHARED_MEMORY = 3, WAITABLE_TIMER = 4, FILE = 5, NAMED_PIPE = 6, REGISTRY = 7, }; pub const IE_EPM_OBJECT_EVENT = IEObjectType.EVENT; pub const IE_EPM_OBJECT_MUTEX = IEObjectType.MUTEX; pub const IE_EPM_OBJECT_SEMAPHORE = IEObjectType.SEMAPHORE; pub const IE_EPM_OBJECT_SHARED_MEMORY = IEObjectType.SHARED_MEMORY; pub const IE_EPM_OBJECT_WAITABLE_TIMER = IEObjectType.WAITABLE_TIMER; pub const IE_EPM_OBJECT_FILE = IEObjectType.FILE; pub const IE_EPM_OBJECT_NAMED_PIPE = IEObjectType.NAMED_PIPE; pub const IE_EPM_OBJECT_REGISTRY = IEObjectType.REGISTRY; const IID_IPersistMoniker_Value = @import("../../zig.zig").Guid.initString("79eac9c9-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IPersistMoniker = &IID_IPersistMoniker_Value; pub const IPersistMoniker = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetClassID: fn( self: *const IPersistMoniker, pClassID: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT, IsDirty: fn( self: *const IPersistMoniker, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Load: fn( self: *const IPersistMoniker, fFullyAvailable: BOOL, pimkName: ?*IMoniker, pibc: ?*IBindCtx, grfMode: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Save: fn( self: *const IPersistMoniker, pimkName: ?*IMoniker, pbc: ?*IBindCtx, fRemember: BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SaveCompleted: fn( self: *const IPersistMoniker, pimkName: ?*IMoniker, pibc: ?*IBindCtx, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetCurMoniker: fn( self: *const IPersistMoniker, ppimkName: ?*?*IMoniker, ) 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 IPersistMoniker_GetClassID(self: *const T, pClassID: ?*Guid) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistMoniker.VTable, self.vtable).GetClassID(@ptrCast(*const IPersistMoniker, self), pClassID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistMoniker_IsDirty(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistMoniker.VTable, self.vtable).IsDirty(@ptrCast(*const IPersistMoniker, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistMoniker_Load(self: *const T, fFullyAvailable: BOOL, pimkName: ?*IMoniker, pibc: ?*IBindCtx, grfMode: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistMoniker.VTable, self.vtable).Load(@ptrCast(*const IPersistMoniker, self), fFullyAvailable, pimkName, pibc, grfMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistMoniker_Save(self: *const T, pimkName: ?*IMoniker, pbc: ?*IBindCtx, fRemember: BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistMoniker.VTable, self.vtable).Save(@ptrCast(*const IPersistMoniker, self), pimkName, pbc, fRemember); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistMoniker_SaveCompleted(self: *const T, pimkName: ?*IMoniker, pibc: ?*IBindCtx) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistMoniker.VTable, self.vtable).SaveCompleted(@ptrCast(*const IPersistMoniker, self), pimkName, pibc); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistMoniker_GetCurMoniker(self: *const T, ppimkName: ?*?*IMoniker) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistMoniker.VTable, self.vtable).GetCurMoniker(@ptrCast(*const IPersistMoniker, self), ppimkName); } };} pub usingnamespace MethodMixin(@This()); }; pub const MONIKERPROPERTY = enum(i32) { MIMETYPEPROP = 0, USE_SRC_URL = 1, CLASSIDPROP = 2, TRUSTEDDOWNLOADPROP = 3, POPUPLEVELPROP = 4, }; pub const MIMETYPEPROP = MONIKERPROPERTY.MIMETYPEPROP; pub const USE_SRC_URL = MONIKERPROPERTY.USE_SRC_URL; pub const CLASSIDPROP = MONIKERPROPERTY.CLASSIDPROP; pub const TRUSTEDDOWNLOADPROP = MONIKERPROPERTY.TRUSTEDDOWNLOADPROP; pub const POPUPLEVELPROP = MONIKERPROPERTY.POPUPLEVELPROP; const IID_IMonikerProp_Value = @import("../../zig.zig").Guid.initString("a5ca5f7f-1847-4d87-9c5b-918509f7511d"); pub const IID_IMonikerProp = &IID_IMonikerProp_Value; pub const IMonikerProp = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, PutProperty: fn( self: *const IMonikerProp, mkp: MONIKERPROPERTY, val: ?[*:0]const u16, ) 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 IMonikerProp_PutProperty(self: *const T, mkp: MONIKERPROPERTY, val: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IMonikerProp.VTable, self.vtable).PutProperty(@ptrCast(*const IMonikerProp, self), mkp, val); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IBindProtocol_Value = @import("../../zig.zig").Guid.initString("79eac9cd-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IBindProtocol = &IID_IBindProtocol_Value; pub const IBindProtocol = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, CreateBinding: fn( self: *const IBindProtocol, szUrl: ?[*:0]const u16, pbc: ?*IBindCtx, ppb: ?*?*IBinding, ) 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 IBindProtocol_CreateBinding(self: *const T, szUrl: ?[*:0]const u16, pbc: ?*IBindCtx, ppb: ?*?*IBinding) callconv(.Inline) HRESULT { return @ptrCast(*const IBindProtocol.VTable, self.vtable).CreateBinding(@ptrCast(*const IBindProtocol, self), szUrl, pbc, ppb); } };} pub usingnamespace MethodMixin(@This()); }; pub const BINDVERB = enum(i32) { GET = 0, POST = 1, PUT = 2, CUSTOM = 3, RESERVED1 = 4, }; pub const BINDVERB_GET = BINDVERB.GET; pub const BINDVERB_POST = BINDVERB.POST; pub const BINDVERB_PUT = BINDVERB.PUT; pub const BINDVERB_CUSTOM = BINDVERB.CUSTOM; pub const BINDVERB_RESERVED1 = BINDVERB.RESERVED1; pub const BINDF = enum(i32) { ASYNCHRONOUS = 1, ASYNCSTORAGE = 2, NOPROGRESSIVERENDERING = 4, OFFLINEOPERATION = 8, GETNEWESTVERSION = 16, NOWRITECACHE = 32, NEEDFILE = 64, PULLDATA = 128, IGNORESECURITYPROBLEM = 256, RESYNCHRONIZE = 512, HYPERLINK = 1024, NO_UI = 2048, SILENTOPERATION = 4096, PRAGMA_NO_CACHE = 8192, GETCLASSOBJECT = 16384, RESERVED_1 = 32768, FREE_THREADED = 65536, DIRECT_READ = 131072, FORMS_SUBMIT = 262144, GETFROMCACHE_IF_NET_FAIL = 524288, FROMURLMON = 1048576, FWD_BACK = 2097152, PREFERDEFAULTHANDLER = 4194304, ENFORCERESTRICTED = 8388608, RESERVED_2 = -2147483648, RESERVED_3 = 16777216, RESERVED_4 = 33554432, RESERVED_5 = 67108864, RESERVED_6 = 134217728, RESERVED_7 = 1073741824, RESERVED_8 = 536870912, }; pub const BINDF_ASYNCHRONOUS = BINDF.ASYNCHRONOUS; pub const BINDF_ASYNCSTORAGE = BINDF.ASYNCSTORAGE; pub const BINDF_NOPROGRESSIVERENDERING = BINDF.NOPROGRESSIVERENDERING; pub const BINDF_OFFLINEOPERATION = BINDF.OFFLINEOPERATION; pub const BINDF_GETNEWESTVERSION = BINDF.GETNEWESTVERSION; pub const BINDF_NOWRITECACHE = BINDF.NOWRITECACHE; pub const BINDF_NEEDFILE = BINDF.NEEDFILE; pub const BINDF_PULLDATA = BINDF.PULLDATA; pub const BINDF_IGNORESECURITYPROBLEM = BINDF.IGNORESECURITYPROBLEM; pub const BINDF_RESYNCHRONIZE = BINDF.RESYNCHRONIZE; pub const BINDF_HYPERLINK = BINDF.HYPERLINK; pub const BINDF_NO_UI = BINDF.NO_UI; pub const BINDF_SILENTOPERATION = BINDF.SILENTOPERATION; pub const BINDF_PRAGMA_NO_CACHE = BINDF.PRAGMA_NO_CACHE; pub const BINDF_GETCLASSOBJECT = BINDF.GETCLASSOBJECT; pub const BINDF_RESERVED_1 = BINDF.RESERVED_1; pub const BINDF_FREE_THREADED = BINDF.FREE_THREADED; pub const BINDF_DIRECT_READ = BINDF.DIRECT_READ; pub const BINDF_FORMS_SUBMIT = BINDF.FORMS_SUBMIT; pub const BINDF_GETFROMCACHE_IF_NET_FAIL = BINDF.GETFROMCACHE_IF_NET_FAIL; pub const BINDF_FROMURLMON = BINDF.FROMURLMON; pub const BINDF_FWD_BACK = BINDF.FWD_BACK; pub const BINDF_PREFERDEFAULTHANDLER = BINDF.PREFERDEFAULTHANDLER; pub const BINDF_ENFORCERESTRICTED = BINDF.ENFORCERESTRICTED; pub const BINDF_RESERVED_2 = BINDF.RESERVED_2; pub const BINDF_RESERVED_3 = BINDF.RESERVED_3; pub const BINDF_RESERVED_4 = BINDF.RESERVED_4; pub const BINDF_RESERVED_5 = BINDF.RESERVED_5; pub const BINDF_RESERVED_6 = BINDF.RESERVED_6; pub const BINDF_RESERVED_7 = BINDF.RESERVED_7; pub const BINDF_RESERVED_8 = BINDF.RESERVED_8; pub const URL_ENCODING = enum(i32) { NONE = 0, ENABLE_UTF8 = 268435456, DISABLE_UTF8 = 536870912, }; pub const URL_ENCODING_NONE = URL_ENCODING.NONE; pub const URL_ENCODING_ENABLE_UTF8 = URL_ENCODING.ENABLE_UTF8; pub const URL_ENCODING_DISABLE_UTF8 = URL_ENCODING.DISABLE_UTF8; pub const REMSECURITY_ATTRIBUTES = extern struct { nLength: u32, lpSecurityDescriptor: u32, bInheritHandle: BOOL, }; pub const RemBINDINFO = extern struct { cbSize: u32, szExtraInfo: ?PWSTR, grfBindInfoF: u32, dwBindVerb: u32, szCustomVerb: ?PWSTR, cbstgmedData: u32, dwOptions: u32, dwOptionsFlags: u32, dwCodePage: u32, securityAttributes: REMSECURITY_ATTRIBUTES, iid: Guid, pUnk: ?*IUnknown, dwReserved: u32, }; pub const RemFORMATETC = extern struct { cfFormat: u32, ptd: u32, dwAspect: u32, lindex: i32, tymed: u32, }; pub const BINDINFO_OPTIONS = enum(i32) { OPTIONS_WININETFLAG = 65536, OPTIONS_ENABLE_UTF8 = 131072, OPTIONS_DISABLE_UTF8 = 262144, OPTIONS_USE_IE_ENCODING = 524288, OPTIONS_BINDTOOBJECT = 1048576, OPTIONS_SECURITYOPTOUT = 2097152, OPTIONS_IGNOREMIMETEXTPLAIN = 4194304, OPTIONS_USEBINDSTRINGCREDS = 8388608, OPTIONS_IGNOREHTTPHTTPSREDIRECTS = 16777216, OPTIONS_IGNORE_SSLERRORS_ONCE = 33554432, WPC_DOWNLOADBLOCKED = 134217728, WPC_LOGGING_ENABLED = 268435456, OPTIONS_ALLOWCONNECTDATA = 536870912, OPTIONS_DISABLEAUTOREDIRECTS = 1073741824, OPTIONS_SHDOCVW_NAVIGATE = -2147483648, }; pub const BINDINFO_OPTIONS_WININETFLAG = BINDINFO_OPTIONS.OPTIONS_WININETFLAG; pub const BINDINFO_OPTIONS_ENABLE_UTF8 = BINDINFO_OPTIONS.OPTIONS_ENABLE_UTF8; pub const BINDINFO_OPTIONS_DISABLE_UTF8 = BINDINFO_OPTIONS.OPTIONS_DISABLE_UTF8; pub const BINDINFO_OPTIONS_USE_IE_ENCODING = BINDINFO_OPTIONS.OPTIONS_USE_IE_ENCODING; pub const BINDINFO_OPTIONS_BINDTOOBJECT = BINDINFO_OPTIONS.OPTIONS_BINDTOOBJECT; pub const BINDINFO_OPTIONS_SECURITYOPTOUT = BINDINFO_OPTIONS.OPTIONS_SECURITYOPTOUT; pub const BINDINFO_OPTIONS_IGNOREMIMETEXTPLAIN = BINDINFO_OPTIONS.OPTIONS_IGNOREMIMETEXTPLAIN; pub const BINDINFO_OPTIONS_USEBINDSTRINGCREDS = BINDINFO_OPTIONS.OPTIONS_USEBINDSTRINGCREDS; pub const BINDINFO_OPTIONS_IGNOREHTTPHTTPSREDIRECTS = BINDINFO_OPTIONS.OPTIONS_IGNOREHTTPHTTPSREDIRECTS; pub const BINDINFO_OPTIONS_IGNORE_SSLERRORS_ONCE = BINDINFO_OPTIONS.OPTIONS_IGNORE_SSLERRORS_ONCE; pub const BINDINFO_WPC_DOWNLOADBLOCKED = BINDINFO_OPTIONS.WPC_DOWNLOADBLOCKED; pub const BINDINFO_WPC_LOGGING_ENABLED = BINDINFO_OPTIONS.WPC_LOGGING_ENABLED; pub const BINDINFO_OPTIONS_ALLOWCONNECTDATA = BINDINFO_OPTIONS.OPTIONS_ALLOWCONNECTDATA; pub const BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS = BINDINFO_OPTIONS.OPTIONS_DISABLEAUTOREDIRECTS; pub const BINDINFO_OPTIONS_SHDOCVW_NAVIGATE = BINDINFO_OPTIONS.OPTIONS_SHDOCVW_NAVIGATE; pub const BSCF = enum(i32) { FIRSTDATANOTIFICATION = 1, INTERMEDIATEDATANOTIFICATION = 2, LASTDATANOTIFICATION = 4, DATAFULLYAVAILABLE = 8, AVAILABLEDATASIZEUNKNOWN = 16, SKIPDRAINDATAFORFILEURLS = 32, @"64BITLENGTHDOWNLOAD" = 64, }; pub const BSCF_FIRSTDATANOTIFICATION = BSCF.FIRSTDATANOTIFICATION; pub const BSCF_INTERMEDIATEDATANOTIFICATION = BSCF.INTERMEDIATEDATANOTIFICATION; pub const BSCF_LASTDATANOTIFICATION = BSCF.LASTDATANOTIFICATION; pub const BSCF_DATAFULLYAVAILABLE = BSCF.DATAFULLYAVAILABLE; pub const BSCF_AVAILABLEDATASIZEUNKNOWN = BSCF.AVAILABLEDATASIZEUNKNOWN; pub const BSCF_SKIPDRAINDATAFORFILEURLS = BSCF.SKIPDRAINDATAFORFILEURLS; pub const BSCF_64BITLENGTHDOWNLOAD = BSCF.@"64BITLENGTHDOWNLOAD"; pub const BINDSTATUS = enum(i32) { FINDINGRESOURCE = 1, CONNECTING = 2, REDIRECTING = 3, BEGINDOWNLOADDATA = 4, DOWNLOADINGDATA = 5, ENDDOWNLOADDATA = 6, BEGINDOWNLOADCOMPONENTS = 7, INSTALLINGCOMPONENTS = 8, ENDDOWNLOADCOMPONENTS = 9, USINGCACHEDCOPY = 10, SENDINGREQUEST = 11, CLASSIDAVAILABLE = 12, MIMETYPEAVAILABLE = 13, CACHEFILENAMEAVAILABLE = 14, BEGINSYNCOPERATION = 15, ENDSYNCOPERATION = 16, BEGINUPLOADDATA = 17, UPLOADINGDATA = 18, ENDUPLOADDATA = 19, PROTOCOLCLASSID = 20, ENCODING = 21, VERIFIEDMIMETYPEAVAILABLE = 22, CLASSINSTALLLOCATION = 23, DECODING = 24, LOADINGMIMEHANDLER = 25, CONTENTDISPOSITIONATTACH = 26, FILTERREPORTMIMETYPE = 27, CLSIDCANINSTANTIATE = 28, IUNKNOWNAVAILABLE = 29, DIRECTBIND = 30, RAWMIMETYPE = 31, PROXYDETECTING = 32, ACCEPTRANGES = 33, COOKIE_SENT = 34, COMPACT_POLICY_RECEIVED = 35, COOKIE_SUPPRESSED = 36, COOKIE_STATE_UNKNOWN = 37, COOKIE_STATE_ACCEPT = 38, COOKIE_STATE_REJECT = 39, COOKIE_STATE_PROMPT = 40, COOKIE_STATE_LEASH = 41, COOKIE_STATE_DOWNGRADE = 42, POLICY_HREF = 43, P3P_HEADER = 44, SESSION_COOKIE_RECEIVED = 45, PERSISTENT_COOKIE_RECEIVED = 46, SESSION_COOKIES_ALLOWED = 47, CACHECONTROL = 48, CONTENTDISPOSITIONFILENAME = 49, MIMETEXTPLAINMISMATCH = 50, PUBLISHERAVAILABLE = 51, DISPLAYNAMEAVAILABLE = 52, SSLUX_NAVBLOCKED = 53, SERVER_MIMETYPEAVAILABLE = 54, SNIFFED_CLASSIDAVAILABLE = 55, @"64BIT_PROGRESS" = 56, // LAST = 56, this enum value conflicts with @"64BIT_PROGRESS" RESERVED_0 = 57, RESERVED_1 = 58, RESERVED_2 = 59, RESERVED_3 = 60, RESERVED_4 = 61, RESERVED_5 = 62, RESERVED_6 = 63, RESERVED_7 = 64, RESERVED_8 = 65, RESERVED_9 = 66, RESERVED_A = 67, RESERVED_B = 68, RESERVED_C = 69, RESERVED_D = 70, RESERVED_E = 71, RESERVED_F = 72, RESERVED_10 = 73, RESERVED_11 = 74, RESERVED_12 = 75, RESERVED_13 = 76, RESERVED_14 = 77, // LAST_PRIVATE = 77, this enum value conflicts with RESERVED_14 }; pub const BINDSTATUS_FINDINGRESOURCE = BINDSTATUS.FINDINGRESOURCE; pub const BINDSTATUS_CONNECTING = BINDSTATUS.CONNECTING; pub const BINDSTATUS_REDIRECTING = BINDSTATUS.REDIRECTING; pub const BINDSTATUS_BEGINDOWNLOADDATA = BINDSTATUS.BEGINDOWNLOADDATA; pub const BINDSTATUS_DOWNLOADINGDATA = BINDSTATUS.DOWNLOADINGDATA; pub const BINDSTATUS_ENDDOWNLOADDATA = BINDSTATUS.ENDDOWNLOADDATA; pub const BINDSTATUS_BEGINDOWNLOADCOMPONENTS = BINDSTATUS.BEGINDOWNLOADCOMPONENTS; pub const BINDSTATUS_INSTALLINGCOMPONENTS = BINDSTATUS.INSTALLINGCOMPONENTS; pub const BINDSTATUS_ENDDOWNLOADCOMPONENTS = BINDSTATUS.ENDDOWNLOADCOMPONENTS; pub const BINDSTATUS_USINGCACHEDCOPY = BINDSTATUS.USINGCACHEDCOPY; pub const BINDSTATUS_SENDINGREQUEST = BINDSTATUS.SENDINGREQUEST; pub const BINDSTATUS_CLASSIDAVAILABLE = BINDSTATUS.CLASSIDAVAILABLE; pub const BINDSTATUS_MIMETYPEAVAILABLE = BINDSTATUS.MIMETYPEAVAILABLE; pub const BINDSTATUS_CACHEFILENAMEAVAILABLE = BINDSTATUS.CACHEFILENAMEAVAILABLE; pub const BINDSTATUS_BEGINSYNCOPERATION = BINDSTATUS.BEGINSYNCOPERATION; pub const BINDSTATUS_ENDSYNCOPERATION = BINDSTATUS.ENDSYNCOPERATION; pub const BINDSTATUS_BEGINUPLOADDATA = BINDSTATUS.BEGINUPLOADDATA; pub const BINDSTATUS_UPLOADINGDATA = BINDSTATUS.UPLOADINGDATA; pub const BINDSTATUS_ENDUPLOADDATA = BINDSTATUS.ENDUPLOADDATA; pub const BINDSTATUS_PROTOCOLCLASSID = BINDSTATUS.PROTOCOLCLASSID; pub const BINDSTATUS_ENCODING = BINDSTATUS.ENCODING; pub const BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE = BINDSTATUS.VERIFIEDMIMETYPEAVAILABLE; pub const BINDSTATUS_CLASSINSTALLLOCATION = BINDSTATUS.CLASSINSTALLLOCATION; pub const BINDSTATUS_DECODING = BINDSTATUS.DECODING; pub const BINDSTATUS_LOADINGMIMEHANDLER = BINDSTATUS.LOADINGMIMEHANDLER; pub const BINDSTATUS_CONTENTDISPOSITIONATTACH = BINDSTATUS.CONTENTDISPOSITIONATTACH; pub const BINDSTATUS_FILTERREPORTMIMETYPE = BINDSTATUS.FILTERREPORTMIMETYPE; pub const BINDSTATUS_CLSIDCANINSTANTIATE = BINDSTATUS.CLSIDCANINSTANTIATE; pub const BINDSTATUS_IUNKNOWNAVAILABLE = BINDSTATUS.IUNKNOWNAVAILABLE; pub const BINDSTATUS_DIRECTBIND = BINDSTATUS.DIRECTBIND; pub const BINDSTATUS_RAWMIMETYPE = BINDSTATUS.RAWMIMETYPE; pub const BINDSTATUS_PROXYDETECTING = BINDSTATUS.PROXYDETECTING; pub const BINDSTATUS_ACCEPTRANGES = BINDSTATUS.ACCEPTRANGES; pub const BINDSTATUS_COOKIE_SENT = BINDSTATUS.COOKIE_SENT; pub const BINDSTATUS_COMPACT_POLICY_RECEIVED = BINDSTATUS.COMPACT_POLICY_RECEIVED; pub const BINDSTATUS_COOKIE_SUPPRESSED = BINDSTATUS.COOKIE_SUPPRESSED; pub const BINDSTATUS_COOKIE_STATE_UNKNOWN = BINDSTATUS.COOKIE_STATE_UNKNOWN; pub const BINDSTATUS_COOKIE_STATE_ACCEPT = BINDSTATUS.COOKIE_STATE_ACCEPT; pub const BINDSTATUS_COOKIE_STATE_REJECT = BINDSTATUS.COOKIE_STATE_REJECT; pub const BINDSTATUS_COOKIE_STATE_PROMPT = BINDSTATUS.COOKIE_STATE_PROMPT; pub const BINDSTATUS_COOKIE_STATE_LEASH = BINDSTATUS.COOKIE_STATE_LEASH; pub const BINDSTATUS_COOKIE_STATE_DOWNGRADE = BINDSTATUS.COOKIE_STATE_DOWNGRADE; pub const BINDSTATUS_POLICY_HREF = BINDSTATUS.POLICY_HREF; pub const BINDSTATUS_P3P_HEADER = BINDSTATUS.P3P_HEADER; pub const BINDSTATUS_SESSION_COOKIE_RECEIVED = BINDSTATUS.SESSION_COOKIE_RECEIVED; pub const BINDSTATUS_PERSISTENT_COOKIE_RECEIVED = BINDSTATUS.PERSISTENT_COOKIE_RECEIVED; pub const BINDSTATUS_SESSION_COOKIES_ALLOWED = BINDSTATUS.SESSION_COOKIES_ALLOWED; pub const BINDSTATUS_CACHECONTROL = BINDSTATUS.CACHECONTROL; pub const BINDSTATUS_CONTENTDISPOSITIONFILENAME = BINDSTATUS.CONTENTDISPOSITIONFILENAME; pub const BINDSTATUS_MIMETEXTPLAINMISMATCH = BINDSTATUS.MIMETEXTPLAINMISMATCH; pub const BINDSTATUS_PUBLISHERAVAILABLE = BINDSTATUS.PUBLISHERAVAILABLE; pub const BINDSTATUS_DISPLAYNAMEAVAILABLE = BINDSTATUS.DISPLAYNAMEAVAILABLE; pub const BINDSTATUS_SSLUX_NAVBLOCKED = BINDSTATUS.SSLUX_NAVBLOCKED; pub const BINDSTATUS_SERVER_MIMETYPEAVAILABLE = BINDSTATUS.SERVER_MIMETYPEAVAILABLE; pub const BINDSTATUS_SNIFFED_CLASSIDAVAILABLE = BINDSTATUS.SNIFFED_CLASSIDAVAILABLE; pub const BINDSTATUS_64BIT_PROGRESS = BINDSTATUS.@"64BIT_PROGRESS"; pub const BINDSTATUS_LAST = BINDSTATUS.@"64BIT_PROGRESS"; pub const BINDSTATUS_RESERVED_0 = BINDSTATUS.RESERVED_0; pub const BINDSTATUS_RESERVED_1 = BINDSTATUS.RESERVED_1; pub const BINDSTATUS_RESERVED_2 = BINDSTATUS.RESERVED_2; pub const BINDSTATUS_RESERVED_3 = BINDSTATUS.RESERVED_3; pub const BINDSTATUS_RESERVED_4 = BINDSTATUS.RESERVED_4; pub const BINDSTATUS_RESERVED_5 = BINDSTATUS.RESERVED_5; pub const BINDSTATUS_RESERVED_6 = BINDSTATUS.RESERVED_6; pub const BINDSTATUS_RESERVED_7 = BINDSTATUS.RESERVED_7; pub const BINDSTATUS_RESERVED_8 = BINDSTATUS.RESERVED_8; pub const BINDSTATUS_RESERVED_9 = BINDSTATUS.RESERVED_9; pub const BINDSTATUS_RESERVED_A = BINDSTATUS.RESERVED_A; pub const BINDSTATUS_RESERVED_B = BINDSTATUS.RESERVED_B; pub const BINDSTATUS_RESERVED_C = BINDSTATUS.RESERVED_C; pub const BINDSTATUS_RESERVED_D = BINDSTATUS.RESERVED_D; pub const BINDSTATUS_RESERVED_E = BINDSTATUS.RESERVED_E; pub const BINDSTATUS_RESERVED_F = BINDSTATUS.RESERVED_F; pub const BINDSTATUS_RESERVED_10 = BINDSTATUS.RESERVED_10; pub const BINDSTATUS_RESERVED_11 = BINDSTATUS.RESERVED_11; pub const BINDSTATUS_RESERVED_12 = BINDSTATUS.RESERVED_12; pub const BINDSTATUS_RESERVED_13 = BINDSTATUS.RESERVED_13; pub const BINDSTATUS_RESERVED_14 = BINDSTATUS.RESERVED_14; pub const BINDSTATUS_LAST_PRIVATE = BINDSTATUS.RESERVED_14; pub const BINDF2 = enum(i32) { DISABLEBASICOVERHTTP = 1, DISABLEAUTOCOOKIEHANDLING = 2, READ_DATA_GREATER_THAN_4GB = 4, DISABLE_HTTP_REDIRECT_XSECURITYID = 8, SETDOWNLOADMODE = 32, DISABLE_HTTP_REDIRECT_CACHING = 64, KEEP_CALLBACK_MODULE_LOADED = 128, ALLOW_PROXY_CRED_PROMPT = 256, RESERVED_17 = 512, RESERVED_16 = 1024, RESERVED_15 = 2048, RESERVED_14 = 4096, RESERVED_13 = 8192, RESERVED_12 = 16384, RESERVED_11 = 32768, RESERVED_10 = 65536, RESERVED_F = 131072, RESERVED_E = 262144, RESERVED_D = 524288, RESERVED_C = 1048576, RESERVED_B = 2097152, RESERVED_A = 4194304, RESERVED_9 = 8388608, RESERVED_8 = 16777216, RESERVED_7 = 33554432, RESERVED_6 = 67108864, RESERVED_5 = 134217728, RESERVED_4 = 268435456, RESERVED_3 = 536870912, RESERVED_2 = 1073741824, RESERVED_1 = -2147483648, }; pub const BINDF2_DISABLEBASICOVERHTTP = BINDF2.DISABLEBASICOVERHTTP; pub const BINDF2_DISABLEAUTOCOOKIEHANDLING = BINDF2.DISABLEAUTOCOOKIEHANDLING; pub const BINDF2_READ_DATA_GREATER_THAN_4GB = BINDF2.READ_DATA_GREATER_THAN_4GB; pub const BINDF2_DISABLE_HTTP_REDIRECT_XSECURITYID = BINDF2.DISABLE_HTTP_REDIRECT_XSECURITYID; pub const BINDF2_SETDOWNLOADMODE = BINDF2.SETDOWNLOADMODE; pub const BINDF2_DISABLE_HTTP_REDIRECT_CACHING = BINDF2.DISABLE_HTTP_REDIRECT_CACHING; pub const BINDF2_KEEP_CALLBACK_MODULE_LOADED = BINDF2.KEEP_CALLBACK_MODULE_LOADED; pub const BINDF2_ALLOW_PROXY_CRED_PROMPT = BINDF2.ALLOW_PROXY_CRED_PROMPT; pub const BINDF2_RESERVED_17 = BINDF2.RESERVED_17; pub const BINDF2_RESERVED_16 = BINDF2.RESERVED_16; pub const BINDF2_RESERVED_15 = BINDF2.RESERVED_15; pub const BINDF2_RESERVED_14 = BINDF2.RESERVED_14; pub const BINDF2_RESERVED_13 = BINDF2.RESERVED_13; pub const BINDF2_RESERVED_12 = BINDF2.RESERVED_12; pub const BINDF2_RESERVED_11 = BINDF2.RESERVED_11; pub const BINDF2_RESERVED_10 = BINDF2.RESERVED_10; pub const BINDF2_RESERVED_F = BINDF2.RESERVED_F; pub const BINDF2_RESERVED_E = BINDF2.RESERVED_E; pub const BINDF2_RESERVED_D = BINDF2.RESERVED_D; pub const BINDF2_RESERVED_C = BINDF2.RESERVED_C; pub const BINDF2_RESERVED_B = BINDF2.RESERVED_B; pub const BINDF2_RESERVED_A = BINDF2.RESERVED_A; pub const BINDF2_RESERVED_9 = BINDF2.RESERVED_9; pub const BINDF2_RESERVED_8 = BINDF2.RESERVED_8; pub const BINDF2_RESERVED_7 = BINDF2.RESERVED_7; pub const BINDF2_RESERVED_6 = BINDF2.RESERVED_6; pub const BINDF2_RESERVED_5 = BINDF2.RESERVED_5; pub const BINDF2_RESERVED_4 = BINDF2.RESERVED_4; pub const BINDF2_RESERVED_3 = BINDF2.RESERVED_3; pub const BINDF2_RESERVED_2 = BINDF2.RESERVED_2; pub const BINDF2_RESERVED_1 = BINDF2.RESERVED_1; pub const AUTHENTICATEF = enum(i32) { PROXY = 1, BASIC = 2, HTTP = 4, }; pub const AUTHENTICATEF_PROXY = AUTHENTICATEF.PROXY; pub const AUTHENTICATEF_BASIC = AUTHENTICATEF.BASIC; pub const AUTHENTICATEF_HTTP = AUTHENTICATEF.HTTP; const IID_IHttpNegotiate_Value = @import("../../zig.zig").Guid.initString("79eac9d2-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IHttpNegotiate = &IID_IHttpNegotiate_Value; pub const IHttpNegotiate = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, BeginningTransaction: fn( self: *const IHttpNegotiate, szURL: ?[*:0]const u16, szHeaders: ?[*:0]const u16, dwReserved: u32, pszAdditionalHeaders: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, OnResponse: fn( self: *const IHttpNegotiate, dwResponseCode: u32, szResponseHeaders: ?[*:0]const u16, szRequestHeaders: ?[*:0]const u16, pszAdditionalRequestHeaders: ?*?PWSTR, ) 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 IHttpNegotiate_BeginningTransaction(self: *const T, szURL: ?[*:0]const u16, szHeaders: ?[*:0]const u16, dwReserved: u32, pszAdditionalHeaders: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IHttpNegotiate.VTable, self.vtable).BeginningTransaction(@ptrCast(*const IHttpNegotiate, self), szURL, szHeaders, dwReserved, pszAdditionalHeaders); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IHttpNegotiate_OnResponse(self: *const T, dwResponseCode: u32, szResponseHeaders: ?[*:0]const u16, szRequestHeaders: ?[*:0]const u16, pszAdditionalRequestHeaders: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IHttpNegotiate.VTable, self.vtable).OnResponse(@ptrCast(*const IHttpNegotiate, self), dwResponseCode, szResponseHeaders, szRequestHeaders, pszAdditionalRequestHeaders); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IHttpNegotiate2_Value = @import("../../zig.zig").Guid.initString("4f9f9fcb-e0f4-48eb-b7ab-fa2ea9365cb4"); pub const IID_IHttpNegotiate2 = &IID_IHttpNegotiate2_Value; pub const IHttpNegotiate2 = extern struct { pub const VTable = extern struct { base: IHttpNegotiate.VTable, GetRootSecurityId: fn( self: *const IHttpNegotiate2, pbSecurityId: [*:0]u8, pcbSecurityId: ?*u32, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IHttpNegotiate.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IHttpNegotiate2_GetRootSecurityId(self: *const T, pbSecurityId: [*:0]u8, pcbSecurityId: ?*u32, dwReserved: usize) callconv(.Inline) HRESULT { return @ptrCast(*const IHttpNegotiate2.VTable, self.vtable).GetRootSecurityId(@ptrCast(*const IHttpNegotiate2, self), pbSecurityId, pcbSecurityId, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IHttpNegotiate3_Value = @import("../../zig.zig").Guid.initString("57b6c80a-34c2-4602-bc26-66a02fc57153"); pub const IID_IHttpNegotiate3 = &IID_IHttpNegotiate3_Value; pub const IHttpNegotiate3 = extern struct { pub const VTable = extern struct { base: IHttpNegotiate2.VTable, GetSerializedClientCertContext: fn( self: *const IHttpNegotiate3, ppbCert: [*]?*u8, pcbCert: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IHttpNegotiate2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IHttpNegotiate3_GetSerializedClientCertContext(self: *const T, ppbCert: [*]?*u8, pcbCert: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IHttpNegotiate3.VTable, self.vtable).GetSerializedClientCertContext(@ptrCast(*const IHttpNegotiate3, self), ppbCert, pcbCert); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IWinInetFileStream_Value = @import("../../zig.zig").Guid.initString("f134c4b7-b1f8-4e75-b886-74b90943becb"); pub const IID_IWinInetFileStream = &IID_IWinInetFileStream_Value; pub const IWinInetFileStream = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetHandleForUnlock: fn( self: *const IWinInetFileStream, hWinInetLockHandle: usize, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetDeleteFile: fn( self: *const IWinInetFileStream, dwReserved: usize, ) 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 IWinInetFileStream_SetHandleForUnlock(self: *const T, hWinInetLockHandle: usize, dwReserved: usize) callconv(.Inline) HRESULT { return @ptrCast(*const IWinInetFileStream.VTable, self.vtable).SetHandleForUnlock(@ptrCast(*const IWinInetFileStream, self), hWinInetLockHandle, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWinInetFileStream_SetDeleteFile(self: *const T, dwReserved: usize) callconv(.Inline) HRESULT { return @ptrCast(*const IWinInetFileStream.VTable, self.vtable).SetDeleteFile(@ptrCast(*const IWinInetFileStream, self), dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IWindowForBindingUI_Value = @import("../../zig.zig").Guid.initString("79eac9d5-bafa-11ce-8c82-00aa004ba90b"); pub const IID_IWindowForBindingUI = &IID_IWindowForBindingUI_Value; pub const IWindowForBindingUI = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetWindow: fn( self: *const IWindowForBindingUI, rguidReason: ?*const Guid, phwnd: ?*?HWND, ) 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 IWindowForBindingUI_GetWindow(self: *const T, rguidReason: ?*const Guid, phwnd: ?*?HWND) callconv(.Inline) HRESULT { return @ptrCast(*const IWindowForBindingUI.VTable, self.vtable).GetWindow(@ptrCast(*const IWindowForBindingUI, self), rguidReason, phwnd); } };} pub usingnamespace MethodMixin(@This()); }; pub const CIP_STATUS = enum(i32) { DISK_FULL = 0, ACCESS_DENIED = 1, NEWER_VERSION_EXISTS = 2, OLDER_VERSION_EXISTS = 3, NAME_CONFLICT = 4, TRUST_VERIFICATION_COMPONENT_MISSING = 5, EXE_SELF_REGISTERATION_TIMEOUT = 6, UNSAFE_TO_ABORT = 7, NEED_REBOOT = 8, NEED_REBOOT_UI_PERMISSION = 9, }; pub const CIP_DISK_FULL = CIP_STATUS.DISK_FULL; pub const CIP_ACCESS_DENIED = CIP_STATUS.ACCESS_DENIED; pub const CIP_NEWER_VERSION_EXISTS = CIP_STATUS.NEWER_VERSION_EXISTS; pub const CIP_OLDER_VERSION_EXISTS = CIP_STATUS.OLDER_VERSION_EXISTS; pub const CIP_NAME_CONFLICT = CIP_STATUS.NAME_CONFLICT; pub const CIP_TRUST_VERIFICATION_COMPONENT_MISSING = CIP_STATUS.TRUST_VERIFICATION_COMPONENT_MISSING; pub const CIP_EXE_SELF_REGISTERATION_TIMEOUT = CIP_STATUS.EXE_SELF_REGISTERATION_TIMEOUT; pub const CIP_UNSAFE_TO_ABORT = CIP_STATUS.UNSAFE_TO_ABORT; pub const CIP_NEED_REBOOT = CIP_STATUS.NEED_REBOOT; pub const CIP_NEED_REBOOT_UI_PERMISSION = CIP_STATUS.NEED_REBOOT_UI_PERMISSION; const IID_ICodeInstall_Value = @import("../../zig.zig").Guid.initString("79eac9d1-baf9-11ce-8c82-00aa004ba90b"); pub const IID_ICodeInstall = &IID_ICodeInstall_Value; pub const ICodeInstall = extern struct { pub const VTable = extern struct { base: IWindowForBindingUI.VTable, OnCodeInstallProblem: fn( self: *const ICodeInstall, ulStatusCode: u32, szDestination: ?[*:0]const u16, szSource: ?[*:0]const u16, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IWindowForBindingUI.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICodeInstall_OnCodeInstallProblem(self: *const T, ulStatusCode: u32, szDestination: ?[*:0]const u16, szSource: ?[*:0]const u16, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const ICodeInstall.VTable, self.vtable).OnCodeInstallProblem(@ptrCast(*const ICodeInstall, self), ulStatusCode, szDestination, szSource, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; pub const Uri_HOST_TYPE = enum(i32) { UNKNOWN = 0, DNS = 1, IPV4 = 2, IPV6 = 3, IDN = 4, }; pub const Uri_HOST_UNKNOWN = Uri_HOST_TYPE.UNKNOWN; pub const Uri_HOST_DNS = Uri_HOST_TYPE.DNS; pub const Uri_HOST_IPV4 = Uri_HOST_TYPE.IPV4; pub const Uri_HOST_IPV6 = Uri_HOST_TYPE.IPV6; pub const Uri_HOST_IDN = Uri_HOST_TYPE.IDN; const IID_IUriContainer_Value = @import("../../zig.zig").Guid.initString("a158a630-ed6f-45fb-b987-f68676f57752"); pub const IID_IUriContainer = &IID_IUriContainer_Value; pub const IUriContainer = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetIUri: fn( self: *const IUriContainer, ppIUri: ?*?*IUri, ) 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 IUriContainer_GetIUri(self: *const T, ppIUri: ?*?*IUri) callconv(.Inline) HRESULT { return @ptrCast(*const IUriContainer.VTable, self.vtable).GetIUri(@ptrCast(*const IUriContainer, self), ppIUri); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IUriBuilderFactory_Value = @import("../../zig.zig").Guid.initString("e982ce48-0b96-440c-bc37-0c869b27a29e"); pub const IID_IUriBuilderFactory = &IID_IUriBuilderFactory_Value; pub const IUriBuilderFactory = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, CreateIUriBuilder: fn( self: *const IUriBuilderFactory, dwFlags: u32, dwReserved: usize, ppIUriBuilder: ?*?*IUriBuilder, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateInitializedIUriBuilder: fn( self: *const IUriBuilderFactory, dwFlags: u32, dwReserved: usize, ppIUriBuilder: ?*?*IUriBuilder, ) 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 IUriBuilderFactory_CreateIUriBuilder(self: *const T, dwFlags: u32, dwReserved: usize, ppIUriBuilder: ?*?*IUriBuilder) callconv(.Inline) HRESULT { return @ptrCast(*const IUriBuilderFactory.VTable, self.vtable).CreateIUriBuilder(@ptrCast(*const IUriBuilderFactory, self), dwFlags, dwReserved, ppIUriBuilder); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IUriBuilderFactory_CreateInitializedIUriBuilder(self: *const T, dwFlags: u32, dwReserved: usize, ppIUriBuilder: ?*?*IUriBuilder) callconv(.Inline) HRESULT { return @ptrCast(*const IUriBuilderFactory.VTable, self.vtable).CreateInitializedIUriBuilder(@ptrCast(*const IUriBuilderFactory, self), dwFlags, dwReserved, ppIUriBuilder); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IWinInetInfo_Value = @import("../../zig.zig").Guid.initString("79eac9d6-bafa-11ce-8c82-00aa004ba90b"); pub const IID_IWinInetInfo = &IID_IWinInetInfo_Value; pub const IWinInetInfo = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, QueryOption: fn( self: *const IWinInetInfo, dwOption: u32, pBuffer: [*]u8, pcbBuf: ?*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 IWinInetInfo_QueryOption(self: *const T, dwOption: u32, pBuffer: [*]u8, pcbBuf: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IWinInetInfo.VTable, self.vtable).QueryOption(@ptrCast(*const IWinInetInfo, self), dwOption, pBuffer, pcbBuf); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IHttpSecurity_Value = @import("../../zig.zig").Guid.initString("79eac9d7-bafa-11ce-8c82-00aa004ba90b"); pub const IID_IHttpSecurity = &IID_IHttpSecurity_Value; pub const IHttpSecurity = extern struct { pub const VTable = extern struct { base: IWindowForBindingUI.VTable, OnSecurityProblem: fn( self: *const IHttpSecurity, dwProblem: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IWindowForBindingUI.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IHttpSecurity_OnSecurityProblem(self: *const T, dwProblem: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IHttpSecurity.VTable, self.vtable).OnSecurityProblem(@ptrCast(*const IHttpSecurity, self), dwProblem); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IWinInetHttpInfo_Value = @import("../../zig.zig").Guid.initString("79eac9d8-bafa-11ce-8c82-00aa004ba90b"); pub const IID_IWinInetHttpInfo = &IID_IWinInetHttpInfo_Value; pub const IWinInetHttpInfo = extern struct { pub const VTable = extern struct { base: IWinInetInfo.VTable, QueryInfo: fn( self: *const IWinInetHttpInfo, dwOption: u32, pBuffer: [*]u8, pcbBuf: ?*u32, pdwFlags: ?*u32, pdwReserved: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IWinInetInfo.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWinInetHttpInfo_QueryInfo(self: *const T, dwOption: u32, pBuffer: [*]u8, pcbBuf: ?*u32, pdwFlags: ?*u32, pdwReserved: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IWinInetHttpInfo.VTable, self.vtable).QueryInfo(@ptrCast(*const IWinInetHttpInfo, self), dwOption, pBuffer, pcbBuf, pdwFlags, pdwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IWinInetHttpTimeouts_Value = @import("../../zig.zig").Guid.initString("f286fa56-c1fd-4270-8e67-b3eb790a81e8"); pub const IID_IWinInetHttpTimeouts = &IID_IWinInetHttpTimeouts_Value; pub const IWinInetHttpTimeouts = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetRequestTimeouts: fn( self: *const IWinInetHttpTimeouts, pdwConnectTimeout: ?*u32, pdwSendTimeout: ?*u32, pdwReceiveTimeout: ?*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 IWinInetHttpTimeouts_GetRequestTimeouts(self: *const T, pdwConnectTimeout: ?*u32, pdwSendTimeout: ?*u32, pdwReceiveTimeout: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IWinInetHttpTimeouts.VTable, self.vtable).GetRequestTimeouts(@ptrCast(*const IWinInetHttpTimeouts, self), pdwConnectTimeout, pdwSendTimeout, pdwReceiveTimeout); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IWinInetCacheHints_Value = @import("../../zig.zig").Guid.initString("dd1ec3b3-8391-4fdb-a9e6-347c3caaa7dd"); pub const IID_IWinInetCacheHints = &IID_IWinInetCacheHints_Value; pub const IWinInetCacheHints = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetCacheExtension: fn( self: *const IWinInetCacheHints, pwzExt: ?[*:0]const u16, pszCacheFile: [*]u8, pcbCacheFile: ?*u32, pdwWinInetError: ?*u32, pdwReserved: ?*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 IWinInetCacheHints_SetCacheExtension(self: *const T, pwzExt: ?[*:0]const u16, pszCacheFile: [*]u8, pcbCacheFile: ?*u32, pdwWinInetError: ?*u32, pdwReserved: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IWinInetCacheHints.VTable, self.vtable).SetCacheExtension(@ptrCast(*const IWinInetCacheHints, self), pwzExt, pszCacheFile, pcbCacheFile, pdwWinInetError, pdwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IWinInetCacheHints2_Value = @import("../../zig.zig").Guid.initString("7857aeac-d31f-49bf-884e-dd46df36780a"); pub const IID_IWinInetCacheHints2 = &IID_IWinInetCacheHints2_Value; pub const IWinInetCacheHints2 = extern struct { pub const VTable = extern struct { base: IWinInetCacheHints.VTable, SetCacheExtension2: fn( self: *const IWinInetCacheHints2, pwzExt: ?[*:0]const u16, pwzCacheFile: ?PWSTR, pcchCacheFile: ?*u32, pdwWinInetError: ?*u32, pdwReserved: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IWinInetCacheHints.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IWinInetCacheHints2_SetCacheExtension2(self: *const T, pwzExt: ?[*:0]const u16, pwzCacheFile: ?PWSTR, pcchCacheFile: ?*u32, pdwWinInetError: ?*u32, pdwReserved: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IWinInetCacheHints2.VTable, self.vtable).SetCacheExtension2(@ptrCast(*const IWinInetCacheHints2, self), pwzExt, pwzCacheFile, pcchCacheFile, pdwWinInetError, pdwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternet_Value = @import("../../zig.zig").Guid.initString("79eac9e0-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternet = &IID_IInternet_Value; pub const IInternet = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); };} pub usingnamespace MethodMixin(@This()); }; pub const BINDSTRING = enum(i32) { HEADERS = 1, ACCEPT_MIMES = 2, EXTRA_URL = 3, LANGUAGE = 4, USERNAME = 5, PASSWORD = 6, UA_PIXELS = 7, UA_COLOR = 8, OS = 9, USER_AGENT = 10, ACCEPT_ENCODINGS = 11, POST_COOKIE = 12, POST_DATA_MIME = 13, URL = 14, IID = 15, FLAG_BIND_TO_OBJECT = 16, PTR_BIND_CONTEXT = 17, XDR_ORIGIN = 18, DOWNLOADPATH = 19, ROOTDOC_URL = 20, INITIAL_FILENAME = 21, PROXY_USERNAME = 22, PROXY_PASSWORD = 23, ENTERPRISE_ID = 24, DOC_URL = 25, SAMESITE_COOKIE_LEVEL = 26, }; pub const BINDSTRING_HEADERS = BINDSTRING.HEADERS; pub const BINDSTRING_ACCEPT_MIMES = BINDSTRING.ACCEPT_MIMES; pub const BINDSTRING_EXTRA_URL = BINDSTRING.EXTRA_URL; pub const BINDSTRING_LANGUAGE = BINDSTRING.LANGUAGE; pub const BINDSTRING_USERNAME = BINDSTRING.USERNAME; pub const BINDSTRING_PASSWORD = BINDSTRING.PASSWORD; pub const BINDSTRING_UA_PIXELS = BINDSTRING.UA_PIXELS; pub const BINDSTRING_UA_COLOR = BINDSTRING.UA_COLOR; pub const BINDSTRING_OS = BINDSTRING.OS; pub const BINDSTRING_USER_AGENT = BINDSTRING.USER_AGENT; pub const BINDSTRING_ACCEPT_ENCODINGS = BINDSTRING.ACCEPT_ENCODINGS; pub const BINDSTRING_POST_COOKIE = BINDSTRING.POST_COOKIE; pub const BINDSTRING_POST_DATA_MIME = BINDSTRING.POST_DATA_MIME; pub const BINDSTRING_URL = BINDSTRING.URL; pub const BINDSTRING_IID = BINDSTRING.IID; pub const BINDSTRING_FLAG_BIND_TO_OBJECT = BINDSTRING.FLAG_BIND_TO_OBJECT; pub const BINDSTRING_PTR_BIND_CONTEXT = BINDSTRING.PTR_BIND_CONTEXT; pub const BINDSTRING_XDR_ORIGIN = BINDSTRING.XDR_ORIGIN; pub const BINDSTRING_DOWNLOADPATH = BINDSTRING.DOWNLOADPATH; pub const BINDSTRING_ROOTDOC_URL = BINDSTRING.ROOTDOC_URL; pub const BINDSTRING_INITIAL_FILENAME = BINDSTRING.INITIAL_FILENAME; pub const BINDSTRING_PROXY_USERNAME = BINDSTRING.PROXY_USERNAME; pub const BINDSTRING_PROXY_PASSWORD = BINDSTRING.PROXY_PASSWORD; pub const BINDSTRING_ENTERPRISE_ID = BINDSTRING.ENTERPRISE_ID; pub const BINDSTRING_DOC_URL = BINDSTRING.DOC_URL; pub const BINDSTRING_SAMESITE_COOKIE_LEVEL = BINDSTRING.SAMESITE_COOKIE_LEVEL; const IID_IInternetBindInfo_Value = @import("../../zig.zig").Guid.initString("79eac9e1-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetBindInfo = &IID_IInternetBindInfo_Value; pub const IInternetBindInfo = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetBindInfo: fn( self: *const IInternetBindInfo, grfBINDF: ?*u32, pbindinfo: ?*BINDINFO, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetBindString: fn( self: *const IInternetBindInfo, ulStringType: u32, ppwzStr: ?*?PWSTR, cEl: u32, pcElFetched: ?*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 IInternetBindInfo_GetBindInfo(self: *const T, grfBINDF: ?*u32, pbindinfo: ?*BINDINFO) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetBindInfo.VTable, self.vtable).GetBindInfo(@ptrCast(*const IInternetBindInfo, self), grfBINDF, pbindinfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetBindInfo_GetBindString(self: *const T, ulStringType: u32, ppwzStr: ?*?PWSTR, cEl: u32, pcElFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetBindInfo.VTable, self.vtable).GetBindString(@ptrCast(*const IInternetBindInfo, self), ulStringType, ppwzStr, cEl, pcElFetched); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetBindInfoEx_Value = @import("../../zig.zig").Guid.initString("a3e015b7-a82c-4dcd-a150-569aeeed36ab"); pub const IID_IInternetBindInfoEx = &IID_IInternetBindInfoEx_Value; pub const IInternetBindInfoEx = extern struct { pub const VTable = extern struct { base: IInternetBindInfo.VTable, GetBindInfoEx: fn( self: *const IInternetBindInfoEx, grfBINDF: ?*u32, pbindinfo: ?*BINDINFO, grfBINDF2: ?*u32, pdwReserved: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IInternetBindInfo.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetBindInfoEx_GetBindInfoEx(self: *const T, grfBINDF: ?*u32, pbindinfo: ?*BINDINFO, grfBINDF2: ?*u32, pdwReserved: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetBindInfoEx.VTable, self.vtable).GetBindInfoEx(@ptrCast(*const IInternetBindInfoEx, self), grfBINDF, pbindinfo, grfBINDF2, pdwReserved); } };} pub usingnamespace MethodMixin(@This()); }; pub const PI_FLAGS = enum(i32) { I_PARSE_URL = 1, I_FILTER_MODE = 2, I_FORCE_ASYNC = 4, I_USE_WORKERTHREAD = 8, I_MIMEVERIFICATION = 16, I_CLSIDLOOKUP = 32, I_DATAPROGRESS = 64, I_SYNCHRONOUS = 128, I_APARTMENTTHREADED = 256, I_CLASSINSTALL = 512, I_PASSONBINDCTX = 8192, I_NOMIMEHANDLER = 32768, I_LOADAPPDIRECT = 16384, D_FORCE_SWITCH = 65536, I_PREFERDEFAULTHANDLER = 131072, }; pub const PI_PARSE_URL = PI_FLAGS.I_PARSE_URL; pub const PI_FILTER_MODE = PI_FLAGS.I_FILTER_MODE; pub const PI_FORCE_ASYNC = PI_FLAGS.I_FORCE_ASYNC; pub const PI_USE_WORKERTHREAD = PI_FLAGS.I_USE_WORKERTHREAD; pub const PI_MIMEVERIFICATION = PI_FLAGS.I_MIMEVERIFICATION; pub const PI_CLSIDLOOKUP = PI_FLAGS.I_CLSIDLOOKUP; pub const PI_DATAPROGRESS = PI_FLAGS.I_DATAPROGRESS; pub const PI_SYNCHRONOUS = PI_FLAGS.I_SYNCHRONOUS; pub const PI_APARTMENTTHREADED = PI_FLAGS.I_APARTMENTTHREADED; pub const PI_CLASSINSTALL = PI_FLAGS.I_CLASSINSTALL; pub const PI_PASSONBINDCTX = PI_FLAGS.I_PASSONBINDCTX; pub const PI_NOMIMEHANDLER = PI_FLAGS.I_NOMIMEHANDLER; pub const PI_LOADAPPDIRECT = PI_FLAGS.I_LOADAPPDIRECT; pub const PD_FORCE_SWITCH = PI_FLAGS.D_FORCE_SWITCH; pub const PI_PREFERDEFAULTHANDLER = PI_FLAGS.I_PREFERDEFAULTHANDLER; pub const PROTOCOLDATA = extern struct { grfFlags: u32, dwState: u32, pData: ?*anyopaque, cbData: u32, }; pub const StartParam = extern struct { iid: Guid, pIBindCtx: ?*IBindCtx, pItf: ?*IUnknown, }; const IID_IInternetProtocolRoot_Value = @import("../../zig.zig").Guid.initString("79eac9e3-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetProtocolRoot = &IID_IInternetProtocolRoot_Value; pub const IInternetProtocolRoot = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Start: fn( self: *const IInternetProtocolRoot, szUrl: ?[*:0]const u16, pOIProtSink: ?*IInternetProtocolSink, pOIBindInfo: ?*IInternetBindInfo, grfPI: u32, dwReserved: HANDLE_PTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Continue: fn( self: *const IInternetProtocolRoot, pProtocolData: ?*PROTOCOLDATA, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Abort: fn( self: *const IInternetProtocolRoot, hrReason: HRESULT, dwOptions: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Terminate: fn( self: *const IInternetProtocolRoot, dwOptions: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Suspend: fn( self: *const IInternetProtocolRoot, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Resume: fn( self: *const IInternetProtocolRoot, ) 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 IInternetProtocolRoot_Start(self: *const T, szUrl: ?[*:0]const u16, pOIProtSink: ?*IInternetProtocolSink, pOIBindInfo: ?*IInternetBindInfo, grfPI: u32, dwReserved: HANDLE_PTR) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolRoot.VTable, self.vtable).Start(@ptrCast(*const IInternetProtocolRoot, self), szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolRoot_Continue(self: *const T, pProtocolData: ?*PROTOCOLDATA) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolRoot.VTable, self.vtable).Continue(@ptrCast(*const IInternetProtocolRoot, self), pProtocolData); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolRoot_Abort(self: *const T, hrReason: HRESULT, dwOptions: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolRoot.VTable, self.vtable).Abort(@ptrCast(*const IInternetProtocolRoot, self), hrReason, dwOptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolRoot_Terminate(self: *const T, dwOptions: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolRoot.VTable, self.vtable).Terminate(@ptrCast(*const IInternetProtocolRoot, self), dwOptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolRoot_Suspend(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolRoot.VTable, self.vtable).Suspend(@ptrCast(*const IInternetProtocolRoot, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolRoot_Resume(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolRoot.VTable, self.vtable).Resume(@ptrCast(*const IInternetProtocolRoot, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetProtocol_Value = @import("../../zig.zig").Guid.initString("79eac9e4-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetProtocol = &IID_IInternetProtocol_Value; pub const IInternetProtocol = extern struct { pub const VTable = extern struct { base: IInternetProtocolRoot.VTable, Read: fn( self: *const IInternetProtocol, pv: [*]u8, cb: u32, pcbRead: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Seek: fn( self: *const IInternetProtocol, dlibMove: LARGE_INTEGER, dwOrigin: u32, plibNewPosition: ?*ULARGE_INTEGER, ) callconv(@import("std").os.windows.WINAPI) HRESULT, LockRequest: fn( self: *const IInternetProtocol, dwOptions: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnlockRequest: fn( self: *const IInternetProtocol, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IInternetProtocolRoot.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocol_Read(self: *const T, pv: [*]u8, cb: u32, pcbRead: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocol.VTable, self.vtable).Read(@ptrCast(*const IInternetProtocol, self), pv, cb, pcbRead); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocol_Seek(self: *const T, dlibMove: LARGE_INTEGER, dwOrigin: u32, plibNewPosition: ?*ULARGE_INTEGER) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocol.VTable, self.vtable).Seek(@ptrCast(*const IInternetProtocol, self), dlibMove, dwOrigin, plibNewPosition); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocol_LockRequest(self: *const T, dwOptions: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocol.VTable, self.vtable).LockRequest(@ptrCast(*const IInternetProtocol, self), dwOptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocol_UnlockRequest(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocol.VTable, self.vtable).UnlockRequest(@ptrCast(*const IInternetProtocol, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetProtocolEx_Value = @import("../../zig.zig").Guid.initString("c7a98e66-1010-492c-a1c8-c809e1f75905"); pub const IID_IInternetProtocolEx = &IID_IInternetProtocolEx_Value; pub const IInternetProtocolEx = extern struct { pub const VTable = extern struct { base: IInternetProtocol.VTable, StartEx: fn( self: *const IInternetProtocolEx, pUri: ?*IUri, pOIProtSink: ?*IInternetProtocolSink, pOIBindInfo: ?*IInternetBindInfo, grfPI: u32, dwReserved: HANDLE_PTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IInternetProtocol.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolEx_StartEx(self: *const T, pUri: ?*IUri, pOIProtSink: ?*IInternetProtocolSink, pOIBindInfo: ?*IInternetBindInfo, grfPI: u32, dwReserved: HANDLE_PTR) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolEx.VTable, self.vtable).StartEx(@ptrCast(*const IInternetProtocolEx, self), pUri, pOIProtSink, pOIBindInfo, grfPI, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetProtocolSink_Value = @import("../../zig.zig").Guid.initString("79eac9e5-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetProtocolSink = &IID_IInternetProtocolSink_Value; pub const IInternetProtocolSink = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Switch: fn( self: *const IInternetProtocolSink, pProtocolData: ?*PROTOCOLDATA, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReportProgress: fn( self: *const IInternetProtocolSink, ulStatusCode: u32, szStatusText: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReportData: fn( self: *const IInternetProtocolSink, grfBSCF: u32, ulProgress: u32, ulProgressMax: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReportResult: fn( self: *const IInternetProtocolSink, hrResult: HRESULT, dwError: u32, szResult: ?[*:0]const u16, ) 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 IInternetProtocolSink_Switch(self: *const T, pProtocolData: ?*PROTOCOLDATA) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolSink.VTable, self.vtable).Switch(@ptrCast(*const IInternetProtocolSink, self), pProtocolData); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolSink_ReportProgress(self: *const T, ulStatusCode: u32, szStatusText: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolSink.VTable, self.vtable).ReportProgress(@ptrCast(*const IInternetProtocolSink, self), ulStatusCode, szStatusText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolSink_ReportData(self: *const T, grfBSCF: u32, ulProgress: u32, ulProgressMax: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolSink.VTable, self.vtable).ReportData(@ptrCast(*const IInternetProtocolSink, self), grfBSCF, ulProgress, ulProgressMax); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolSink_ReportResult(self: *const T, hrResult: HRESULT, dwError: u32, szResult: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolSink.VTable, self.vtable).ReportResult(@ptrCast(*const IInternetProtocolSink, self), hrResult, dwError, szResult); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetProtocolSinkStackable_Value = @import("../../zig.zig").Guid.initString("79eac9f0-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetProtocolSinkStackable = &IID_IInternetProtocolSinkStackable_Value; pub const IInternetProtocolSinkStackable = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SwitchSink: fn( self: *const IInternetProtocolSinkStackable, pOIProtSink: ?*IInternetProtocolSink, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CommitSwitch: fn( self: *const IInternetProtocolSinkStackable, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RollbackSwitch: fn( self: *const IInternetProtocolSinkStackable, ) 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 IInternetProtocolSinkStackable_SwitchSink(self: *const T, pOIProtSink: ?*IInternetProtocolSink) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolSinkStackable.VTable, self.vtable).SwitchSink(@ptrCast(*const IInternetProtocolSinkStackable, self), pOIProtSink); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolSinkStackable_CommitSwitch(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolSinkStackable.VTable, self.vtable).CommitSwitch(@ptrCast(*const IInternetProtocolSinkStackable, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolSinkStackable_RollbackSwitch(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolSinkStackable.VTable, self.vtable).RollbackSwitch(@ptrCast(*const IInternetProtocolSinkStackable, self)); } };} pub usingnamespace MethodMixin(@This()); }; pub const OIBDG_FLAGS = enum(i32) { APARTMENTTHREADED = 256, DATAONLY = 4096, }; pub const OIBDG_APARTMENTTHREADED = OIBDG_FLAGS.APARTMENTTHREADED; pub const OIBDG_DATAONLY = OIBDG_FLAGS.DATAONLY; const IID_IInternetSession_Value = @import("../../zig.zig").Guid.initString("79eac9e7-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetSession = &IID_IInternetSession_Value; pub const IInternetSession = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, RegisterNameSpace: fn( self: *const IInternetSession, pCF: ?*IClassFactory, rclsid: ?*const Guid, pwzProtocol: ?[*:0]const u16, cPatterns: u32, ppwzPatterns: ?*const ?PWSTR, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnregisterNameSpace: fn( self: *const IInternetSession, pCF: ?*IClassFactory, pszProtocol: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RegisterMimeFilter: fn( self: *const IInternetSession, pCF: ?*IClassFactory, rclsid: ?*const Guid, pwzType: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnregisterMimeFilter: fn( self: *const IInternetSession, pCF: ?*IClassFactory, pwzType: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateBinding: fn( self: *const IInternetSession, pBC: ?*IBindCtx, szUrl: ?[*:0]const u16, pUnkOuter: ?*IUnknown, ppUnk: ?*?*IUnknown, ppOInetProt: ?*?*IInternetProtocol, dwOption: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetSessionOption: fn( self: *const IInternetSession, dwOption: u32, pBuffer: ?*anyopaque, dwBufferLength: u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetSessionOption: fn( self: *const IInternetSession, dwOption: u32, pBuffer: ?*anyopaque, pdwBufferLength: ?*u32, dwReserved: 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 IInternetSession_RegisterNameSpace(self: *const T, pCF: ?*IClassFactory, rclsid: ?*const Guid, pwzProtocol: ?[*:0]const u16, cPatterns: u32, ppwzPatterns: ?*const ?PWSTR, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSession.VTable, self.vtable).RegisterNameSpace(@ptrCast(*const IInternetSession, self), pCF, rclsid, pwzProtocol, cPatterns, ppwzPatterns, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSession_UnregisterNameSpace(self: *const T, pCF: ?*IClassFactory, pszProtocol: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSession.VTable, self.vtable).UnregisterNameSpace(@ptrCast(*const IInternetSession, self), pCF, pszProtocol); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSession_RegisterMimeFilter(self: *const T, pCF: ?*IClassFactory, rclsid: ?*const Guid, pwzType: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSession.VTable, self.vtable).RegisterMimeFilter(@ptrCast(*const IInternetSession, self), pCF, rclsid, pwzType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSession_UnregisterMimeFilter(self: *const T, pCF: ?*IClassFactory, pwzType: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSession.VTable, self.vtable).UnregisterMimeFilter(@ptrCast(*const IInternetSession, self), pCF, pwzType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSession_CreateBinding(self: *const T, pBC: ?*IBindCtx, szUrl: ?[*:0]const u16, pUnkOuter: ?*IUnknown, ppUnk: ?*?*IUnknown, ppOInetProt: ?*?*IInternetProtocol, dwOption: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSession.VTable, self.vtable).CreateBinding(@ptrCast(*const IInternetSession, self), pBC, szUrl, pUnkOuter, ppUnk, ppOInetProt, dwOption); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSession_SetSessionOption(self: *const T, dwOption: u32, pBuffer: ?*anyopaque, dwBufferLength: u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSession.VTable, self.vtable).SetSessionOption(@ptrCast(*const IInternetSession, self), dwOption, pBuffer, dwBufferLength, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSession_GetSessionOption(self: *const T, dwOption: u32, pBuffer: ?*anyopaque, pdwBufferLength: ?*u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSession.VTable, self.vtable).GetSessionOption(@ptrCast(*const IInternetSession, self), dwOption, pBuffer, pdwBufferLength, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetThreadSwitch_Value = @import("../../zig.zig").Guid.initString("79eac9e8-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetThreadSwitch = &IID_IInternetThreadSwitch_Value; pub const IInternetThreadSwitch = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Prepare: fn( self: *const IInternetThreadSwitch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Continue: fn( self: *const IInternetThreadSwitch, ) 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 IInternetThreadSwitch_Prepare(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetThreadSwitch.VTable, self.vtable).Prepare(@ptrCast(*const IInternetThreadSwitch, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetThreadSwitch_Continue(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetThreadSwitch.VTable, self.vtable).Continue(@ptrCast(*const IInternetThreadSwitch, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetPriority_Value = @import("../../zig.zig").Guid.initString("79eac9eb-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetPriority = &IID_IInternetPriority_Value; pub const IInternetPriority = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetPriority: fn( self: *const IInternetPriority, nPriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPriority: fn( self: *const IInternetPriority, pnPriority: ?*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 IInternetPriority_SetPriority(self: *const T, nPriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetPriority.VTable, self.vtable).SetPriority(@ptrCast(*const IInternetPriority, self), nPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetPriority_GetPriority(self: *const T, pnPriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetPriority.VTable, self.vtable).GetPriority(@ptrCast(*const IInternetPriority, self), pnPriority); } };} pub usingnamespace MethodMixin(@This()); }; pub const PARSEACTION = enum(i32) { CANONICALIZE = 1, FRIENDLY = 2, SECURITY_URL = 3, ROOTDOCUMENT = 4, DOCUMENT = 5, ANCHOR = 6, ENCODE_IS_UNESCAPE = 7, DECODE_IS_ESCAPE = 8, PATH_FROM_URL = 9, URL_FROM_PATH = 10, MIME = 11, SERVER = 12, SCHEMA = 13, SITE = 14, DOMAIN = 15, LOCATION = 16, SECURITY_DOMAIN = 17, ESCAPE = 18, UNESCAPE = 19, }; pub const PARSE_CANONICALIZE = PARSEACTION.CANONICALIZE; pub const PARSE_FRIENDLY = PARSEACTION.FRIENDLY; pub const PARSE_SECURITY_URL = PARSEACTION.SECURITY_URL; pub const PARSE_ROOTDOCUMENT = PARSEACTION.ROOTDOCUMENT; pub const PARSE_DOCUMENT = PARSEACTION.DOCUMENT; pub const PARSE_ANCHOR = PARSEACTION.ANCHOR; pub const PARSE_ENCODE_IS_UNESCAPE = PARSEACTION.ENCODE_IS_UNESCAPE; pub const PARSE_DECODE_IS_ESCAPE = PARSEACTION.DECODE_IS_ESCAPE; pub const PARSE_PATH_FROM_URL = PARSEACTION.PATH_FROM_URL; pub const PARSE_URL_FROM_PATH = PARSEACTION.URL_FROM_PATH; pub const PARSE_MIME = PARSEACTION.MIME; pub const PARSE_SERVER = PARSEACTION.SERVER; pub const PARSE_SCHEMA = PARSEACTION.SCHEMA; pub const PARSE_SITE = PARSEACTION.SITE; pub const PARSE_DOMAIN = PARSEACTION.DOMAIN; pub const PARSE_LOCATION = PARSEACTION.LOCATION; pub const PARSE_SECURITY_DOMAIN = PARSEACTION.SECURITY_DOMAIN; pub const PARSE_ESCAPE = PARSEACTION.ESCAPE; pub const PARSE_UNESCAPE = PARSEACTION.UNESCAPE; pub const PSUACTION = enum(i32) { DEFAULT = 1, SECURITY_URL_ONLY = 2, }; pub const PSU_DEFAULT = PSUACTION.DEFAULT; pub const PSU_SECURITY_URL_ONLY = PSUACTION.SECURITY_URL_ONLY; pub const QUERYOPTION = enum(i32) { EXPIRATION_DATE = 1, TIME_OF_LAST_CHANGE = 2, CONTENT_ENCODING = 3, CONTENT_TYPE = 4, REFRESH = 5, RECOMBINE = 6, CAN_NAVIGATE = 7, USES_NETWORK = 8, IS_CACHED = 9, IS_INSTALLEDENTRY = 10, IS_CACHED_OR_MAPPED = 11, USES_CACHE = 12, IS_SECURE = 13, IS_SAFE = 14, USES_HISTORYFOLDER = 15, IS_CACHED_AND_USABLE_OFFLINE = 16, }; pub const QUERY_EXPIRATION_DATE = QUERYOPTION.EXPIRATION_DATE; pub const QUERY_TIME_OF_LAST_CHANGE = QUERYOPTION.TIME_OF_LAST_CHANGE; pub const QUERY_CONTENT_ENCODING = QUERYOPTION.CONTENT_ENCODING; pub const QUERY_CONTENT_TYPE = QUERYOPTION.CONTENT_TYPE; pub const QUERY_REFRESH = QUERYOPTION.REFRESH; pub const QUERY_RECOMBINE = QUERYOPTION.RECOMBINE; pub const QUERY_CAN_NAVIGATE = QUERYOPTION.CAN_NAVIGATE; pub const QUERY_USES_NETWORK = QUERYOPTION.USES_NETWORK; pub const QUERY_IS_CACHED = QUERYOPTION.IS_CACHED; pub const QUERY_IS_INSTALLEDENTRY = QUERYOPTION.IS_INSTALLEDENTRY; pub const QUERY_IS_CACHED_OR_MAPPED = QUERYOPTION.IS_CACHED_OR_MAPPED; pub const QUERY_USES_CACHE = QUERYOPTION.USES_CACHE; pub const QUERY_IS_SECURE = QUERYOPTION.IS_SECURE; pub const QUERY_IS_SAFE = QUERYOPTION.IS_SAFE; pub const QUERY_USES_HISTORYFOLDER = QUERYOPTION.USES_HISTORYFOLDER; pub const QUERY_IS_CACHED_AND_USABLE_OFFLINE = QUERYOPTION.IS_CACHED_AND_USABLE_OFFLINE; const IID_IInternetProtocolInfo_Value = @import("../../zig.zig").Guid.initString("79eac9ec-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetProtocolInfo = &IID_IInternetProtocolInfo_Value; pub const IInternetProtocolInfo = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, ParseUrl: fn( self: *const IInternetProtocolInfo, pwzUrl: ?[*:0]const u16, ParseAction: PARSEACTION, dwParseFlags: u32, pwzResult: ?PWSTR, cchResult: u32, pcchResult: ?*u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CombineUrl: fn( self: *const IInternetProtocolInfo, pwzBaseUrl: ?[*:0]const u16, pwzRelativeUrl: ?[*:0]const u16, dwCombineFlags: u32, pwzResult: ?PWSTR, cchResult: u32, pcchResult: ?*u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CompareUrl: fn( self: *const IInternetProtocolInfo, pwzUrl1: ?[*:0]const u16, pwzUrl2: ?[*:0]const u16, dwCompareFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, QueryInfo: fn( self: *const IInternetProtocolInfo, pwzUrl: ?[*:0]const u16, OueryOption: QUERYOPTION, dwQueryFlags: u32, pBuffer: [*]u8, cbBuffer: u32, pcbBuf: ?*u32, dwReserved: 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 IInternetProtocolInfo_ParseUrl(self: *const T, pwzUrl: ?[*:0]const u16, ParseAction: PARSEACTION, dwParseFlags: u32, pwzResult: ?PWSTR, cchResult: u32, pcchResult: ?*u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolInfo.VTable, self.vtable).ParseUrl(@ptrCast(*const IInternetProtocolInfo, self), pwzUrl, ParseAction, dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolInfo_CombineUrl(self: *const T, pwzBaseUrl: ?[*:0]const u16, pwzRelativeUrl: ?[*:0]const u16, dwCombineFlags: u32, pwzResult: ?PWSTR, cchResult: u32, pcchResult: ?*u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolInfo.VTable, self.vtable).CombineUrl(@ptrCast(*const IInternetProtocolInfo, self), pwzBaseUrl, pwzRelativeUrl, dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolInfo_CompareUrl(self: *const T, pwzUrl1: ?[*:0]const u16, pwzUrl2: ?[*:0]const u16, dwCompareFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolInfo.VTable, self.vtable).CompareUrl(@ptrCast(*const IInternetProtocolInfo, self), pwzUrl1, pwzUrl2, dwCompareFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetProtocolInfo_QueryInfo(self: *const T, pwzUrl: ?[*:0]const u16, OueryOption: QUERYOPTION, dwQueryFlags: u32, pBuffer: [*]u8, cbBuffer: u32, pcbBuf: ?*u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetProtocolInfo.VTable, self.vtable).QueryInfo(@ptrCast(*const IInternetProtocolInfo, self), pwzUrl, OueryOption, dwQueryFlags, pBuffer, cbBuffer, pcbBuf, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; pub const INTERNETFEATURELIST = enum(i32) { OBJECT_CACHING = 0, ZONE_ELEVATION = 1, MIME_HANDLING = 2, MIME_SNIFFING = 3, WINDOW_RESTRICTIONS = 4, WEBOC_POPUPMANAGEMENT = 5, BEHAVIORS = 6, DISABLE_MK_PROTOCOL = 7, LOCALMACHINE_LOCKDOWN = 8, SECURITYBAND = 9, RESTRICT_ACTIVEXINSTALL = 10, VALIDATE_NAVIGATE_URL = 11, RESTRICT_FILEDOWNLOAD = 12, ADDON_MANAGEMENT = 13, PROTOCOL_LOCKDOWN = 14, HTTP_USERNAME_PASSWORD_DISABLE = 15, SAFE_BINDTOOBJECT = 16, UNC_SAVEDFILECHECK = 17, GET_URL_DOM_FILEPATH_UNENCODED = 18, TABBED_BROWSING = 19, SSLUX = 20, DISABLE_NAVIGATION_SOUNDS = 21, DISABLE_LEGACY_COMPRESSION = 22, FORCE_ADDR_AND_STATUS = 23, XMLHTTP = 24, DISABLE_TELNET_PROTOCOL = 25, FEEDS = 26, BLOCK_INPUT_PROMPTS = 27, ENTRY_COUNT = 28, }; pub const FEATURE_OBJECT_CACHING = INTERNETFEATURELIST.OBJECT_CACHING; pub const FEATURE_ZONE_ELEVATION = INTERNETFEATURELIST.ZONE_ELEVATION; pub const FEATURE_MIME_HANDLING = INTERNETFEATURELIST.MIME_HANDLING; pub const FEATURE_MIME_SNIFFING = INTERNETFEATURELIST.MIME_SNIFFING; pub const FEATURE_WINDOW_RESTRICTIONS = INTERNETFEATURELIST.WINDOW_RESTRICTIONS; pub const FEATURE_WEBOC_POPUPMANAGEMENT = INTERNETFEATURELIST.WEBOC_POPUPMANAGEMENT; pub const FEATURE_BEHAVIORS = INTERNETFEATURELIST.BEHAVIORS; pub const FEATURE_DISABLE_MK_PROTOCOL = INTERNETFEATURELIST.DISABLE_MK_PROTOCOL; pub const FEATURE_LOCALMACHINE_LOCKDOWN = INTERNETFEATURELIST.LOCALMACHINE_LOCKDOWN; pub const FEATURE_SECURITYBAND = INTERNETFEATURELIST.SECURITYBAND; pub const FEATURE_RESTRICT_ACTIVEXINSTALL = INTERNETFEATURELIST.RESTRICT_ACTIVEXINSTALL; pub const FEATURE_VALIDATE_NAVIGATE_URL = INTERNETFEATURELIST.VALIDATE_NAVIGATE_URL; pub const FEATURE_RESTRICT_FILEDOWNLOAD = INTERNETFEATURELIST.RESTRICT_FILEDOWNLOAD; pub const FEATURE_ADDON_MANAGEMENT = INTERNETFEATURELIST.ADDON_MANAGEMENT; pub const FEATURE_PROTOCOL_LOCKDOWN = INTERNETFEATURELIST.PROTOCOL_LOCKDOWN; pub const FEATURE_HTTP_USERNAME_PASSWORD_DISABLE = INTERNETFEATURELIST.HTTP_USERNAME_PASSWORD_DISABLE; pub const FEATURE_SAFE_BINDTOOBJECT = INTERNETFEATURELIST.SAFE_BINDTOOBJECT; pub const FEATURE_UNC_SAVEDFILECHECK = INTERNETFEATURELIST.UNC_SAVEDFILECHECK; pub const FEATURE_GET_URL_DOM_FILEPATH_UNENCODED = INTERNETFEATURELIST.GET_URL_DOM_FILEPATH_UNENCODED; pub const FEATURE_TABBED_BROWSING = INTERNETFEATURELIST.TABBED_BROWSING; pub const FEATURE_SSLUX = INTERNETFEATURELIST.SSLUX; pub const FEATURE_DISABLE_NAVIGATION_SOUNDS = INTERNETFEATURELIST.DISABLE_NAVIGATION_SOUNDS; pub const FEATURE_DISABLE_LEGACY_COMPRESSION = INTERNETFEATURELIST.DISABLE_LEGACY_COMPRESSION; pub const FEATURE_FORCE_ADDR_AND_STATUS = INTERNETFEATURELIST.FORCE_ADDR_AND_STATUS; pub const FEATURE_XMLHTTP = INTERNETFEATURELIST.XMLHTTP; pub const FEATURE_DISABLE_TELNET_PROTOCOL = INTERNETFEATURELIST.DISABLE_TELNET_PROTOCOL; pub const FEATURE_FEEDS = INTERNETFEATURELIST.FEEDS; pub const FEATURE_BLOCK_INPUT_PROMPTS = INTERNETFEATURELIST.BLOCK_INPUT_PROMPTS; pub const FEATURE_ENTRY_COUNT = INTERNETFEATURELIST.ENTRY_COUNT; const IID_IInternetSecurityMgrSite_Value = @import("../../zig.zig").Guid.initString("79eac9ed-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetSecurityMgrSite = &IID_IInternetSecurityMgrSite_Value; pub const IInternetSecurityMgrSite = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetWindow: fn( self: *const IInternetSecurityMgrSite, phwnd: ?*?HWND, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnableModeless: fn( self: *const IInternetSecurityMgrSite, fEnable: BOOL, ) 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 IInternetSecurityMgrSite_GetWindow(self: *const T, phwnd: ?*?HWND) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityMgrSite.VTable, self.vtable).GetWindow(@ptrCast(*const IInternetSecurityMgrSite, self), phwnd); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityMgrSite_EnableModeless(self: *const T, fEnable: BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityMgrSite.VTable, self.vtable).EnableModeless(@ptrCast(*const IInternetSecurityMgrSite, self), fEnable); } };} pub usingnamespace MethodMixin(@This()); }; pub const PUAF = enum(i32) { DEFAULT = 0, NOUI = 1, ISFILE = 2, WARN_IF_DENIED = 4, FORCEUI_FOREGROUND = 8, CHECK_TIFS = 16, DONTCHECKBOXINDIALOG = 32, TRUSTED = 64, ACCEPT_WILDCARD_SCHEME = 128, ENFORCERESTRICTED = 256, NOSAVEDFILECHECK = 512, REQUIRESAVEDFILECHECK = 1024, DONT_USE_CACHE = 4096, RESERVED1 = 8192, RESERVED2 = 16384, LMZ_UNLOCKED = 65536, LMZ_LOCKED = 131072, DEFAULTZONEPOL = 262144, NPL_USE_LOCKED_IF_RESTRICTED = 524288, NOUIIFLOCKED = 1048576, DRAGPROTOCOLCHECK = 2097152, }; pub const PUAF_DEFAULT = PUAF.DEFAULT; pub const PUAF_NOUI = PUAF.NOUI; pub const PUAF_ISFILE = PUAF.ISFILE; pub const PUAF_WARN_IF_DENIED = PUAF.WARN_IF_DENIED; pub const PUAF_FORCEUI_FOREGROUND = PUAF.FORCEUI_FOREGROUND; pub const PUAF_CHECK_TIFS = PUAF.CHECK_TIFS; pub const PUAF_DONTCHECKBOXINDIALOG = PUAF.DONTCHECKBOXINDIALOG; pub const PUAF_TRUSTED = PUAF.TRUSTED; pub const PUAF_ACCEPT_WILDCARD_SCHEME = PUAF.ACCEPT_WILDCARD_SCHEME; pub const PUAF_ENFORCERESTRICTED = PUAF.ENFORCERESTRICTED; pub const PUAF_NOSAVEDFILECHECK = PUAF.NOSAVEDFILECHECK; pub const PUAF_REQUIRESAVEDFILECHECK = PUAF.REQUIRESAVEDFILECHECK; pub const PUAF_DONT_USE_CACHE = PUAF.DONT_USE_CACHE; pub const PUAF_RESERVED1 = PUAF.RESERVED1; pub const PUAF_RESERVED2 = PUAF.RESERVED2; pub const PUAF_LMZ_UNLOCKED = PUAF.LMZ_UNLOCKED; pub const PUAF_LMZ_LOCKED = PUAF.LMZ_LOCKED; pub const PUAF_DEFAULTZONEPOL = PUAF.DEFAULTZONEPOL; pub const PUAF_NPL_USE_LOCKED_IF_RESTRICTED = PUAF.NPL_USE_LOCKED_IF_RESTRICTED; pub const PUAF_NOUIIFLOCKED = PUAF.NOUIIFLOCKED; pub const PUAF_DRAGPROTOCOLCHECK = PUAF.DRAGPROTOCOLCHECK; pub const PUAFOUT = enum(i32) { DEFAULT = 0, ISLOCKZONEPOLICY = 1, }; pub const PUAFOUT_DEFAULT = PUAFOUT.DEFAULT; pub const PUAFOUT_ISLOCKZONEPOLICY = PUAFOUT.ISLOCKZONEPOLICY; pub const SZM_FLAGS = enum(i32) { CREATE = 0, DELETE = 1, }; pub const SZM_CREATE = SZM_FLAGS.CREATE; pub const SZM_DELETE = SZM_FLAGS.DELETE; const IID_IInternetSecurityManager_Value = @import("../../zig.zig").Guid.initString("79eac9ee-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetSecurityManager = &IID_IInternetSecurityManager_Value; pub const IInternetSecurityManager = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetSecuritySite: fn( self: *const IInternetSecurityManager, pSite: ?*IInternetSecurityMgrSite, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetSecuritySite: fn( self: *const IInternetSecurityManager, ppSite: ?*?*IInternetSecurityMgrSite, ) callconv(@import("std").os.windows.WINAPI) HRESULT, MapUrlToZone: fn( self: *const IInternetSecurityManager, pwszUrl: ?[*:0]const u16, pdwZone: ?*u32, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetSecurityId: fn( self: *const IInternetSecurityManager, pwszUrl: ?[*:0]const u16, pbSecurityId: *[512]u8, pcbSecurityId: ?*u32, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ProcessUrlAction: fn( self: *const IInternetSecurityManager, pwszUrl: ?[*:0]const u16, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, pContext: ?*u8, cbContext: u32, dwFlags: u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, QueryCustomPolicy: fn( self: *const IInternetSecurityManager, pwszUrl: ?[*:0]const u16, guidKey: ?*const Guid, ppPolicy: [*]?*u8, pcbPolicy: ?*u32, pContext: ?*u8, cbContext: u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetZoneMapping: fn( self: *const IInternetSecurityManager, dwZone: u32, lpszPattern: ?[*:0]const u16, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetZoneMappings: fn( self: *const IInternetSecurityManager, dwZone: u32, ppenumString: ?*?*IEnumString, dwFlags: 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 IInternetSecurityManager_SetSecuritySite(self: *const T, pSite: ?*IInternetSecurityMgrSite) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManager.VTable, self.vtable).SetSecuritySite(@ptrCast(*const IInternetSecurityManager, self), pSite); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManager_GetSecuritySite(self: *const T, ppSite: ?*?*IInternetSecurityMgrSite) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManager.VTable, self.vtable).GetSecuritySite(@ptrCast(*const IInternetSecurityManager, self), ppSite); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManager_MapUrlToZone(self: *const T, pwszUrl: ?[*:0]const u16, pdwZone: ?*u32, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManager.VTable, self.vtable).MapUrlToZone(@ptrCast(*const IInternetSecurityManager, self), pwszUrl, pdwZone, dwFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManager_GetSecurityId(self: *const T, pwszUrl: ?[*:0]const u16, pbSecurityId: *[512]u8, pcbSecurityId: ?*u32, dwReserved: usize) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManager.VTable, self.vtable).GetSecurityId(@ptrCast(*const IInternetSecurityManager, self), pwszUrl, pbSecurityId, pcbSecurityId, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManager_ProcessUrlAction(self: *const T, pwszUrl: ?[*:0]const u16, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, pContext: ?*u8, cbContext: u32, dwFlags: u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManager.VTable, self.vtable).ProcessUrlAction(@ptrCast(*const IInternetSecurityManager, self), pwszUrl, dwAction, pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManager_QueryCustomPolicy(self: *const T, pwszUrl: ?[*:0]const u16, guidKey: ?*const Guid, ppPolicy: [*]?*u8, pcbPolicy: ?*u32, pContext: ?*u8, cbContext: u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManager.VTable, self.vtable).QueryCustomPolicy(@ptrCast(*const IInternetSecurityManager, self), pwszUrl, guidKey, ppPolicy, pcbPolicy, pContext, cbContext, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManager_SetZoneMapping(self: *const T, dwZone: u32, lpszPattern: ?[*:0]const u16, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManager.VTable, self.vtable).SetZoneMapping(@ptrCast(*const IInternetSecurityManager, self), dwZone, lpszPattern, dwFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManager_GetZoneMappings(self: *const T, dwZone: u32, ppenumString: ?*?*IEnumString, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManager.VTable, self.vtable).GetZoneMappings(@ptrCast(*const IInternetSecurityManager, self), dwZone, ppenumString, dwFlags); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetSecurityManagerEx_Value = @import("../../zig.zig").Guid.initString("f164edf1-cc7c-4f0d-9a94-34222625c393"); pub const IID_IInternetSecurityManagerEx = &IID_IInternetSecurityManagerEx_Value; pub const IInternetSecurityManagerEx = extern struct { pub const VTable = extern struct { base: IInternetSecurityManager.VTable, ProcessUrlActionEx: fn( self: *const IInternetSecurityManagerEx, pwszUrl: ?[*:0]const u16, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, pContext: ?*u8, cbContext: u32, dwFlags: u32, dwReserved: u32, pdwOutFlags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IInternetSecurityManager.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManagerEx_ProcessUrlActionEx(self: *const T, pwszUrl: ?[*:0]const u16, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, pContext: ?*u8, cbContext: u32, dwFlags: u32, dwReserved: u32, pdwOutFlags: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManagerEx.VTable, self.vtable).ProcessUrlActionEx(@ptrCast(*const IInternetSecurityManagerEx, self), pwszUrl, dwAction, pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved, pdwOutFlags); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetSecurityManagerEx2_Value = @import("../../zig.zig").Guid.initString("f1e50292-a795-4117-8e09-2b560a72ac60"); pub const IID_IInternetSecurityManagerEx2 = &IID_IInternetSecurityManagerEx2_Value; pub const IInternetSecurityManagerEx2 = extern struct { pub const VTable = extern struct { base: IInternetSecurityManagerEx.VTable, MapUrlToZoneEx2: fn( self: *const IInternetSecurityManagerEx2, pUri: ?*IUri, pdwZone: ?*u32, dwFlags: u32, ppwszMappedUrl: ?*?PWSTR, pdwOutFlags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ProcessUrlActionEx2: fn( self: *const IInternetSecurityManagerEx2, pUri: ?*IUri, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, pContext: ?*u8, cbContext: u32, dwFlags: u32, dwReserved: usize, pdwOutFlags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetSecurityIdEx2: fn( self: *const IInternetSecurityManagerEx2, pUri: ?*IUri, pbSecurityId: *[512]u8, pcbSecurityId: ?*u32, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT, QueryCustomPolicyEx2: fn( self: *const IInternetSecurityManagerEx2, pUri: ?*IUri, guidKey: ?*const Guid, ppPolicy: [*]?*u8, pcbPolicy: ?*u32, pContext: ?*u8, cbContext: u32, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IInternetSecurityManagerEx.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManagerEx2_MapUrlToZoneEx2(self: *const T, pUri: ?*IUri, pdwZone: ?*u32, dwFlags: u32, ppwszMappedUrl: ?*?PWSTR, pdwOutFlags: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManagerEx2.VTable, self.vtable).MapUrlToZoneEx2(@ptrCast(*const IInternetSecurityManagerEx2, self), pUri, pdwZone, dwFlags, ppwszMappedUrl, pdwOutFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManagerEx2_ProcessUrlActionEx2(self: *const T, pUri: ?*IUri, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, pContext: ?*u8, cbContext: u32, dwFlags: u32, dwReserved: usize, pdwOutFlags: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManagerEx2.VTable, self.vtable).ProcessUrlActionEx2(@ptrCast(*const IInternetSecurityManagerEx2, self), pUri, dwAction, pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved, pdwOutFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManagerEx2_GetSecurityIdEx2(self: *const T, pUri: ?*IUri, pbSecurityId: *[512]u8, pcbSecurityId: ?*u32, dwReserved: usize) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManagerEx2.VTable, self.vtable).GetSecurityIdEx2(@ptrCast(*const IInternetSecurityManagerEx2, self), pUri, pbSecurityId, pcbSecurityId, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetSecurityManagerEx2_QueryCustomPolicyEx2(self: *const T, pUri: ?*IUri, guidKey: ?*const Guid, ppPolicy: [*]?*u8, pcbPolicy: ?*u32, pContext: ?*u8, cbContext: u32, dwReserved: usize) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetSecurityManagerEx2.VTable, self.vtable).QueryCustomPolicyEx2(@ptrCast(*const IInternetSecurityManagerEx2, self), pUri, guidKey, ppPolicy, pcbPolicy, pContext, cbContext, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IZoneIdentifier_Value = @import("../../zig.zig").Guid.initString("cd45f185-1b21-48e2-967b-ead743a8914e"); pub const IID_IZoneIdentifier = &IID_IZoneIdentifier_Value; pub const IZoneIdentifier = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetId: fn( self: *const IZoneIdentifier, pdwZone: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetId: fn( self: *const IZoneIdentifier, dwZone: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Remove: fn( self: *const IZoneIdentifier, ) 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 IZoneIdentifier_GetId(self: *const T, pdwZone: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier.VTable, self.vtable).GetId(@ptrCast(*const IZoneIdentifier, self), pdwZone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IZoneIdentifier_SetId(self: *const T, dwZone: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier.VTable, self.vtable).SetId(@ptrCast(*const IZoneIdentifier, self), dwZone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IZoneIdentifier_Remove(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier.VTable, self.vtable).Remove(@ptrCast(*const IZoneIdentifier, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IZoneIdentifier2_Value = @import("../../zig.zig").Guid.initString("eb5e760c-09ef-45c0-b510-70830ce31e6a"); pub const IID_IZoneIdentifier2 = &IID_IZoneIdentifier2_Value; pub const IZoneIdentifier2 = extern struct { pub const VTable = extern struct { base: IZoneIdentifier.VTable, GetLastWriterPackageFamilyName: fn( self: *const IZoneIdentifier2, packageFamilyName: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetLastWriterPackageFamilyName: fn( self: *const IZoneIdentifier2, packageFamilyName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveLastWriterPackageFamilyName: fn( self: *const IZoneIdentifier2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAppZoneId: fn( self: *const IZoneIdentifier2, zone: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetAppZoneId: fn( self: *const IZoneIdentifier2, zone: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveAppZoneId: fn( self: *const IZoneIdentifier2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IZoneIdentifier.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IZoneIdentifier2_GetLastWriterPackageFamilyName(self: *const T, packageFamilyName: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier2.VTable, self.vtable).GetLastWriterPackageFamilyName(@ptrCast(*const IZoneIdentifier2, self), packageFamilyName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IZoneIdentifier2_SetLastWriterPackageFamilyName(self: *const T, packageFamilyName: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier2.VTable, self.vtable).SetLastWriterPackageFamilyName(@ptrCast(*const IZoneIdentifier2, self), packageFamilyName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IZoneIdentifier2_RemoveLastWriterPackageFamilyName(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier2.VTable, self.vtable).RemoveLastWriterPackageFamilyName(@ptrCast(*const IZoneIdentifier2, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IZoneIdentifier2_GetAppZoneId(self: *const T, zone: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier2.VTable, self.vtable).GetAppZoneId(@ptrCast(*const IZoneIdentifier2, self), zone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IZoneIdentifier2_SetAppZoneId(self: *const T, zone: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier2.VTable, self.vtable).SetAppZoneId(@ptrCast(*const IZoneIdentifier2, self), zone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IZoneIdentifier2_RemoveAppZoneId(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IZoneIdentifier2.VTable, self.vtable).RemoveAppZoneId(@ptrCast(*const IZoneIdentifier2, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetHostSecurityManager_Value = @import("../../zig.zig").Guid.initString("3af280b6-cb3f-11d0-891e-00c04fb6bfc4"); pub const IID_IInternetHostSecurityManager = &IID_IInternetHostSecurityManager_Value; pub const IInternetHostSecurityManager = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetSecurityId: fn( self: *const IInternetHostSecurityManager, pbSecurityId: [*:0]u8, pcbSecurityId: ?*u32, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ProcessUrlAction: fn( self: *const IInternetHostSecurityManager, dwAction: u32, pPolicy: ?*u8, cbPolicy: u32, pContext: ?[*:0]u8, cbContext: u32, dwFlags: u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, QueryCustomPolicy: fn( self: *const IInternetHostSecurityManager, guidKey: ?*const Guid, ppPolicy: ?[*]?*u8, pcbPolicy: ?*u32, pContext: [*:0]u8, cbContext: u32, dwReserved: 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 IInternetHostSecurityManager_GetSecurityId(self: *const T, pbSecurityId: [*:0]u8, pcbSecurityId: ?*u32, dwReserved: usize) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetHostSecurityManager.VTable, self.vtable).GetSecurityId(@ptrCast(*const IInternetHostSecurityManager, self), pbSecurityId, pcbSecurityId, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetHostSecurityManager_ProcessUrlAction(self: *const T, dwAction: u32, pPolicy: ?*u8, cbPolicy: u32, pContext: ?[*:0]u8, cbContext: u32, dwFlags: u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetHostSecurityManager.VTable, self.vtable).ProcessUrlAction(@ptrCast(*const IInternetHostSecurityManager, self), dwAction, pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetHostSecurityManager_QueryCustomPolicy(self: *const T, guidKey: ?*const Guid, ppPolicy: ?[*]?*u8, pcbPolicy: ?*u32, pContext: [*:0]u8, cbContext: u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetHostSecurityManager.VTable, self.vtable).QueryCustomPolicy(@ptrCast(*const IInternetHostSecurityManager, self), guidKey, ppPolicy, pcbPolicy, pContext, cbContext, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; pub const URLZONE = enum(i32) { INVALID = -1, PREDEFINED_MIN = 0, // LOCAL_MACHINE = 0, this enum value conflicts with PREDEFINED_MIN INTRANET = 1, TRUSTED = 2, INTERNET = 3, UNTRUSTED = 4, PREDEFINED_MAX = 999, USER_MIN = 1000, USER_MAX = 10000, }; pub const URLZONE_INVALID = URLZONE.INVALID; pub const URLZONE_PREDEFINED_MIN = URLZONE.PREDEFINED_MIN; pub const URLZONE_LOCAL_MACHINE = URLZONE.PREDEFINED_MIN; pub const URLZONE_INTRANET = URLZONE.INTRANET; pub const URLZONE_TRUSTED = URLZONE.TRUSTED; pub const URLZONE_INTERNET = URLZONE.INTERNET; pub const URLZONE_UNTRUSTED = URLZONE.UNTRUSTED; pub const URLZONE_PREDEFINED_MAX = URLZONE.PREDEFINED_MAX; pub const URLZONE_USER_MIN = URLZONE.USER_MIN; pub const URLZONE_USER_MAX = URLZONE.USER_MAX; pub const URLTEMPLATE = enum(i32) { CUSTOM = 0, PREDEFINED_MIN = 65536, // LOW = 65536, this enum value conflicts with PREDEFINED_MIN MEDLOW = 66816, MEDIUM = 69632, MEDHIGH = 70912, HIGH = 73728, PREDEFINED_MAX = 131072, }; pub const URLTEMPLATE_CUSTOM = URLTEMPLATE.CUSTOM; pub const URLTEMPLATE_PREDEFINED_MIN = URLTEMPLATE.PREDEFINED_MIN; pub const URLTEMPLATE_LOW = URLTEMPLATE.PREDEFINED_MIN; pub const URLTEMPLATE_MEDLOW = URLTEMPLATE.MEDLOW; pub const URLTEMPLATE_MEDIUM = URLTEMPLATE.MEDIUM; pub const URLTEMPLATE_MEDHIGH = URLTEMPLATE.MEDHIGH; pub const URLTEMPLATE_HIGH = URLTEMPLATE.HIGH; pub const URLTEMPLATE_PREDEFINED_MAX = URLTEMPLATE.PREDEFINED_MAX; pub const INET_ZONE_MANAGER_CONSTANTS = enum(i32) { PATH = 260, DESCRIPTION = 200, }; pub const MAX_ZONE_PATH = INET_ZONE_MANAGER_CONSTANTS.PATH; pub const MAX_ZONE_DESCRIPTION = INET_ZONE_MANAGER_CONSTANTS.DESCRIPTION; pub const ZAFLAGS = enum(i32) { CUSTOM_EDIT = 1, ADD_SITES = 2, REQUIRE_VERIFICATION = 4, INCLUDE_PROXY_OVERRIDE = 8, INCLUDE_INTRANET_SITES = 16, NO_UI = 32, SUPPORTS_VERIFICATION = 64, UNC_AS_INTRANET = 128, DETECT_INTRANET = 256, USE_LOCKED_ZONES = 65536, VERIFY_TEMPLATE_SETTINGS = 131072, NO_CACHE = 262144, }; pub const ZAFLAGS_CUSTOM_EDIT = ZAFLAGS.CUSTOM_EDIT; pub const ZAFLAGS_ADD_SITES = ZAFLAGS.ADD_SITES; pub const ZAFLAGS_REQUIRE_VERIFICATION = ZAFLAGS.REQUIRE_VERIFICATION; pub const ZAFLAGS_INCLUDE_PROXY_OVERRIDE = ZAFLAGS.INCLUDE_PROXY_OVERRIDE; pub const ZAFLAGS_INCLUDE_INTRANET_SITES = ZAFLAGS.INCLUDE_INTRANET_SITES; pub const ZAFLAGS_NO_UI = ZAFLAGS.NO_UI; pub const ZAFLAGS_SUPPORTS_VERIFICATION = ZAFLAGS.SUPPORTS_VERIFICATION; pub const ZAFLAGS_UNC_AS_INTRANET = ZAFLAGS.UNC_AS_INTRANET; pub const ZAFLAGS_DETECT_INTRANET = ZAFLAGS.DETECT_INTRANET; pub const ZAFLAGS_USE_LOCKED_ZONES = ZAFLAGS.USE_LOCKED_ZONES; pub const ZAFLAGS_VERIFY_TEMPLATE_SETTINGS = ZAFLAGS.VERIFY_TEMPLATE_SETTINGS; pub const ZAFLAGS_NO_CACHE = ZAFLAGS.NO_CACHE; pub const ZONEATTRIBUTES = extern struct { cbSize: u32, szDisplayName: [260]u16, szDescription: [200]u16, szIconPath: [260]u16, dwTemplateMinLevel: u32, dwTemplateRecommended: u32, dwTemplateCurrentLevel: u32, dwFlags: u32, }; pub const URLZONEREG = enum(i32) { DEFAULT = 0, HKLM = 1, HKCU = 2, }; pub const URLZONEREG_DEFAULT = URLZONEREG.DEFAULT; pub const URLZONEREG_HKLM = URLZONEREG.HKLM; pub const URLZONEREG_HKCU = URLZONEREG.HKCU; const IID_IInternetZoneManager_Value = @import("../../zig.zig").Guid.initString("79eac9ef-baf9-11ce-8c82-00aa004ba90b"); pub const IID_IInternetZoneManager = &IID_IInternetZoneManager_Value; pub const IInternetZoneManager = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetZoneAttributes: fn( self: *const IInternetZoneManager, dwZone: u32, pZoneAttributes: ?*ZONEATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetZoneAttributes: fn( self: *const IInternetZoneManager, dwZone: u32, pZoneAttributes: ?*ZONEATTRIBUTES, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetZoneCustomPolicy: fn( self: *const IInternetZoneManager, dwZone: u32, guidKey: ?*const Guid, ppPolicy: ?*?*u8, pcbPolicy: ?*u32, urlZoneReg: URLZONEREG, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetZoneCustomPolicy: fn( self: *const IInternetZoneManager, dwZone: u32, guidKey: ?*const Guid, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetZoneActionPolicy: fn( self: *const IInternetZoneManager, dwZone: u32, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetZoneActionPolicy: fn( self: *const IInternetZoneManager, dwZone: u32, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PromptAction: fn( self: *const IInternetZoneManager, dwAction: u32, hwndParent: ?HWND, pwszUrl: ?[*:0]const u16, pwszText: ?[*:0]const u16, dwPromptFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, LogAction: fn( self: *const IInternetZoneManager, dwAction: u32, pwszUrl: ?[*:0]const u16, pwszText: ?[*:0]const u16, dwLogFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateZoneEnumerator: fn( self: *const IInternetZoneManager, pdwEnum: ?*u32, pdwCount: ?*u32, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetZoneAt: fn( self: *const IInternetZoneManager, dwEnum: u32, dwIndex: u32, pdwZone: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DestroyZoneEnumerator: fn( self: *const IInternetZoneManager, dwEnum: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CopyTemplatePoliciesToZone: fn( self: *const IInternetZoneManager, dwTemplate: u32, dwZone: u32, dwReserved: 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 IInternetZoneManager_GetZoneAttributes(self: *const T, dwZone: u32, pZoneAttributes: ?*ZONEATTRIBUTES) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).GetZoneAttributes(@ptrCast(*const IInternetZoneManager, self), dwZone, pZoneAttributes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_SetZoneAttributes(self: *const T, dwZone: u32, pZoneAttributes: ?*ZONEATTRIBUTES) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).SetZoneAttributes(@ptrCast(*const IInternetZoneManager, self), dwZone, pZoneAttributes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_GetZoneCustomPolicy(self: *const T, dwZone: u32, guidKey: ?*const Guid, ppPolicy: ?*?*u8, pcbPolicy: ?*u32, urlZoneReg: URLZONEREG) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).GetZoneCustomPolicy(@ptrCast(*const IInternetZoneManager, self), dwZone, guidKey, ppPolicy, pcbPolicy, urlZoneReg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_SetZoneCustomPolicy(self: *const T, dwZone: u32, guidKey: ?*const Guid, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).SetZoneCustomPolicy(@ptrCast(*const IInternetZoneManager, self), dwZone, guidKey, pPolicy, cbPolicy, urlZoneReg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_GetZoneActionPolicy(self: *const T, dwZone: u32, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).GetZoneActionPolicy(@ptrCast(*const IInternetZoneManager, self), dwZone, dwAction, pPolicy, cbPolicy, urlZoneReg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_SetZoneActionPolicy(self: *const T, dwZone: u32, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).SetZoneActionPolicy(@ptrCast(*const IInternetZoneManager, self), dwZone, dwAction, pPolicy, cbPolicy, urlZoneReg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_PromptAction(self: *const T, dwAction: u32, hwndParent: ?HWND, pwszUrl: ?[*:0]const u16, pwszText: ?[*:0]const u16, dwPromptFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).PromptAction(@ptrCast(*const IInternetZoneManager, self), dwAction, hwndParent, pwszUrl, pwszText, dwPromptFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_LogAction(self: *const T, dwAction: u32, pwszUrl: ?[*:0]const u16, pwszText: ?[*:0]const u16, dwLogFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).LogAction(@ptrCast(*const IInternetZoneManager, self), dwAction, pwszUrl, pwszText, dwLogFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_CreateZoneEnumerator(self: *const T, pdwEnum: ?*u32, pdwCount: ?*u32, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).CreateZoneEnumerator(@ptrCast(*const IInternetZoneManager, self), pdwEnum, pdwCount, dwFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_GetZoneAt(self: *const T, dwEnum: u32, dwIndex: u32, pdwZone: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).GetZoneAt(@ptrCast(*const IInternetZoneManager, self), dwEnum, dwIndex, pdwZone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_DestroyZoneEnumerator(self: *const T, dwEnum: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).DestroyZoneEnumerator(@ptrCast(*const IInternetZoneManager, self), dwEnum); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManager_CopyTemplatePoliciesToZone(self: *const T, dwTemplate: u32, dwZone: u32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManager.VTable, self.vtable).CopyTemplatePoliciesToZone(@ptrCast(*const IInternetZoneManager, self), dwTemplate, dwZone, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetZoneManagerEx_Value = @import("../../zig.zig").Guid.initString("a4c23339-8e06-431e-9bf4-7e711c085648"); pub const IID_IInternetZoneManagerEx = &IID_IInternetZoneManagerEx_Value; pub const IInternetZoneManagerEx = extern struct { pub const VTable = extern struct { base: IInternetZoneManager.VTable, GetZoneActionPolicyEx: fn( self: *const IInternetZoneManagerEx, dwZone: u32, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetZoneActionPolicyEx: fn( self: *const IInternetZoneManagerEx, dwZone: u32, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IInternetZoneManager.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManagerEx_GetZoneActionPolicyEx(self: *const T, dwZone: u32, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManagerEx.VTable, self.vtable).GetZoneActionPolicyEx(@ptrCast(*const IInternetZoneManagerEx, self), dwZone, dwAction, pPolicy, cbPolicy, urlZoneReg, dwFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManagerEx_SetZoneActionPolicyEx(self: *const T, dwZone: u32, dwAction: u32, pPolicy: [*:0]u8, cbPolicy: u32, urlZoneReg: URLZONEREG, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManagerEx.VTable, self.vtable).SetZoneActionPolicyEx(@ptrCast(*const IInternetZoneManagerEx, self), dwZone, dwAction, pPolicy, cbPolicy, urlZoneReg, dwFlags); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IInternetZoneManagerEx2_Value = @import("../../zig.zig").Guid.initString("edc17559-dd5d-4846-8eef-8becba5a4abf"); pub const IID_IInternetZoneManagerEx2 = &IID_IInternetZoneManagerEx2_Value; pub const IInternetZoneManagerEx2 = extern struct { pub const VTable = extern struct { base: IInternetZoneManagerEx.VTable, GetZoneAttributesEx: fn( self: *const IInternetZoneManagerEx2, dwZone: u32, pZoneAttributes: ?*ZONEATTRIBUTES, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetZoneSecurityState: fn( self: *const IInternetZoneManagerEx2, dwZoneIndex: u32, fRespectPolicy: BOOL, pdwState: ?*u32, pfPolicyEncountered: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetIESecurityState: fn( self: *const IInternetZoneManagerEx2, fRespectPolicy: BOOL, pdwState: ?*u32, pfPolicyEncountered: ?*BOOL, fNoCache: BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FixUnsecureSettings: fn( self: *const IInternetZoneManagerEx2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IInternetZoneManagerEx.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManagerEx2_GetZoneAttributesEx(self: *const T, dwZone: u32, pZoneAttributes: ?*ZONEATTRIBUTES, dwFlags: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManagerEx2.VTable, self.vtable).GetZoneAttributesEx(@ptrCast(*const IInternetZoneManagerEx2, self), dwZone, pZoneAttributes, dwFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManagerEx2_GetZoneSecurityState(self: *const T, dwZoneIndex: u32, fRespectPolicy: BOOL, pdwState: ?*u32, pfPolicyEncountered: ?*BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManagerEx2.VTable, self.vtable).GetZoneSecurityState(@ptrCast(*const IInternetZoneManagerEx2, self), dwZoneIndex, fRespectPolicy, pdwState, pfPolicyEncountered); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManagerEx2_GetIESecurityState(self: *const T, fRespectPolicy: BOOL, pdwState: ?*u32, pfPolicyEncountered: ?*BOOL, fNoCache: BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManagerEx2.VTable, self.vtable).GetIESecurityState(@ptrCast(*const IInternetZoneManagerEx2, self), fRespectPolicy, pdwState, pfPolicyEncountered, fNoCache); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IInternetZoneManagerEx2_FixUnsecureSettings(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IInternetZoneManagerEx2.VTable, self.vtable).FixUnsecureSettings(@ptrCast(*const IInternetZoneManagerEx2, self)); } };} pub usingnamespace MethodMixin(@This()); }; pub const CODEBASEHOLD = extern struct { cbSize: u32, szDistUnit: ?PWSTR, szCodeBase: ?PWSTR, dwVersionMS: u32, dwVersionLS: u32, dwStyle: u32, }; pub const SOFTDISTINFO = extern struct { cbSize: u32, dwFlags: u32, dwAdState: u32, szTitle: ?PWSTR, szAbstract: ?PWSTR, szHREF: ?PWSTR, dwInstalledVersionMS: u32, dwInstalledVersionLS: u32, dwUpdateVersionMS: u32, dwUpdateVersionLS: u32, dwAdvertisedVersionMS: u32, dwAdvertisedVersionLS: u32, dwReserved: u32, }; const IID_ISoftDistExt_Value = @import("../../zig.zig").Guid.initString("b15b8dc1-c7e1-11d0-8680-00aa00bdcb71"); pub const IID_ISoftDistExt = &IID_ISoftDistExt_Value; pub const ISoftDistExt = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, ProcessSoftDist: fn( self: *const ISoftDistExt, szCDFURL: ?[*:0]const u16, pSoftDistElement: ?*IXMLElement, lpsdi: ?*SOFTDISTINFO, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFirstCodeBase: fn( self: *const ISoftDistExt, szCodeBase: ?*?PWSTR, dwMaxSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetNextCodeBase: fn( self: *const ISoftDistExt, szCodeBase: ?*?PWSTR, dwMaxSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AsyncInstallDistributionUnit: fn( self: *const ISoftDistExt, pbc: ?*IBindCtx, pvReserved: ?*anyopaque, flags: u32, lpcbh: ?*CODEBASEHOLD, ) 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 ISoftDistExt_ProcessSoftDist(self: *const T, szCDFURL: ?[*:0]const u16, pSoftDistElement: ?*IXMLElement, lpsdi: ?*SOFTDISTINFO) callconv(.Inline) HRESULT { return @ptrCast(*const ISoftDistExt.VTable, self.vtable).ProcessSoftDist(@ptrCast(*const ISoftDistExt, self), szCDFURL, pSoftDistElement, lpsdi); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISoftDistExt_GetFirstCodeBase(self: *const T, szCodeBase: ?*?PWSTR, dwMaxSize: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const ISoftDistExt.VTable, self.vtable).GetFirstCodeBase(@ptrCast(*const ISoftDistExt, self), szCodeBase, dwMaxSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISoftDistExt_GetNextCodeBase(self: *const T, szCodeBase: ?*?PWSTR, dwMaxSize: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const ISoftDistExt.VTable, self.vtable).GetNextCodeBase(@ptrCast(*const ISoftDistExt, self), szCodeBase, dwMaxSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ISoftDistExt_AsyncInstallDistributionUnit(self: *const T, pbc: ?*IBindCtx, pvReserved: ?*anyopaque, flags: u32, lpcbh: ?*CODEBASEHOLD) callconv(.Inline) HRESULT { return @ptrCast(*const ISoftDistExt.VTable, self.vtable).AsyncInstallDistributionUnit(@ptrCast(*const ISoftDistExt, self), pbc, pvReserved, flags, lpcbh); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ICatalogFileInfo_Value = @import("../../zig.zig").Guid.initString("711c7600-6b48-11d1-b403-00aa00b92af1"); pub const IID_ICatalogFileInfo = &IID_ICatalogFileInfo_Value; pub const ICatalogFileInfo = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetCatalogFile: fn( self: *const ICatalogFileInfo, ppszCatalogFile: ?*?PSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetJavaTrust: fn( self: *const ICatalogFileInfo, ppJavaTrust: ?*?*anyopaque, ) 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 ICatalogFileInfo_GetCatalogFile(self: *const T, ppszCatalogFile: ?*?PSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ICatalogFileInfo.VTable, self.vtable).GetCatalogFile(@ptrCast(*const ICatalogFileInfo, self), ppszCatalogFile); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ICatalogFileInfo_GetJavaTrust(self: *const T, ppJavaTrust: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const ICatalogFileInfo.VTable, self.vtable).GetJavaTrust(@ptrCast(*const ICatalogFileInfo, self), ppJavaTrust); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IDataFilter_Value = @import("../../zig.zig").Guid.initString("69d14c80-c18e-11d0-a9ce-006097942311"); pub const IID_IDataFilter = &IID_IDataFilter_Value; pub const IDataFilter = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, DoEncode: fn( self: *const IDataFilter, dwFlags: u32, lInBufferSize: i32, pbInBuffer: [*:0]u8, lOutBufferSize: i32, pbOutBuffer: [*:0]u8, lInBytesAvailable: i32, plInBytesRead: ?*i32, plOutBytesWritten: ?*i32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DoDecode: fn( self: *const IDataFilter, dwFlags: u32, lInBufferSize: i32, pbInBuffer: [*:0]u8, lOutBufferSize: i32, pbOutBuffer: [*:0]u8, lInBytesAvailable: i32, plInBytesRead: ?*i32, plOutBytesWritten: ?*i32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetEncodingLevel: fn( self: *const IDataFilter, dwEncLevel: 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 IDataFilter_DoEncode(self: *const T, dwFlags: u32, lInBufferSize: i32, pbInBuffer: [*:0]u8, lOutBufferSize: i32, pbOutBuffer: [*:0]u8, lInBytesAvailable: i32, plInBytesRead: ?*i32, plOutBytesWritten: ?*i32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDataFilter.VTable, self.vtable).DoEncode(@ptrCast(*const IDataFilter, self), dwFlags, lInBufferSize, pbInBuffer, lOutBufferSize, pbOutBuffer, lInBytesAvailable, plInBytesRead, plOutBytesWritten, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDataFilter_DoDecode(self: *const T, dwFlags: u32, lInBufferSize: i32, pbInBuffer: [*:0]u8, lOutBufferSize: i32, pbOutBuffer: [*:0]u8, lInBytesAvailable: i32, plInBytesRead: ?*i32, plOutBytesWritten: ?*i32, dwReserved: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDataFilter.VTable, self.vtable).DoDecode(@ptrCast(*const IDataFilter, self), dwFlags, lInBufferSize, pbInBuffer, lOutBufferSize, pbOutBuffer, lInBytesAvailable, plInBytesRead, plOutBytesWritten, dwReserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDataFilter_SetEncodingLevel(self: *const T, dwEncLevel: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IDataFilter.VTable, self.vtable).SetEncodingLevel(@ptrCast(*const IDataFilter, self), dwEncLevel); } };} pub usingnamespace MethodMixin(@This()); }; pub const PROTOCOLFILTERDATA = extern struct { cbSize: u32, pProtocolSink: ?*IInternetProtocolSink, pProtocol: ?*IInternetProtocol, pUnk: ?*IUnknown, dwFilterFlags: u32, }; pub const DATAINFO = extern struct { ulTotalSize: u32, ulavrPacketSize: u32, ulConnectSpeed: u32, ulProcessorSpeed: u32, }; const IID_IEncodingFilterFactory_Value = @import("../../zig.zig").Guid.initString("70bdde00-c18e-11d0-a9ce-006097942311"); pub const IID_IEncodingFilterFactory = &IID_IEncodingFilterFactory_Value; pub const IEncodingFilterFactory = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, FindBestFilter: fn( self: *const IEncodingFilterFactory, pwzCodeIn: ?[*:0]const u16, pwzCodeOut: ?[*:0]const u16, info: DATAINFO, ppDF: ?*?*IDataFilter, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultFilter: fn( self: *const IEncodingFilterFactory, pwzCodeIn: ?[*:0]const u16, pwzCodeOut: ?[*:0]const u16, ppDF: ?*?*IDataFilter, ) 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 IEncodingFilterFactory_FindBestFilter(self: *const T, pwzCodeIn: ?[*:0]const u16, pwzCodeOut: ?[*:0]const u16, info: DATAINFO, ppDF: ?*?*IDataFilter) callconv(.Inline) HRESULT { return @ptrCast(*const IEncodingFilterFactory.VTable, self.vtable).FindBestFilter(@ptrCast(*const IEncodingFilterFactory, self), pwzCodeIn, pwzCodeOut, info, ppDF); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEncodingFilterFactory_GetDefaultFilter(self: *const T, pwzCodeIn: ?[*:0]const u16, pwzCodeOut: ?[*:0]const u16, ppDF: ?*?*IDataFilter) callconv(.Inline) HRESULT { return @ptrCast(*const IEncodingFilterFactory.VTable, self.vtable).GetDefaultFilter(@ptrCast(*const IEncodingFilterFactory, self), pwzCodeIn, pwzCodeOut, ppDF); } };} pub usingnamespace MethodMixin(@This()); }; pub const HIT_LOGGING_INFO = extern struct { dwStructSize: u32, lpszLoggedUrlName: ?PSTR, StartTime: SYSTEMTIME, EndTime: SYSTEMTIME, lpszExtendedInfo: ?PSTR, }; pub const CONFIRMSAFETY = extern struct { clsid: Guid, pUnk: ?*IUnknown, dwFlags: u32, }; const IID_IWrappedProtocol_Value = @import("../../zig.zig").Guid.initString("53c84785-8425-4dc5-971b-e58d9c19f9b6"); pub const IID_IWrappedProtocol = &IID_IWrappedProtocol_Value; pub const IWrappedProtocol = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetWrapperCode: fn( self: *const IWrappedProtocol, pnCode: ?*i32, dwReserved: usize, ) 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 IWrappedProtocol_GetWrapperCode(self: *const T, pnCode: ?*i32, dwReserved: usize) callconv(.Inline) HRESULT { return @ptrCast(*const IWrappedProtocol.VTable, self.vtable).GetWrapperCode(@ptrCast(*const IWrappedProtocol, self), pnCode, dwReserved); } };} pub usingnamespace MethodMixin(@This()); }; pub const BINDHANDLETYPES = enum(i32) { APPCACHE = 0, DEPENDENCY = 1, COUNT = 2, }; pub const BINDHANDLETYPES_APPCACHE = BINDHANDLETYPES.APPCACHE; pub const BINDHANDLETYPES_DEPENDENCY = BINDHANDLETYPES.DEPENDENCY; pub const BINDHANDLETYPES_COUNT = BINDHANDLETYPES.COUNT; const IID_IGetBindHandle_Value = @import("../../zig.zig").Guid.initString("af0ff408-129d-4b20-91f0-02bd23d88352"); pub const IID_IGetBindHandle = &IID_IGetBindHandle_Value; pub const IGetBindHandle = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetBindHandle: fn( self: *const IGetBindHandle, enumRequestedHandle: BINDHANDLETYPES, pRetHandle: ?*?HANDLE, ) 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 IGetBindHandle_GetBindHandle(self: *const T, enumRequestedHandle: BINDHANDLETYPES, pRetHandle: ?*?HANDLE) callconv(.Inline) HRESULT { return @ptrCast(*const IGetBindHandle.VTable, self.vtable).GetBindHandle(@ptrCast(*const IGetBindHandle, self), enumRequestedHandle, pRetHandle); } };} pub usingnamespace MethodMixin(@This()); }; pub const PROTOCOL_ARGUMENT = extern struct { szMethod: ?[*:0]const u16, szTargetUrl: ?[*:0]const u16, }; const IID_IBindCallbackRedirect_Value = @import("../../zig.zig").Guid.initString("11c81bc2-121e-4ed5-b9c4-b430bd54f2c0"); pub const IID_IBindCallbackRedirect = &IID_IBindCallbackRedirect_Value; pub const IBindCallbackRedirect = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Redirect: fn( self: *const IBindCallbackRedirect, lpcUrl: ?[*:0]const u16, vbCancel: ?*i16, ) 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 IBindCallbackRedirect_Redirect(self: *const T, lpcUrl: ?[*:0]const u16, vbCancel: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IBindCallbackRedirect.VTable, self.vtable).Redirect(@ptrCast(*const IBindCallbackRedirect, self), lpcUrl, vbCancel); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IBindHttpSecurity_Value = @import("../../zig.zig").Guid.initString("a9eda967-f50e-4a33-b358-206f6ef3086d"); pub const IID_IBindHttpSecurity = &IID_IBindHttpSecurity_Value; pub const IBindHttpSecurity = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetIgnoreCertMask: fn( self: *const IBindHttpSecurity, pdwIgnoreCertMask: ?*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 IBindHttpSecurity_GetIgnoreCertMask(self: *const T, pdwIgnoreCertMask: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IBindHttpSecurity.VTable, self.vtable).GetIgnoreCertMask(@ptrCast(*const IBindHttpSecurity, self), pdwIgnoreCertMask); } };} pub usingnamespace MethodMixin(@This()); }; //-------------------------------------------------------------------------------- // Section: Functions (73) //-------------------------------------------------------------------------------- pub extern "urlmon" fn CreateURLMoniker( pMkCtx: ?*IMoniker, szURL: ?[*:0]const u16, ppmk: ?*?*IMoniker, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CreateURLMonikerEx( pMkCtx: ?*IMoniker, szURL: ?[*:0]const u16, ppmk: ?*?*IMoniker, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn GetClassURL( szURL: ?[*:0]const u16, pClsID: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.0' pub extern "urlmon" fn CreateAsyncBindCtx( reserved: u32, pBSCb: ?*IBindStatusCallback, pEFetc: ?*IEnumFORMATETC, ppBC: ?*?*IBindCtx, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CreateURLMonikerEx2( pMkCtx: ?*IMoniker, pUri: ?*IUri, ppmk: ?*?*IMoniker, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CreateAsyncBindCtxEx( pbc: ?*IBindCtx, dwOptions: u32, pBSCb: ?*IBindStatusCallback, pEnum: ?*IEnumFORMATETC, ppBC: ?*?*IBindCtx, reserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn MkParseDisplayNameEx( pbc: ?*IBindCtx, szDisplayName: ?[*:0]const u16, pchEaten: ?*u32, ppmk: ?*?*IMoniker, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn RegisterBindStatusCallback( pBC: ?*IBindCtx, pBSCb: ?*IBindStatusCallback, ppBSCBPrev: ?*?*IBindStatusCallback, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn RevokeBindStatusCallback( pBC: ?*IBindCtx, pBSCb: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn GetClassFileOrMime( pBC: ?*IBindCtx, szFilename: ?[*:0]const u16, // TODO: what to do with BytesParamIndex 3? pBuffer: ?*anyopaque, cbSize: u32, szMime: ?[*:0]const u16, dwReserved: u32, pclsid: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn IsValidURL( pBC: ?*IBindCtx, szURL: ?[*:0]const u16, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoGetClassObjectFromURL( rCLASSID: ?*const Guid, szCODE: ?[*:0]const u16, dwFileVersionMS: u32, dwFileVersionLS: u32, szTYPE: ?[*:0]const u16, pBindCtx: ?*IBindCtx, dwClsContext: CLSCTX, pvReserved: ?*anyopaque, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn IEInstallScope( pdwScope: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn FaultInIEFeature( hWnd: ?HWND, pClassSpec: ?*uCLSSPEC, pQuery: ?*QUERYCONTEXT, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn GetComponentIDFromCLSSPEC( pClassspec: ?*uCLSSPEC, ppszComponentID: ?*?PSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn IsAsyncMoniker( pmk: ?*IMoniker, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn RegisterMediaTypes( ctypes: u32, rgszTypes: [*]const ?[*:0]const u8, rgcfTypes: [*:0]u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn FindMediaType( rgszTypes: ?[*:0]const u8, rgcfTypes: ?*u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.0' pub extern "urlmon" fn CreateFormatEnumerator( cfmtetc: u32, rgfmtetc: [*]FORMATETC, ppenumfmtetc: ?*?*IEnumFORMATETC, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn RegisterFormatEnumerator( pBC: ?*IBindCtx, pEFetc: ?*IEnumFORMATETC, reserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn RevokeFormatEnumerator( pBC: ?*IBindCtx, pEFetc: ?*IEnumFORMATETC, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn RegisterMediaTypeClass( pBC: ?*IBindCtx, ctypes: u32, rgszTypes: [*]const ?[*:0]const u8, rgclsID: [*]Guid, reserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn FindMediaTypeClass( pBC: ?*IBindCtx, szType: ?[*:0]const u8, pclsID: ?*Guid, reserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn UrlMkSetSessionOption( dwOption: u32, // TODO: what to do with BytesParamIndex 2? pBuffer: ?*anyopaque, dwBufferLength: u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn UrlMkGetSessionOption( dwOption: u32, // TODO: what to do with BytesParamIndex 2? pBuffer: ?*anyopaque, dwBufferLength: u32, pdwBufferLengthOut: ?*u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn FindMimeFromData( pBC: ?*IBindCtx, pwzUrl: ?[*:0]const u16, // TODO: what to do with BytesParamIndex 3? pBuffer: ?*anyopaque, cbSize: u32, pwzMimeProposed: ?[*:0]const u16, dwMimeFlags: u32, ppwzMimeOut: ?*?PWSTR, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn ObtainUserAgentString( dwOption: u32, pszUAOut: [*:0]u8, cbSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CompareSecurityIds( pbSecurityId1: [*:0]u8, dwLen1: u32, pbSecurityId2: [*:0]u8, dwLen2: u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CompatFlagsFromClsid( pclsid: ?*Guid, pdwCompatFlags: ?*u32, pdwMiscStatusFlags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn SetAccessForIEAppContainer( hObject: ?HANDLE, ieObjectType: IEObjectType, dwAccessMask: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn HlinkSimpleNavigateToString( szTarget: ?[*:0]const u16, szLocation: ?[*:0]const u16, szTargetFrameName: ?[*:0]const u16, pUnk: ?*IUnknown, pbc: ?*IBindCtx, param5: ?*IBindStatusCallback, grfHLNF: u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn HlinkSimpleNavigateToMoniker( pmkTarget: ?*IMoniker, szLocation: ?[*:0]const u16, szTargetFrameName: ?[*:0]const u16, pUnk: ?*IUnknown, pbc: ?*IBindCtx, param5: ?*IBindStatusCallback, grfHLNF: u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLOpenStreamA( param0: ?*IUnknown, param1: ?[*:0]const u8, param2: u32, param3: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLOpenStreamW( param0: ?*IUnknown, param1: ?[*:0]const u16, param2: u32, param3: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLOpenPullStreamA( param0: ?*IUnknown, param1: ?[*:0]const u8, param2: u32, param3: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLOpenPullStreamW( param0: ?*IUnknown, param1: ?[*:0]const u16, param2: u32, param3: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLDownloadToFileA( param0: ?*IUnknown, param1: ?[*:0]const u8, param2: ?[*:0]const u8, param3: u32, param4: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLDownloadToFileW( param0: ?*IUnknown, param1: ?[*:0]const u16, param2: ?[*:0]const u16, param3: u32, param4: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLDownloadToCacheFileA( param0: ?*IUnknown, param1: ?[*:0]const u8, param2: [*:0]u8, cchFileName: u32, param4: u32, param5: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLDownloadToCacheFileW( param0: ?*IUnknown, param1: ?[*:0]const u16, param2: [*:0]u16, cchFileName: u32, param4: u32, param5: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLOpenBlockingStreamA( param0: ?*IUnknown, param1: ?[*:0]const u8, param2: ?*?*IStream, param3: u32, param4: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn URLOpenBlockingStreamW( param0: ?*IUnknown, param1: ?[*:0]const u16, param2: ?*?*IStream, param3: u32, param4: ?*IBindStatusCallback, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn HlinkGoBack( pUnk: ?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn HlinkGoForward( pUnk: ?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn HlinkNavigateString( pUnk: ?*IUnknown, szTarget: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn HlinkNavigateMoniker( pUnk: ?*IUnknown, pmkTarget: ?*IMoniker, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetParseUrl( pwzUrl: ?[*:0]const u16, ParseAction: PARSEACTION, dwFlags: u32, pszResult: [*:0]u16, cchResult: u32, pcchResult: ?*u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetParseIUri( pIUri: ?*IUri, ParseAction: PARSEACTION, dwFlags: u32, pwzResult: [*:0]u16, cchResult: u32, pcchResult: ?*u32, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetCombineUrl( pwzBaseUrl: ?[*:0]const u16, pwzRelativeUrl: ?[*:0]const u16, dwCombineFlags: u32, pszResult: [*:0]u16, cchResult: u32, pcchResult: ?*u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetCombineUrlEx( pBaseUri: ?*IUri, pwzRelativeUrl: ?[*:0]const u16, dwCombineFlags: u32, ppCombinedUri: ?*?*IUri, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetCombineIUri( pBaseUri: ?*IUri, pRelativeUri: ?*IUri, dwCombineFlags: u32, ppCombinedUri: ?*?*IUri, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetCompareUrl( pwzUrl1: ?[*:0]const u16, pwzUrl2: ?[*:0]const u16, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetGetProtocolFlags( pwzUrl: ?[*:0]const u16, pdwFlags: ?*u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetQueryInfo( pwzUrl: ?[*:0]const u16, QueryOptions: QUERYOPTION, dwQueryFlags: u32, // TODO: what to do with BytesParamIndex 4? pvBuffer: ?*anyopaque, cbBuffer: u32, pcbBuffer: ?*u32, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetGetSession( dwSessionMode: u32, ppIInternetSession: ?*?*IInternetSession, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetGetSecurityUrl( pwszUrl: ?[*:0]const u16, ppwszSecUrl: ?*?PWSTR, psuAction: PSUACTION, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetGetSecurityUrlEx( pUri: ?*IUri, ppSecUri: ?*?*IUri, psuAction: PSUACTION, dwReserved: usize, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetSetFeatureEnabled( FeatureEntry: INTERNETFEATURELIST, dwFlags: u32, fEnable: BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetIsFeatureEnabled( FeatureEntry: INTERNETFEATURELIST, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetIsFeatureEnabledForUrl( FeatureEntry: INTERNETFEATURELIST, dwFlags: u32, szURL: ?[*:0]const u16, pSecMgr: ?*IInternetSecurityManager, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetIsFeatureEnabledForIUri( FeatureEntry: INTERNETFEATURELIST, dwFlags: u32, pIUri: ?*IUri, pSecMgr: ?*IInternetSecurityManagerEx2, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetIsFeatureZoneElevationEnabled( szFromURL: ?[*:0]const u16, szToURL: ?[*:0]const u16, pSecMgr: ?*IInternetSecurityManager, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CopyStgMedium( pcstgmedSrc: ?*const STGMEDIUM, pstgmedDest: ?*STGMEDIUM, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CopyBindInfo( pcbiSrc: ?*const BINDINFO, pbiDest: ?*BINDINFO, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn ReleaseBindInfo( pbindinfo: ?*BINDINFO, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "urlmon" fn IEGetUserPrivateNamespaceName( ) callconv(@import("std").os.windows.WINAPI) ?PWSTR; pub extern "urlmon" fn CoInternetCreateSecurityManager( pSP: ?*IServiceProvider, ppSM: ?*?*IInternetSecurityManager, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn CoInternetCreateZoneManager( pSP: ?*IServiceProvider, ppZM: ?*?*IInternetZoneManager, dwReserved: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn GetSoftwareUpdateInfo( szDistUnit: ?[*:0]const u16, psdi: ?*SOFTDISTINFO, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn SetSoftwareUpdateAdvertisementState( szDistUnit: ?[*:0]const u16, dwAdState: u32, dwAdvertisedVersionMS: u32, dwAdvertisedVersionLS: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "urlmon" fn IsLoggingEnabledA( pszUrl: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "urlmon" fn IsLoggingEnabledW( pwszUrl: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "urlmon" fn WriteHitLogging( lpLogginginfo: ?*HIT_LOGGING_INFO, ) callconv(@import("std").os.windows.WINAPI) BOOL; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (6) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../../zig.zig").unicode_mode) { .ansi => struct { pub const URLOpenStream = thismodule.URLOpenStreamA; pub const URLOpenPullStream = thismodule.URLOpenPullStreamA; pub const URLDownloadToFile = thismodule.URLDownloadToFileA; pub const URLDownloadToCacheFile = thismodule.URLDownloadToCacheFileA; pub const URLOpenBlockingStream = thismodule.URLOpenBlockingStreamA; pub const IsLoggingEnabled = thismodule.IsLoggingEnabledA; }, .wide => struct { pub const URLOpenStream = thismodule.URLOpenStreamW; pub const URLOpenPullStream = thismodule.URLOpenPullStreamW; pub const URLDownloadToFile = thismodule.URLDownloadToFileW; pub const URLDownloadToCacheFile = thismodule.URLDownloadToCacheFileW; pub const URLOpenBlockingStream = thismodule.URLOpenBlockingStreamW; pub const IsLoggingEnabled = thismodule.IsLoggingEnabledW; }, .unspecified => if (@import("builtin").is_test) struct { pub const URLOpenStream = *opaque{}; pub const URLOpenPullStream = *opaque{}; pub const URLDownloadToFile = *opaque{}; pub const URLDownloadToCacheFile = *opaque{}; pub const URLOpenBlockingStream = *opaque{}; pub const IsLoggingEnabled = *opaque{}; } else struct { pub const URLOpenStream = @compileError("'URLOpenStream' requires that UNICODE be set to true or false in the root module"); pub const URLOpenPullStream = @compileError("'URLOpenPullStream' requires that UNICODE be set to true or false in the root module"); pub const URLDownloadToFile = @compileError("'URLDownloadToFile' requires that UNICODE be set to true or false in the root module"); pub const URLDownloadToCacheFile = @compileError("'URLDownloadToCacheFile' requires that UNICODE be set to true or false in the root module"); pub const URLOpenBlockingStream = @compileError("'URLOpenBlockingStream' requires that UNICODE be set to true or false in the root module"); pub const IsLoggingEnabled = @compileError("'IsLoggingEnabled' requires that UNICODE be set to true or false in the root module"); }, }; //-------------------------------------------------------------------------------- // Section: Imports (30) //-------------------------------------------------------------------------------- const Guid = @import("../../zig.zig").Guid; const BINDINFO = @import("../../system/com.zig").BINDINFO; const BOOL = @import("../../foundation.zig").BOOL; const CLSCTX = @import("../../system/com.zig").CLSCTX; const FORMATETC = @import("../../system/com.zig").FORMATETC; const HANDLE = @import("../../foundation.zig").HANDLE; const HANDLE_PTR = @import("../../foundation.zig").HANDLE_PTR; const HRESULT = @import("../../foundation.zig").HRESULT; const HWND = @import("../../foundation.zig").HWND; const IBindCtx = @import("../../system/com.zig").IBindCtx; const IBinding = @import("../../system/com.zig").IBinding; const IBindStatusCallback = @import("../../system/com.zig").IBindStatusCallback; const IClassFactory = @import("../../system/com.zig").IClassFactory; const IEnumFORMATETC = @import("../../system/com.zig").IEnumFORMATETC; const IEnumString = @import("../../system/com.zig").IEnumString; const IMoniker = @import("../../system/com.zig").IMoniker; const IServiceProvider = @import("../../system/com.zig").IServiceProvider; const IStream = @import("../../system/com.zig").IStream; const IUnknown = @import("../../system/com.zig").IUnknown; const IUri = @import("../../system/com.zig").IUri; const IUriBuilder = @import("../../system/com.zig").IUriBuilder; const IXMLElement = @import("../../data/xml/ms_xml.zig").IXMLElement; const LARGE_INTEGER = @import("../../foundation.zig").LARGE_INTEGER; const PSTR = @import("../../foundation.zig").PSTR; const PWSTR = @import("../../foundation.zig").PWSTR; const QUERYCONTEXT = @import("../../system/com.zig").QUERYCONTEXT; const STGMEDIUM = @import("../../system/com.zig").STGMEDIUM; const SYSTEMTIME = @import("../../foundation.zig").SYSTEMTIME; const uCLSSPEC = @import("../../system/com.zig").uCLSSPEC; const ULARGE_INTEGER = @import("../../foundation.zig").ULARGE_INTEGER; 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/com/urlmon.zig
pub const sibling = 0x01; pub const location = 0x02; pub const name = 0x03; pub const ordering = 0x09; pub const subscr_data = 0x0a; pub const byte_size = 0x0b; pub const bit_offset = 0x0c; pub const bit_size = 0x0d; pub const element_list = 0x0f; pub const stmt_list = 0x10; pub const low_pc = 0x11; pub const high_pc = 0x12; pub const language = 0x13; pub const member = 0x14; pub const discr = 0x15; pub const discr_value = 0x16; pub const visibility = 0x17; pub const import = 0x18; pub const string_length = 0x19; pub const common_reference = 0x1a; pub const comp_dir = 0x1b; pub const const_value = 0x1c; pub const containing_type = 0x1d; pub const default_value = 0x1e; pub const @"inline" = 0x20; pub const is_optional = 0x21; pub const lower_bound = 0x22; pub const producer = 0x25; pub const prototyped = 0x27; pub const return_addr = 0x2a; pub const start_scope = 0x2c; pub const bit_stride = 0x2e; pub const upper_bound = 0x2f; pub const abstract_origin = 0x31; pub const accessibility = 0x32; pub const address_class = 0x33; pub const artificial = 0x34; pub const base_types = 0x35; pub const calling_convention = 0x36; pub const count = 0x37; pub const data_member_location = 0x38; pub const decl_column = 0x39; pub const decl_file = 0x3a; pub const decl_line = 0x3b; pub const declaration = 0x3c; pub const discr_list = 0x3d; pub const encoding = 0x3e; pub const external = 0x3f; pub const frame_base = 0x40; pub const friend = 0x41; pub const identifier_case = 0x42; pub const macro_info = 0x43; pub const namelist_items = 0x44; pub const priority = 0x45; pub const segment = 0x46; pub const specification = 0x47; pub const static_link = 0x48; pub const @"type" = 0x49; pub const use_location = 0x4a; pub const variable_parameter = 0x4b; pub const virtuality = 0x4c; pub const vtable_elem_location = 0x4d; // DWARF 3 values. pub const allocated = 0x4e; pub const associated = 0x4f; pub const data_location = 0x50; pub const byte_stride = 0x51; pub const entry_pc = 0x52; pub const use_UTF8 = 0x53; pub const extension = 0x54; pub const ranges = 0x55; pub const trampoline = 0x56; pub const call_column = 0x57; pub const call_file = 0x58; pub const call_line = 0x59; pub const description = 0x5a; pub const binary_scale = 0x5b; pub const decimal_scale = 0x5c; pub const small = 0x5d; pub const decimal_sign = 0x5e; pub const digit_count = 0x5f; pub const picture_string = 0x60; pub const mutable = 0x61; pub const threads_scaled = 0x62; pub const explicit = 0x63; pub const object_pointer = 0x64; pub const endianity = 0x65; pub const elemental = 0x66; pub const pure = 0x67; pub const recursive = 0x68; // DWARF 4. pub const signature = 0x69; pub const main_subprogram = 0x6a; pub const data_bit_offset = 0x6b; pub const const_expr = 0x6c; pub const enum_class = 0x6d; pub const linkage_name = 0x6e; // DWARF 5 pub const string_length_bit_size = 0x6f; pub const string_length_byte_size = 0x70; pub const rank = 0x71; pub const str_offsets_base = 0x72; pub const addr_base = 0x73; pub const rnglists_base = 0x74; pub const dwo_name = 0x76; pub const reference = 0x77; pub const rvalue_reference = 0x78; pub const macros = 0x79; pub const call_all_calls = 0x7a; pub const call_all_source_calls = 0x7b; pub const call_all_tail_calls = 0x7c; pub const call_return_pc = 0x7d; pub const call_value = 0x7e; pub const call_origin = 0x7f; pub const call_parameter = 0x80; pub const call_pc = 0x81; pub const call_tail_call = 0x82; pub const call_target = 0x83; pub const call_target_clobbered = 0x84; pub const call_data_location = 0x85; pub const call_data_value = 0x86; pub const @"noreturn" = 0x87; pub const alignment = 0x88; pub const export_symbols = 0x89; pub const deleted = 0x8a; pub const defaulted = 0x8b; pub const loclists_base = 0x8c; pub const lo_user = 0x2000; // Implementation-defined range start. pub const hi_user = 0x3fff; // Implementation-defined range end. // SGI/MIPS extensions. pub const MIPS_fde = 0x2001; pub const MIPS_loop_begin = 0x2002; pub const MIPS_tail_loop_begin = 0x2003; pub const MIPS_epilog_begin = 0x2004; pub const MIPS_loop_unroll_factor = 0x2005; pub const MIPS_software_pipeline_depth = 0x2006; pub const MIPS_linkage_name = 0x2007; pub const MIPS_stride = 0x2008; pub const MIPS_abstract_name = 0x2009; pub const MIPS_clone_origin = 0x200a; pub const MIPS_has_inlines = 0x200b; // HP extensions. pub const HP_block_index = 0x2000; pub const HP_unmodifiable = 0x2001; // Same as AT.MIPS_fde. pub const HP_prologue = 0x2005; // Same as AT.MIPS_loop_unroll. pub const HP_epilogue = 0x2008; // Same as AT.MIPS_stride. pub const HP_actuals_stmt_list = 0x2010; pub const HP_proc_per_section = 0x2011; pub const HP_raw_data_ptr = 0x2012; pub const HP_pass_by_reference = 0x2013; pub const HP_opt_level = 0x2014; pub const HP_prof_version_id = 0x2015; pub const HP_opt_flags = 0x2016; pub const HP_cold_region_low_pc = 0x2017; pub const HP_cold_region_high_pc = 0x2018; pub const HP_all_variables_modifiable = 0x2019; pub const HP_linkage_name = 0x201a; pub const HP_prof_flags = 0x201b; // In comp unit of procs_info for -g. pub const HP_unit_name = 0x201f; pub const HP_unit_size = 0x2020; pub const HP_widened_byte_size = 0x2021; pub const HP_definition_points = 0x2022; pub const HP_default_location = 0x2023; pub const HP_is_result_param = 0x2029; // GNU extensions. pub const sf_names = 0x2101; pub const src_info = 0x2102; pub const mac_info = 0x2103; pub const src_coords = 0x2104; pub const body_begin = 0x2105; pub const body_end = 0x2106; pub const GNU_vector = 0x2107; // Thread-safety annotations. // See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation . pub const GNU_guarded_by = 0x2108; pub const GNU_pt_guarded_by = 0x2109; pub const GNU_guarded = 0x210a; pub const GNU_pt_guarded = 0x210b; pub const GNU_locks_excluded = 0x210c; pub const GNU_exclusive_locks_required = 0x210d; pub const GNU_shared_locks_required = 0x210e; // One-definition rule violation detection. // See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo . pub const GNU_odr_signature = 0x210f; // Template template argument name. // See http://gcc.gnu.org/wiki/TemplateParmsDwarf . pub const GNU_template_name = 0x2110; // The GNU call site extension. // See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open . pub const GNU_call_site_value = 0x2111; pub const GNU_call_site_data_value = 0x2112; pub const GNU_call_site_target = 0x2113; pub const GNU_call_site_target_clobbered = 0x2114; pub const GNU_tail_call = 0x2115; pub const GNU_all_tail_call_sites = 0x2116; pub const GNU_all_call_sites = 0x2117; pub const GNU_all_source_call_sites = 0x2118; // Section offset into .debug_macro section. pub const GNU_macros = 0x2119; // Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission. pub const GNU_dwo_name = 0x2130; pub const GNU_dwo_id = 0x2131; pub const GNU_ranges_base = 0x2132; pub const GNU_addr_base = 0x2133; pub const GNU_pubnames = 0x2134; pub const GNU_pubtypes = 0x2135; // VMS extensions. pub const VMS_rtnbeg_pd_address = 0x2201; // GNAT extensions. // GNAT descriptive type. // See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . pub const use_GNAT_descriptive_type = 0x2301; pub const GNAT_descriptive_type = 0x2302; // UPC extension. pub const upc_threads_scaled = 0x3210; // PGI (STMicroelectronics) extensions. pub const PGI_lbase = 0x3a00; pub const PGI_soffset = 0x3a01; pub const PGI_lstride = 0x3a02;
lib/std/dwarf/AT.zig
const std = @import("std"); const builtin = @import("builtin"); const mem = std.mem; const os = std.os; const fs = std.fs; const Compilation = @import("Compilation.zig"); /// Returns the sub_path that worked, or `null` if none did. /// The path of the returned Directory is relative to `base`. /// The handle of the returned Directory is open. fn testZigInstallPrefix(base_dir: fs.Dir) ?Compilation.Directory { const test_index_file = "std" ++ fs.path.sep_str ++ "std.zig"; zig_dir: { // Try lib/zig/std/std.zig const lib_zig = "lib" ++ fs.path.sep_str ++ "zig"; var test_zig_dir = base_dir.openDir(lib_zig, .{}) catch break :zig_dir; const file = test_zig_dir.openFile(test_index_file, .{}) catch { test_zig_dir.close(); break :zig_dir; }; file.close(); return Compilation.Directory{ .handle = test_zig_dir, .path = lib_zig }; } // Try lib/std/std.zig var test_zig_dir = base_dir.openDir("lib", .{}) catch return null; const file = test_zig_dir.openFile(test_index_file, .{}) catch { test_zig_dir.close(); return null; }; file.close(); return Compilation.Directory{ .handle = test_zig_dir, .path = "lib" }; } /// This is a small wrapper around selfExePathAlloc that adds support for WASI /// based on a hard-coded Preopen directory ("/zig") pub fn findZigExePath(allocator: mem.Allocator) ![]u8 { if (builtin.os.tag == .wasi) { var args = try std.process.argsWithAllocator(allocator); defer args.deinit(); // On WASI, argv[0] is always just the basename of the current executable const argv0 = args.next() orelse return error.FileNotFound; // Check these paths: // 1. "/zig/{exe_name}" // 2. "/zig/bin/{exe_name}" const base_paths_to_check = &[_][]const u8{ "/zig", "/zig/bin" }; const exe_names_to_check = &[_][]const u8{ fs.path.basename(argv0), "zig.wasm" }; for (base_paths_to_check) |base_path| { for (exe_names_to_check) |exe_name| { const test_path = fs.path.join(allocator, &.{ base_path, exe_name }) catch continue; defer allocator.free(test_path); // Make sure it's a file we're pointing to const file = os.fstatat(os.wasi.AT.FDCWD, test_path, 0) catch continue; if (file.filetype != .REGULAR_FILE) continue; // Path seems to be valid, let's try to turn it into an absolute path var real_path_buf: [fs.MAX_PATH_BYTES]u8 = undefined; if (os.realpath(test_path, &real_path_buf)) |real_path| { return allocator.dupe(u8, real_path); // Success: return absolute path } else |_| continue; } } return error.FileNotFound; } return fs.selfExePathAlloc(allocator); } /// Both the directory handle and the path are newly allocated resources which the caller now owns. pub fn findZigLibDir(gpa: mem.Allocator) !Compilation.Directory { const self_exe_path = try findZigExePath(gpa); defer gpa.free(self_exe_path); return findZigLibDirFromSelfExe(gpa, self_exe_path); } /// Both the directory handle and the path are newly allocated resources which the caller now owns. pub fn findZigLibDirFromSelfExe( allocator: mem.Allocator, self_exe_path: []const u8, ) error{ OutOfMemory, FileNotFound }!Compilation.Directory { const cwd = fs.cwd(); var cur_path: []const u8 = self_exe_path; while (fs.path.dirname(cur_path)) |dirname| : (cur_path = dirname) { var base_dir = cwd.openDir(dirname, .{}) catch continue; defer base_dir.close(); const sub_directory = testZigInstallPrefix(base_dir) orelse continue; return Compilation.Directory{ .handle = sub_directory.handle, .path = try fs.path.join(allocator, &[_][]const u8{ dirname, sub_directory.path.? }), }; } return error.FileNotFound; } /// Caller owns returned memory. pub fn resolveGlobalCacheDir(allocator: mem.Allocator) ![]u8 { if (std.process.getEnvVarOwned(allocator, "ZIG_GLOBAL_CACHE_DIR")) |value| { if (value.len > 0) { return value; } else { allocator.free(value); } } else |_| {} const appname = "zig"; if (builtin.os.tag != .windows) { if (std.os.getenv("XDG_CACHE_HOME")) |cache_root| { return fs.path.join(allocator, &[_][]const u8{ cache_root, appname }); } else if (std.os.getenv("HOME")) |home| { return fs.path.join(allocator, &[_][]const u8{ home, ".cache", appname }); } } if (builtin.os.tag == .wasi) { // On WASI, we have no way to get an App data dir, so we try to use a fixed // Preopen path "/cache" as a last resort const path = "/cache"; const file = os.fstatat(os.wasi.AT.FDCWD, path, 0) catch return error.CacheDirUnavailable; if (file.filetype != .DIRECTORY) return error.CacheDirUnavailable; return allocator.dupe(u8, path); } else { return fs.getAppDataDir(allocator, appname); } }
src/introspect.zig
const std = @import("../../index.zig"); const debug = std.debug; const math = std.math; pub const abs = @import("abs.zig").abs; pub const acosh = @import("acosh.zig").acosh; pub const acos = @import("acos.zig").acos; pub const arg = @import("arg.zig").arg; pub const asinh = @import("asinh.zig").asinh; pub const asin = @import("asin.zig").asin; pub const atanh = @import("atanh.zig").atanh; pub const atan = @import("atan.zig").atan; pub const conj = @import("conj.zig").conj; pub const cosh = @import("cosh.zig").cosh; pub const cos = @import("cos.zig").cos; pub const exp = @import("exp.zig").exp; pub const log = @import("log.zig").log; pub const pow = @import("pow.zig").pow; pub const proj = @import("proj.zig").proj; pub const sinh = @import("sinh.zig").sinh; pub const sin = @import("sin.zig").sin; pub const sqrt = @import("sqrt.zig").sqrt; pub const tanh = @import("tanh.zig").tanh; pub const tan = @import("tan.zig").tan; pub fn Complex(comptime T: type) type { return struct { const Self = @This(); re: T, im: T, pub fn new(re: T, im: T) Self { return Self{ .re = re, .im = im, }; } pub fn add(self: Self, other: Self) Self { return Self{ .re = self.re + other.re, .im = self.im + other.im, }; } pub fn sub(self: Self, other: Self) Self { return Self{ .re = self.re - other.re, .im = self.im - other.im, }; } pub fn mul(self: Self, other: Self) Self { return Self{ .re = self.re * other.re - self.im * other.im, .im = self.im * other.re + self.re * other.im, }; } pub fn div(self: Self, other: Self) Self { const re_num = self.re * other.re + self.im * other.im; const im_num = self.im * other.re - self.re * other.im; const den = other.re * other.re + other.im * other.im; return Self{ .re = re_num / den, .im = im_num / den, }; } pub fn conjugate(self: Self) Self { return Self{ .re = self.re, .im = -self.im, }; } pub fn reciprocal(self: Self) Self { const m = self.re * self.re + self.im * self.im; return Self{ .re = self.re / m, .im = -self.im / m, }; } pub fn magnitude(self: Self) T { return math.sqrt(self.re * self.re + self.im * self.im); } }; } const epsilon = 0.0001; test "complex.add" { const a = Complex(f32).new(5, 3); const b = Complex(f32).new(2, 7); const c = a.add(b); debug.assert(c.re == 7 and c.im == 10); } test "complex.sub" { const a = Complex(f32).new(5, 3); const b = Complex(f32).new(2, 7); const c = a.sub(b); debug.assert(c.re == 3 and c.im == -4); } test "complex.mul" { const a = Complex(f32).new(5, 3); const b = Complex(f32).new(2, 7); const c = a.mul(b); debug.assert(c.re == -11 and c.im == 41); } test "complex.div" { const a = Complex(f32).new(5, 3); const b = Complex(f32).new(2, 7); const c = a.div(b); debug.assert(math.approxEq(f32, c.re, f32(31) / 53, epsilon) and math.approxEq(f32, c.im, f32(-29) / 53, epsilon)); } test "complex.conjugate" { const a = Complex(f32).new(5, 3); const c = a.conjugate(); debug.assert(c.re == 5 and c.im == -3); } test "complex.reciprocal" { const a = Complex(f32).new(5, 3); const c = a.reciprocal(); debug.assert(math.approxEq(f32, c.re, f32(5) / 34, epsilon) and math.approxEq(f32, c.im, f32(-3) / 34, epsilon)); } test "complex.magnitude" { const a = Complex(f32).new(5, 3); const c = a.magnitude(); debug.assert(math.approxEq(f32, c, 5.83095, epsilon)); } test "complex.cmath" { _ = @import("abs.zig"); _ = @import("acosh.zig"); _ = @import("acos.zig"); _ = @import("arg.zig"); _ = @import("asinh.zig"); _ = @import("asin.zig"); _ = @import("atanh.zig"); _ = @import("atan.zig"); _ = @import("conj.zig"); _ = @import("cosh.zig"); _ = @import("cos.zig"); _ = @import("exp.zig"); _ = @import("log.zig"); _ = @import("pow.zig"); _ = @import("proj.zig"); _ = @import("sinh.zig"); _ = @import("sin.zig"); _ = @import("sqrt.zig"); _ = @import("tanh.zig"); _ = @import("tan.zig"); }
std/math/complex/index.zig
const std = @import("std"); const assert = std.debug.assert; /// A mixin usable with `pub usingnamespace MMIO(@This())` on any enum(usize). /// Adds IO functions for interacting with MMIO addresses defined in the enum members. fn MMIO(comptime T: type) type { return struct { pub fn write(self: T, comptime U: type, data: U) void { writeOffset(self, U, 0, data); } pub fn read(self: T, comptime U: type) U { return readOffset(self, U, 0); } pub fn writeOffset(self: T, comptime U: type, offset: usize, data: U) void { comptime assert(@typeInfo(U) == .Int); const ptr = @intToPtr([*]volatile U, @enumToInt(self)); ptr[offset] = data; } pub fn readOffset(self: T, comptime U: type, offset: usize) U { comptime assert(@typeInfo(U) == .Int); const ptr = @intToPtr([*]volatile U, @enumToInt(self)); return ptr[offset]; } }; } /// MMIO addresses for the UART. pub const Uart = enum(usize) { /// Base address, write/read data base = 0x1000_0000, /// Interrupt Enable Register ier = 0x1000_0001, /// FIFO Control Register fcr = 0x1000_0002, /// Line Control Register lcr = 0x1000_0003, // Line Status Register lsr = 0x1000_0005, pub usingnamespace MMIO(@This()); }; /// MMIO adresses for the Core Local Interrupter. pub const CLINT = enum(usize) { /// The machine time counter. QEMU increments this at a frequency of 10Mhz. mtime = 0x0200_bff8, /// The machine time compare register, a timer interrupt is fired iff mtimecmp >= mtime mtimecmp = 0x0200_4000, pub usingnamespace MMIO(@This()); }; /// MMIO addresses for the Platform Level Interrupt Controller. pub const PLIC = enum(usize) { /// Sets the priority of a particular interrupt source priority = 0x0c00_0000, /// Contains a list of interrupts that have been triggered (are pending) pending = 0x0c00_1000, /// Enable/disable certain interrupt sources enable = 0x0c00_2000, /// Sets the threshold that interrupts must meet before being able to trigger. threshold = 0x0c20_0000, /// Returns the next interrupt in priority order or completes handling of a particular interrupt. claim_or_complete = 0x0c20_0004, pub usingnamespace MMIO(@This()); };
src/mmio.zig
const std = @import("../std.zig"); const Cpu = std.Target.Cpu; pub const Feature = enum { addsubiw, avr0, avr1, avr2, avr25, avr3, avr31, avr35, avr4, avr5, avr51, avr6, avrtiny, @"break", des, eijmpcall, elpm, elpmx, ijmpcall, jmpcall, lpm, lpmx, movw, mul, rmw, smallstack, special, spm, spmx, sram, tinyencoding, xmega, xmegau, }; pub usingnamespace Cpu.Feature.feature_set_fns(Feature); pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= Cpu.Feature.Set.needed_bit_count); var result: [len]Cpu.Feature = undefined; result[@enumToInt(Feature.addsubiw)] = .{ .llvm_name = "addsubiw", .description = "Enable 16-bit register-immediate addition and subtraction instructions", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.avr0)] = .{ .llvm_name = "avr0", .description = "The device is a part of the avr0 family", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.avr1)] = .{ .llvm_name = "avr1", .description = "The device is a part of the avr1 family", .dependencies = featureSet(&[_]Feature{ .avr0, .lpm, }), }; result[@enumToInt(Feature.avr2)] = .{ .llvm_name = "avr2", .description = "The device is a part of the avr2 family", .dependencies = featureSet(&[_]Feature{ .addsubiw, .avr1, .ijmpcall, .sram, }), }; result[@enumToInt(Feature.avr25)] = .{ .llvm_name = "avr25", .description = "The device is a part of the avr25 family", .dependencies = featureSet(&[_]Feature{ .avr2, .@"break", .lpmx, .movw, .spm, }), }; result[@enumToInt(Feature.avr3)] = .{ .llvm_name = "avr3", .description = "The device is a part of the avr3 family", .dependencies = featureSet(&[_]Feature{ .avr2, .jmpcall, }), }; result[@enumToInt(Feature.avr31)] = .{ .llvm_name = "avr31", .description = "The device is a part of the avr31 family", .dependencies = featureSet(&[_]Feature{ .avr3, .elpm, }), }; result[@enumToInt(Feature.avr35)] = .{ .llvm_name = "avr35", .description = "The device is a part of the avr35 family", .dependencies = featureSet(&[_]Feature{ .avr3, .@"break", .lpmx, .movw, .spm, }), }; result[@enumToInt(Feature.avr4)] = .{ .llvm_name = "avr4", .description = "The device is a part of the avr4 family", .dependencies = featureSet(&[_]Feature{ .avr2, .@"break", .lpmx, .movw, .mul, .spm, }), }; result[@enumToInt(Feature.avr5)] = .{ .llvm_name = "avr5", .description = "The device is a part of the avr5 family", .dependencies = featureSet(&[_]Feature{ .avr3, .@"break", .lpmx, .movw, .mul, .spm, }), }; result[@enumToInt(Feature.avr51)] = .{ .llvm_name = "avr51", .description = "The device is a part of the avr51 family", .dependencies = featureSet(&[_]Feature{ .avr5, .elpm, .elpmx, }), }; result[@enumToInt(Feature.avr6)] = .{ .llvm_name = "avr6", .description = "The device is a part of the avr6 family", .dependencies = featureSet(&[_]Feature{ .avr51, }), }; result[@enumToInt(Feature.avrtiny)] = .{ .llvm_name = "avrtiny", .description = "The device is a part of the avrtiny family", .dependencies = featureSet(&[_]Feature{ .avr0, .@"break", .sram, .tinyencoding, }), }; result[@enumToInt(Feature.@"break")] = .{ .llvm_name = "break", .description = "The device supports the `BREAK` debugging instruction", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.des)] = .{ .llvm_name = "des", .description = "The device supports the `DES k` encryption instruction", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.eijmpcall)] = .{ .llvm_name = "eijmpcall", .description = "The device supports the `EIJMP`/`EICALL` instructions", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.elpm)] = .{ .llvm_name = "elpm", .description = "The device supports the ELPM instruction", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.elpmx)] = .{ .llvm_name = "elpmx", .description = "The device supports the `ELPM Rd, Z[+]` instructions", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.ijmpcall)] = .{ .llvm_name = "ijmpcall", .description = "The device supports `IJMP`/`ICALL`instructions", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.jmpcall)] = .{ .llvm_name = "jmpcall", .description = "The device supports the `JMP` and `CALL` instructions", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.lpm)] = .{ .llvm_name = "lpm", .description = "The device supports the `LPM` instruction", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.lpmx)] = .{ .llvm_name = "lpmx", .description = "The device supports the `LPM Rd, Z[+]` instruction", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.movw)] = .{ .llvm_name = "movw", .description = "The device supports the 16-bit MOVW instruction", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.mul)] = .{ .llvm_name = "mul", .description = "The device supports the multiplication instructions", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.rmw)] = .{ .llvm_name = "rmw", .description = "The device supports the read-write-modify instructions: XCH, LAS, LAC, LAT", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.smallstack)] = .{ .llvm_name = "smallstack", .description = "The device has an 8-bit stack pointer", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.special)] = .{ .llvm_name = "special", .description = "Enable use of the entire instruction set - used for debugging", .dependencies = featureSet(&[_]Feature{ .addsubiw, .@"break", .des, .eijmpcall, .elpm, .elpmx, .ijmpcall, .jmpcall, .lpm, .lpmx, .movw, .mul, .rmw, .spm, .spmx, .sram, }), }; result[@enumToInt(Feature.spm)] = .{ .llvm_name = "spm", .description = "The device supports the `SPM` instruction", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.spmx)] = .{ .llvm_name = "spmx", .description = "The device supports the `SPM Z+` instruction", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.sram)] = .{ .llvm_name = "sram", .description = "The device has random access memory", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.tinyencoding)] = .{ .llvm_name = "tinyencoding", .description = "The device has Tiny core specific instruction encodings", .dependencies = featureSet(&[_]Feature{}), }; result[@enumToInt(Feature.xmega)] = .{ .llvm_name = "xmega", .description = "The device is a part of the xmega family", .dependencies = featureSet(&[_]Feature{ .avr51, .des, .eijmpcall, .spmx, }), }; result[@enumToInt(Feature.xmegau)] = .{ .llvm_name = "xmegau", .description = "The device is a part of the xmegau family", .dependencies = featureSet(&[_]Feature{ .rmw, .xmega, }), }; const ti = @typeInfo(Feature); for (result) |*elem, i| { elem.index = i; elem.name = ti.Enum.fields[i].name; } break :blk result; }; pub const cpu = struct { pub const at43usb320 = Cpu{ .name = "at43usb320", .llvm_name = "at43usb320", .features = featureSet(&[_]Feature{ .avr31, }), }; pub const at43usb355 = Cpu{ .name = "at43usb355", .llvm_name = "at43usb355", .features = featureSet(&[_]Feature{ .avr3, }), }; pub const at76c711 = Cpu{ .name = "at76c711", .llvm_name = "at76c711", .features = featureSet(&[_]Feature{ .avr3, }), }; pub const at86rf401 = Cpu{ .name = "at86rf401", .llvm_name = "at86rf401", .features = featureSet(&[_]Feature{ .avr2, .lpmx, .movw, }), }; pub const at90c8534 = Cpu{ .name = "at90c8534", .llvm_name = "at90c8534", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90can128 = Cpu{ .name = "at90can128", .llvm_name = "at90can128", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const at90can32 = Cpu{ .name = "at90can32", .llvm_name = "at90can32", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const at90can64 = Cpu{ .name = "at90can64", .llvm_name = "at90can64", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const at90pwm1 = Cpu{ .name = "at90pwm1", .llvm_name = "at90pwm1", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const at90pwm161 = Cpu{ .name = "at90pwm161", .llvm_name = "at90pwm161", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const at90pwm2 = Cpu{ .name = "at90pwm2", .llvm_name = "at90pwm2", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const at90pwm216 = Cpu{ .name = "at90pwm216", .llvm_name = "at90pwm216", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const at90pwm2b = Cpu{ .name = "at90pwm2b", .llvm_name = "at90pwm2b", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const at90pwm3 = Cpu{ .name = "at90pwm3", .llvm_name = "at90pwm3", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const at90pwm316 = Cpu{ .name = "at90pwm316", .llvm_name = "at90pwm316", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const at90pwm3b = Cpu{ .name = "at90pwm3b", .llvm_name = "at90pwm3b", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const at90pwm81 = Cpu{ .name = "at90pwm81", .llvm_name = "at90pwm81", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const at90s1200 = Cpu{ .name = "at90s1200", .llvm_name = "at90s1200", .features = featureSet(&[_]Feature{ .avr0, }), }; pub const at90s2313 = Cpu{ .name = "at90s2313", .llvm_name = "at90s2313", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90s2323 = Cpu{ .name = "at90s2323", .llvm_name = "at90s2323", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90s2333 = Cpu{ .name = "at90s2333", .llvm_name = "at90s2333", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90s2343 = Cpu{ .name = "at90s2343", .llvm_name = "at90s2343", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90s4414 = Cpu{ .name = "at90s4414", .llvm_name = "at90s4414", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90s4433 = Cpu{ .name = "at90s4433", .llvm_name = "at90s4433", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90s4434 = Cpu{ .name = "at90s4434", .llvm_name = "at90s4434", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90s8515 = Cpu{ .name = "at90s8515", .llvm_name = "at90s8515", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90s8535 = Cpu{ .name = "at90s8535", .llvm_name = "at90s8535", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const at90scr100 = Cpu{ .name = "at90scr100", .llvm_name = "at90scr100", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const at90usb1286 = Cpu{ .name = "at90usb1286", .llvm_name = "at90usb1286", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const at90usb1287 = Cpu{ .name = "at90usb1287", .llvm_name = "at90usb1287", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const at90usb162 = Cpu{ .name = "at90usb162", .llvm_name = "at90usb162", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const at90usb646 = Cpu{ .name = "at90usb646", .llvm_name = "at90usb646", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const at90usb647 = Cpu{ .name = "at90usb647", .llvm_name = "at90usb647", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const at90usb82 = Cpu{ .name = "at90usb82", .llvm_name = "at90usb82", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const at94k = Cpu{ .name = "at94k", .llvm_name = "at94k", .features = featureSet(&[_]Feature{ .avr3, .lpmx, .movw, .mul, }), }; pub const ata5272 = Cpu{ .name = "ata5272", .llvm_name = "ata5272", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const ata5505 = Cpu{ .name = "ata5505", .llvm_name = "ata5505", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const ata5790 = Cpu{ .name = "ata5790", .llvm_name = "ata5790", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const ata5795 = Cpu{ .name = "ata5795", .llvm_name = "ata5795", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const ata6285 = Cpu{ .name = "ata6285", .llvm_name = "ata6285", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const ata6286 = Cpu{ .name = "ata6286", .llvm_name = "ata6286", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const ata6289 = Cpu{ .name = "ata6289", .llvm_name = "ata6289", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega103 = Cpu{ .name = "atmega103", .llvm_name = "atmega103", .features = featureSet(&[_]Feature{ .avr31, }), }; pub const atmega128 = Cpu{ .name = "atmega128", .llvm_name = "atmega128", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega1280 = Cpu{ .name = "atmega1280", .llvm_name = "atmega1280", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega1281 = Cpu{ .name = "atmega1281", .llvm_name = "atmega1281", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega1284 = Cpu{ .name = "atmega1284", .llvm_name = "atmega1284", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega1284p = Cpu{ .name = "atmega1284p", .llvm_name = "atmega1284p", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega1284rfr2 = Cpu{ .name = "atmega1284rfr2", .llvm_name = "atmega1284rfr2", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega128a = Cpu{ .name = "atmega128a", .llvm_name = "atmega128a", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega128rfa1 = Cpu{ .name = "atmega128rfa1", .llvm_name = "atmega128rfa1", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega128rfr2 = Cpu{ .name = "atmega128rfr2", .llvm_name = "atmega128rfr2", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const atmega16 = Cpu{ .name = "atmega16", .llvm_name = "atmega16", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega161 = Cpu{ .name = "atmega161", .llvm_name = "atmega161", .features = featureSet(&[_]Feature{ .avr3, .lpmx, .movw, .mul, .spm, }), }; pub const atmega162 = Cpu{ .name = "atmega162", .llvm_name = "atmega162", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega163 = Cpu{ .name = "atmega163", .llvm_name = "atmega163", .features = featureSet(&[_]Feature{ .avr3, .lpmx, .movw, .mul, .spm, }), }; pub const atmega164a = Cpu{ .name = "atmega164a", .llvm_name = "atmega164a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega164p = Cpu{ .name = "atmega164p", .llvm_name = "atmega164p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega164pa = Cpu{ .name = "atmega164pa", .llvm_name = "atmega164pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega165 = Cpu{ .name = "atmega165", .llvm_name = "atmega165", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega165a = Cpu{ .name = "atmega165a", .llvm_name = "atmega165a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega165p = Cpu{ .name = "atmega165p", .llvm_name = "atmega165p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega165pa = Cpu{ .name = "atmega165pa", .llvm_name = "atmega165pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega168 = Cpu{ .name = "atmega168", .llvm_name = "atmega168", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega168a = Cpu{ .name = "atmega168a", .llvm_name = "atmega168a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega168p = Cpu{ .name = "atmega168p", .llvm_name = "atmega168p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega168pa = Cpu{ .name = "atmega168pa", .llvm_name = "atmega168pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega169 = Cpu{ .name = "atmega169", .llvm_name = "atmega169", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega169a = Cpu{ .name = "atmega169a", .llvm_name = "atmega169a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega169p = Cpu{ .name = "atmega169p", .llvm_name = "atmega169p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega169pa = Cpu{ .name = "atmega169pa", .llvm_name = "atmega169pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega16a = Cpu{ .name = "atmega16a", .llvm_name = "atmega16a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega16hva = Cpu{ .name = "atmega16hva", .llvm_name = "atmega16hva", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega16hva2 = Cpu{ .name = "atmega16hva2", .llvm_name = "atmega16hva2", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega16hvb = Cpu{ .name = "atmega16hvb", .llvm_name = "atmega16hvb", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega16hvbrevb = Cpu{ .name = "atmega16hvbrevb", .llvm_name = "atmega16hvbrevb", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega16m1 = Cpu{ .name = "atmega16m1", .llvm_name = "atmega16m1", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega16u2 = Cpu{ .name = "atmega16u2", .llvm_name = "atmega16u2", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const atmega16u4 = Cpu{ .name = "atmega16u4", .llvm_name = "atmega16u4", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega2560 = Cpu{ .name = "atmega2560", .llvm_name = "atmega2560", .features = featureSet(&[_]Feature{ .avr6, }), }; pub const atmega2561 = Cpu{ .name = "atmega2561", .llvm_name = "atmega2561", .features = featureSet(&[_]Feature{ .avr6, }), }; pub const atmega2564rfr2 = Cpu{ .name = "atmega2564rfr2", .llvm_name = "atmega2564rfr2", .features = featureSet(&[_]Feature{ .avr6, }), }; pub const atmega256rfr2 = Cpu{ .name = "atmega256rfr2", .llvm_name = "atmega256rfr2", .features = featureSet(&[_]Feature{ .avr6, }), }; pub const atmega32 = Cpu{ .name = "atmega32", .llvm_name = "atmega32", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega323 = Cpu{ .name = "atmega323", .llvm_name = "atmega323", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega324a = Cpu{ .name = "atmega324a", .llvm_name = "atmega324a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega324p = Cpu{ .name = "atmega324p", .llvm_name = "atmega324p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega324pa = Cpu{ .name = "atmega324pa", .llvm_name = "atmega324pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega325 = Cpu{ .name = "atmega325", .llvm_name = "atmega325", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega3250 = Cpu{ .name = "atmega3250", .llvm_name = "atmega3250", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega3250a = Cpu{ .name = "atmega3250a", .llvm_name = "atmega3250a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega3250p = Cpu{ .name = "atmega3250p", .llvm_name = "atmega3250p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega3250pa = Cpu{ .name = "atmega3250pa", .llvm_name = "atmega3250pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega325a = Cpu{ .name = "atmega325a", .llvm_name = "atmega325a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega325p = Cpu{ .name = "atmega325p", .llvm_name = "atmega325p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega325pa = Cpu{ .name = "atmega325pa", .llvm_name = "atmega325pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega328 = Cpu{ .name = "atmega328", .llvm_name = "atmega328", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega328p = Cpu{ .name = "atmega328p", .llvm_name = "atmega328p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega329 = Cpu{ .name = "atmega329", .llvm_name = "atmega329", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega3290 = Cpu{ .name = "atmega3290", .llvm_name = "atmega3290", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega3290a = Cpu{ .name = "atmega3290a", .llvm_name = "atmega3290a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega3290p = Cpu{ .name = "atmega3290p", .llvm_name = "atmega3290p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega3290pa = Cpu{ .name = "atmega3290pa", .llvm_name = "atmega3290pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega329a = Cpu{ .name = "atmega329a", .llvm_name = "atmega329a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega329p = Cpu{ .name = "atmega329p", .llvm_name = "atmega329p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega329pa = Cpu{ .name = "atmega329pa", .llvm_name = "atmega329pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega32a = Cpu{ .name = "atmega32a", .llvm_name = "atmega32a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega32c1 = Cpu{ .name = "atmega32c1", .llvm_name = "atmega32c1", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega32hvb = Cpu{ .name = "atmega32hvb", .llvm_name = "atmega32hvb", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega32hvbrevb = Cpu{ .name = "atmega32hvbrevb", .llvm_name = "atmega32hvbrevb", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega32m1 = Cpu{ .name = "atmega32m1", .llvm_name = "atmega32m1", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega32u2 = Cpu{ .name = "atmega32u2", .llvm_name = "atmega32u2", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const atmega32u4 = Cpu{ .name = "atmega32u4", .llvm_name = "atmega32u4", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega32u6 = Cpu{ .name = "atmega32u6", .llvm_name = "atmega32u6", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega406 = Cpu{ .name = "atmega406", .llvm_name = "atmega406", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega48 = Cpu{ .name = "atmega48", .llvm_name = "atmega48", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega48a = Cpu{ .name = "atmega48a", .llvm_name = "atmega48a", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega48p = Cpu{ .name = "atmega48p", .llvm_name = "atmega48p", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega48pa = Cpu{ .name = "atmega48pa", .llvm_name = "atmega48pa", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega64 = Cpu{ .name = "atmega64", .llvm_name = "atmega64", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega640 = Cpu{ .name = "atmega640", .llvm_name = "atmega640", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega644 = Cpu{ .name = "atmega644", .llvm_name = "atmega644", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega644a = Cpu{ .name = "atmega644a", .llvm_name = "atmega644a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega644p = Cpu{ .name = "atmega644p", .llvm_name = "atmega644p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega644pa = Cpu{ .name = "atmega644pa", .llvm_name = "atmega644pa", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega644rfr2 = Cpu{ .name = "atmega644rfr2", .llvm_name = "atmega644rfr2", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega645 = Cpu{ .name = "atmega645", .llvm_name = "atmega645", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega6450 = Cpu{ .name = "atmega6450", .llvm_name = "atmega6450", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega6450a = Cpu{ .name = "atmega6450a", .llvm_name = "atmega6450a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega6450p = Cpu{ .name = "atmega6450p", .llvm_name = "atmega6450p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega645a = Cpu{ .name = "atmega645a", .llvm_name = "atmega645a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega645p = Cpu{ .name = "atmega645p", .llvm_name = "atmega645p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega649 = Cpu{ .name = "atmega649", .llvm_name = "atmega649", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega6490 = Cpu{ .name = "atmega6490", .llvm_name = "atmega6490", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega6490a = Cpu{ .name = "atmega6490a", .llvm_name = "atmega6490a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega6490p = Cpu{ .name = "atmega6490p", .llvm_name = "atmega6490p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega649a = Cpu{ .name = "atmega649a", .llvm_name = "atmega649a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega649p = Cpu{ .name = "atmega649p", .llvm_name = "atmega649p", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega64a = Cpu{ .name = "atmega64a", .llvm_name = "atmega64a", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega64c1 = Cpu{ .name = "atmega64c1", .llvm_name = "atmega64c1", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega64hve = Cpu{ .name = "atmega64hve", .llvm_name = "atmega64hve", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega64m1 = Cpu{ .name = "atmega64m1", .llvm_name = "atmega64m1", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega64rfr2 = Cpu{ .name = "atmega64rfr2", .llvm_name = "atmega64rfr2", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const atmega8 = Cpu{ .name = "atmega8", .llvm_name = "atmega8", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega8515 = Cpu{ .name = "atmega8515", .llvm_name = "atmega8515", .features = featureSet(&[_]Feature{ .avr2, .lpmx, .movw, .mul, .spm, }), }; pub const atmega8535 = Cpu{ .name = "atmega8535", .llvm_name = "atmega8535", .features = featureSet(&[_]Feature{ .avr2, .lpmx, .movw, .mul, .spm, }), }; pub const atmega88 = Cpu{ .name = "atmega88", .llvm_name = "atmega88", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega88a = Cpu{ .name = "atmega88a", .llvm_name = "atmega88a", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega88p = Cpu{ .name = "atmega88p", .llvm_name = "atmega88p", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega88pa = Cpu{ .name = "atmega88pa", .llvm_name = "atmega88pa", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega8a = Cpu{ .name = "atmega8a", .llvm_name = "atmega8a", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega8hva = Cpu{ .name = "atmega8hva", .llvm_name = "atmega8hva", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const atmega8u2 = Cpu{ .name = "atmega8u2", .llvm_name = "atmega8u2", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const attiny10 = Cpu{ .name = "attiny10", .llvm_name = "attiny10", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const attiny102 = Cpu{ .name = "attiny102", .llvm_name = "attiny102", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const attiny104 = Cpu{ .name = "attiny104", .llvm_name = "attiny104", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const attiny11 = Cpu{ .name = "attiny11", .llvm_name = "attiny11", .features = featureSet(&[_]Feature{ .avr1, }), }; pub const attiny12 = Cpu{ .name = "attiny12", .llvm_name = "attiny12", .features = featureSet(&[_]Feature{ .avr1, }), }; pub const attiny13 = Cpu{ .name = "attiny13", .llvm_name = "attiny13", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny13a = Cpu{ .name = "attiny13a", .llvm_name = "attiny13a", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny15 = Cpu{ .name = "attiny15", .llvm_name = "attiny15", .features = featureSet(&[_]Feature{ .avr1, }), }; pub const attiny1634 = Cpu{ .name = "attiny1634", .llvm_name = "attiny1634", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const attiny167 = Cpu{ .name = "attiny167", .llvm_name = "attiny167", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const attiny20 = Cpu{ .name = "attiny20", .llvm_name = "attiny20", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const attiny22 = Cpu{ .name = "attiny22", .llvm_name = "attiny22", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const attiny2313 = Cpu{ .name = "attiny2313", .llvm_name = "attiny2313", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny2313a = Cpu{ .name = "attiny2313a", .llvm_name = "attiny2313a", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny24 = Cpu{ .name = "attiny24", .llvm_name = "attiny24", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny24a = Cpu{ .name = "attiny24a", .llvm_name = "attiny24a", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny25 = Cpu{ .name = "attiny25", .llvm_name = "attiny25", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny26 = Cpu{ .name = "attiny26", .llvm_name = "attiny26", .features = featureSet(&[_]Feature{ .avr2, .lpmx, }), }; pub const attiny261 = Cpu{ .name = "attiny261", .llvm_name = "attiny261", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny261a = Cpu{ .name = "attiny261a", .llvm_name = "attiny261a", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny28 = Cpu{ .name = "attiny28", .llvm_name = "attiny28", .features = featureSet(&[_]Feature{ .avr1, }), }; pub const attiny4 = Cpu{ .name = "attiny4", .llvm_name = "attiny4", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const attiny40 = Cpu{ .name = "attiny40", .llvm_name = "attiny40", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const attiny4313 = Cpu{ .name = "attiny4313", .llvm_name = "attiny4313", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny43u = Cpu{ .name = "attiny43u", .llvm_name = "attiny43u", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny44 = Cpu{ .name = "attiny44", .llvm_name = "attiny44", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny44a = Cpu{ .name = "attiny44a", .llvm_name = "attiny44a", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny45 = Cpu{ .name = "attiny45", .llvm_name = "attiny45", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny461 = Cpu{ .name = "attiny461", .llvm_name = "attiny461", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny461a = Cpu{ .name = "attiny461a", .llvm_name = "attiny461a", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny48 = Cpu{ .name = "attiny48", .llvm_name = "attiny48", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny5 = Cpu{ .name = "attiny5", .llvm_name = "attiny5", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const attiny828 = Cpu{ .name = "attiny828", .llvm_name = "attiny828", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny84 = Cpu{ .name = "attiny84", .llvm_name = "attiny84", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny84a = Cpu{ .name = "attiny84a", .llvm_name = "attiny84a", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny85 = Cpu{ .name = "attiny85", .llvm_name = "attiny85", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny861 = Cpu{ .name = "attiny861", .llvm_name = "attiny861", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny861a = Cpu{ .name = "attiny861a", .llvm_name = "attiny861a", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny87 = Cpu{ .name = "attiny87", .llvm_name = "attiny87", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny88 = Cpu{ .name = "attiny88", .llvm_name = "attiny88", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const attiny9 = Cpu{ .name = "attiny9", .llvm_name = "attiny9", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const atxmega128a1 = Cpu{ .name = "atxmega128a1", .llvm_name = "atxmega128a1", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega128a1u = Cpu{ .name = "atxmega128a1u", .llvm_name = "atxmega128a1u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega128a3 = Cpu{ .name = "atxmega128a3", .llvm_name = "atxmega128a3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega128a3u = Cpu{ .name = "atxmega128a3u", .llvm_name = "atxmega128a3u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega128a4u = Cpu{ .name = "atxmega128a4u", .llvm_name = "atxmega128a4u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega128b1 = Cpu{ .name = "atxmega128b1", .llvm_name = "atxmega128b1", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega128b3 = Cpu{ .name = "atxmega128b3", .llvm_name = "atxmega128b3", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega128c3 = Cpu{ .name = "atxmega128c3", .llvm_name = "atxmega128c3", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega128d3 = Cpu{ .name = "atxmega128d3", .llvm_name = "atxmega128d3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega128d4 = Cpu{ .name = "atxmega128d4", .llvm_name = "atxmega128d4", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega16a4 = Cpu{ .name = "atxmega16a4", .llvm_name = "atxmega16a4", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega16a4u = Cpu{ .name = "atxmega16a4u", .llvm_name = "atxmega16a4u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega16c4 = Cpu{ .name = "atxmega16c4", .llvm_name = "atxmega16c4", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega16d4 = Cpu{ .name = "atxmega16d4", .llvm_name = "atxmega16d4", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega16e5 = Cpu{ .name = "atxmega16e5", .llvm_name = "atxmega16e5", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega192a3 = Cpu{ .name = "atxmega192a3", .llvm_name = "atxmega192a3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega192a3u = Cpu{ .name = "atxmega192a3u", .llvm_name = "atxmega192a3u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega192c3 = Cpu{ .name = "atxmega192c3", .llvm_name = "atxmega192c3", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega192d3 = Cpu{ .name = "atxmega192d3", .llvm_name = "atxmega192d3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega256a3 = Cpu{ .name = "atxmega256a3", .llvm_name = "atxmega256a3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega256a3b = Cpu{ .name = "atxmega256a3b", .llvm_name = "atxmega256a3b", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega256a3bu = Cpu{ .name = "atxmega256a3bu", .llvm_name = "atxmega256a3bu", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega256a3u = Cpu{ .name = "atxmega256a3u", .llvm_name = "atxmega256a3u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega256c3 = Cpu{ .name = "atxmega256c3", .llvm_name = "atxmega256c3", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega256d3 = Cpu{ .name = "atxmega256d3", .llvm_name = "atxmega256d3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega32a4 = Cpu{ .name = "atxmega32a4", .llvm_name = "atxmega32a4", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega32a4u = Cpu{ .name = "atxmega32a4u", .llvm_name = "atxmega32a4u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega32c4 = Cpu{ .name = "atxmega32c4", .llvm_name = "atxmega32c4", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega32d4 = Cpu{ .name = "atxmega32d4", .llvm_name = "atxmega32d4", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega32e5 = Cpu{ .name = "atxmega32e5", .llvm_name = "atxmega32e5", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega32x1 = Cpu{ .name = "atxmega32x1", .llvm_name = "atxmega32x1", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega384c3 = Cpu{ .name = "atxmega384c3", .llvm_name = "atxmega384c3", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega384d3 = Cpu{ .name = "atxmega384d3", .llvm_name = "atxmega384d3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega64a1 = Cpu{ .name = "atxmega64a1", .llvm_name = "atxmega64a1", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega64a1u = Cpu{ .name = "atxmega64a1u", .llvm_name = "atxmega64a1u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega64a3 = Cpu{ .name = "atxmega64a3", .llvm_name = "atxmega64a3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega64a3u = Cpu{ .name = "atxmega64a3u", .llvm_name = "atxmega64a3u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega64a4u = Cpu{ .name = "atxmega64a4u", .llvm_name = "atxmega64a4u", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega64b1 = Cpu{ .name = "atxmega64b1", .llvm_name = "atxmega64b1", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega64b3 = Cpu{ .name = "atxmega64b3", .llvm_name = "atxmega64b3", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega64c3 = Cpu{ .name = "atxmega64c3", .llvm_name = "atxmega64c3", .features = featureSet(&[_]Feature{ .xmegau, }), }; pub const atxmega64d3 = Cpu{ .name = "atxmega64d3", .llvm_name = "atxmega64d3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega64d4 = Cpu{ .name = "atxmega64d4", .llvm_name = "atxmega64d4", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const atxmega8e5 = Cpu{ .name = "atxmega8e5", .llvm_name = "atxmega8e5", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const avr1 = Cpu{ .name = "avr1", .llvm_name = "avr1", .features = featureSet(&[_]Feature{ .avr1, }), }; pub const avr2 = Cpu{ .name = "avr2", .llvm_name = "avr2", .features = featureSet(&[_]Feature{ .avr2, }), }; pub const avr25 = Cpu{ .name = "avr25", .llvm_name = "avr25", .features = featureSet(&[_]Feature{ .avr25, }), }; pub const avr3 = Cpu{ .name = "avr3", .llvm_name = "avr3", .features = featureSet(&[_]Feature{ .avr3, }), }; pub const avr31 = Cpu{ .name = "avr31", .llvm_name = "avr31", .features = featureSet(&[_]Feature{ .avr31, }), }; pub const avr35 = Cpu{ .name = "avr35", .llvm_name = "avr35", .features = featureSet(&[_]Feature{ .avr35, }), }; pub const avr4 = Cpu{ .name = "avr4", .llvm_name = "avr4", .features = featureSet(&[_]Feature{ .avr4, }), }; pub const avr5 = Cpu{ .name = "avr5", .llvm_name = "avr5", .features = featureSet(&[_]Feature{ .avr5, }), }; pub const avr51 = Cpu{ .name = "avr51", .llvm_name = "avr51", .features = featureSet(&[_]Feature{ .avr51, }), }; pub const avr6 = Cpu{ .name = "avr6", .llvm_name = "avr6", .features = featureSet(&[_]Feature{ .avr6, }), }; pub const avrtiny = Cpu{ .name = "avrtiny", .llvm_name = "avrtiny", .features = featureSet(&[_]Feature{ .avrtiny, }), }; pub const avrxmega1 = Cpu{ .name = "avrxmega1", .llvm_name = "avrxmega1", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const avrxmega2 = Cpu{ .name = "avrxmega2", .llvm_name = "avrxmega2", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const avrxmega3 = Cpu{ .name = "avrxmega3", .llvm_name = "avrxmega3", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const avrxmega4 = Cpu{ .name = "avrxmega4", .llvm_name = "avrxmega4", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const avrxmega5 = Cpu{ .name = "avrxmega5", .llvm_name = "avrxmega5", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const avrxmega6 = Cpu{ .name = "avrxmega6", .llvm_name = "avrxmega6", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const avrxmega7 = Cpu{ .name = "avrxmega7", .llvm_name = "avrxmega7", .features = featureSet(&[_]Feature{ .xmega, }), }; pub const m3000 = Cpu{ .name = "m3000", .llvm_name = "m3000", .features = featureSet(&[_]Feature{ .avr5, }), }; }; /// All avr CPUs, sorted alphabetically by name. /// TODO: Replace this with usage of `std.meta.declList`. It does work, but stage1 /// compiler has inefficient memory and CPU usage, affecting build times. pub const all_cpus = &[_]*const Cpu{ &cpu.at43usb320, &cpu.at43usb355, &cpu.at76c711, &cpu.at86rf401, &cpu.at90c8534, &cpu.at90can128, &cpu.at90can32, &cpu.at90can64, &cpu.at90pwm1, &cpu.at90pwm161, &cpu.at90pwm2, &cpu.at90pwm216, &cpu.at90pwm2b, &cpu.at90pwm3, &cpu.at90pwm316, &cpu.at90pwm3b, &cpu.at90pwm81, &cpu.at90s1200, &cpu.at90s2313, &cpu.at90s2323, &cpu.at90s2333, &cpu.at90s2343, &cpu.at90s4414, &cpu.at90s4433, &cpu.at90s4434, &cpu.at90s8515, &cpu.at90s8535, &cpu.at90scr100, &cpu.at90usb1286, &cpu.at90usb1287, &cpu.at90usb162, &cpu.at90usb646, &cpu.at90usb647, &cpu.at90usb82, &cpu.at94k, &cpu.ata5272, &cpu.ata5505, &cpu.ata5790, &cpu.ata5795, &cpu.ata6285, &cpu.ata6286, &cpu.ata6289, &cpu.atmega103, &cpu.atmega128, &cpu.atmega1280, &cpu.atmega1281, &cpu.atmega1284, &cpu.atmega1284p, &cpu.atmega1284rfr2, &cpu.atmega128a, &cpu.atmega128rfa1, &cpu.atmega128rfr2, &cpu.atmega16, &cpu.atmega161, &cpu.atmega162, &cpu.atmega163, &cpu.atmega164a, &cpu.atmega164p, &cpu.atmega164pa, &cpu.atmega165, &cpu.atmega165a, &cpu.atmega165p, &cpu.atmega165pa, &cpu.atmega168, &cpu.atmega168a, &cpu.atmega168p, &cpu.atmega168pa, &cpu.atmega169, &cpu.atmega169a, &cpu.atmega169p, &cpu.atmega169pa, &cpu.atmega16a, &cpu.atmega16hva, &cpu.atmega16hva2, &cpu.atmega16hvb, &cpu.atmega16hvbrevb, &cpu.atmega16m1, &cpu.atmega16u2, &cpu.atmega16u4, &cpu.atmega2560, &cpu.atmega2561, &cpu.atmega2564rfr2, &cpu.atmega256rfr2, &cpu.atmega32, &cpu.atmega323, &cpu.atmega324a, &cpu.atmega324p, &cpu.atmega324pa, &cpu.atmega325, &cpu.atmega3250, &cpu.atmega3250a, &cpu.atmega3250p, &cpu.atmega3250pa, &cpu.atmega325a, &cpu.atmega325p, &cpu.atmega325pa, &cpu.atmega328, &cpu.atmega328p, &cpu.atmega329, &cpu.atmega3290, &cpu.atmega3290a, &cpu.atmega3290p, &cpu.atmega3290pa, &cpu.atmega329a, &cpu.atmega329p, &cpu.atmega329pa, &cpu.atmega32a, &cpu.atmega32c1, &cpu.atmega32hvb, &cpu.atmega32hvbrevb, &cpu.atmega32m1, &cpu.atmega32u2, &cpu.atmega32u4, &cpu.atmega32u6, &cpu.atmega406, &cpu.atmega48, &cpu.atmega48a, &cpu.atmega48p, &cpu.atmega48pa, &cpu.atmega64, &cpu.atmega640, &cpu.atmega644, &cpu.atmega644a, &cpu.atmega644p, &cpu.atmega644pa, &cpu.atmega644rfr2, &cpu.atmega645, &cpu.atmega6450, &cpu.atmega6450a, &cpu.atmega6450p, &cpu.atmega645a, &cpu.atmega645p, &cpu.atmega649, &cpu.atmega6490, &cpu.atmega6490a, &cpu.atmega6490p, &cpu.atmega649a, &cpu.atmega649p, &cpu.atmega64a, &cpu.atmega64c1, &cpu.atmega64hve, &cpu.atmega64m1, &cpu.atmega64rfr2, &cpu.atmega8, &cpu.atmega8515, &cpu.atmega8535, &cpu.atmega88, &cpu.atmega88a, &cpu.atmega88p, &cpu.atmega88pa, &cpu.atmega8a, &cpu.atmega8hva, &cpu.atmega8u2, &cpu.attiny10, &cpu.attiny102, &cpu.attiny104, &cpu.attiny11, &cpu.attiny12, &cpu.attiny13, &cpu.attiny13a, &cpu.attiny15, &cpu.attiny1634, &cpu.attiny167, &cpu.attiny20, &cpu.attiny22, &cpu.attiny2313, &cpu.attiny2313a, &cpu.attiny24, &cpu.attiny24a, &cpu.attiny25, &cpu.attiny26, &cpu.attiny261, &cpu.attiny261a, &cpu.attiny28, &cpu.attiny4, &cpu.attiny40, &cpu.attiny4313, &cpu.attiny43u, &cpu.attiny44, &cpu.attiny44a, &cpu.attiny45, &cpu.attiny461, &cpu.attiny461a, &cpu.attiny48, &cpu.attiny5, &cpu.attiny828, &cpu.attiny84, &cpu.attiny84a, &cpu.attiny85, &cpu.attiny861, &cpu.attiny861a, &cpu.attiny87, &cpu.attiny88, &cpu.attiny9, &cpu.atxmega128a1, &cpu.atxmega128a1u, &cpu.atxmega128a3, &cpu.atxmega128a3u, &cpu.atxmega128a4u, &cpu.atxmega128b1, &cpu.atxmega128b3, &cpu.atxmega128c3, &cpu.atxmega128d3, &cpu.atxmega128d4, &cpu.atxmega16a4, &cpu.atxmega16a4u, &cpu.atxmega16c4, &cpu.atxmega16d4, &cpu.atxmega16e5, &cpu.atxmega192a3, &cpu.atxmega192a3u, &cpu.atxmega192c3, &cpu.atxmega192d3, &cpu.atxmega256a3, &cpu.atxmega256a3b, &cpu.atxmega256a3bu, &cpu.atxmega256a3u, &cpu.atxmega256c3, &cpu.atxmega256d3, &cpu.atxmega32a4, &cpu.atxmega32a4u, &cpu.atxmega32c4, &cpu.atxmega32d4, &cpu.atxmega32e5, &cpu.atxmega32x1, &cpu.atxmega384c3, &cpu.atxmega384d3, &cpu.atxmega64a1, &cpu.atxmega64a1u, &cpu.atxmega64a3, &cpu.atxmega64a3u, &cpu.atxmega64a4u, &cpu.atxmega64b1, &cpu.atxmega64b3, &cpu.atxmega64c3, &cpu.atxmega64d3, &cpu.atxmega64d4, &cpu.atxmega8e5, &cpu.avr1, &cpu.avr2, &cpu.avr25, &cpu.avr3, &cpu.avr31, &cpu.avr35, &cpu.avr4, &cpu.avr5, &cpu.avr51, &cpu.avr6, &cpu.avrtiny, &cpu.avrxmega1, &cpu.avrxmega2, &cpu.avrxmega3, &cpu.avrxmega4, &cpu.avrxmega5, &cpu.avrxmega6, &cpu.avrxmega7, &cpu.m3000, };
lib/std/target/avr.zig
const std = @import("std"); const random = std.crypto.random; const ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; const ULID_LEN = 26; pub fn ulid() [16]u8 { const time_bits = @intCast(u48, std.time.milliTimestamp()); const rand_bits = random.int(u80); const value = (@as(u128, time_bits) << 80) | @as(u128, rand_bits); const big_endian_ulid = std.mem.nativeToBig(u128, value); return @bitCast([16]u8, big_endian_ulid); } pub const MonotonicFactory = struct { rng: std.rand.DefaultCsprng, // TODO: make these the exact size needed when issue is resolved: https://github.com/ziglang/zig/issues/7836 // Set this to true to ensure that each value returned from ulidNow is greater than the last last_timestamp_ms: u64 = 0, last_random: u128 = 0, pub fn init() !@This() { var seed: [32]u8 = undefined; random.bytes(&seed); return @This(){ .rng = std.rand.DefaultCsprng.init(seed), }; } pub fn ulidNow(this: *@This()) [16]u8 { const time = @intCast(u48, std.time.milliTimestamp()); if (this.last_timestamp_ms == time) { this.last_random += 1; } else { this.last_timestamp_ms = time; this.last_random = this.rng.random.int(u80); } const ulid_int = (@as(u128, time) << 80) | @as(u128, this.last_random); const ulid_int_big = std.mem.nativeToBig(u128, ulid_int); return @bitCast([16]u8, ulid_int_big); } }; const LOOKUP = gen_lookup_table: { const CharType = union(enum) { Invalid: void, Ignored: void, Value: u5, }; var lookup = [1]CharType{.Invalid} ** 256; for (ALPHABET) |char, idx| { lookup[char] = .{ .Value = idx }; lookup[std.ascii.toLower(char)] = .{ .Value = idx }; } lookup['O'] = .{ .Value = 0 }; lookup['o'] = .{ .Value = 0 }; lookup['I'] = .{ .Value = 1 }; lookup['i'] = .{ .Value = 1 }; lookup['L'] = .{ .Value = 1 }; lookup['l'] = .{ .Value = 1 }; lookup['-'] = .Ignored; break :gen_lookup_table lookup; }; pub fn encodeTo(buffer: []u8, valueIn: [16]u8) !void { if (buffer.len < ULID_LEN) return error.BufferToSmall; var value = std.mem.bigToNative(u128, @bitCast(u128, valueIn)); var i: usize = ULID_LEN; while (i > 0) : (i -= 1) { buffer[i - 1] = ALPHABET[@truncate(u5, value)]; value >>= 5; } } pub fn encode(value: [16]u8) [ULID_LEN]u8 { var buffer: [ULID_LEN]u8 = undefined; encodeTo(&buffer, value) catch |err| switch (err) { error.BufferToSmall => unreachable, }; return buffer; } pub fn decode(text: []const u8) ![16]u8 { if (text.len < ULID_LEN) return error.InvalidLength; var value: u128 = 0; var chars_not_ignored: usize = 0; for (text) |char| { switch (LOOKUP[char]) { .Invalid => return error.InvalidCharacter, .Ignored => {}, .Value => |char_val| { chars_not_ignored += 1; if (chars_not_ignored > ULID_LEN) { return error.InvalidLength; } if (@shlWithOverflow(u128, value, 5, &value)) { return error.Overflow; } value |= char_val; }, } } const big_endian_ulid = std.mem.nativeToBig(u128, value); return @bitCast([16]u8, big_endian_ulid); } pub fn cmp(a: [16]u8, b: [16]u8) std.math.Order { for (a) |a_val, idx| { if (a_val == b[idx]) { continue; } else if (a_val > b[idx]) { return .gt; } else { return .lt; } } return .eq; } pub fn eq(a: [16]u8, b: [16]u8) bool { return cmp(a, b) == .eq; } test "valid" { const val1 = [16]u8{ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, }; const enc1 = "21850M2GA1850M2GA1850M2GA1"; try std.testing.expectEqual(val1, try decode(enc1)); try std.testing.expectEqualSlices(u8, enc1, &encode(val1)); const val2 = [16]u8{ 0x4d, 0x4e, 0x38, 0x50, 0x51, 0x44, 0x4a, 0x59, 0x45, 0x42, 0x34, 0x33, 0x5a, 0x41, 0x37, 0x56 }; const enc2 = "2D9RW50MA499CMAGHM6DD42DTP"; var lower: [enc2.len]u8 = undefined; for (enc2) |char, idx| { lower[idx] = std.ascii.toLower(char); } try std.testing.expectEqualSlices(u8, enc2, &encode(val2)); try std.testing.expectEqual(val2, try decode(enc2)); try std.testing.expectEqual(val2, try decode(&lower)); const enc3 = "2D9RW-50MA-499C-MAGH-M6DD-42DTP"; try std.testing.expectEqual(val2, try decode(enc3)); } test "invalid length" { try std.testing.expectError(error.InvalidLength, decode("")); try std.testing.expectError(error.InvalidLength, decode("2D9RW50MA499CMAGHM6DD42DT")); try std.testing.expectError(error.InvalidLength, decode("2D9RW50MA499CMAGHM6DD42DTPP")); } test "invalid characters" { try std.testing.expectError(error.InvalidCharacter, decode("2D9RW50[A499CMAGHM6DD42DTP")); try std.testing.expectError(error.InvalidCharacter, decode("2D9RW50MA49%CMAGHM6DD42DTP")); } test "overflows" { try std.testing.expectError(error.Overflow, decode("8ZZZZZZZZZZZZZZZZZZZZZZZZZ")); try std.testing.expectError(error.Overflow, decode("ZZZZZZZZZZZZZZZZZZZZZZZZZZ")); } test "compare ulids" {} test "Monotonic ULID factory: sequential output always increases" { var ulid_factory = try MonotonicFactory.init(); var generated_ulids: [1024][16]u8 = undefined; for (generated_ulids) |*ulid_to_generate| { ulid_to_generate.* = ulid_factory.ulidNow(); } var prev_ulid = generated_ulids[0]; for (generated_ulids[1..]) |current_ulid| { try std.testing.expectEqual(std.math.Order.gt, cmp(current_ulid, prev_ulid)); } }
ulid.zig
const std = @import("std"); const builtin = @import("builtin"); const build_root = "../build/"; const is_windows = std.Target.current.os.tag == .windows; const is_macos = std.Target.current.os.tag == .macos; pub fn build(b: *std.build.Builder) anyerror!void { const mode = b.standardReleaseOptions(); // Previously was exe.enableSystemLinkerHack(): See https://github.com/jeffkdev/sokol-zig-examples/issues/2 if (is_macos) try b.env_map.put("ZIG_SYSTEM_LINKER_HACK", "1"); // Probably can take command line arg to build different examples // For now rename the mainFile const below (ex: "example_triangle.zig") const mainFile = "example_triangle.zig"; var exe = b.addExecutable("program", "../src/" ++ mainFile); exe.addIncludeDir("../src/"); exe.setBuildMode(mode); const cFlags = if (is_macos) [_][]const u8{ "-std=c99", "-ObjC", "-fobjc-arc" } else [_][]const u8{"-std=c99"}; exe.addCSourceFile("../src/compile_sokol.c", &cFlags); const cpp_args = [_][]const u8{ "-Wno-deprecated-declarations", "-Wno-return-type-c-linkage", "-fno-exceptions", "-fno-threadsafe-statics" }; exe.addCSourceFile("../src/cimgui/imgui/imgui.cpp", &cpp_args); exe.addCSourceFile("../src/cimgui/imgui/imgui_demo.cpp", &cpp_args); exe.addCSourceFile("../src/cimgui/imgui/imgui_draw.cpp", &cpp_args); exe.addCSourceFile("../src/cimgui/imgui/imgui_widgets.cpp", &cpp_args); exe.addCSourceFile("../src/cimgui/cimgui.cpp", &cpp_args); // Shaders exe.addCSourceFile("../src/shaders/cube_compile.c", &[_][]const u8{"-std=c99"}); exe.addCSourceFile("../src/shaders/triangle_compile.c", &[_][]const u8{"-std=c99"}); exe.addCSourceFile("../src/shaders/instancing_compile.c", &[_][]const u8{"-std=c99"}); exe.linkLibC(); if (is_windows) { //See https://github.com/ziglang/zig/issues/8531 only matters in release mode exe.want_lto = false; exe.linkSystemLibrary("user32"); exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("ole32"); // For Sokol audio } else if (is_macos) { const frameworks_dir = try macos_frameworks_dir(b); exe.addFrameworkDir(frameworks_dir); exe.linkFramework("Foundation"); exe.linkFramework("Cocoa"); exe.linkFramework("Quartz"); exe.linkFramework("QuartzCore"); exe.linkFramework("Metal"); exe.linkFramework("MetalKit"); exe.linkFramework("OpenGL"); exe.linkFramework("Audiotoolbox"); exe.linkFramework("CoreAudio"); exe.linkSystemLibrary("c++"); } else { // Not tested @panic("OS not supported. Try removing panic in build.zig if you want to test this"); exe.linkSystemLibrary("GL"); exe.linkSystemLibrary("GLEW"); } const run_cmd = exe.run(); const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); b.default_step.dependOn(&exe.step); b.installArtifact(exe); } // helper function to get SDK path on Mac sourced from: https://github.com/floooh/sokol-zig fn macos_frameworks_dir(b: *std.build.Builder) ![]u8 { var str = try b.exec(&[_][]const u8{ "xcrun", "--show-sdk-path" }); const strip_newline = std.mem.lastIndexOf(u8, str, "\n"); if (strip_newline) |index| { str = str[0..index]; } const frameworks_dir = try std.mem.concat(b.allocator, u8, &[_][]const u8{ str, "/System/Library/Frameworks" }); return frameworks_dir; }
src/build.zig
const std = @import("std"); // const // print = std.debug.// print; const memEql = std.mem.eql; const stringToEnum = std.meta.stringToEnum; const types = @import("types.zig"); const parse = @import("parse.zig"); const Atom = types.Atom; const AtomList = types.AtomList; const Variable = types.Variable; const VarList = types.VarList; const Value = types.Value; const SpecialForms = types.SpecialForms; const Func = types.Func; const Function = types.Function; const SyntaxErrors = types.SyntaxErrors; /// Addition; some dummy functions to play with -> add takes 2 params (order independant) pub fn add(l: Atom, r: Atom) Atom { return Atom{ .number = l.number + r.number }; } /// Division; order dependant pub fn sub(l: Atom, r: Atom) Atom { return Atom{ .number = l.number - r.number }; } /// Negation; neg takes 1 param pub fn neg(l: Atom) Atom { return Atom{ .number = -l.number }; } pub fn less(l: Atom, r: Atom) Atom { return Atom{ .number = if (l.number < r.number) 1.0 else 0 }; } pub const Env = struct { outer: ?*Env, varlist: VarList, pub fn copy(self: *const Env) Env { return Env{ .outer = self.outer, .varlist = self.varlist }; } pub fn push(self: *Env, symbol: []const u8, value: Value) void { var node = VarList.Node{ .data = Variable{ .name = symbol, .value = value } }; self.varlist.prepend(&node); } pub fn find(self: *const Env, symbol: []const u8) ?*const Env { var it = self.varlist.first; while (it) |node| : (it = node.next) { if (memEql(u8, node.data.name, symbol)) return self; } return if (self.outer) |outer_node| outer_node.find(symbol) else null; } pub fn get(self: *const Env, symbol: []const u8) !Value { if (self.find(symbol)) |env| { var it = env.varlist.first; while (it) |node| : (it = node.next) { if (memEql(u8, node.data.name, symbol)) return node.data.value; } return error.KeyDisappearedAfterFinding; } else { return error.CannotFindKeyInEnvs; } } pub fn addArgs(self: *Env, names: AtomList, values: AtomList) SyntaxErrors!void { if (names.len() != values.len()) return error.UserFunctionParameterArgumentLengthMismatch; comptime var i = 0; var name = names.first; var value = values.first; while (name) |nameNode| : (name = nameNode.next) { if (value) |valueNode| { self.push(nameNode.data.keyword, Value{ .atom = valueNode.data }); value = valueNode.next; // the same as name = nameNode.next on continuation } } } }; pub fn evalProgram(comptime ast: AtomList) SyntaxErrors!AtomList { var corelist = VarList{}; const functions = [_]Variable{ Variable{ .name = "add", .value = Value{ .func = Func{ .funcTwo = &add } } }, Variable{ .name = "sub", .value = Value{ .func = Func{ .funcTwo = &sub } } }, Variable{ .name = "less", .value = Value{ .func = Func{ .funcTwo = &less } } }, }; for (functions) |function| { var func = VarList.Node{ .data = function }; corelist.prepend(&func); } var global_env = Env{ .outer = null, .varlist = corelist }; var results = AtomList{}; var it = ast.first; while (it) |node| : (it = node.next) { const evaluation = try comptime eval(node.data, &global_env); var new_node = AtomList.Node{ .data = evaluation }; if (results.len() >= 1) { results.first.?.findLast().insertAfter(&new_node); // front to back growth } else { results.prepend(&new_node); } } return results; } pub fn eval(x: Atom, env: *Env) SyntaxErrors!Atom { @setEvalBranchQuota(1_000_000); return switch (x) { .number => x, // number evaluates to itself .keyword => (try env.get(x.keyword)).atom, // non function keywords .function => error.NoFunctionShouldBeHere, // we shouldn't see a bare function .list => blk: { if (x.list.len() == 0) break :blk x; // list is empty, return emptylist const node = comptime x.list.first.?; const data = comptime node.data; const next = comptime node.next; if (data != .keyword) break :blk eval(comptime data, comptime env); // evaluate it if not a kwd if (next == null) break :blk (try env.get(data.keyword)).atom; // if its termina, find it (variable) if (stringToEnum(comptime SpecialForms, data.keyword)) |special_form| { // special form break :blk switch (special_form) { .def => handleDefSpecialForm(next.?, env), .@"if" => handleIfSpecialForm(next.?, env), .@"fn" => handleFnSpecialForm(next.?, env), }; } else { // function that's not a special form break :blk handleFunction(node, env); } }, }; } /// No bool values, like the cool kids pub fn handleIfSpecialForm(conditional: *types.AtomList.Node, env: *Env) SyntaxErrors!Atom { const evaluated_condition = try eval(conditional.data, env); const is_true = switch (evaluated_condition) { .number => if (evaluated_condition.number == 0.0) false else true, // only 0.0 is false! else => true, }; const first = conditional.next.?.data; // first branch if true const second = conditional.next.?.next.?.data; // take second branch if false return if (is_true) try eval(first, env) else try eval(second, env); } /// Define variables and functions pub fn handleDefSpecialForm(variable_name_node: *types.AtomList.Node, env: *Env) SyntaxErrors!Atom { const value_node = variable_name_node.next orelse return error.NoDefinedValue; const atom = try eval(value_node.data, env); const value = switch (atom) { .function => Value{ .func = Func{ .funcUser = atom.function } }, else => Value{ .atom = atom }, }; env.push(variable_name_node.data.keyword, value); return atom; } // build arg and body lists for function pub fn handleFnSpecialForm(args: *types.AtomList.Node, env: *Env) SyntaxErrors!Atom { var arg = AtomList{}; var argnode = AtomList.Node{ .data = args.data }; arg.prepend(&argnode); var bod = AtomList{}; if (args.next) |body| bod.prepend(body); var new_env = env.copy(); var func_data = Function{ .args = arg, .body = bod, .env = &new_env }; return Atom{ .function = &func_data }; } pub fn handleFunction(topnode: *types.AtomList.Node, env: *Env) SyntaxErrors!Atom { const next = topnode.next.?; var copy = AtomList.Node{ .data = try eval(next.data, env) }; var args = AtomList{}; args.prepend(&copy); var it = next.next; while (it) |node| : (it = node.next) { // traverse any other args var new_node = AtomList.Node{ .data = try eval(node.data, env) }; copy.insertAfter(&new_node); // append } const val = (try env.get(topnode.data.keyword)); switch (val) { .func => return try applyFunction(val.func, args), .atom => return val.atom, } return (try env.get(topnode.data.keyword)).atom; } pub fn applyFunction(func: Func, args: AtomList) !Atom { return switch (func) { .funcZero => func.funcZero.*(), .funcOne => func.funcOne.*(args.first.?.data), .funcTwo => func.funcTwo.*(args.first.?.data, args.first.?.next.?.data), .funcUser => blk: { const n = func.funcUser.args.first.?.data; var new_env = Env{ .outer = func.funcUser.env, .varlist = VarList{} }; switch (func.funcUser.args.first.?.data) { .list => { const names = Atom{ .list = n.list }; try new_env.addArgs(names.list, args); }, .keyword => { const names = Atom{ .keyword = n.keyword }; var list = AtomList{}; var node = AtomList.Node{ .data = names }; list.prepend(&node); try new_env.addArgs(list, args); }, else => return error.SomethingFellThroughTheEvalCracks, } break :blk try eval(Atom{ .list = func.funcUser.body }, &new_env); }, }; }
eval.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const mem = std.mem; test "for loop with pointer elem var" { const source = "abcdefg"; var target: [source.len]u8 = undefined; mem.copy(u8, target[0..], source); mangleString(target[0..]); try expect(mem.eql(u8, &target, "bcdefgh")); for (source) |*c, i| { _ = i; try expect(@TypeOf(c) == *const u8); } for (target) |*c, i| { _ = i; try expect(@TypeOf(c) == *u8); } } fn mangleString(s: []u8) void { for (s) |*c| { c.* += 1; } } test "basic for loop" { const expected_result = [_]u8{ 9, 8, 7, 6, 0, 1, 2, 3 } ** 3; var buffer: [expected_result.len]u8 = undefined; var buf_index: usize = 0; const array = [_]u8{ 9, 8, 7, 6 }; for (array) |item| { buffer[buf_index] = item; buf_index += 1; } for (array) |item, index| { _ = item; buffer[buf_index] = @intCast(u8, index); buf_index += 1; } const array_ptr = &array; for (array_ptr) |item| { buffer[buf_index] = item; buf_index += 1; } for (array_ptr) |item, index| { _ = item; buffer[buf_index] = @intCast(u8, index); buf_index += 1; } const unknown_size: []const u8 = &array; for (unknown_size) |item| { buffer[buf_index] = item; buf_index += 1; } for (unknown_size) |_, index| { buffer[buf_index] = @intCast(u8, index); buf_index += 1; } try expect(mem.eql(u8, buffer[0..buf_index], &expected_result)); } test "2 break statements and an else" { const S = struct { fn entry(t: bool, f: bool) !void { var buf: [10]u8 = undefined; var ok = false; ok = for (buf) |item| { _ = item; if (f) break false; if (t) break true; } else false; try expect(ok); } }; try S.entry(true, false); comptime try S.entry(true, false); } test "for with null and T peer types and inferred result location type" { const S = struct { fn doTheTest(slice: []const u8) !void { if (for (slice) |item| { if (item == 10) { break item; } } else null) |v| { _ = v; @panic("fail"); } } }; try S.doTheTest(&[_]u8{ 1, 2 }); comptime try S.doTheTest(&[_]u8{ 1, 2 }); } test "for copies its payload" { const S = struct { fn doTheTest() !void { var x = [_]usize{ 1, 2, 3 }; for (x) |value, i| { // Modify the original array x[i] += 99; try expectEqual(value, i + 1); } } }; try S.doTheTest(); comptime try S.doTheTest(); } test "for on slice with allowzero ptr" { const S = struct { fn doTheTest(slice: []const u8) !void { var ptr = @ptrCast([*]allowzero const u8, slice.ptr)[0..slice.len]; for (ptr) |x, i| try expect(x == i + 1); for (ptr) |*x, i| try expect(x.* == i + 1); } }; try S.doTheTest(&[_]u8{ 1, 2, 3, 4 }); comptime try S.doTheTest(&[_]u8{ 1, 2, 3, 4 }); }
test/behavior/for_stage1.zig
const std = @import("std"); const APEMetadata = @import("metadata.zig").APEMetadata; const Allocator = std.mem.Allocator; pub const APEHeader = struct { version: u32, /// Tag size in bytes including footer and all tag items tag_size: u32, item_count: u32, flags: APETagFlags, pub const len: usize = 32; pub const identifier = "APETAGEX"; pub fn read(reader: anytype) !APEHeader { const header = try reader.readBytesNoEof(APEHeader.len); if (!std.mem.eql(u8, header[0..8], identifier)) { return error.InvalidIdentifier; } return APEHeader{ .version = std.mem.readIntSliceLittle(u32, header[8..12]), .tag_size = std.mem.readIntSliceLittle(u32, header[12..16]), .item_count = std.mem.readIntSliceLittle(u32, header[16..20]), .flags = APETagFlags{ .flags = std.mem.readIntSliceLittle(u32, header[20..24]) }, // last 8 bytes are reserved, we can just assume they are zero // since erroring if they are non-zero seems unnecessary }; } pub fn sizeIncludingHeader(self: APEHeader) usize { return self.tag_size + (if (self.flags.hasHeader()) APEHeader.len else 0); } }; /// Shared between APE headers, footers, and items pub const APETagFlags = struct { flags: u32, pub fn hasHeader(self: APETagFlags) bool { return self.flags & (1 << 31) != 0; } pub fn hasFooter(self: APETagFlags) bool { return self.flags & (1 << 30) != 0; } pub fn isHeader(self: APETagFlags) bool { return self.flags & (1 << 29) != 0; } pub fn isReadOnly(self: APETagFlags) bool { return self.flags & 1 != 0; } pub const ItemDataType = enum { utf8, binary, external, reserved, }; pub fn itemDataType(self: APETagFlags) ItemDataType { const data_type_bits = (self.flags & 6) >> 1; return switch (data_type_bits) { 0 => .utf8, 1 => .binary, 2 => .external, 3 => .reserved, else => unreachable, }; } }; pub fn readFromHeader(allocator: Allocator, reader: anytype, seekable_stream: anytype) !APEMetadata { const start_offset = try seekable_stream.getPos(); const header = try APEHeader.read(reader); const end_offset = start_offset + APEHeader.len + header.tag_size; if (end_offset > try seekable_stream.getEndPos()) { return error.EndOfStream; } var ape_metadata = APEMetadata.init(allocator, header, start_offset, end_offset); errdefer ape_metadata.deinit(); const footer_size = if (header.flags.hasFooter()) APEHeader.len else 0; const end_of_items_offset = ape_metadata.metadata.end_offset - footer_size; try readItems(allocator, reader, seekable_stream, &ape_metadata, end_of_items_offset); if (header.flags.hasFooter()) { _ = try APEHeader.read(reader); } return ape_metadata; } /// Expects the seekable_stream position to be at the end of the footer that is being read. pub fn readFromFooter(allocator: Allocator, reader: anytype, seekable_stream: anytype) !APEMetadata { var end_pos = try seekable_stream.getPos(); if (end_pos < APEHeader.len) { return error.EndOfStream; } try seekable_stream.seekBy(-@intCast(i64, APEHeader.len)); const footer = try APEHeader.read(reader); // the size is meant to include the footer, so if it doesn't // have room for the footer we just read, it's invalid if (footer.tag_size < APEHeader.len) { return error.InvalidSize; } var ape_metadata = APEMetadata.init(allocator, footer, 0, 0); errdefer ape_metadata.deinit(); var metadata = &ape_metadata.metadata; metadata.end_offset = try seekable_stream.getPos(); const total_size = footer.sizeIncludingHeader(); if (total_size > metadata.end_offset) { return error.EndOfStream; } metadata.start_offset = metadata.end_offset - total_size; try seekable_stream.seekTo(metadata.start_offset); if (footer.flags.hasHeader()) { _ = try APEHeader.read(reader); } const end_of_items_offset = metadata.end_offset - APEHeader.len; try readItems(allocator, reader, seekable_stream, &ape_metadata, end_of_items_offset); return ape_metadata; } pub fn readItems(allocator: Allocator, reader: anytype, seekable_stream: anytype, ape_metadata: *APEMetadata, end_of_items_offset: usize) !void { var metadata_map = &ape_metadata.metadata.map; if (end_of_items_offset < 9) { return error.EndOfStream; } // The `- 9` comes from (u32 size + u32 flags + \x00 item key terminator) const end_of_items_offset_with_space_for_item = end_of_items_offset - 9; var i: usize = 0; while (i < ape_metadata.header_or_footer.item_count and try seekable_stream.getPos() < end_of_items_offset_with_space_for_item) : (i += 1) { const value_size = try reader.readIntLittle(u32); // short circuit for impossibly long values, no need to actually // allocate and try reading them const cur_pos = try seekable_stream.getPos(); if (cur_pos + value_size > end_of_items_offset) { return error.EndOfStream; } const item_flags = APETagFlags{ .flags = try reader.readIntLittle(u32) }; switch (item_flags.itemDataType()) { .utf8 => { const key = try reader.readUntilDelimiterAlloc(allocator, '\x00', end_of_items_offset - try seekable_stream.getPos()); defer allocator.free(key); var value = try allocator.alloc(u8, value_size); defer allocator.free(value); try reader.readNoEof(value); // reject invalid UTF-8 if (!std.unicode.utf8ValidateSlice(value)) { continue; } try metadata_map.put(key, value); }, // TODO: Maybe do something with binary/external data, for now // we're only interested in text metadata though .binary, .external, .reserved => { try reader.skipUntilDelimiterOrEof('\x00'); try seekable_stream.seekBy(value_size); }, } } // TODO: seems like we should do some validation here, // like checking that i == item_count or that we've read the // full data? }
src/ape.zig
const std = @import("std"); const log = std.log; const assert = std.debug.assert; const cudaz = @import("cudaz"); const cu = cudaz.cu; const png = @import("png.zig"); const utils = @import("utils.zig"); // const hw1_kernel = @import("hw1_kernel.zig"); const resources_dir = "resources/hw1_resources/"; pub fn main() anyerror!void { log.info("***** HW1 ******", .{}); var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){}; var alloc = general_purpose_allocator.allocator(); const args = try std.process.argsAlloc(alloc); defer std.process.argsFree(alloc, args); var stream = try cudaz.Stream.init(0); defer stream.deinit(); const img = try png.Image.fromFilePath(alloc, resources_dir ++ "cinque_terre_small.png"); defer img.deinit(); log.info("Loaded {}", .{img}); var d_img = try cudaz.allocAndCopy(png.Rgb24, img.px.rgb24); defer cudaz.free(d_img); var gray = try png.grayscale(alloc, img.width, img.height); defer gray.deinit(); var d_gray = try cudaz.alloc(png.Gray8, img.width * img.height); defer cudaz.free(d_gray); try cudaz.memset(png.Gray8, d_gray, 0); const kernel = try cudaz.Function("rgba_to_greyscale").init(); // const kernel = try cudaz.FnStruct("rgba_to_greyscale", hw1_kernel.rgba_to_greyscale).init(); var timer = cudaz.GpuTimer.start(&stream); try kernel.launch( &stream, cudaz.Grid.init1D(img.height * img.width, 64), .{ @ptrCast([*c]const cu.uchar3, d_img.ptr), @ptrCast([*c]u8, d_gray.ptr), @intCast(c_int, img.height), @intCast(c_int, img.width), // std.mem.sliceAsBytes(d_img), // std.mem.sliceAsBytes(d_gray), }, ); timer.stop(); stream.synchronize(); try cudaz.memcpyDtoH(png.Gray8, gray.px.gray8, d_gray); log.info("Got grayscale {}", .{img}); try gray.writeToFilePath(resources_dir ++ "output.png"); try utils.validate_output(alloc, resources_dir, 1.0); }
CS344/src/hw1.zig
const std = @import("std"); pub const DemoInterface = struct { instance: InstanceType, initFn: InitFn, deinitFn: DeinitFn, onUIFn: OnUIFn, isVisibleFn: IsVisibleFn, showFn: ShowFn, pub const InstanceType = *u8; pub const InitFn = fn (instance: InstanceType, allocator: std.mem.Allocator) anyerror!void; pub const DeinitFn = fn (instance: InstanceType) void; pub const OnUIFn = fn (instance: InstanceType) anyerror!void; pub const IsVisibleFn = fn (instance: InstanceType) bool; pub const ShowFn = fn (instance: InstanceType) void; const Self = @This(); pub fn init(self: *Self, allocator: std.mem.Allocator) anyerror!void { return self.initFn(self.instance, allocator); } pub fn deinit(self: *Self) void { self.deinitFn(self.instance); } pub fn onUI(self: *Self) anyerror!void { return self.onUIFn(self.instance); } pub fn isVisible(self: *Self) bool { return self.isVisibleFn(self.instance); } pub fn show(self: *Self) void { self.showFn(self.instance); } }; pub const NullDemo = struct { allocator: std.mem.Allocator, const Self = @This(); pub fn init(self: *Self, allocator: std.mem.Allocator) anyerror!void { self.allocator = allocator; } pub fn deinit(self: *Self) void { self.allocator.destroy(self); } pub fn onUI(self: *Self) !void { _ = self; return error.Nothing; } pub fn isVisible(self: *Self) bool { _ = self; return false; } pub fn show(self: *Self) void { _ = self; } pub fn getInterface(self: *Self) DemoInterface { return DemoInterface{ .instance = @ptrCast(DemoInterface.InstanceType, self), .initFn = @ptrCast(DemoInterface.InitFn, init), .deinitFn = @ptrCast(DemoInterface.DeinitFn, deinit), .onUIFn = @ptrCast(DemoInterface.OnUIFn, onUI), .isVisibleFn = @ptrCast(DemoInterface.IsVisibleFn, isVisible), .showFn = @ptrCast(DemoInterface.ShowFn, show), }; } };
src/demos/demo_interface.zig
const std = @import("std"); const os = std.os; const fmt = std.fmt; pub const proto = @import("proto.zig"); pub const resolv = @import("resolvconf.zig"); const dns = @import("dns"); const rdata = dns.rdata; pub const DNSPacket = dns.Packet; pub const DNSPacketRCode = dns.ResponseCode; pub const DNSClass = dns.Class; const Allocator = std.mem.Allocator; const MainDNSError = error{ UnknownReplyId, GotQuestion, RCodeErr, }; test "zigdig" { _ = @import("packet.zig"); _ = @import("proto.zig"); _ = @import("resolvconf.zig"); } /// Print a slice of DNSResource to stderr. fn printList(ctx: *dns.DeserializationContext, pkt: dns.Packet, resource_list: []dns.Resource) !void { // TODO the formatting here is not good... std.debug.warn(";;name\t\t\trrtype\tclass\tttl\trdata\n", .{}); for (resource_list) |resource| { var resource_data = try dns.ResourceData.fromOpaque(ctx, resource.typ, resource.opaque_rdata); std.debug.warn("{}\t{}\t{}\t{}\t{}\n", .{ resource.name, @tagName(resource.typ), @tagName(resource.class), resource.ttl, resource_data, }); } std.debug.warn("\n", .{}); } /// Print a packet to stderr. pub fn printPacket(ctx: *dns.DeserializationContext, pkt: dns.Packet) !void { std.debug.warn("id: {}, opcode: {}, rcode: {}\n", .{ pkt.header.id, pkt.header.opcode, pkt.header.response_code, }); std.debug.warn("qd: {}, an: {}, ns: {}, ar: {}\n\n", .{ pkt.header.question_length, pkt.header.answer_length, pkt.header.nameserver_length, pkt.header.additional_length, }); if (pkt.header.question_length > 0) { std.debug.warn(";;-- question --\n", .{}); std.debug.warn(";;name\ttype\tclass\n", .{}); for (pkt.questions) |question| { std.debug.warn(";{}\t{}\t{}\n", .{ question.name, @tagName(question.typ), @tagName(question.class), }); } std.debug.warn("\n", .{}); } if (pkt.header.answer_length > 0) { std.debug.warn(";; -- answer --\n", .{}); try printList(ctx, pkt, pkt.answers); } else { std.debug.warn(";; no answer\n", .{}); } if (pkt.header.nameserver_length > 0) { std.debug.warn(";; -- authority --\n", .{}); try printList(ctx, pkt, pkt.nameservers); } else { std.debug.warn(";; no authority\n\n", .{}); } if (pkt.header.additional_length > 0) { std.debug.warn(";; -- additional --\n", .{}); try printList(ctx, pkt, pkt.additionals); } else { std.debug.warn(";; no additional\n\n", .{}); } } /// Sends pkt over a given socket directed by `addr`, returns a boolean /// if this was successful or not. A value of false should direct clients /// to follow the next nameserver in the list. fn resolve(allocator: *Allocator, addr: *std.net.Address, pkt: DNSPacket) !bool { // TODO this fails on linux when addr is an ip6 addr... var sockfd = try proto.openDNSSocket(); errdefer std.os.close(sockfd); var buf = try allocator.alloc(u8, pkt.size()); try proto.sendDNSPacket(sockfd, addr, pkt, buf); var recvpkt = try proto.recvDNSPacket(sockfd, allocator); defer recvpkt.deinit(); std.debug.warn("recv packet: {}\n", .{recvpkt.header}); // safety checks against unknown udp replies on the same socket if (recvpkt.header.id != pkt.header.id) return MainDNSError.UnknownReplyId; if (!recvpkt.header.qr_flag) return MainDNSError.GotQuestion; switch (recvpkt.header.rcode) { .NoError => { try printPacket(recvpkt); return true; }, .ServFail => { // if SERVFAIL, the resolver should push to the next one. return false; }, .NotImpl, .Refused, .FmtError, .NameErr => { std.debug.warn("response code: {}\n", .{recvpkt.header.rcode}); return MainDNSError.RCodeErr; }, } } /// Make a DNSPacket containing a single question out of the question's /// QNAME and QTYPE. Both are strings and so are converted to the respective /// DNSName and DNSType enum values internally. /// Sets a random packet ID. pub fn makeDNSPacket( allocator: *std.mem.Allocator, name: []const u8, qtype_str: []const u8, ) !DNSPacket { var qtype = try dns.Type.fromStr(qtype_str); var pkt = DNSPacket.init(allocator, ""[0..]); // set random u16 as the id + all the other goodies in the header const seed = @truncate(u64, @bitCast(u128, std.time.nanoTimestamp())); var r = std.rand.DefaultPrng.init(seed); const random_id = r.random.int(u16); pkt.header.id = random_id; pkt.header.rd = true; var question = dns.Question{ .qname = try dns.Name.fromString(allocator, name), .qtype = qtype, .qclass = DNSClass.IN, }; try pkt.addQuestion(question); return pkt; } pub fn oldMain() anyerror!void { var allocator_instance = std.heap.GeneralPurposeAllocator(.{}){}; defer { _ = allocator_instance.deinit(); } const allocator = &allocator_instance.allocator; var args_it = std.process.args(); _ = args_it.skip(); const name = (args_it.nextPosix() orelse { std.debug.warn("no name provided\n", .{}); return error.InvalidArgs; }); const qtype = (args_it.nextPosix() orelse { std.debug.warn("no qtype provided\n", .{}); return error.InvalidArgs; }); var pkt = try makeDNSPacket(allocator, name, qtype); std.debug.warn("sending packet: {}\n", .{pkt.header}); // read /etc/resolv.conf for nameserver var nameservers = try resolv.readNameservers(allocator); defer resolv.freeNameservers(allocator, nameservers); for (nameservers.items) |nameserver| { if (nameserver[0] == 0) continue; // we don't know if the given nameserver address is ip4 or ip6, so we // try parsing it as ip4, then ip6. var ns_addr = try std.net.Address.parseIp(nameserver, 53); if (try resolve(allocator, &ns_addr, pkt)) break; } } pub fn main() !void { var allocator_instance = std.heap.GeneralPurposeAllocator(.{}){}; defer { _ = allocator_instance.deinit(); } const allocator = &allocator_instance.allocator; var args_it = std.process.args(); _ = args_it.skip(); const name_string = (args_it.nextPosix() orelse { std.debug.warn("no name provided\n", .{}); return error.InvalidArgs; }); const qtype_str = (args_it.nextPosix() orelse { std.debug.warn("no qtype provided\n", .{}); return error.InvalidArgs; }); const qtype = dns.ResourceType.fromString(qtype_str) catch |err| switch (err) { error.InvalidResourceType => { std.debug.warn("invalid query type provided\n", .{}); return error.InvalidArgs; }, }; var name_buffer: [128][]const u8 = undefined; const name = try dns.Name.fromString(name_string, &name_buffer); const packet = dns.Packet{ .header = .{ .id = dns.helpers.randomId(), .is_response = false, .wanted_recursion = true, .question_length = 1, }, .questions = &[_]dns.Question{ .{ .name = name, .typ = qtype, .class = .IN, }, }, .answers = &[_]dns.Resource{}, .nameservers = &[_]dns.Resource{}, .additionals = &[_]dns.Resource{}, }; std.debug.warn("{}\n", .{packet}); const conn = try dns.helpers.openSocketAnyResolver(); defer conn.file.close(); std.debug.warn("selected nameserver: {}\n", .{conn.address}); try dns.helpers.sendPacket(conn, packet); var work_memory: [0x100000]u8 = undefined; var fba = std.heap.FixedBufferAllocator.init(&work_memory); var ctx = dns.DeserializationContext.init(&fba.allocator); defer ctx.deinit(); const reply = try dns.helpers.recvPacket(conn, &ctx); std.debug.warn("reply!!!: {}\n", .{reply}); std.debug.assert(reply.header.id == packet.header.id); std.debug.assert(reply.header.is_response); try printPacket(&ctx, reply); }
src/main.zig
const std = @import("std"); pub const paging = @import("../paging.zig"); const dcommon = @import("../common/dcommon.zig"); const hw = @import("../hw.zig"); pub var K_DIRECTORY: *PageTable = undefined; pub const PAGING = paging.configuration(.{ .vaddress_mask = 0x0000003f_fffff000, }); comptime { std.debug.assert(dcommon.daintree_kernel_start == PAGING.kernel_base); } fn flagsToRWX(flags: paging.MapFlags) RWX { return switch (flags) { .non_leaf => RWX.non_leaf, .kernel_promisc => RWX.rwx, .kernel_data => RWX.rw, .kernel_rodata => RWX.ro, .kernel_code => RWX.rx, .peripheral => RWX.rw, }; } pub fn flushTLB() void { asm volatile ("sfence.vma" ::: "memory"); } pub fn mapPage(phys_address: usize, flags: paging.MapFlags) paging.Error!usize { return K_DIRECTORY.pageAt(256).mapFreePage(2, PAGING.kernel_base, phys_address, flags) orelse error.OutOfMemory; } pub const PageTable = packed struct { entries: [PAGING.index_size]u64, pub fn map(self: *PageTable, index: usize, phys_address: usize, flags: paging.MapFlags) void { self.entries[index] = (ArchPte{ .rwx = flagsToRWX(flags), .u = 0, .g = 0, .a = 1, // XXX ??? .d = 1, // XXX ??? .ppn = @truncate(u44, phys_address >> PAGING.page_bits), }).toU64(); } pub fn mapFreePage(self: *PageTable, comptime level: u2, base_address: usize, phys_address: usize, flags: paging.MapFlags) ?usize { var i: usize = 0; if (level < 3) { // Recurse into subtables. while (i < self.entries.len) : (i += 1) { if ((self.entries[i] & 0x1) == 0x0) { var new_phys = paging.bump.alloc(PageTable); self.map(i, @ptrToInt(new_phys), .non_leaf); } if ((self.entries[i] & 0xf) == 0x1) { // Valid non-leaf entry if (self.pageAt(i).mapFreePage( level + 1, base_address + (i << (PAGING.page_bits + PAGING.index_bits * (3 - level))), phys_address, flags, )) |addr| { return addr; } } } } else { while (i < self.entries.len) : (i += 1) { if ((self.entries[i] & 0x1) == 0) { // Empty page -- allocate. self.map(i, phys_address, flags); return base_address + (i << PAGING.page_bits); } } } return null; } fn pageAt(self: *const PageTable, index: usize) *PageTable { const entry = self.entries[index]; if ((entry & 0xf) != 0x1) @panic("pageAt on non-page"); return @intToPtr(*PageTable, ((entry & ArchPte.PPN_MASK) >> ArchPte.PPN_OFFSET) << PAGING.page_bits); } }; pub const STACK_PAGES = 16; pub const SATP = struct { pub fn toU64(satp: SATP) callconv(.Inline) u64 { return @as(u64, satp.ppn) | (@as(u64, satp.asid) << 44) | (@as(u64, @enumToInt(satp.mode)) << 60); } ppn: u44, asid: u16, mode: enum(u4) { bare = 0, sv39 = 8, sv48 = 9, }, }; pub const RWX = enum(u3) { non_leaf = 0b000, ro = 0b001, rw = 0b011, rx = 0b101, rwx = 0b111, }; pub const ArchPte = struct { pub const PPN_MASK: u64 = 0x003fffff_fffffc00; pub const PPN_OFFSET = 10; pub fn toU64(pte: ArchPte) callconv(.Inline) u64 { return @as(u64, pte.v) | (@as(u64, @enumToInt(pte.rwx)) << 1) | (@as(u64, pte.u) << 4) | (@as(u64, pte.g) << 5) | (@as(u64, pte.a) << 6) | (@as(u64, pte.d) << 7) | (@as(u64, pte.ppn) << 10); } // Set rwx=000 to indicate a non-leaf PTE. v: u1 = 1, rwx: RWX, u: u1, // Accessible to usermode. g: u1, // Global mapping (exists in all address spaces). a: u1, // Access bit. d: u1, // Dirty bit. // _res_rsw: u2, // Reserved; ignore. ppn: u44, // _res: u10, };
dainkrnl/src/riscv64/paging.zig
const clap = @import("clap"); const datetime = @import("datetime"); const message = @import("message.zig"); const producer = @import("producer.zig"); const sab = @import("sab"); const std = @import("std"); const event = std.event; const fs = std.fs; const heap = std.heap; const io = std.io; const log = std.log; const math = std.math; const mem = std.mem; const process = std.process; pub const io_mode = io.Mode.evented; const params = comptime blk: { @setEvalBranchQuota(100000); break :blk [_]clap.Param(clap.Help){ clap.parseParam("-h, --help Print this message to stdout") catch unreachable, clap.parseParam("-l, --low <COLOR> The color when a bar is a low value.") catch unreachable, clap.parseParam("-m, --mid <COLOR> The color when a bar is a medium value.") catch unreachable, clap.parseParam("-h, --high <COLOR> The color when a bar is a high value.") catch unreachable, }; }; fn usage(stream: anytype) !void { try stream.writeAll("Usage: "); try clap.usage(stream, &params); try stream.writeAll( \\ \\Help message here \\ \\Options: \\ ); try clap.help(stream, &params); } pub fn main() !void { var gba = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = &gba.allocator; defer _ = gba.deinit(); log.debug("Parsing arguments", .{}); var diag = clap.Diagnostic{}; var args = clap.parse(clap.Help, &params, .{ .diagnostic = &diag }) catch |err| { const stderr = io.getStdErr().writer(); diag.report(stderr, err) catch {}; usage(stderr) catch {}; return err; }; if (args.flag("--help")) return try usage(io.getStdOut().writer()); const low = args.option("--low") orelse "-"; const mid = args.option("--mid") orelse "-"; const high = args.option("--high") orelse "-"; log.debug("Getting $HOME", .{}); const home_dir_path = try process.getEnvVarOwned(allocator, "HOME"); defer allocator.free(home_dir_path); const home_dir = try fs.cwd().openDir(home_dir_path, .{}); //defer home_dir.close(); // Seems like ChildProcess is broken with `io_mode == .evented` // broken LLVM module found: Basic Block in function 'std.child_process.ChildProcess.spawnPosix' // does not have terminator! // label %OkResume //const xtitle = try std.ChildProcess.init(&[_][]const u8{"xtitle"}, allocator); //try xtitle.spawn(); var buf: [128]message.Message = undefined; var channel: event.Channel(message.Message) = undefined; channel.init(&buf); // event.Locked.init doesn't compile... var locked_state = event.Locked(State){ .lock = event.Lock{}, .private_data = State{ .now = datetime.Datetime.now() }, }; log.debug("Setting up pipeline", .{}); const p1 = async producer.date(&channel); const p2 = async producer.mem(&channel); const p3 = async producer.cpu(&channel); const p4 = async producer.rss(&channel, home_dir); const p5 = async producer.mail(&channel, home_dir); const p6 = async producer.bspwm(&channel); const c1 = async consumer(&channel, &locked_state); renderer(allocator, &locked_state, .{ .low = low, .mid = mid, .high = high, }) catch |err| { log.emerg("Failed to render bar: {}", .{err}); return err; }; log.debug("Goodnight", .{}); } const Options = struct { low: []const u8, mid: []const u8, high: []const u8, }; // This structure should be deep copiable, so that the renderer can keep // track of a `prev` version of the state for comparison. const State = struct { now: datetime.Datetime, mem_percent_used: u8 = 0, rss_unread: usize = 0, mail_unread: usize = 0, // Support up to 128 threads cpu_percent: [128]?u8 = [_]?u8{null} ** 128, monitors: [4]Monitor = [_]Monitor{.{}} ** 4, }; const Monitor = struct { is_active: bool = false, workspaces: [20]Workspace = [_]Workspace{.{}} ** 20, }; const Workspace = packed struct { is_active: bool = false, focused: bool = false, occupied: bool = false, }; fn consumer(channel: *event.Channel(message.Message), locked_state: *event.Locked(State)) void { const Cpu = struct { user: usize = 0, sys: usize = 0, idle: usize = 0, }; var cpu_last = [_]Cpu{.{}} ** 128; while (true) { const change = channel.get(); const held = locked_state.acquire(); const state = held.value; defer held.release(); switch (change) { .date => |now| state.now = now, .rss => |rss| state.rss_unread = rss.unread, .mail => |mail| state.mail_unread = mail.unread, .mem => |memory| { const used = memory.total - memory.available; state.mem_percent_used = @intCast(u8, (used * 100) / memory.total); }, .cpu => |cpu| { const i = cpu.id; const last = cpu_last[i]; const user = math.sub(usize, cpu.user, last.user) catch 0; const sys = math.sub(usize, cpu.sys, last.sys) catch 0; const idle = math.sub(usize, cpu.idle, last.idle) catch 0; const cpu_usage = ((user + sys) * 100) / math.max(1, user + sys + idle); state.cpu_percent[i] = @intCast(u8, cpu_usage); cpu_last[i] = .{ .user = cpu.user, .sys = cpu.sys, .idle = cpu.idle, }; }, .workspace => |workspace| { const mon = &state.monitors[workspace.monitor_id]; mon.is_active = true; mon.workspaces[workspace.id] = .{ .is_active = true, .focused = workspace.flags.focused, .occupied = workspace.flags.occupied, }; }, } } } // We seperate the renderer loop from the consumer loop, so that we can throttle // how often we redraw the bar. If the consumer was to render the bar on every message, // we would output multible bars when something happends close together. It is just // better to wait for a few more messages before drawing. The renderer will look at // the `locked_state` once in a while (N times per sec) and redraw of anything changed // from the last iteration. fn renderer(allocator: *mem.Allocator, locked_state: *event.Locked(State), options: Options) !void { const loop = event.Loop.instance.?; const stdout = io.getStdOut().writer(); const out = std.ArrayList(u8).init(allocator).writer(); const bars = [_][]const u8{ try std.fmt.allocPrint(allocator, "%{{F{s}}} ", .{options.low}), try std.fmt.allocPrint(allocator, "%{{F{s}}}▁", .{options.low}), try std.fmt.allocPrint(allocator, "%{{F{s}}}▂", .{options.low}), try std.fmt.allocPrint(allocator, "%{{F{s}}}▃", .{options.mid}), try std.fmt.allocPrint(allocator, "%{{F{s}}}▄", .{options.mid}), try std.fmt.allocPrint(allocator, "%{{F{s}}}▅", .{options.mid}), try std.fmt.allocPrint(allocator, "%{{F{s}}}▆", .{options.high}), try std.fmt.allocPrint(allocator, "%{{F{s}}}▇", .{options.high}), try std.fmt.allocPrint(allocator, "%{{F{s}}}█", .{options.high}), }; var prev = blk: { const held = locked_state.acquire(); defer held.release(); break :blk held.value.*; }; while (true) : (loop.sleep(std.time.ns_per_s / 15)) { const curr = blk: { const held = locked_state.acquire(); defer held.release(); break :blk held.value.*; }; if (std.meta.eql(prev, curr)) continue; prev = curr; for (curr.monitors) |monitor, mon_id| { if (!monitor.is_active) continue; try out.print("%{{S{}}}", .{mon_id}); try out.writeAll("%{l} "); for (monitor.workspaces) |workspace, i| { if (!workspace.is_active) continue; const focus: usize = @boolToInt(workspace.focused); const occupied: usize = @boolToInt(workspace.occupied); try out.print("%{{+o}}{s} {}{s}{s}%{{-o}}", .{ ([_][]const u8{ "", "%{+u}" })[focus], i + 1, ([_][]const u8{ " ", "*" })[occupied], ([_][]const u8{ "", "%{-u}" })[focus], }); } try out.writeAll("%{r}"); try out.print("%{{+o}} mail:rss {:0>2}:{:0>2} %{{-o}} ", .{ curr.mail_unread, curr.rss_unread }); try out.writeAll("%{+o} "); try sab.draw(out, u8, curr.mem_percent_used, .{ .len = 1, .steps = &bars }); try out.writeAll("%{F-} "); for (curr.cpu_percent) |m_cpu| { const cpu = m_cpu orelse continue; try sab.draw(out, u8, cpu, .{ .len = 1, .steps = &bars }); } try out.writeAll("%{F-} %{-o} "); // Danish daylight saving fixup code var date = curr.now; const summer_start = try datetime.Datetime.create(date.date.year, 3, 28, 2, 0, 0, 0, date.zone); const summer_end = try datetime.Datetime.create(date.date.year, 10, 31, 3, 0, 0, 0, date.zone); if (summer_start.lte(date) and date.lte(summer_end)) date = date.shiftHours(1); try out.print("%{{+o}} {s} {d:0>2} {s} {d:0>2}:{d:0>2} %{{-o}} ", .{ date.date.monthName()[0..3], date.date.day, @tagName(date.date.dayOfWeek())[0..3], date.time.hour, date.time.minute, }); } try out.writeAll("\n"); try stdout.writeAll(out.context.items); out.context.shrinkRetainingCapacity(0); } }
src/main.zig
const builtin = @import("builtin"); const std = @import("std"); const math = std.math; const mem = std.mem; const meta = std.meta; const testing = std.testing; const trait = meta.trait; /// Find the field name which is most likly to be the tag of 'union_field'. /// This function looks at all fields declared before 'union_field'. If one /// of these field is an enum which has the same fields as the 'union_field's /// type, then that is assume to be the tag of 'union_field'. pub fn findTagFieldName(comptime Container: type, comptime union_field: []const u8) ?[]const u8 { const info = @typeInfo(Container); if (info != .Struct) @compileError(@typeName(Container) ++ " is not a struct."); const container_fields = info.Struct.fields; const u_index = for (container_fields) |f, i| { if (mem.eql(u8, f.name, union_field)) break i; } else { @compileError("No field called " ++ union_field ++ " in " ++ @typeName(Container)); }; const union_info = @typeInfo(container_fields[u_index].field_type); if (union_info != .Union) @compileError(union_field ++ " is not a union."); // Check all fields before 'union_field'. outer: for (container_fields) |field, i| { if (u_index <= i) break; const Enum = field.field_type; const enum_info = @typeInfo(Enum); if (enum_info != .Enum) continue; // Check if 'Enum' and 'Union' have the same names // of their fields. const u_fields = union_info.Union.fields; const e_fields = enum_info.Enum.fields; if (u_fields.len != e_fields.len) continue; // The 'Enum' and 'Union' have to have the same fields for (u_fields) |u_field| { if (!@hasField(Enum, u_field.name)) continue :outer; } return field.name; } return null; } fn testFindTagFieldName(comptime Container: type, comptime union_field: []const u8, expect: ?[]const u8) !void { if (comptime findTagFieldName(Container, union_field)) |actual| { try testing.expectEqualStrings(expect.?, actual); } else { try testing.expectEqual(expect, null); } } test "findTagFieldName" { const Union = union { a: void, b: u8, c: u16, }; const Tag = enum { a, b, c, }; try testFindTagFieldName(struct { tag: Tag, un: Union, }, "un", "tag"); try testFindTagFieldName(struct { tag: Tag, not_tag: u8, un: Union, not_tag2: struct {}, not_tag3: enum { a, b, q, }, }, "un", "tag"); try testFindTagFieldName(struct { not_tag: u8, un: Union, not_tag2: struct {}, not_tag3: enum { a, b, q, }, }, "un", null); } /// Calculates the packed size of 'value'. The packed size is the size 'value' /// would have if unions did not have to have the size of their biggest field. pub fn packedLength(value: anytype) error{InvalidTag}!usize { @setEvalBranchQuota(10000000); const T = @TypeOf(value); switch (@typeInfo(T)) { .Void => return 0, .Int => |i| { if (i.bits % 8 != 0) @compileError("Does not support none power of two intergers"); return @as(usize, i.bits / 8); }, .Enum => return packedLength(@enumToInt(value)) catch unreachable, .Array => { var res: usize = 0; for (value) |item| res += try packedLength(item); return res; }, .Struct => |s| { if (s.layout != .Packed) @compileError(@typeName(T) ++ " is not packed"); var res: usize = 0; inline for (s.fields) |struct_field| { switch (@typeInfo(struct_field.field_type)) { .Union => |u| { if (u.layout != .Packed and u.layout != .Extern) @compileError(@typeName(struct_field.field_type) ++ " is not packed or extern"); if (u.tag_type != null) @compileError(@typeName(struct_field.field_type) ++ " cannot have a tag."); // Find the field most likly to be this unions tag. const tag_field = (comptime findTagFieldName(T, struct_field.name)) orelse @compileError("Could not find a tag for " ++ struct_field.name ++ " in " ++ @typeName(T)); const tag = @field(value, tag_field); const union_value = @field(value, struct_field.name); const TagEnum = @TypeOf(tag); // Switch over all tags. 'TagEnum' have the same field names as // 'union' so if one member of 'TagEnum' matches 'tag', then // we can add the size of ''@field(union, tag_name)' to res and // break out. var found: bool = false; inline for (@typeInfo(TagEnum).Enum.fields) |enum_field| { if (@field(TagEnum, enum_field.name) == tag) { const union_field = @field(union_value, enum_field.name); res += try packedLength(union_field); found = true; } } // If no member of 'TagEnum' match, then 'tag' must be a value // it is not suppose to be. if (!found) return error.InvalidTag; }, else => res += try packedLength(@field(value, struct_field.name)), } } return res; }, else => @compileError(@typeName(T) ++ " not supported"), } } fn testPackedLength(value: anytype, expect: error{InvalidTag}!usize) !void { if (packedLength(value)) |size| { const expected_size = expect catch unreachable; try testing.expectEqual(expected_size, size); } else |err| { const expected_err = if (expect) |_| unreachable else |e| e; try testing.expectEqual(expected_err, err); } } test "packedLength" { const E = enum(u8) { a, b, c, }; const U = packed union { a: void, b: u8, c: u16, }; const S = packed struct { tag: E, pad: u8, data: U, }; try testPackedLength(S{ .tag = E.a, .pad = 0, .data = U{ .a = {} } }, 2); try testPackedLength(S{ .tag = E.b, .pad = 0, .data = U{ .b = 0 } }, 3); try testPackedLength(S{ .tag = E.c, .pad = 0, .data = U{ .c = 0 } }, 4); } pub fn CommandDecoder(comptime Command: type, comptime isEnd: fn (Command) bool) type { return struct { bytes: []u8, i: usize = 0, pub fn next(decoder: *@This()) !?*Command { const bytes = decoder.bytes[decoder.i..]; if (bytes.len == 0) return null; var buf = [_]u8{0} ** @sizeOf(Command); const len = math.min(bytes.len, buf.len); // Copy the bytes to a buffer of size @sizeOf(Command). // The reason this is done is that s.len might be smaller // than @sizeOf(Command) but still contain a command because // encoded commands can be smaller that @sizeOf(Command). // If the command we are trying to decode is invalid this // will be caught by the calculation of the commands length. mem.copy(u8, &buf, bytes[0..len]); const command = mem.bytesAsSlice(Command, buf[0..])[0]; const command_len = try packedLength(command); if (decoder.bytes.len - decoder.i < command_len) return error.InvalidCommand; decoder.i += command_len; if (isEnd(command)) decoder.bytes = decoder.bytes[0..decoder.i]; return @ptrCast(*Command, bytes.ptr); } }; }
src/core/script.zig
const std = @import("std"); const gl = @import("opengl.zig"); const math = std.math; const default_allocator = std.heap.page_allocator; const ArrayList = std.ArrayList; usingnamespace @import("util.zig"); pub const window_name = "genexp003"; pub const window_width = 1920; pub const window_height = 1080; pub const GenerativeExperimentState = struct { prng: std.rand.DefaultPrng, square: SandShape, triangle: SandShape, circle: SandShape, pub fn init() GenerativeExperimentState { return GenerativeExperimentState{ .prng = std.rand.DefaultPrng.init(0), .square = SandShape.init(default_allocator), .triangle = SandShape.init(default_allocator), .circle = SandShape.init(default_allocator), }; } pub fn deinit(self: GenerativeExperimentState) void { self.square.deinit(); self.triangle.deinit(); self.circle.deinit(); } }; const SandPoint = struct { p: [16]Vec2, fn init(x: f32, y: f32, rand: *std.rand.Random) SandPoint { var self = SandPoint{ .p = undefined }; for (self.p) |*p| { p.*.x = x + (16.0 * rand.float(f32) - 8.0); p.*.y = y + (16.0 * rand.float(f32) - 8.0); } return self; } }; const SandShape = struct { points: ArrayList(SandPoint), fn init(allocator: *std.mem.Allocator) SandShape { return SandShape{ .points = ArrayList(SandPoint).init(allocator), }; } fn deinit(self: SandShape) void { self.points.deinit(); } fn draw(self: SandShape) void { gl.begin(gl.LINES); for (self.points.items) |point, point_index| { for (point.p) |p0, i| { const p1 = &self.points.items[(point_index + 1) % self.points.items.len].p[i]; gl.vertex2f(p0.x, p0.y); gl.vertex2f(p1.x, p1.y); } } gl.end(); } }; pub fn setup(genexp: *GenerativeExperimentState) !void { const rand = &genexp.prng.random; try genexp.square.points.append(SandPoint.init(-100.0, -100.0, rand)); try genexp.square.points.append(SandPoint.init(100.0, -100.0, rand)); try genexp.square.points.append(SandPoint.init(100.0, 100.0, rand)); try genexp.square.points.append(SandPoint.init(-100.0, 100.0, rand)); try genexp.triangle.points.append(SandPoint.init(0.0, 100.0, rand)); try genexp.triangle.points.append(SandPoint.init(-100.0, -100.0, rand)); try genexp.triangle.points.append(SandPoint.init(100.0, -100.0, rand)); { const num_segments: u32 = 8; var i: u32 = 0; while (i < num_segments) : (i += 1) { const f = @intToFloat(f32, i) / @intToFloat(f32, num_segments); const x = 120.0 * math.cos(2.0 * math.pi * f); const y = 120.0 * math.sin(2.0 * math.pi * f); try genexp.circle.points.append(SandPoint.init(x, y, rand)); } } gl.enable(gl.BLEND); gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); } pub fn update(genexp: *GenerativeExperimentState, time: f64, dt: f32) void { gl.clearBufferfv(gl.COLOR, 0, &[4]f32{ 1.0, 1.0, 1.0, 1.0 }); gl.color4f(0.0, 0.0, 0.0, 0.5); gl.pushMatrix(); gl.translatef(-300.0, 0.0, 0.0); genexp.square.draw(); gl.popMatrix(); gl.pushMatrix(); gl.translatef(300.0, 0.0, 0.0); genexp.triangle.draw(); gl.popMatrix(); gl.pushMatrix(); gl.translatef(0.0, 300.0, 0.0); genexp.circle.draw(); gl.popMatrix(); }
src/genexp003.zig
const std = @import("std"); const UserCmdInfo = struct { tick_count: i32, view_angles: [3]f32, forwardmove: f32, sidemove: f32, upmove: f32, buttons: u32, }; fn parseUserCmdInfo(buf: []const u8, prev: UserCmdInfo) !UserCmdInfo { var stream = std.io.fixedBufferStream(buf); var br = std.io.bitReader(.Little, stream.reader()); var info = prev; if (1 == try br.readBitsNoEof(u1, 1)) { _ = try br.reader().readIntLittle(i32); // CommandNumber } if (1 == try br.readBitsNoEof(u1, 1)) { info.tick_count = try br.reader().readIntLittle(i32); } if (1 == try br.readBitsNoEof(u1, 1)) { info.view_angles[0] = @bitCast(f32, try br.reader().readIntLittle(i32)); } if (1 == try br.readBitsNoEof(u1, 1)) { info.view_angles[1] = @bitCast(f32, try br.reader().readIntLittle(i32)); } if (1 == try br.readBitsNoEof(u1, 1)) { info.view_angles[2] = @bitCast(f32, try br.reader().readIntLittle(i32)); } if (1 == try br.readBitsNoEof(u1, 1)) { info.forwardmove = @bitCast(f32, try br.reader().readIntLittle(i32)); } else { info.forwardmove = 0; } if (1 == try br.readBitsNoEof(u1, 1)) { info.sidemove = @bitCast(f32, try br.reader().readIntLittle(i32)); } else { info.sidemove = 0; } if (1 == try br.readBitsNoEof(u1, 1)) { _ = @bitCast(f32, try br.reader().readIntLittle(i32)); // UpMove } if (1 == try br.readBitsNoEof(u1, 1)) { info.buttons = try br.reader().readIntLittle(u32); } else { info.buttons = 0; } return info; } pub fn convert(r: anytype, w: anytype) !void { if (!try r.isBytes("HL2DEMO\x00")) return error.BadDemo; // DemoFileStamp if (4 != try r.readIntLittle(i32)) return error.BadDemo; // DemoProtocol try r.skipBytes(4, .{}); // NetworkProtocol try r.skipBytes(260, .{}); // ServerName try r.skipBytes(260, .{}); // ClientName const map_name = try r.readBytesNoEof(260); try r.skipBytes(260, .{}); // GameDirectory try r.skipBytes(4, .{}); // PlaybackTime try r.skipBytes(4, .{}); // PlaybackTicks try r.skipBytes(4, .{}); // PlaybackFrames try r.skipBytes(4, .{}); // SignOnLength try w.print("start map {s}\n", .{std.mem.sliceTo(&map_name, 0)}); try w.print("0>\n", .{}); var last_tick: i32 = 0; var last_cmd_info = UserCmdInfo{ .tick_count = 0, .view_angles = .{ 0, 0, 0 }, .forwardmove = 0, .sidemove = 0, .upmove = 0, .buttons = 0, }; while (true) { const msg = r.readIntLittle(u8) catch |err| switch (err) { error.EndOfStream => break, else => |e| return e, }; const tick = try r.readIntLittle(i32); const slot = try r.readIntLittle(u8); _ = slot; switch (msg) { 1, 2 => { // SignOn/Packet try r.skipBytes(76 * 2, .{}); // PacketInfo try r.skipBytes(4, .{}); // InSequence try r.skipBytes(4, .{}); // OutSequence const size = try r.readIntLittle(u32); try r.skipBytes(size, .{}); // Data }, 3 => {}, // SyncTick 4 => { // ConsoleCmd const size = try r.readIntLittle(u32); try r.skipBytes(size, .{}); // Data }, 5 => { // UserCmd try r.skipBytes(4, .{}); // Cmd const size = try r.readIntLittle(u32); if (tick <= last_tick) { // skip this one try r.skipBytes(size, .{}); } else { // try and parse it var buf: [64]u8 = undefined; try r.readNoEof(buf[0..size]); const info = try parseUserCmdInfo(buf[0..size], last_cmd_info); if (last_tick == 0) { last_cmd_info.view_angles = info.view_angles; } const buttons_off = "jduzbo"; const buttons_on = "JDUZBO"; const buttons_mask = [6]u32{ 1 << 1, 1 << 2, 1 << 5, 1 << 19, 1 << 0, 1 << 11 }; var buttons: [6]u8 = undefined; for (buttons) |*b, i| { b.* = if ((buttons_mask[i] & info.buttons) != 0) buttons_on[i] else buttons_off[i]; } try w.print("+{}>{d} {d}||{s}||setang {d} {d}\n", .{ tick - last_tick, info.sidemove / 175.0, info.forwardmove / 175.0, &buttons, info.view_angles[0], info.view_angles[1], }); last_tick = tick; last_cmd_info = info; } }, 6 => { // DataTables const size = try r.readIntLittle(u32); try r.skipBytes(size, .{}); // Data }, 7 => { // Stop std.log.info("Reached stop message at tick {}", .{tick}); break; }, 8 => { // CustomData try r.skipBytes(4, .{}); // Type const size = try r.readIntLittle(u32); try r.skipBytes(size, .{}); // Data }, 9 => { // StringTables const size = try r.readIntLittle(u32); try r.skipBytes(size, .{}); // Data }, else => return error.BadDemo, } } } pub fn main() anyerror!void { var dem = try std.fs.cwd().openFile("demo.dem", .{}); defer dem.close(); var tas = try std.fs.cwd().createFile("tas.p2tas", .{}); defer tas.close(); var buf_dem = std.io.bufferedReader(dem.reader()); var buf_tas = std.io.bufferedWriter(tas.writer()); try convert(buf_dem.reader(), buf_tas.writer()); try buf_tas.flush(); }
src/main.zig
usingnamespace @import("common.zig"); usingnamespace @import("pipelines.zig"); const camera = @import("camera.zig"); const cube_cpu = @import("cube.zig").cpu_mesh; const MAX_LAYER_COUNT = 16; const MAX_EXT_COUNT = 16; const FRAME_LATENCY = 3; const MESH_UPLOAD_QUEUE_SIZE = 16; const WIDTH = 1600; const HEIGHT = 900; const USE_VALIDATION = std.builtin.mode != .ReleaseFast; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = &gpa.allocator; pub fn main() !void { // exit doesn't play well with defers, // so we use an inner function to ensure they run. try mainNoExit(); std.os.exit(0); } pub fn mainNoExit() !void { const qtr_pi = 0.7853981625; var main_cam: camera.Camera = .{ .transform = .{ .position = .{0, 0, 10} }, .aspect = @intToFloat(f32, WIDTH) / @intToFloat(f32, HEIGHT), .fov = qtr_pi, .near = 0.01, .far = 100, }; var controller: camera.EditorCameraController = .{ .speed = 10 }; try sdl.Init(.{ .video = true }); defer sdl.Quit(); const centered = sdl.Window.pos_centered; const window = try sdl.Window.create("SDL Test", centered, centered, WIDTH, HEIGHT, .{ .vulkan = true }); defer window.destroy(); // Create vulkan instance var instance = blk: { var layers: StackBuffer([*:0]const u8, MAX_LAYER_COUNT) = .{}; { const instance_layer_count = try vk.EnumerateInstanceLayerPropertiesCount(); if (instance_layer_count > 0) { const instance_layers_buf = try allocator.alloc(vk.LayerProperties, instance_layer_count); defer allocator.free(instance_layers_buf); const instance_layers = (try vk.EnumerateInstanceLayerProperties(instance_layers_buf)).properties; if (USE_VALIDATION) { const validation_layer_name = "VK_LAYER_KHRONOS_validation"; if (hasLayer(validation_layer_name, instance_layers)) { layers.add(validation_layer_name); } else { std.debug.print("Warning: Validation requested, but layer "++validation_layer_name++" does not exist on this computer.\n", .{}); std.debug.print("Validation will not be enabled.\n", .{}); } } } } var extensions: StackBuffer([*:0]const u8, MAX_EXT_COUNT) = .{}; extensions.count = (try sdl.vulkan.getInstanceExtensions(window, &extensions.buf)).len; // Our shaders require this extension. //extensions.add(vk.GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME); if (USE_VALIDATION) { extensions.add(vk.EXT_DEBUG_UTILS_EXTENSION_NAME); } const app_info: vk.ApplicationInfo = .{ .pApplicationName = "SDL Test", .applicationVersion = vk.MAKE_VERSION(0, 0, 1), .pEngineName = "SDL Test", .engineVersion = vk.MAKE_VERSION(0, 0, 1), .apiVersion = vk.API_VERSION_1_1, }; break :blk try vk.CreateInstance(.{ .pApplicationInfo = &app_info, .enabledLayerCount = @intCast(u32, layers.count), .ppEnabledLayerNames = &layers.buf, .enabledExtensionCount = @intCast(u32, extensions.count), .ppEnabledExtensionNames = &extensions.buf, }, null); }; defer vk.DestroyInstance(instance, null); var d = try Demo.init(window, instance); defer d.deinit(); var cube_transform: Transform = .{}; var running = true; var last_time_ms: f32 = 0; run_loop: while (running) { // Crunch some numbers const time_ms = @intToFloat(f32, sdl.getTicks()); defer last_time_ms = time_ms; const time_seconds = time_ms / 1000.0; const delta_time_ms = time_ms - last_time_ms; const delta_time_seconds = delta_time_ms / 1000.0; const time_ns: f32 = 0; const time_us: f32 = 0; controller.newFrame(); // Process events until we have seen them all while (sdl.pollEvent()) |e| { if (e.type == .QUIT) { running = false; break :run_loop; } controller.handleEvent(e); } // Move the camera controller.updateCamera(delta_time_seconds, &main_cam); // Spin cube cube_transform.rotation[1] += 1.0 * delta_time_seconds; const cube_obj_mat = cube_transform.toMatrix(); const vp = main_cam.viewProjection(); const cube_mvp = mulmf44(vp, cube_obj_mat); // Pass time to shader d.push_constants.time = .{time_seconds, time_ms, time_ns, time_us}; d.push_constants.resolution = .{ @intToFloat(f32, d.swap_width), @intToFloat(f32, d.swap_height), }; d.push_constants.mvp = cube_mvp; d.push_constants.m = cube_obj_mat; try d.renderFrame(); } } const Demo = struct { instance: vk.Instance, gpu: vk.PhysicalDevice, gpu_props: vk.PhysicalDeviceProperties, queue_props: []vk.QueueFamilyProperties, gpu_features: vk.PhysicalDeviceFeatures, surface: vk.SurfaceKHR, graphics_queue_family_index: u32, present_queue_family_index: u32, separate_present_queue: bool, device: vk.Device, present_queue: vk.Queue, graphics_queue: vk.Queue, vma_allocator: vma.Allocator, swapchain_image_format: vk.Format, swapchain: vk.SwapchainKHR, swapchain_image_count: u32, swap_width: u32, swap_height: u32, render_pass: vk.RenderPass, pipeline_cache: vk.PipelineCache, pipeline_layout: vk.PipelineLayout, fractal_pipeline: vk.Pipeline, mesh_pipeline: vk.Pipeline, swapchain_images: [FRAME_LATENCY]vk.Image = [_]vk.Image{.Null} ** FRAME_LATENCY, swapchain_image_views: [FRAME_LATENCY]vk.ImageView = [_]vk.ImageView{.Null} ** FRAME_LATENCY, swapchain_framebuffers: [FRAME_LATENCY]vk.Framebuffer = [_]vk.Framebuffer{.Null} ** FRAME_LATENCY, command_pools: [FRAME_LATENCY]vk.CommandPool = [_]vk.CommandPool{.Null} ** FRAME_LATENCY, upload_buffers: [FRAME_LATENCY]vk.CommandBuffer = [_]vk.CommandBuffer{.Null} ** FRAME_LATENCY, graphics_buffers: [FRAME_LATENCY]vk.CommandBuffer = [_]vk.CommandBuffer{.Null} ** FRAME_LATENCY, upload_complete_sems: [FRAME_LATENCY]vk.Semaphore = [_]vk.Semaphore{.Null} ** FRAME_LATENCY, img_acquired_sems: [FRAME_LATENCY]vk.Semaphore = [_]vk.Semaphore{.Null} ** FRAME_LATENCY, swapchain_image_sems: [FRAME_LATENCY]vk.Semaphore = [_]vk.Semaphore{.Null} ** FRAME_LATENCY, render_complete_sems: [FRAME_LATENCY]vk.Semaphore = [_]vk.Semaphore{.Null} ** FRAME_LATENCY, frame_idx: u32 = 0, swap_img_idx: u32 = 0, fences: [FRAME_LATENCY]vk.Fence = [_]vk.Fence{.Null} ** FRAME_LATENCY, cube_gpu: GpuMesh, mesh_upload_count: u32 = 0, mesh_upload_queue: [MESH_UPLOAD_QUEUE_SIZE]GpuMesh = undefined, push_constants: PushConstants = .{ .time = Float4{0,0,0,0}, .resolution = Float2{1,1}, .mvp = .{}, .m = .{}, }, fn init(window: *sdl.Window, instance: vk.Instance) !Demo { const gpu = try selectGpu(instance); const gpu_props = vk.GetPhysicalDeviceProperties(gpu); const queue_family_count = vk.GetPhysicalDeviceQueueFamilyPropertiesCount(gpu); var queue_props = try allocator.alloc(vk.QueueFamilyProperties, queue_family_count); errdefer allocator.free(queue_props); const actual_len = vk.GetPhysicalDeviceQueueFamilyProperties(gpu, queue_props).len; queue_props = allocator.shrink(queue_props, actual_len); const gpu_features = vk.GetPhysicalDeviceFeatures(gpu); const surface = try sdl.vulkan.createSurface(window, instance); var present_index: ?u32 = null; var graphics_index: ?u32 = null; for (queue_props) |*f, i| { const supports_present = (try vk.GetPhysicalDeviceSurfaceSupportKHR(gpu, @intCast(u32, i), surface)) != 0; const supports_graphics = f.queueFlags.graphics; if (supports_graphics and supports_present) { present_index = @intCast(u32, i); graphics_index = @intCast(u32, i); break; } if (supports_graphics and graphics_index == null) { graphics_index = @intCast(u32, i); } if (supports_present and present_index == null) { present_index = @intCast(u32, i); } } if (present_index == null) return error.NoPresentQueueFound; if (graphics_index == null) return error.NoGraphicsQueueFound; var device_ext_names: StackBuffer([*:0]const u8, MAX_EXT_COUNT) = .{}; device_ext_names.add(vk.KHR_SWAPCHAIN_EXTENSION_NAME); const device = try createDevice(gpu, graphics_index.?, present_index.?, device_ext_names.span()); const graphics_queue = vk.GetDeviceQueue(device, graphics_index.?, 0); const present_queue = if (present_index.? == graphics_index.?) graphics_queue else vk.GetDeviceQueue(device, present_index.?, 0); // Create Allocator const vma_funcs = vma.VulkanFunctions.init(instance, device); const vma_alloc = try vma.Allocator.create(.{ .physicalDevice = gpu, .device = device, .pVulkanFunctions = &vma_funcs, .instance = instance, .vulkanApiVersion = vk.API_VERSION_1_0, .frameInUseCount = 0, }); const surface_format = blk: { const format_count = try vk.GetPhysicalDeviceSurfaceFormatsCountKHR(gpu, surface); const formats_buf = try allocator.alloc(vk.SurfaceFormatKHR, format_count); defer allocator.free(formats_buf); const formats = (try vk.GetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, formats_buf)).surfaceFormats; break :blk pickSurfaceFormat(formats); }; // Create Swapchain var swap_img_count: u32 = FRAME_LATENCY; var width: u32 = WIDTH; var height: u32 = HEIGHT; const swapchain = create_swapchain: { const present_mode = blk: { const present_mode_count = try vk.GetPhysicalDeviceSurfacePresentModesCountKHR(gpu, surface); const present_modes_buf = try allocator.alloc(vk.PresentModeKHR, present_mode_count); defer allocator.free(present_modes_buf); const present_modes = (try vk.GetPhysicalDeviceSurfacePresentModesKHR(gpu, surface, present_modes_buf)).presentModes; // The FIFO present mode is guaranteed by the spec to be supported // and to have no tearing. It's a great default present mode to use. // ^ This comment is from the C code, but it prefers the immediate mode // and can only happen to choose fifo if that mode is first. const preferred_present_modes = [_]vk.PresentModeKHR{ .IMMEDIATE, .FIFO, }; const present_mode_index = std.mem.indexOfAny(vk.PresentModeKHR, present_modes, &preferred_present_modes) orelse 0; break :blk present_modes[present_mode_index]; }; const surf_caps = try vk.GetPhysicalDeviceSurfaceCapabilitiesKHR(gpu, surface); var swapchain_extent: vk.Extent2D = undefined; // width and height are either both 0xFFFFFFFF, or both not 0xFFFFFFFF. if (surf_caps.currentExtent.width == 0xFFFFFFFF) { // If the surface size is undefined, the size is set to the size // of the images requested, which must fit within the minimum and // maximum values. swapchain_extent = .{ .width = std.math.clamp(WIDTH, surf_caps.minImageExtent.width, surf_caps.maxImageExtent.width), .height = std.math.clamp(HEIGHT, surf_caps.minImageExtent.height, surf_caps.maxImageExtent.height), }; } else { // If the surface size is defined, the swap chain size must match swapchain_extent = surf_caps.currentExtent; width = surf_caps.currentExtent.width; height = surf_caps.currentExtent.height; } // Determine the number of VkImages to use in the swap chain. // Application desires to acquire 3 images at a time for triple // buffering if (swap_img_count < surf_caps.minImageCount) { swap_img_count = surf_caps.minImageCount; } // If maxImageCount is 0, we can ask for as many images as we want; // otherwise we're limited to maxImageCount if ((surf_caps.maxImageCount > 0) and (swap_img_count > surf_caps.maxImageCount)) { // Application must settle for fewer images than desired: swap_img_count = surf_caps.maxImageCount; } var pre_transform: vk.SurfaceTransformFlagsKHR = .{}; if (surf_caps.supportedTransforms.identity) { pre_transform.identity = true; } else { pre_transform = surf_caps.currentTransform; } const preferred_alpha_flags = [_]vk.CompositeAlphaFlagsKHR{ .{ .opaqueBit = true }, .{ .preMultiplied = true }, .{ .postMultiplied = true }, .{ .inherit = true }, }; const composite_alpha: vk.CompositeAlphaFlagsKHR = for (preferred_alpha_flags) |f| { if (surf_caps.supportedCompositeAlpha.hasAllSet(f)) { break f; } } else .{ .opaqueBit = true }; break :create_swapchain try vk.CreateSwapchainKHR(device, .{ .surface = surface, .minImageCount = swap_img_count, .imageFormat = surface_format.format, .imageColorSpace = surface_format.colorSpace, .imageExtent = swapchain_extent, .imageArrayLayers = 1, .imageUsage = .{ .colorAttachment = true }, .imageSharingMode = .EXCLUSIVE, .compositeAlpha = composite_alpha, .preTransform = pre_transform, .presentMode = present_mode, .clipped = 0, }, null); }; // Create Render Pass const render_pass = create_render_pass: { const attachments = [_]vk.AttachmentDescription{ .{ .format = surface_format.format, .samples = .{ .t1 = true }, .loadOp = .CLEAR, .storeOp = .STORE, .stencilLoadOp = .DONT_CARE, .stencilStoreOp = .DONT_CARE, .initialLayout = .COLOR_ATTACHMENT_OPTIMAL, .finalLayout = .PRESENT_SRC_KHR, } }; const attachment_refs = [_]vk.AttachmentReference{ .{ .attachment = 0, .layout = .COLOR_ATTACHMENT_OPTIMAL }, }; const subpasses = [_]vk.SubpassDescription{ .{ .pipelineBindPoint = .GRAPHICS, .colorAttachmentCount = attachment_refs.len, .pColorAttachments = &attachment_refs, } }; break :create_render_pass try vk.CreateRenderPass(device, .{ .attachmentCount = attachments.len, .pAttachments = &attachments, .subpassCount = subpasses.len, .pSubpasses = &subpasses, }, null); }; // Create Pipeline Cache const pipeline_cache = try vk.CreatePipelineCache(device, .{}, null); // Create Graphics Pipeline Layout const pipeline_layout = create_layout: { const ranges = [_]vk.PushConstantRange{ .{ .stageFlags = vk.ShaderStageFlags.allGraphics, .offset = 0, .size = PUSH_CONSTANT_BYTES, } }; break :create_layout try vk.CreatePipelineLayout(device, .{ .pushConstantRangeCount = ranges.len, .pPushConstantRanges = &ranges, }, null); }; const fractal_pipeline = try createFractalPipeline(device, pipeline_cache, render_pass, width, height, pipeline_layout); const mesh_pipeline = try createMeshPipeline(device, pipeline_cache, render_pass, width, height, pipeline_layout); // Create Cube Mesh const cube = try GpuMesh.init(device, vma_alloc, cube_cpu); var d = Demo{ .instance = instance, .gpu = gpu, .vma_allocator = vma_alloc, .gpu_props = gpu_props, .queue_props = queue_props, .gpu_features = gpu_features, .surface = surface, .graphics_queue_family_index = graphics_index.?, .present_queue_family_index = present_index.?, .separate_present_queue = (graphics_index.? != present_index.?), .device = device, .present_queue = present_queue, .graphics_queue = graphics_queue, .swapchain = swapchain, .swapchain_image_count = swap_img_count, .swapchain_image_format = surface_format.format, .swap_width = width, .swap_height = height, .render_pass = render_pass, .pipeline_cache = pipeline_cache, .pipeline_layout = pipeline_layout, .fractal_pipeline = fractal_pipeline, .mesh_pipeline = mesh_pipeline, .cube_gpu = cube, }; d.uploadMesh(cube); // Create Semaphores { var i: u32 = 0; while (i < FRAME_LATENCY) : (i += 1) { d.upload_complete_sems[i] = try vk.CreateSemaphore(device, .{}, null); d.img_acquired_sems[i] = try vk.CreateSemaphore(device, .{}, null); d.swapchain_image_sems[i] = try vk.CreateSemaphore(device, .{}, null); d.render_complete_sems[i] = try vk.CreateSemaphore(device, .{}, null); } } // Get Swapchain Images _ = try vk.GetSwapchainImagesKHR(device, swapchain, d.swapchain_images[0..swap_img_count]); // Create Image Views { var create_info: vk.ImageViewCreateInfo = .{ .viewType = .T_2D, .format = surface_format.format, .components = .{ .r=.R, .g=.G, .b=.B, .a=.A }, .subresourceRange = .{ .aspectMask = .{ .color = true }, .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, .layerCount = 1, }, .image = .Null, // will initialize in loop }; var i: u32 = 0; while (i < FRAME_LATENCY) : (i += 1) { create_info.image = d.swapchain_images[i]; d.swapchain_image_views[i] = try vk.CreateImageView(device, create_info, null); } } // Create Framebuffers { var create_info: vk.FramebufferCreateInfo = .{ .renderPass = render_pass, .width = width, .height = height, .layers = 1, .attachmentCount = 1, .pAttachments = &d.swapchain_image_views, }; var i: u32 = 0; while (i < FRAME_LATENCY) : (i += 1) { d.swapchain_framebuffers[i] = try vk.CreateFramebuffer(device, create_info, null); create_info.pAttachments += 1; } } // Create Command Pools for (d.command_pools) |*c| { c.* = try vk.CreateCommandPool(device, .{ .queueFamilyIndex = graphics_index.?, }, null); } // Allocate Command Buffers { var alloc_info: vk.CommandBufferAllocateInfo = .{ .level = .PRIMARY, .commandBufferCount = 2, .commandPool = .Null, }; var i: u32 = 0; while (i < FRAME_LATENCY) : (i += 1) { alloc_info.commandPool = d.command_pools[i]; var results: [2]vk.CommandBuffer = undefined; try vk.AllocateCommandBuffers(device, alloc_info, &results); d.graphics_buffers[i] = results[0]; d.upload_buffers[i] = results[1]; } } // Create Descriptor Set Pools // Create Descriptor Sets // Create Fences { var create_info: vk.FenceCreateInfo = .{ .flags = .{ .signaled = true }, }; var i: u32 = 0; while (i < FRAME_LATENCY) : (i += 1) { d.fences[i] = try vk.CreateFence(device, create_info, null); } } return d; } fn renderFrame(d: *Demo) !void { const device = d.device; const swapchain = d.swapchain; const frame_idx = d.frame_idx; const fences = &d.fences; const graphics_queue = d.graphics_queue; const present_queue = d.present_queue; const img_acquired_sem = d.img_acquired_sems[frame_idx]; const render_complete_sem = d.render_complete_sems[frame_idx]; // Ensure no more than FRAME_LATENCY renderings are outstanding _ = vk.WaitForFences(device, arrayPtr(&fences[frame_idx]), vk.TRUE, ~@as(u64, 0)) catch unreachable; vk.ResetFences(device, arrayPtr(&fences[frame_idx])) catch unreachable; // Acquire Image const swap_img_idx: u32 = while (true) { if (vk.AcquireNextImageKHR(device, swapchain, ~@as(u64, 0), img_acquired_sem, .Null)) |result| { if (result.result == .SUBOPTIMAL_KHR) { // demo->swapchain is not as optimal as it could be, but the platform's // presentation engine will still present the image correctly. } break result.imageIndex; } else |err| switch (err) { error.VK_OUT_OF_DATE_KHR => { // demo->swapchain is out of date (e.g. the window was resized) and // must be recreated: // resize(d); // loop again }, error.VK_SURFACE_LOST_KHR => { // If the surface was lost we could re-create it. // But the surface is owned by SDL2 return error.VK_SURFACE_LOST_KHR; }, else => |e| return e, } } else unreachable; d.swap_img_idx = swap_img_idx; const upload_buffer = d.upload_buffers[frame_idx]; const graphics_buffer = d.graphics_buffers[frame_idx]; var upload_sem = vk.Semaphore.Null; // Render { const command_pool = d.command_pools[frame_idx]; vk.ResetCommandPool(device, command_pool, .{}) catch unreachable; // Record { //Upload { const status = vk.GetFenceStatus(device, d.cube_gpu.uploaded) catch unreachable; if (status == .NOT_READY) { vk.BeginCommandBuffer(upload_buffer, .{}) catch unreachable; const region: vk.BufferCopy = .{ .srcOffset = 0, .dstOffset = 0, .size = d.cube_gpu.size, }; vk.CmdCopyBuffer(upload_buffer, d.cube_gpu.host.buffer, d.cube_gpu.gpu.buffer, arrayPtr(&region)); vk.EndCommandBuffer(upload_buffer) catch unreachable; upload_sem = d.upload_complete_sems[frame_idx]; const submit_info: vk.SubmitInfo = .{ .commandBufferCount = 1, .pCommandBuffers = arrayPtr(&upload_buffer), .signalSemaphoreCount = 1, .pSignalSemaphores = arrayPtr(&upload_sem), }; vk.QueueSubmit(d.graphics_queue, arrayPtr(&submit_info), d.cube_gpu.uploaded) catch unreachable; } } vk.BeginCommandBuffer(graphics_buffer, .{}) catch unreachable; // Transition Swapchain Image { var old_layout = vk.ImageLayout.UNDEFINED; // Note: This can never be true, we use this var to index // into buffers of length FRAME_LATENCY above. if (frame_idx >= FRAME_LATENCY) { old_layout = .PRESENT_SRC_KHR; } const barrier: vk.ImageMemoryBarrier = .{ .srcAccessMask = .{ .colorAttachmentRead = true }, .dstAccessMask = .{ .colorAttachmentWrite = true }, .oldLayout = old_layout, .newLayout = .COLOR_ATTACHMENT_OPTIMAL, .image = d.swapchain_images[frame_idx], .srcQueueFamilyIndex = vk.QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = vk.QUEUE_FAMILY_IGNORED, .subresourceRange = .{ .aspectMask = .{ .color = true }, .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, .layerCount = 1, }, }; vk.CmdPipelineBarrier( graphics_buffer, .{ .colorAttachmentOutput = true }, // src stage .{ .colorAttachmentOutput = true }, // dst stage .{}, // dependency flags &[_]vk.MemoryBarrier{}, &[_]vk.BufferMemoryBarrier{}, arrayPtr(&barrier), ); } // Render Pass { const render_pass = d.render_pass; const framebuffer = d.swapchain_framebuffers[frame_idx]; const clear_value: vk.ClearValue = .{ .color = .{ .float32 = .{ 0, 1, 1, 1 }, }}; const width = d.swap_width; const height = d.swap_height; const fwidth = @intToFloat(f32, width); const fheight = @intToFloat(f32, height); const full_screen_rect: vk.Rect2D = .{ .offset = .{ .x = 0, .y = 0 }, .extent = .{ .width = width, .height = height }, }; const viewport: vk.Viewport = .{ .x = 0, .y = fheight, .width = fwidth, .height = -fheight, .minDepth = 0, .maxDepth = 1, }; vk.CmdBeginRenderPass(graphics_buffer, .{ .renderPass = render_pass, .framebuffer = framebuffer, .renderArea = full_screen_rect, .clearValueCount = 1, .pClearValues = arrayPtr(&clear_value), }, .INLINE); // Render Setup vk.CmdSetViewport(graphics_buffer, 0, arrayPtr(&viewport)); vk.CmdSetScissor(graphics_buffer, 0, arrayPtr(&full_screen_rect)); vk.CmdPushConstants( graphics_buffer, d.pipeline_layout, vk.ShaderStageFlags.allGraphics, 0, // offset std.mem.asBytes(&d.push_constants), ); // Fractal vk.CmdBindPipeline(graphics_buffer, .GRAPHICS, d.fractal_pipeline); vk.CmdDraw(graphics_buffer, 3, 1, 0, 0); // Cube { const idx_count = cube_cpu.index_count; const vert_count = cube_cpu.vertex_count; const idx_size = idx_count * (@as(usize, @sizeOf(u16)) << @intCast(u1, @enumToInt(d.cube_gpu.idx_type))); const pos_size = @sizeOf(Float3) * vert_count; const colors_size = @sizeOf(Float3) * vert_count; const b = d.cube_gpu.gpu.buffer; const buffers = [_]vk.Buffer{b, b, b}; const offsets = [_]vk.DeviceSize{ idx_size, idx_size + pos_size, idx_size + pos_size + colors_size, }; vk.CmdBindPipeline(graphics_buffer, .GRAPHICS, d.mesh_pipeline); vk.CmdBindIndexBuffer(graphics_buffer, b, 0, .UINT16); vk.CmdBindVertexBuffers(graphics_buffer, 0, &buffers, &offsets); vk.CmdDrawIndexed(graphics_buffer, idx_count, 1, 0, 0, 0); } } vk.CmdEndRenderPass(graphics_buffer); } vk.EndCommandBuffer(graphics_buffer) catch unreachable; } // Submit { var wait_sems: StackBuffer(vk.Semaphore, 16) = .{}; var wait_stage_flags: StackBufferAligned(vk.PipelineStageFlags, 16, 4) = .{}; wait_sems.add(img_acquired_sem); wait_stage_flags.add(.{ .colorAttachmentOutput = true }); if (upload_sem != .Null) { wait_sems.add(upload_sem); wait_stage_flags.add(.{ .transfer = true }); } assert(wait_sems.count == wait_stage_flags.count); const submit_info: vk.SubmitInfo = .{ .waitSemaphoreCount = @intCast(u32, wait_sems.count), .pWaitSemaphores = &wait_sems.buf, .pWaitDstStageMask = &wait_stage_flags.buf, .commandBufferCount = 1, .pCommandBuffers = arrayPtr(&graphics_buffer), .signalSemaphoreCount = 1, .pSignalSemaphores = arrayPtr(&render_complete_sem), }; try vk.QueueSubmit(graphics_queue, arrayPtr(&submit_info), fences[frame_idx]); } // Present { var wait_sem = render_complete_sem; if (d.separate_present_queue) { const swapchain_sem = d.swapchain_image_sems[frame_idx]; // If we are using separate queues, change image ownership to the // present queue before presenting, waiting for the draw complete // semaphore and signalling the ownership released semaphore when // finished const submit_info: vk.SubmitInfo = .{ .waitSemaphoreCount = 1, .pWaitSemaphores = arrayPtr(&render_complete_sem), // .commandBufferCount = 1, // .pCommandBuffers = // &d->swapchain_images[swap_img_idx].graphics_to_present_cmd; .signalSemaphoreCount = 1, .pSignalSemaphores = arrayPtr(&swapchain_sem), }; try vk.QueueSubmit(present_queue, arrayPtr(&submit_info), .Null); wait_sem = swapchain_sem; } const present_result = vk.QueuePresentKHR(present_queue, .{ .waitSemaphoreCount = 1, .pWaitSemaphores = arrayPtr(&wait_sem), .swapchainCount = 1, .pSwapchains = arrayPtr(&swapchain), .pImageIndices = arrayPtr(&swap_img_idx), }); d.frame_idx = (frame_idx + 1) % FRAME_LATENCY; if (present_result) |result| { if (result == .SUBOPTIMAL_KHR) { // demo->swapchain is not as optimal as it could be, but the platform's // presentation engine will still present the image correctly. } } else |err| switch (err) { error.VK_OUT_OF_DATE_KHR => { // demo->swapchain is out of date (e.g. the window was resized) and // must be recreated: // resize(d); }, error.VK_SURFACE_LOST_KHR => { // If the surface was lost we could re-create it. // But the surface is owned by SDL2 return error.VK_SURFACE_LOST_KHR; }, else => |e| return e, } } } fn deinit(d: *Demo) void { const device = d.device; vk.DeviceWaitIdle(device) catch {}; var i: u32 = 0; while (i < FRAME_LATENCY) : (i += 1) { vk.DestroyFence(device, d.fences[i], null); vk.DestroySemaphore(device, d.upload_complete_sems[i], null); vk.DestroySemaphore(device, d.render_complete_sems[i], null); vk.DestroySemaphore(device, d.swapchain_image_sems[i], null); vk.DestroySemaphore(device, d.img_acquired_sems[i], null); vk.DestroyImageView(device, d.swapchain_image_views[i], null); vk.DestroyFramebuffer(device, d.swapchain_framebuffers[i], null); vk.DestroyCommandPool(device, d.command_pools[i], null); } d.cube_gpu.deinit(device, d.vma_allocator); allocator.free(d.queue_props); vk.DestroyPipelineLayout(device, d.pipeline_layout, null); vk.DestroyPipeline(device, d.mesh_pipeline, null); vk.DestroyPipeline(device, d.fractal_pipeline, null); vk.DestroyPipelineCache(device, d.pipeline_cache, null); vk.DestroyRenderPass(device, d.render_pass, null); vk.DestroySwapchainKHR(device, d.swapchain, null); vk.DestroySurfaceKHR(d.instance, d.surface, null); d.vma_allocator.destroy(); vk.DestroyDevice(d.device, null); d.* = undefined; } fn uploadMesh(demo: *Demo, m: GpuMesh) void { const idx = demo.mesh_upload_count; demo.mesh_upload_queue[idx] = m; demo.mesh_upload_count = idx + 1; } }; fn hasLayer(name: []const u8, layers: []const vk.LayerProperties) bool { for (layers) |*layer| { const layer_name = std.mem.spanZ(&layer.layerName); if (std.mem.eql(u8, name, layer_name)) { return true; } } return false; } fn selectGpu(instance: vk.Instance) !vk.PhysicalDevice { const num_physical_devices = try vk.EnumeratePhysicalDevicesCount(instance); const physical_devices_buf = try allocator.alloc(vk.PhysicalDevice, num_physical_devices); defer allocator.free(physical_devices_buf); const physical_devices = (try vk.EnumeratePhysicalDevices(instance, physical_devices_buf)).physicalDevices; const NUM_PHYS_DEVICE_TYPES = @enumToInt(vk.PhysicalDeviceType.CPU) + 1; var first_device_by_type = [_]?u32{null} ** NUM_PHYS_DEVICE_TYPES; for (physical_devices) |device, i| { const properties = vk.GetPhysicalDeviceProperties(device); const type_index = @intCast(usize, @enumToInt(properties.deviceType)); // the bounds assert from the C code is generated by the zig // compiler automatically, we don't need to write it out. if (first_device_by_type[type_index] == null) { first_device_by_type[type_index] = @intCast(u32, i); } } const preferred_device_types = [_]vk.PhysicalDeviceType{ .DISCRETE_GPU, .INTEGRATED_GPU, .VIRTUAL_GPU, .CPU, .OTHER }; for (preferred_device_types) |dev_type| { if (first_device_by_type[@intCast(usize, @enumToInt(dev_type))]) |device_index| { return physical_devices[device_index]; } } return error.NoSuitableGPU; } fn createDevice( gpu: vk.PhysicalDevice, graphics_queue_family_index: u32, present_queue_family_index: u32, extensions: []const [*:0]const u8, ) !vk.Device { const queue_priorities = [_]f32{ 0 }; const queues = [_]vk.DeviceQueueCreateInfo{ .{ .queueFamilyIndex = graphics_queue_family_index, .queueCount = queue_priorities.len, .pQueuePriorities = &queue_priorities, }, .{ .queueFamilyIndex = present_queue_family_index, .queueCount = queue_priorities.len, .pQueuePriorities = &queue_priorities, }, }; const num_queues: u32 = if (graphics_queue_family_index == present_queue_family_index) 1 else 2; return try vk.CreateDevice(gpu, .{ .pQueueCreateInfos = &queues, .queueCreateInfoCount = num_queues, .enabledExtensionCount = @intCast(u32, extensions.len), .ppEnabledExtensionNames = extensions.ptr, }, null); } fn pickSurfaceFormat(formats: []const vk.SurfaceFormatKHR) vk.SurfaceFormatKHR { const desired_formats = [_]vk.Format{ .R8G8B8A8_UNORM, .B8G8R8A8_UNORM, .A2B10G10R10_UNORM_PACK32, .A2R10G10B10_UNORM_PACK32, .R16G16B16A16_SFLOAT, }; for (desired_formats) |target| { for (formats) |f| { if (f.format == target) { return f; } } } return formats[0]; } fn StackBuffer(comptime T: type, comptime N: usize) type { return StackBufferAligned(T, N, null); } fn StackBufferAligned(comptime T: type, comptime N: usize, comptime alignment: ?usize) type { return struct { const Self = @This(); buf: [N]T align(alignment orelse @alignOf(T)) = undefined, count: usize = 0, pub fn add(self: *Self, value: T) void { // Compiler adds a length assert, we don't need one. self.buf[self.count] = value; self.count += 1; } pub fn span(self: *Self) []align(alignment orelse @alignOf(T)) T { return self.buf[0..self.count]; } }; }
src/main.zig
const std = @import("std"); const builtin = @import("builtin"); const build_options = @import("build_options"); const zigmod = @import("zigmod"); const util = zigmod.util; const CliError = error { UnknownCommand, }; const commands = struct { const fetch = zigmod.commands_to_bootstrap.fetch; usingnamespace zigmod.commands_core; }; fn printVersion() void { util.print("zpp {s} {s} {s}", .{ build_options.version, @tagName(builtin.os.tag), @tagName(builtin.cpu.arch), }); } fn printHelp(mod_only: bool) void { if (mod_only) { util.print("The available subcommands are:", .{}); } else { util.print("The available commands are:", .{}); util.print(" - help", .{}); util.print(" - version", .{}); } inline for (std.meta.declarations(commands)) |decl| { util.print(" - mod {s}", .{decl.name}); } util.print("", .{}); printVersion(); } pub fn main() !void { const gpa = std.heap.c_allocator; const proc_args = try std.process.argsAlloc(gpa); const args = proc_args[1..]; if ( args.len == 0 or std.mem.eql(u8, args[0], "help") or std.mem.eql(u8, args[0], "--help") or std.mem.eql(u8, args[0], "-h") ) { printHelp(false); return; } if ( std.mem.eql(u8, args[0], "version") or std.mem.eql(u8, args[0], "--version") ) { printVersion(); return; } if (!std.mem.eql(u8, args[0], "mod")) { util.fail("Unknown command \"{s}\" for \"zpp\"", .{ args[0] }); return CliError.UnknownCommand; } if (args.len == 1) { printHelp(true); return; } const offset: usize = 1; if (builtin.os.tag == .windows) { const win32 = @import("win32"); const console = win32.system.console; const h_out = console.GetStdHandle(console.STD_OUTPUT_HANDLE); _ = console.SetConsoleMode(h_out, console.CONSOLE_MODE.initFlags(.{ .ENABLE_PROCESSED_INPUT = 1, //ENABLE_PROCESSED_OUTPUT .ENABLE_LINE_INPUT = 1, //ENABLE_WRAP_AT_EOL_OUTPUT .ENABLE_ECHO_INPUT = 1, //ENABLE_VIRTUAL_TERMINAL_PROCESSING })); } try zigmod.init(); defer zigmod.deinit(); inline for (std.meta.declarations(commands)) |decl| { if (std.mem.eql(u8, args[offset], decl.name)) { const cmd = @field(commands, decl.name); try cmd.execute(args[offset+1..]); return; } } const prefix = try std.fmt.allocPrint(gpa, "zigmod-{s}", .{ args[offset] }); defer gpa.free(prefix); var sub_cmd_args = std.ArrayList([]const u8).init(gpa); defer sub_cmd_args.deinit(); try sub_cmd_args.append(prefix); for (args[offset+1..]) |item| try sub_cmd_args.append(item); const result = std.ChildProcess.exec(.{ .allocator = gpa, .argv = sub_cmd_args.items, }) catch |e| switch (e) { error.FileNotFound => { util.fail( "Unknown command \"{s}\" for \"zpp mod\"", .{ args[offset] }, ); }, else => return e, }; try std.io.getStdOut().writeAll(result.stdout); try std.io.getStdErr().writeAll(result.stderr); }
src/main.zig
const std = @import("std"); /// Parses arguments for the given specification and our current process. /// - `Spec` is the configuration of the arguments. /// - `allocator` is the allocator that is used to allocate all required memory pub fn parseForCurrentProcess(comptime Spec: type, allocator: *std.mem.Allocator) !ParseArgsResult(Spec) { var args = std.process.args(); const executable_name = try (args.next(allocator) orelse { try std.io.getStdErr().writer().writeAll("Failed to get executable name from the argument list!\n"); return error.NoExecutableName; }); errdefer allocator.free(executable_name); var result = try parse(Spec, &args, allocator); result.executable_name = executable_name; return result; } /// Parses arguments for the given specification. /// - `Spec` is the configuration of the arguments. /// - `args` is an ArgIterator that will yield the command line arguments. /// - `allocator` is the allocator that is used to allocate all required memory /// /// Note that `.executable_name` in the result will not be set! pub fn parse(comptime Spec: type, args: *std.process.ArgIterator, allocator: *std.mem.Allocator) !ParseArgsResult(Spec) { var result = ParseArgsResult(Spec){ .arena = std.heap.ArenaAllocator.init(allocator), .options = Spec{}, .positionals = undefined, .executable_name = null, }; errdefer result.arena.deinit(); var arglist = std.ArrayList([]const u8).init(allocator); errdefer arglist.deinit(); while (args.next(&result.arena.allocator)) |item_or_error| { const item = try item_or_error; if (std.mem.startsWith(u8, item, "--")) { if (std.mem.eql(u8, item, "--")) { // double hyphen is considered 'everything from here now is positional' break; } const Pair = struct { name: []const u8, value: ?[]const u8, }; const pair = if (std.mem.indexOf(u8, item, "=")) |index| Pair{ .name = item[2..index], .value = item[index + 1 ..], } else Pair{ .name = item[2..], .value = null, }; var found = false; inline for (std.meta.fields(Spec)) |fld| { if (std.mem.eql(u8, pair.name, fld.name)) { try parseOption(Spec, &result, args, fld.name, pair.value); found = true; } } if (!found) { try std.io.getStdErr().writer().print("Unknown command line option: {s}\n", .{pair.name}); return error.EncounteredUnknownArgument; } } else if (std.mem.startsWith(u8, item, "-")) { if (std.mem.eql(u8, item, "-")) { // single hyphen is considered a positional argument try arglist.append(item); } else { if (@hasDecl(Spec, "shorthands")) { for (item[1..]) |char, index| { var found = false; inline for (std.meta.fields(@TypeOf(Spec.shorthands))) |fld| { if (fld.name.len != 1) @compileError("All shorthand fields must be exactly one character long!"); if (fld.name[0] == char) { const real_name = @field(Spec.shorthands, fld.name); const real_fld_type = @TypeOf(@field(result.options, real_name)); // -2 because we stripped of the "-" at the beginning if (requiresArg(real_fld_type) and index != item.len - 2) { try std.io.getStdErr().writer().writeAll("An option with argument must be the last option for short command line options.\n"); return error.EncounteredUnexpectedArgument; } try parseOption(Spec, &result, args, real_name, null); found = true; } } if (!found) { try std.io.getStdErr().writer().print("Unknown command line option: -{c}\n", .{char}); return error.EncounteredUnknownArgument; } } } else { try std.io.getStdErr().writer().writeAll("Short command line options are not supported.\n"); return error.EncounteredUnsupportedArgument; } } } else { try arglist.append(item); } } // This will consume the rest of the arguments as positional ones. // Only executes when the above loop is broken. while (args.next(&result.arena.allocator)) |item_or_error| { const item = try item_or_error; try arglist.append(item); } result.positionals = arglist.toOwnedSlice(); return result; } /// The return type of the argument parser. pub fn ParseArgsResult(comptime Spec: type) type { return struct { const Self = @This(); arena: std.heap.ArenaAllocator, /// The options with either default or set values. options: Spec, /// The positional arguments that were passed to the process. positionals: [][]const u8, /// Name of the executable file (or: zeroth argument) executable_name: ?[]const u8, pub fn deinit(self: Self) void { self.arena.child_allocator.free(self.positionals); if (self.executable_name) |n| self.arena.child_allocator.free(n); self.arena.deinit(); } }; } /// Returns true if the given type requires an argument to be parsed. fn requiresArg(comptime T: type) bool { const H = struct { fn doesArgTypeRequireArg(comptime Type: type) bool { if (Type == []const u8) return true; return switch (@as(std.builtin.TypeId, @typeInfo(Type))) { .Int, .Float, .Enum => true, .Bool => false, .Struct, .Union => true, else => @compileError(@typeName(Type) ++ " is not a supported argument type!"), }; } }; const ti = @typeInfo(T); if (ti == .Optional) { return H.doesArgTypeRequireArg(ti.Optional.child); } else { return H.doesArgTypeRequireArg(T); } } /// Parses a boolean option. fn parseBoolean(str: []const u8) !bool { return if (std.mem.eql(u8, str, "yes")) true else if (std.mem.eql(u8, str, "true")) true else if (std.mem.eql(u8, str, "y")) true else if (std.mem.eql(u8, str, "no")) false else if (std.mem.eql(u8, str, "false")) false else if (std.mem.eql(u8, str, "n")) false else return error.NotABooleanValue; } /// Parses an int option. fn parseInt(comptime T: type, str: []const u8) !T { var buf = str; var multiplier: T = 1; if (buf.len != 0) { var base1024 = false; if (std.ascii.toLower(buf[buf.len - 1]) == 'i') { //ki vs k for instance buf.len -= 1; base1024 = true; } if (buf.len != 0) { var pow: u3 = switch (buf[buf.len - 1]) { 'k', 'K' => 1, //kilo 'm', 'M' => 2, //mega 'g', 'G' => 3, //giga 't', 'T' => 4, //tera 'p', 'P' => 5, //peta else => 0 }; if (pow != 0) { buf.len -= 1; if (comptime std.math.maxInt(T) < 1024) return error.Overflow; var base: T = if (base1024) 1024 else 1000; multiplier = try std.math.powi(T, base, @intCast(T, pow)); } } } const ret: T = switch (@typeInfo(T).Int.signedness) { .signed => try std.fmt.parseInt(T, buf, 0), .unsigned => try std.fmt.parseUnsigned(T, buf, 0), }; return try std.math.mul(T, ret, multiplier); } test "parseInt" { const tst = std.testing; tst.expectEqual(@as(i32, 50), try parseInt(i32, "50")); tst.expectEqual(@as(i32, 6000), try parseInt(i32, "6k")); tst.expectEqual(@as(u32, 2048), try parseInt(u32, "0x2KI")); tst.expectEqual(@as(i8, 0), try parseInt(i8, "0")); tst.expectEqual(@as(usize, 10_000_000_000), try parseInt(usize, "0xAg")); tst.expectError(error.Overflow, parseInt(i2, "1m")); tst.expectError(error.Overflow, parseInt(u16, "1Ti")); } /// Converts an argument value to the target type. fn convertArgumentValue(comptime T: type, textInput: []const u8) !T { if (T == []const u8) return textInput; switch (@typeInfo(T)) { .Optional => |opt| return try convertArgumentValue(opt.child, textInput), .Bool => if (textInput.len > 0) return try parseBoolean(textInput) else return true, // boolean options are always true .Int => |int| return try parseInt(T, textInput), .Float => return try std.fmt.parseFloat(T, textInput), .Enum => { if (@hasDecl(T, "parse")) { return try T.parse(textInput); } else { return std.meta.stringToEnum(T, textInput) orelse return error.InvalidEnumeration; } }, .Struct, .Union => { if (@hasDecl(T, "parse")) { return try T.parse(textInput); } else { @compileError(@typeName(T) ++ " has no public visible `fn parse([]const u8) !T`!"); } }, else => @compileError(@typeName(T) ++ " is not a supported argument type!"), } } /// Parses an option value into the correct type. fn parseOption( comptime Spec: type, result: *ParseArgsResult(Spec), args: *std.process.ArgIterator, /// The name of the option that is currently parsed. comptime name: []const u8, /// Optional pre-defined value for options that use `--foo=bar` value: ?[]const u8, ) !void { const field_type = @TypeOf(@field(result.options, name)); @field(result.options, name) = if (requiresArg(field_type)) blk: { const argval = if (value) |val| val else try (args.next(&result.arena.allocator) orelse { try std.io.getStdErr().writer().print( "Missing argument for {s}.\n", .{name}, ); return error.MissingArgument; }); break :blk convertArgumentValue(field_type, argval) catch |err| { try outputParseError(name, err); return err; }; } else convertArgumentValue(field_type, if (value) |val| val else "") catch |err| { try outputParseError(name, err); return err; }; // argument is "empty" } /// Helper function that will print an error message when a value could not be parsed, then return the same error again fn outputParseError(option: []const u8, err: anytype) !void { try std.io.getStdErr().writer().print("Failed to parse option {s}: {s}\n", .{ option, @errorName(err), }); return err; }
args.zig
const std = @import("std"); const utils = @import("../ecs/utils.zig"); const Cache = @import("cache.zig").Cache; pub const Assets = struct { caches: std.AutoHashMap(u32, usize), allocator: std.mem.Allocator, pub fn init(allocator: std.mem.Allocator) Assets { return Assets{ .caches = std.AutoHashMap(u32, usize).init(allocator), .allocator = allocator, }; } pub fn deinit(self: *Assets) void { var iter = self.caches.iterator(); while (iter.next()) |ptr| { // HACK: we dont know the Type here but we need to call deinit @intToPtr(*Cache(u1), ptr.value_ptr.*).deinit(); } self.caches.deinit(); } pub fn get(self: *Assets, comptime AssetT: type) *Cache(AssetT) { if (self.caches.get(utils.typeId(AssetT))) |tid| { return @intToPtr(*Cache(AssetT), tid); } var cache = Cache(AssetT).initPtr(self.allocator); _ = self.caches.put(utils.typeId(AssetT), @ptrToInt(cache)) catch unreachable; return cache; } pub fn load(self: *Assets, id: u16, comptime loader: anytype) ReturnType(loader, false) { return self.get(ReturnType(loader, true)).load(id, loader); } fn ReturnType(comptime loader: anytype, strip_ptr: bool) type { var ret = @typeInfo(@TypeOf(@field(loader, "load"))).BoundFn.return_type.?; if (strip_ptr) { return std.meta.Child(ret); } return ret; } }; test "assets" { const Thing = struct { fart: i32, pub fn deinit(self: *@This()) void { std.testing.allocator.destroy(self); } }; const OtherThing = struct { fart: i32, pub fn deinit(self: *@This()) void { std.testing.allocator.destroy(self); } }; const OtherThingLoadArgs = struct { pub fn load(_: @This()) *OtherThing { return std.testing.allocator.create(OtherThing) catch unreachable; } }; const ThingLoadArgs = struct { pub fn load(_: @This()) *Thing { return std.testing.allocator.create(Thing) catch unreachable; } }; var assets = Assets.init(std.testing.allocator); defer assets.deinit(); _ = assets.get(Thing).load(6, ThingLoadArgs{}); try std.testing.expectEqual(assets.get(Thing).size(), 1); _ = assets.load(4, ThingLoadArgs{}); try std.testing.expectEqual(assets.get(Thing).size(), 2); _ = assets.get(OtherThing).load(6, OtherThingLoadArgs{}); try std.testing.expectEqual(assets.get(OtherThing).size(), 1); _ = assets.load(8, OtherThingLoadArgs{}); try std.testing.expectEqual(assets.get(OtherThing).size(), 2); assets.get(OtherThing).clear(); try std.testing.expectEqual(assets.get(OtherThing).size(), 0); }
src/resources/assets.zig
const std = @import("std"); const io = std.io; const heap = std.heap; const mem = std.mem; const testing = std.testing; pub const Line = struct { data: []const u8, start: u64, end: u64, }; pub fn LineReader(comptime BufferSize: usize, comptime ReaderType: type) type { return struct { const Self = @This(); allocator: *mem.Allocator, reader: ReaderType, data: std.ArrayList(u8), file_position: u64, index: usize, pub fn init(allocator: *mem.Allocator, reader: ReaderType) !Self { return Self{ .allocator = allocator, .reader = reader, .data = try std.ArrayList(u8).initCapacity(allocator, BufferSize * 2), .file_position = 0, .index = 0, }; } pub fn deinit(self: *Self) void { self.data.deinit(); } pub fn next(self: *Self) !?Line { while (true) { // try to find the next line feed. if (mem.indexOfScalarPos(u8, self.data.items, self.index, '\n')) |pos| { const data = self.data.items[self.index..pos]; self.index = pos + 1; const start = self.file_position; self.file_position += data.len + 1; if (data.len == 0) return null; return Line{ .data = data, .start = start, .end = start + data.len, }; } const remaining = self.data.items[self.index..]; self.data.expandToCapacity(); mem.copy(u8, self.data.items, remaining); mem.set(u8, self.data.items[remaining.len..], 0); const read = try self.reader.read(self.data.items[remaining.len..]); if (read <= 0) return null; self.index = 0; } } }; } test "line reader" { var arena = heap.ArenaAllocator.init(testing.allocator); defer arena.deinit(); var allocator = &arena.allocator; const TestCase = struct { buffer_size: comptime_int, input: []const u8, exp: []const []const u8, }; const testCases = &[_]TestCase{ .{ .buffer_size = 17, .input = "foobar\nbarbaz\nquxfoo\nhello\n", .exp = &[_][]const u8{ "foobar", "barbaz", "quxfoo", "hello", }, }, .{ .buffer_size = 6, .input = "foobar\nbarbaz\nquxfoo\nhello\n", .exp = &[_][]const u8{ "foobar", "barbaz", "quxfoo", "hello", }, }, .{ .buffer_size = 1024, .input = "foobar\nbarbaz\nquxfoo\nhello\n", .exp = &[_][]const u8{ "foobar", "barbaz", "quxfoo", "hello", }, }, .{ .buffer_size = 1024, .input = "foobarbazqux\n", .exp = &[_][]const u8{ "foobarbazqux", }, }, }; inline for (testCases) |tc| { var data_fbs = io.fixedBufferStream(tc.input); var data_reader = data_fbs.reader(); const LineReaderType = LineReader(tc.buffer_size, @TypeOf(data_reader)); var reader = try LineReaderType.init(allocator, data_reader); defer reader.deinit(); var lines = std.ArrayList([]const u8).init(allocator); defer lines.deinit(); while (try reader.next()) |line| { try lines.append(try mem.dupe(allocator, u8, line.data)); } try testing.expectEqual(@as(usize, tc.exp.len), lines.items.len); for (tc.exp) |exp, i| { try testing.expectEqualStrings(exp, lines.items[i]); } } } test "line reader 2" { const data = \\0.926180288429449,49.4405866526212,IMB/76056/X/0098,45,,rue,bouchée,,76480,Bardouville,individuel,cible,FI-76056-0003,deploye,FRTE,f,pavillon \\2.68171572103789,48.7695509509645,IMB/77350/X/029D,3,,rue,lavoisier,,77330,Ozoir-la-Ferrière,entre 2 et 11,cible,FI-77350-000K,deploye,FRTE,f,immeuble \\2.65426573589452,48.5293885834212,IMB/77288/S/02OK,46,,avenue,thiers,,77000,Melun,entre 2 et 11,en cours de deploiement,FI-77288-001A,deploye,FRTE,f,pavillon \\4.58216820843911,46.0628503177034,IMB/69151/X/00JG,23,,chemin,d'emilienne,,69460,Le Perréon,individuel,cible,FI-69151-0006,deploye,FRTE,f,pavillon \\0.932963897800278,49.4343680744479,IMB/76056/X/000O,2390,,chemin,du roy,,76480,Bardouville,individuel,cible,FI-76056-0003,deploye,FRTE,f,pavillon ; const exp = &[_][]const u8{ "0.926180288429449,49.4405866526212,IMB/76056/X/0098,45,,rue,bouchée,,76480,Bardouville,individuel,cible,FI-76056-0003,deploye,FRTE,f,pavillon", "2.68171572103789,48.7695509509645,IMB/77350/X/029D,3,,rue,lavoisier,,77330,Ozoir-la-Ferrière,entre 2 et 11,cible,FI-77350-000K,deploye,FRTE,f,immeuble", "2.65426573589452,48.5293885834212,IMB/77288/S/02OK,46,,avenue,thiers,,77000,Melun,entre 2 et 11,en cours de deploiement,FI-77288-001A,deploye,FRTE,f,pavillon", "4.58216820843911,46.0628503177034,IMB/69151/X/00JG,23,,chemin,d'emilienne,,69460,Le Perréon,individuel,cible,FI-69151-0006,deploye,FRTE,f,pavillon", "0.932963897800278,49.4343680744479,IMB/76056/X/000O,2390,,chemin,du roy,,76480,Bardouville,individuel,cible,FI-76056-0003,deploye,FRTE,f,pavillon", }; var data_fbs = io.fixedBufferStream(data); var data_reader = data_fbs.reader(); const LineReaderType = LineReader(1024, @TypeOf(data_reader)); var reader = try LineReaderType.init(testing.allocator, data_reader); defer reader.deinit(); var i: usize = 0; while (try reader.next()) |line| { try testing.expectEqualStrings(exp[i], line.data); i += 1; } }
line_reader.zig
const std = @import("std"); const tools = @import("tools"); const with_trace = true; const with_dissassemble = 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 run(input: []const u8, allocator: std.mem.Allocator) tools.RunError![2][]const u8 { const AffineFunc = tools.ModArith(i48).AffineFunc; const part1 = ans1: { const cardmax = 10006; // identité // indexof(card) -> card // stack: // indexof(card) -> cardmax-card // cut n: // indexof(card) -> (card-n) % (cardmax+1) // deal inc: // indexof(card) -> (card*inc) % (cardmax+1) // -> et on compose. ça donne une fonction affine modulo m ? // indexof(x) -> (a*x+b) % (cardmax+1) const m = (cardmax + 1); var shuffle = AffineFunc{ .a = 1, .b = 0 }; var it = std.mem.tokenize(u8, input, "\n"); while (it.next()) |line| { var step = blk: { if (tools.match_pattern("deal with increment {}", line)) |vals| { const inc = @intCast(i32, vals[0].imm); break :blk AffineFunc{ .a = inc, .b = 0 }; } else if (tools.match_pattern("cut {}", line)) |vals| { const amount = @intCast(i32, vals[0].imm); break :blk AffineFunc{ .a = 1, .b = -amount }; } else if (tools.match_pattern("deal into new stack", line)) |_| { break :blk AffineFunc{ .a = -1, .b = -1 }; } else { trace("skipping '{s}'\n", .{line}); break :blk AffineFunc{ .a = 1, .b = 0 }; } }; shuffle = AffineFunc.compose(step, shuffle, m); } //var idx: T = 0; //while (idx <= cardmax) : (idx += 1) { // trace("indexof({}) -> {}\n", .{ idx, f.eval(idx) }); //} //const g = f.invert(m); //trace("cardat({}) -> {}\n", .{ 4703, g.eval(4703) }); break :ans1 shuffle.eval(2019, m); }; const part2 = ans2: { const cardmax = 119315717514047 - 1; const m = (cardmax + 1); var shuffle = AffineFunc{ .a = 1, .b = 0 }; var it = std.mem.tokenize(u8, input, "\n"); while (it.next()) |line| { var step = blk: { if (tools.match_pattern("deal with increment {}", line)) |vals| { const inc = @intCast(i32, vals[0].imm); break :blk AffineFunc{ .a = inc, .b = 0 }; } else if (tools.match_pattern("cut {}", line)) |vals| { const amount = @intCast(i32, vals[0].imm); break :blk AffineFunc{ .a = 1, .b = -amount }; } else if (tools.match_pattern("deal into new stack", line)) |_| { break :blk AffineFunc{ .a = -1, .b = -1 }; } else { trace("skipping '{s}'\n", .{line}); break :blk AffineFunc{ .a = 1, .b = 0 }; } }; shuffle = AffineFunc.compose(step, shuffle, m); } const manyshuffle = AffineFunc.autocompose(shuffle, 101741582076661, m); const invshuffle = AffineFunc.invert(manyshuffle, m); break :ans2 invshuffle.eval(2020, m); }; return [_][]const u8{ try std.fmt.allocPrint(allocator, "{}", .{part1}), try std.fmt.allocPrint(allocator, "{}", .{part2}), }; } pub const main = tools.defaultMain("2019/day22.txt", run);
2019/day22.zig
const std = @import("std"); const tools = @import("tools"); const with_trace = false; const with_dissassemble = false; const assert = std.debug.assert; fn trace(comptime fmt: []const u8, args: anytype) void { if (with_trace) std.debug.print(fmt, args); } const Computer = tools.IntCode_Computer; pub fn run(input: []const u8, allocator: std.mem.Allocator) ![2][]const u8 { const int_count = blk: { var int_count: usize = 0; var it = std.mem.split(u8, input, ","); while (it.next()) |_| int_count += 1; break :blk int_count; }; const boot_image = try allocator.alloc(Computer.Data, int_count); defer allocator.free(boot_image); { var it = std.mem.split(u8, input, ","); var i: usize = 0; while (it.next()) |n_text| : (i += 1) { const trimmed = std.mem.trim(u8, n_text, " \n\r\t"); boot_image[i] = try std.fmt.parseInt(Computer.Data, trimmed, 10); } } if (with_dissassemble) Computer.disassemble(boot_image); const names = [_][]const u8{ "Amp A", "Amp B", "Amp C", "Amp D", "Amp E" }; var computers: [5]Computer = undefined; for (computers) |*c, i| { c.* = Computer{ .name = names[i], .memory = try allocator.alloc(Computer.Data, int_count), }; } defer for (computers) |c| { allocator.free(c.memory); }; // part1: var max_output_1: Computer.Data = 0; { var buf: [5]Computer.Data = undefined; var it = tools.generate_permutations(Computer.Data, &[_]Computer.Data{ 0, 1, 2, 3, 4 }); while (it.next(&buf)) |phases| { var bus: Computer.Data = 0; for (computers) |*c, i| { c.boot(boot_image); // input the phase: trace("starting {}\n", .{c.name}); _ = async c.run(); assert(!c.is_halted() and c.io_mode == .input); c.io_port = phases[i]; trace("wrting input to {} = {}\n", .{ c.name, c.io_port }); trace("resuming {}\n", .{c.name}); resume c.io_runframe; assert(!c.is_halted() and c.io_mode == .input); c.io_port = bus; trace("wrting input to {} = {}\n", .{ c.name, c.io_port }); trace("resuming {}\n", .{c.name}); resume c.io_runframe; assert(!c.is_halted() and c.io_mode == .output); bus = c.io_port; trace("copying output from {} = {}\n", .{ c.name, c.io_port }); trace("resuming {}\n", .{c.name}); resume c.io_runframe; assert(c.is_halted()); } if (bus > max_output_1) { max_output_1 = bus; } } } // part 2: var max_output_2: Computer.Data = 0; { var buf: [5]Computer.Data = undefined; var it = tools.generate_permutations(Computer.Data, &[_]Computer.Data{ 9, 8, 7, 6, 5 }); while (it.next(&buf)) |phases| { for (computers) |*c, i| { c.boot(boot_image); // input the phase: trace("starting {}\n", .{c.name}); _ = async c.run(); assert(!c.is_halted() and c.io_mode == .input); c.io_port = phases[i]; trace("wrting input to {} = {}\n", .{ c.name, c.io_port }); trace("resuming {}\n", .{c.name}); resume c.io_runframe; } const output = blk: { var bus: Computer.Data = 0; var halted = false; while (!halted) { for (computers) |*c, i| { if (c.io_mode == .input) { c.io_port = bus; trace("wrting input to {} = {}\n", .{ c.name, c.io_port }); } trace("resuming {}\n", .{c.name}); resume c.io_runframe; if (c.is_halted()) { assert(halted or i == 0); // everybody should stop at the same time. halted = true; } else if (c.io_mode == .output) { trace("copying output from {} = {}\n", .{ c.name, c.io_port }); bus = c.io_port; } } } break :blk bus; }; if (output > max_output_2) { max_output_2 = output; } } } return [_][]const u8{ try std.fmt.allocPrint(allocator, "{}", .{max_output_1}), try std.fmt.allocPrint(allocator, "{}", .{max_output_2}), }; } pub const main = tools.defaultMain("2019/day07.txt", run);
2019/day07.zig
const std = @import("std"); const tools = @import("tools"); const with_trace = true; const assert = std.debug.assert; fn trace(comptime fmt: []const u8, args: anytype) void { if (with_trace) std.debug.print(fmt, args); } fn insert(pats: anytype, in: anytype, out: anytype) !void { //trace("pattern bits: {} -> {}\n", .{ countones(in), countones(out) }); const transfos2 = [_][]u8{ &[_]u8{ 0, 1, 2, 3 }, // ident &[_]u8{ 1, 3, 0, 2 }, // rot 90 &[_]u8{ 3, 2, 1, 0 }, // rot 180 &[_]u8{ 2, 0, 3, 1 }, // rot 270 &[_]u8{ 1, 0, 3, 2 }, // flip x &[_]u8{ 3, 1, 2, 0 }, &[_]u8{ 2, 3, 0, 1 }, &[_]u8{ 0, 2, 1, 3 }, &[_]u8{ 2, 3, 0, 1 }, // flip y &[_]u8{ 0, 2, 1, 3 }, &[_]u8{ 1, 0, 3, 2 }, &[_]u8{ 3, 1, 2, 0 }, }; const transfos3 = [_][]u8{ &[_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // ident &[_]u8{ 2, 5, 8, 1, 4, 7, 0, 3, 6 }, // rot 90 &[_]u8{ 8, 7, 6, 5, 4, 3, 2, 1, 0 }, // rot 180 &[_]u8{ 6, 3, 0, 7, 4, 1, 8, 5, 2 }, // rot 270 &[_]u8{ 2, 1, 0, 5, 4, 3, 8, 7, 6 }, // flip x &[_]u8{ 8, 5, 2, 7, 4, 1, 6, 3, 0 }, &[_]u8{ 6, 7, 8, 3, 4, 5, 0, 1, 2 }, &[_]u8{ 0, 3, 6, 1, 4, 7, 2, 5, 8 }, &[_]u8{ 6, 7, 8, 3, 4, 5, 0, 1, 2 }, // flip y &[_]u8{ 0, 3, 6, 1, 4, 7, 2, 5, 8 }, &[_]u8{ 2, 1, 0, 5, 4, 3, 8, 7, 6 }, &[_]u8{ 8, 5, 2, 7, 4, 1, 6, 3, 0 }, }; const trans = if (in.len == 2 * 2) &transfos2 else &transfos3; for (trans) |t| { var in2 = in; for (t) |to, from| in2[to] = in[from]; assert(countones(in) == countones(in2)); if (false) { const s = if (in.len == 2 * 2) 2 else 3; trace("--- pattern=\n", .{}); for (in2[0 .. s * s]) |m, i| { const c: u8 = if (m == 1) '#' else '.'; trace("{c}", .{c}); if (i % s == s - 1) trace("\n", .{}); } } if (try pats.put(in2, out)) |prev| { assert(std.mem.eql(u1, &prev.value, &out)); } } } fn countones(map: anytype) usize { var c: usize = 0; for (map) |m| c += m; return c; } 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, "day21.txt", limit); defer allocator.free(text); var patterns2 = std.AutoHashMap([2 * 2]u1, [3 * 3]u1).init(allocator); var patterns3 = std.AutoHashMap([3 * 3]u1, [4 * 4]u1).init(allocator); defer patterns2.deinit(); defer patterns3.deinit(); { var rawpatterns: usize = 0; var it = std.mem.split(u8, text, "\n"); while (it.next()) |line| { if (tools.match_pattern("{} => {}", line)) |vals| { rawpatterns += 1; const in = vals[0].name; const out = vals[1].name; if (in.len == 2 * 2 + 1 and out.len == 3 * 3 + 2) { const i = [2 * 2]u1{ if (in[0 * 3 + 0] == '#') 1 else 0, if (in[0 * 3 + 1] == '#') 1 else 0, if (in[1 * 3 + 0] == '#') 1 else 0, if (in[1 * 3 + 1] == '#') 1 else 0, }; const o = [3 * 3]u1{ if (out[0 * 4 + 0] == '#') 1 else 0, if (out[0 * 4 + 1] == '#') 1 else 0, if (out[0 * 4 + 2] == '#') 1 else 0, if (out[1 * 4 + 0] == '#') 1 else 0, if (out[1 * 4 + 1] == '#') 1 else 0, if (out[1 * 4 + 2] == '#') 1 else 0, if (out[2 * 4 + 0] == '#') 1 else 0, if (out[2 * 4 + 1] == '#') 1 else 0, if (out[2 * 4 + 2] == '#') 1 else 0, }; try insert(&patterns2, i, o); } else if (in.len == 3 * 3 + 2 and out.len == 4 * 4 + 3) { const i = [3 * 3]u1{ if (in[0 * 4 + 0] == '#') 1 else 0, if (in[0 * 4 + 1] == '#') 1 else 0, if (in[0 * 4 + 2] == '#') 1 else 0, if (in[1 * 4 + 0] == '#') 1 else 0, if (in[1 * 4 + 1] == '#') 1 else 0, if (in[1 * 4 + 2] == '#') 1 else 0, if (in[2 * 4 + 0] == '#') 1 else 0, if (in[2 * 4 + 1] == '#') 1 else 0, if (in[2 * 4 + 2] == '#') 1 else 0, }; const o = [4 * 4]u1{ if (out[0 * 5 + 0] == '#') 1 else 0, if (out[0 * 5 + 1] == '#') 1 else 0, if (out[0 * 5 + 2] == '#') 1 else 0, if (out[0 * 5 + 3] == '#') 1 else 0, if (out[1 * 5 + 0] == '#') 1 else 0, if (out[1 * 5 + 1] == '#') 1 else 0, if (out[1 * 5 + 2] == '#') 1 else 0, if (out[1 * 5 + 3] == '#') 1 else 0, if (out[2 * 5 + 0] == '#') 1 else 0, if (out[2 * 5 + 1] == '#') 1 else 0, if (out[2 * 5 + 2] == '#') 1 else 0, if (out[2 * 5 + 3] == '#') 1 else 0, if (out[3 * 5 + 0] == '#') 1 else 0, if (out[3 * 5 + 1] == '#') 1 else 0, if (out[3 * 5 + 2] == '#') 1 else 0, if (out[3 * 5 + 3] == '#') 1 else 0, }; try insert(&patterns3, i, o); } else { unreachable; } } } trace("patterns: {} -> {}+{}.\n", .{ rawpatterns, patterns2.count(), patterns3.count() }); } var maps = [2][]u1{ try allocator.alloc(u1, 3000 * 3000), try allocator.alloc(u1, 3000 * 3000) }; defer for (maps) |m| allocator.free(m); var size: u32 = 3; std.mem.copy(u1, maps[0][0 .. size * size], &[_]u1{ 0, 1, 0, 0, 0, 1, 1, 1, 1 }); var iter: u32 = 0; while (iter < 18) : (iter += 1) { const in = maps[iter % 2][0 .. size * size]; var check_consummed: usize = 0; var check_produced: usize = 0; if (size % 2 == 0) { const sn = (size / 2) * 3; const out = maps[1 - iter % 2][0 .. sn * sn]; var pat: [2 * 2]u1 = undefined; var yp: u32 = 0; var yn: u32 = 0; while (yp < size) : (yp += 2) { var xp: u32 = 0; var xn: u32 = 0; while (xp < size) : (xp += 2) { pat[0 * 2 + 0] = in[(yp + 0) * size + (xp + 0)]; pat[0 * 2 + 1] = in[(yp + 0) * size + (xp + 1)]; pat[1 * 2 + 0] = in[(yp + 1) * size + (xp + 0)]; pat[1 * 2 + 1] = in[(yp + 1) * size + (xp + 1)]; const kv = patterns2.get(pat) orelse unreachable; check_consummed += countones(kv.key); check_produced += countones(kv.value); const new = kv.value; out[(yn + 0) * sn + (xn + 0)] = new[0 * 3 + 0]; out[(yn + 0) * sn + (xn + 1)] = new[0 * 3 + 1]; out[(yn + 0) * sn + (xn + 2)] = new[0 * 3 + 2]; out[(yn + 1) * sn + (xn + 0)] = new[1 * 3 + 0]; out[(yn + 1) * sn + (xn + 1)] = new[1 * 3 + 1]; out[(yn + 1) * sn + (xn + 2)] = new[1 * 3 + 2]; out[(yn + 2) * sn + (xn + 0)] = new[2 * 3 + 0]; out[(yn + 2) * sn + (xn + 1)] = new[2 * 3 + 1]; out[(yn + 2) * sn + (xn + 2)] = new[2 * 3 + 2]; xn += 3; } yn += 3; } size = sn; } else { assert(size % 3 == 0); const sn = (size / 3) * 4; const out = maps[1 - iter % 2][0 .. sn * sn]; var pat: [3 * 3]u1 = undefined; var yp: u32 = 0; var yn: u32 = 0; while (yp < size) : (yp += 3) { var xp: u32 = 0; var xn: u32 = 0; while (xp < size) : (xp += 3) { pat[0 * 3 + 0] = in[(yp + 0) * size + (xp + 0)]; pat[0 * 3 + 1] = in[(yp + 0) * size + (xp + 1)]; pat[0 * 3 + 2] = in[(yp + 0) * size + (xp + 2)]; pat[1 * 3 + 0] = in[(yp + 1) * size + (xp + 0)]; pat[1 * 3 + 1] = in[(yp + 1) * size + (xp + 1)]; pat[1 * 3 + 2] = in[(yp + 1) * size + (xp + 2)]; pat[2 * 3 + 0] = in[(yp + 2) * size + (xp + 0)]; pat[2 * 3 + 1] = in[(yp + 2) * size + (xp + 1)]; pat[2 * 3 + 2] = in[(yp + 2) * size + (xp + 2)]; const kv = patterns3.get(pat) orelse unreachable; check_consummed += countones(kv.key); check_produced += countones(kv.value); const new = kv.value; out[(yn + 0) * sn + (xn + 0)] = new[0 * 4 + 0]; out[(yn + 0) * sn + (xn + 1)] = new[0 * 4 + 1]; out[(yn + 0) * sn + (xn + 2)] = new[0 * 4 + 2]; out[(yn + 0) * sn + (xn + 3)] = new[0 * 4 + 3]; out[(yn + 1) * sn + (xn + 0)] = new[1 * 4 + 0]; out[(yn + 1) * sn + (xn + 1)] = new[1 * 4 + 1]; out[(yn + 1) * sn + (xn + 2)] = new[1 * 4 + 2]; out[(yn + 1) * sn + (xn + 3)] = new[1 * 4 + 3]; out[(yn + 2) * sn + (xn + 0)] = new[2 * 4 + 0]; out[(yn + 2) * sn + (xn + 1)] = new[2 * 4 + 1]; out[(yn + 2) * sn + (xn + 2)] = new[2 * 4 + 2]; out[(yn + 2) * sn + (xn + 3)] = new[2 * 4 + 3]; out[(yn + 3) * sn + (xn + 0)] = new[3 * 4 + 0]; out[(yn + 3) * sn + (xn + 1)] = new[3 * 4 + 1]; out[(yn + 3) * sn + (xn + 2)] = new[3 * 4 + 2]; out[(yn + 3) * sn + (xn + 3)] = new[3 * 4 + 3]; xn += 4; } yn += 4; } size = sn; } { const out = maps[1 - iter % 2][0 .. size * size]; assert(check_consummed == countones(in)); assert(check_produced == countones(out)); trace("--- iter={}: {}\n", .{ iter + 1, countones(out) }); //for (out) |m, i| { // const c: u8 = if (m == 1) '#' else '.'; // trace("{c}", .{c}); // if (i % size == size - 1) // trace("\n", .{}); //} } } const count = countones(maps[iter % 2][0 .. size * size]); try stdout.print("steps={}, count={}\n", .{ iter, count }); }
2017/day21.zig
const std = @import("std"); const mem = std.mem; const meta = std.meta; const testing = std.testing; const builtin = std.builtin; const debug = std.debug; const TypeInfo = builtin.TypeInfo; pub const RecursiveField = struct { path: []const []const u8, field_type: type, default_value: anytype, is_comptime: bool, alignment: comptime_int, pub fn of(comptime T: type) []RecursiveField { @setEvalBranchQuota(100000); var fields: [count(T)]RecursiveField = undefined; var i: comptime_int = 0; push(RecursiveField, &i, &fields, &[1]RecursiveField{.{ .path = &[0][]const u8{}, .field_type = T, .default_value = null, .is_comptime = false, .alignment = @alignOf(T), }}); switch (@typeInfo(T)) { .Struct, .Union => for (meta.fields(T)) |field| { push( RecursiveField, &i, &fields, addBase(&[1][]const u8{field.name}, RecursiveField.of(field.field_type)), ); }, else => {}, } // @compileLog(i); // for (fields) |field| { // @compileLog(field.path); // } return &fields; } pub fn count(comptime T: type) comptime_int { switch (@typeInfo(T)) { .Struct, .Union => { var n: comptime_int = 1; // the 1 is the field continaing the struct for (meta.fields(T)) |field| { n += count(field.field_type); } return n; }, else => return 1, } } fn addBase(comptime base: []const []const u8, comptime fields: []const RecursiveField) []const RecursiveField { var new_fields: [fields.len]RecursiveField = undefined; for (fields) |field, i| { new_fields[i] = RecursiveField{ .path = base ++ field.path, .field_type = field.field_type, .default_value = field.default_value, .is_comptime = field.is_comptime, .alignment = field.alignment, }; } return &new_fields; } pub fn lessThan(_: void, comptime lhs: RecursiveField, comptime rhs: RecursiveField) bool { var l_str = @typeName(lhs.field_type); var r_str = @typeName(rhs.field_type); // Start with lenth comparison if (l_str.len != r_str.len) { return l_str.len < r_str.len; } // fall back to lexical order by bytes. var k: usize = 0; while (k < l_str.len and l_str[k] == r_str[k]) : (k += 1) {} if (k == l_str.len) return false; // equal case return l_str[k] < r_str[k]; } }; fn push(comptime T: type, comptime i: *comptime_int, array: []T, new: []const T) void { mem.copy(T, array[i.*..], new); i.* += new.len; } test "recursive field on single" { const expected = [_]RecursiveField{ .{ .path = &[_][]const u8{}, .field_type = usize, .default_value = null, .is_comptime = false, .alignment = @alignOf(usize) }, }; const actual = RecursiveField.of(usize); inline for (actual) |actual_field, i| { const expected_field = expected[i]; try testing.expectEqual(expected_field.path.len, actual_field.path.len); inline for (expected_field.path) |expected_id, j| { try testing.expectEqual(expected_field.path.len, actual_field.path.len); _ = expected_id; _ = j; } } } test "recursive field on struct" { const T = struct { x: usize, y: usize, }; const expected = [_]RecursiveField{ .{ .path = &[_][]const u8{}, .field_type = T, .default_value = null, .is_comptime = false, .alignment = @alignOf(T) }, .{ .path = &[_][]const u8{"x"}, .field_type = usize, .default_value = null, .is_comptime = false, .alignment = @alignOf(usize) }, .{ .path = &[_][]const u8{"y"}, .field_type = usize, .default_value = null, .is_comptime = false, .alignment = @alignOf(usize) }, }; const actual = RecursiveField.of(T); // inline for (actual) |field| { // @compileLog(field.path); // } try testing.expectEqual(expected.len, actual.len); inline for (actual) |actual_field, i| { const expected_field = expected[i]; try testing.expectEqual(expected_field.path.len, actual_field.path.len); inline for (expected_field.path) |expected_id, j| { try testing.expectEqual(expected_field.path.len, actual_field.path.len); _ = expected_id; _ = j; } } } test "recursive field on nested" { const B = struct { j: usize, }; const Z = struct { a: usize, b: B, c: usize, }; const T = struct { x: usize, y: usize, z: Z, }; const expected = [_]RecursiveField{ .{ .path = &[_][]const u8{}, .field_type = T, .default_value = null, .is_comptime = false, .alignment = @alignOf(T) }, .{ .path = &[_][]const u8{"x"}, .field_type = usize, .default_value = null, .is_comptime = false, .alignment = @alignOf(usize) }, .{ .path = &[_][]const u8{"y"}, .field_type = usize, .default_value = null, .is_comptime = false, .alignment = @alignOf(usize) }, .{ .path = &[_][]const u8{"z"}, .field_type = Z, .default_value = null, .is_comptime = false, .alignment = @alignOf(Z) }, .{ .path = &[_][]const u8{ "z", "a" }, .field_type = usize, .default_value = null, .is_comptime = false, .alignment = @alignOf(usize) }, .{ .path = &[_][]const u8{ "z", "b" }, .field_type = B, .default_value = null, .is_comptime = false, .alignment = @alignOf(B) }, .{ .path = &[_][]const u8{ "z", "b", "j" }, .field_type = usize, .default_value = null, .is_comptime = false, .alignment = @alignOf(usize) }, .{ .path = &[_][]const u8{ "z", "c" }, .field_type = usize, .default_value = null, .is_comptime = false, .alignment = @alignOf(usize) }, }; const actual = RecursiveField.of(T); // inline for (actual) |field| { // @compileLog(field.path); // } try testing.expectEqual(expected.len, actual.len); inline for (actual) |actual_field, i| { const expected_field = expected[i]; try testing.expectEqual(expected_field.path.len, actual_field.path.len); inline for (expected_field.path) |expected_id, j| { try testing.expectEqual(expected_field.path.len, actual_field.path.len); _ = expected_id; _ = j; } } }
src/recursive_field.zig
const std = @import("std"); const zen = std.os.zen; const Keyboard = zen.Server.Keyboard; const MailboxId = zen.MailboxId; const Message = zen.Message; // Circular buffer to hold keypress data. const BUFFER_SIZE = 1024; var buffer = []u8 { 0 } ** BUFFER_SIZE; var buffer_start: usize = 0; var buffer_end: usize = 0; // FIXME: Severely incomplete and poorly formatted. const scancodes = []u8 { 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; // Thread that is blocked on a read. var waiting_thread: ?MailboxId = null; //// // Handle keypresses. // fn handleKeyEvent() void { // Check whether there's data in the keyboard buffer. const status = zen.inb(0x64); if ((status & 1) == 0) return; // Fetch the scancode, and ignore key releases. const code = zen.inb(0x60); if ((code & 0x80) != 0) return; // Fetch the character associated with the keypress. const char = scancodes[code]; if (waiting_thread) |thread| { // If a thread was blocked reading, send the character to it. waiting_thread = null; zen.send(Message { .sender = Keyboard, .receiver = thread, .type = 0, .payload = char, }); } else { // Otherwise, save the character into the buffer. buffer[buffer_end] = char; buffer_end = (buffer_end + 1) % buffer.len; } } //// // Handle a read request from another thread. // fn handleRead(reader: &const MailboxId) void { if (buffer_start == buffer_end) { // If the buffer is empty, make the thread wait. waiting_thread = *reader; } else { // Otherwise, fetch the first character from the buffer and send it. const char = buffer[buffer_start]; zen.send(Message { .sender = Keyboard, .receiver = *reader, .type = 0, .payload = char, }); buffer_start = (buffer_start + 1) % buffer.len; } } //// // Entry point. // pub fn main() void { // Instruct the kernel to send IRQ1 notifications to the Keyboard port. zen.createPort(Keyboard); zen.subscribeIRQ(1, Keyboard); // Receive messages from the Keyboard port. var message = Message.from(Keyboard); while (true) { zen.receive(&message); switch (message.sender) { MailboxId.Kernel => handleKeyEvent(), else => handleRead(message.sender), } } }
servers/keyboard/main.zig
const std = @import("std"); const os = std.os; const vt = @import("vt-term.zig"); const assertOrPanic = std.debug.assertOrPanic; const EZError = error{ NotImplemented, NoUserInput, }; const EditMode = enum { Normal, Insert, Visual, }; const EditorState = struct { index: usize, // index within row slice cpos: vt.CursorPos, // location of terminal cursor i_cpos: vt.CursorPos, // initial location of terminal cursor (after prompt) max_cpos: vt.CursorPos, // Farthest cursor position mode: EditMode, // current editor mode seq_timer: usize, // timeout for multi-key sequences termd: vt.TerminalDimensions, // last queried terminal dimensions done: bool, // editor is ready to return to user in_buf: []u8, // buffer used to store input in_len: usize, // current user input size const Self = @This(); fn init(prompt: []const u8, buf: []u8) !Self { var state = EditorState{ .cpos = undefined, .i_cpos = undefined, .max_cpos = undefined, .termd = undefined, .index = 0, .mode = EditMode.Normal, .seq_timer = 0, .done = false, .in_buf = buf, .in_len = 0, }; try std_out.write(prompt); try state.updateCursorPos(); state.i_cpos = state.cpos; state.max_cpos = state.cpos; state.updateTerminalSize(); return state; } fn setCursorPos(state: *Self, pos: vt.CursorPos) !void { try vt.setCursorPos(pos); } fn getCursorPos(state: *Self) !vt.CursorPos { return try vt.getCursorPos(); } fn updateCursorPos(state: *Self) !void { state.cpos = try vt.getCursorPos(); } fn updateTerminalSize(state: *Self) void { state.termd = vt.getTerminalSize(); } fn setEditMode(state: *Self, mode: EditMode) void { state.mode = mode; } fn getEditorDone(state: *Self) bool { return state.done; } fn getCurrentUserInput(state: *Self) []u8 { return state.in_buf[0..state.in_len]; } fn moveCursorUp(state: *Self) void {} fn moveCursorDown(state: *Self) void {} fn moveCursorRight(state: *Self) !void { if (state.index < state.in_len) { vt.cursorForward(1) catch return; state.index += 1; try state.updateCursorPos(); } } fn moveCursorLeft(state: *Self) !void { if (state.index > 0) { vt.cursorBackward(1) catch return; state.index -= 1; try state.updateCursorPos(); } } fn copyRight(state: *Self, num: usize) void { //TODO: check that cursor won't go past screen if (state.in_len < state.in_buf.len - num) { std.mem.copy(u8, state.in_buf[state.index + num .. state.in_len + num], state.in_buf[state.index..state.in_len]); } } fn refreshScreen(state: *Self) !void { try state.setCursorPos(state.i_cpos); try vt.eraseCursorToEndOfDisplay(); try std_out.write(state.in_buf[0..state.in_len]); state.max_cpos = try state.getCursorPos(); try state.setCursorPos(state.cpos); } fn insertCharacter(state: *Self, key: u8) void { state.copyRight(1); state.in_buf[state.index] = key; state.in_len += 1; state.index += 1; if (state.cpos.col < state.termd.width - 1) { state.cpos.col += 1; } else { state.cpos.col = 0; if (state.cpos.row < state.termd.height - 1) { state.cpos.row += 1; // else at bottom of screen already } } } fn registerKey(state: *Self, key: u8) !void { const kmem = [1]u8{key}; const kslice = kmem[0..]; state.updateTerminalSize(); switch (state.mode) { EditMode.Insert => switch (key) { CTRL('c') => { state.done = true; }, CTRL('d') => { state.setEditMode(EditMode.Normal); }, else => { state.insertCharacter(key); }, }, EditMode.Normal => switch (key) { 'l' => { try state.moveCursorRight(); }, 'k' => { state.moveCursorUp(); }, 'j' => { state.moveCursorDown(); }, 'h' => { try state.moveCursorLeft(); }, 'i' => { state.setEditMode(EditMode.Insert); }, CTRL('c') => { state.done = true; }, else => {}, }, EditMode.Visual => switch (key) { CTRL('c') => { state.done = true; }, else => { unreachable; }, }, } try state.refreshScreen(); return; } }; const std_in = os.File.openHandle(os.posix.STDIN_FILENO); const std_out = os.File.openHandle(os.posix.STDOUT_FILENO); const std_err = os.File.openHandle(os.posix.STDERR_FILENO); const default_max_line_len = 4096; var runtime_allocator: ?*std.mem.Allocator = null; //***************************************************************************** // Description: Displays prompt, returns user input // Parameters: []u8 - Prompt to display, slice // Return: ![]u8 - User input or error if not successful //***************************************************************************** pub fn eazyInputSlice(prompt: []const u8) ![]u8 { if (!os.isTty(0)) { _ = handleNotTty(); } else if (vt.isUnsupportedTerm()) { _ = handleUnsupportedTerm(); } else { const ret_slice_null_terminated = try getEazyInput(prompt); // TODO: how much memory does the length portion of the slice take up? return ret_slice_null_terminated[0 .. ret_slice_null_terminated.len - 1]; } return error.eazyInputNoUserInput; } //***************************************************************************** // Description: Frees memory previously returned by eazyInputSliceAlloc // Parameters: []u8 - slice of memory to free // Return: !void - error if unsuccessful or allocator not initialized //***************************************************************************** pub fn eazyInputSliceFree(user_input: []const u8) !void { if (runtime_allocator) |allocator| { allocator.free(user_input[0..]); return; } else { return error.ez_allocator_uninitialized; } } //***************************************************************************** // Description: Allocates memory for the user input // Parameters: []u8 - Prompt to display, slice // Return: ![]u8 - User input or error if not successful //***************************************************************************** fn eazyInputSliceAlloc(comptime T: type, n: usize) ![]T { if (runtime_allocator) |allocator| { var buf = try allocator.alloc(T, n); std.mem.set(u8, buf, 0); return buf; } else { const allocator = struct { var direct_allocator = std.heap.DirectAllocator.init(); var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator); }; runtime_allocator = &(allocator.arena_allocator.allocator); var buf = try runtime_allocator.?.alloc(T, n); std.mem.set(u8, buf, 0); return buf; } } fn handleNotTty() ![]u8 { return EZError.NotImplemented; } fn handleUnsupportedTerm() ![]u8 { return EZError.NotImplemented; } fn getEazyInput(prompt: []const u8) ![]u8 { var fbuf: [default_max_line_len]u8 = undefined; var orig_term = try vt.enableRawTerminalMode(); defer vt.setTerminalMode(&orig_term) catch {}; // best effort var state = try EditorState.init(prompt, fbuf[0..]); while (!state.getEditorDone()) { if (getKeypress()) |key| { try state.registerKey(key); } else |err| return err; } var ret_input = state.getCurrentUserInput(); if (ret_input.len > 0) { var buf = try eazyInputSliceAlloc(u8, ret_input.len); errdefer eazyInputSliceFree(buf) catch {}; std.mem.copy(u8, ret_input, buf); return buf; } return EZError.NoUserInput; } fn getKeypress() !u8 { var c = []u8{0}; var count = try std_in.read(c[0..1]); if (count == 1) return c[0] else return error.noKeypress; } inline fn CTRL(c: u8) u8 { return c & u8(0x1F); } fn strnslice(c_str: ?[*]const u8, n: usize) []const u8 { // TODO: how to return const slice only if input was const? // check for null pointer input, convert to zero length slice var slice: []const u8 = undefined; if (c_str) |p| { for (p[0..n]) |c, i| { if (c == 0) { slice = p[0..i]; break; } } else { slice = p[0..n]; } } else { slice = ([]u8{0})[0..0]; } return slice; } test "eazyinput.zig: strnslice" { const cstr_null: ?[*]const u8 = null; const cstr_0: ?[*]const u8 = c""; const cstr_1: ?[*]const u8 = c"123456"; // string is null pointer std.debug.assert(std.mem.compare(u8, strnslice(cstr_null, 10), ""[0..0]) == std.mem.Compare.Equal); // null terminator is first byte std.debug.assert(std.mem.compare(u8, strnslice(cstr_0, 10), ""[0..0]) == std.mem.Compare.Equal); // null terminator is at "n" index std.debug.assert(std.mem.compare(u8, strnslice(cstr_1, 6), "123456"[0..6]) == std.mem.Compare.Equal); // null terminator is beyond "n" index std.debug.assert(std.mem.compare(u8, strnslice(cstr_1, 5), "123456"[0..5]) == std.mem.Compare.Equal); // null terminator is before "n" index std.debug.assert(std.mem.compare(u8, strnslice(cstr_1, 7), "123456"[0..6]) == std.mem.Compare.Equal); } test "eazyinput.zig: allocations and frees" { var buf = try eazyInputSliceAlloc(u8, default_max_line_len); try eazyInputSliceFree(buf); } test "eazyinput.zig: top level call" { var ret = try getEazyInput("prompt"[0..]); defer eazyInputSliceFree(ret) catch {}; }
src/main.zig
const std = @import("std"); pub const vk = @import("lib/vulkan.zig"); pub const vez = @import("lib/vez.zig"); pub const c = @import("lib/glfw3.zig"); const base = @import("main.zig"); const NameSet = std.AutoHashMap([256]u8, void); pub const isDebug = @import("builtin").mode == .Debug; pub fn makeVkVersion(major: u32, minor: anytype, patch: anytype) u32 { return (major << 22) | ((minor << 12) | patch); } pub const VulkanError = error{ Incomplete, NotReady, Timeout, EventSet, EventReset, ThreadIdle, ThreadDone, OperationDeferred, OperationNotDeferred, OutOfHostMemory, OutOfDeviceMemory, InitializationFailed, DeviceLost, MemoryMapFailed, LayerNotPresent, ExtensionNotPresent, FeatureNotPresent, IncompatibleDriver, TooManyObjects, FormatNotSupported, FragmentedPool, UnknownError, OutOfPoolMemory, InvalidExternalHandle, Fragmentation, InvalidAddress, SurfaceLost, NativeWindowInUse, Suboptimal, OutOfDate, IncompatibleDisplay, ValidationFailed, InvalidShader, IncompatibleVersion, InvalidDrmFormatModifierPlaneLayout, NotPermitted, FullScreenExclusiveModeLost, PipelineCompileRequired, }; pub fn convert(result: vk.Result) VulkanError!void { return switch (result) { .SUCCESS => return, .SUBOPTIMAL_KHR => VulkanError.Suboptimal, .INCOMPLETE => VulkanError.Incomplete, .NOT_READY => VulkanError.NotReady, .TIMEOUT => VulkanError.Timeout, .EVENT_SET => VulkanError.EventSet, .EVENT_RESET => VulkanError.EventReset, .THREAD_IDLE_KHR => VulkanError.ThreadIdle, .THREAD_DONE_KHR => VulkanError.ThreadDone, .OPERATION_DEFERRED_KHR => VulkanError.OperationDeferred, .OPERATION_NOT_DEFERRED_KHR => VulkanError.OperationNotDeferred, .ERROR_OUT_OF_HOST_MEMORY => VulkanError.OutOfHostMemory, .ERROR_OUT_OF_DEVICE_MEMORY => VulkanError.OutOfDeviceMemory, .ERROR_INITIALIZATION_FAILED => VulkanError.InitializationFailed, .ERROR_DEVICE_LOST => VulkanError.DeviceLost, .ERROR_MEMORY_MAP_FAILED => VulkanError.MemoryMapFailed, .ERROR_LAYER_NOT_PRESENT => VulkanError.LayerNotPresent, .ERROR_EXTENSION_NOT_PRESENT => VulkanError.ExtensionNotPresent, .ERROR_FEATURE_NOT_PRESENT => VulkanError.FeatureNotPresent, .ERROR_INCOMPATIBLE_DRIVER => VulkanError.IncompatibleDriver, .ERROR_TOO_MANY_OBJECTS => VulkanError.TooManyObjects, .ERROR_FORMAT_NOT_SUPPORTED => VulkanError.FormatNotSupported, .ERROR_FRAGMENTED_POOL => VulkanError.FragmentedPool, .ERROR_UNKNOWN => VulkanError.UnknownError, .ERROR_OUT_OF_POOL_MEMORY => VulkanError.OutOfPoolMemory, .ERROR_INVALID_EXTERNAL_HANDLE => VulkanError.InvalidExternalHandle, .ERROR_FRAGMENTATION => VulkanError.Fragmentation, .ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS => VulkanError.InvalidAddress, .ERROR_SURFACE_LOST_KHR => VulkanError.SurfaceLost, .ERROR_NATIVE_WINDOW_IN_USE_KHR => VulkanError.NativeWindowInUse, .ERROR_OUT_OF_DATE_KHR => VulkanError.OutOfDate, .ERROR_INCOMPATIBLE_DISPLAY_KHR => VulkanError.IncompatibleDisplay, .ERROR_VALIDATION_FAILED_EXT => VulkanError.ValidationFailed, .ERROR_INVALID_SHADER_NV => VulkanError.InvalidShader, .ERROR_INCOMPATIBLE_VERSION_KHR => VulkanError.IncompatibleVersion, .ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT => VulkanError.InvalidDrmFormatModifierPlaneLayout, .ERROR_NOT_PERMITTED_EXT => VulkanError.NotPermitted, .ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT => VulkanError.FullScreenExclusiveModeLost, .ERROR_PIPELINE_COMPILE_REQUIRED_EXT => VulkanError.PipelineCompileRequired, else => unreachable, }; } pub fn getInstanceLayers(allocator: *std.mem.Allocator) !NameSet { const stdout = std.io.getStdOut().writer(); var extensionCount: u32 = 0; try convert(vez.enumerateInstanceExtensionProperties(null, &extensionCount, null)); var extensions = try allocator.alloc(vk.ExtensionProperties, extensionCount); defer allocator.free(extensions); try convert(vez.enumerateInstanceExtensionProperties(null, &extensionCount, extensions.ptr)); if (isDebug) { try stdout.writeAll("Available extensions: "); for (extensions) |extension| { try stdout.print("{}, ", .{@ptrCast([*:0]const u8, &extension.extensionName)}); } try stdout.writeAll("\n"); } // Enumerate all available instance layers var layerCount: u32 = 0; try convert(vez.enumerateInstanceLayerProperties(&layerCount, null)); var layerProperties = try allocator.alloc(vk.LayerProperties, layerCount); defer allocator.free(layerProperties); try convert(vez.enumerateInstanceLayerProperties(&layerCount, layerProperties.ptr)); var set = NameSet.init(allocator); for (layerProperties) |prop| { _ = try set.put(prop.layerName, .{}); } return set; } pub const Buffer = struct { handle: vk.Buffer, memory: vk.DeviceMemory, size: usize, pub fn init(self: *@This(), device: vk.Device, usage: vk.BufferUsageFlags, size: usize) VulkanError!void { // Create the device side buffer. var bufferCreateInfo = vez.BufferCreateInfo{ .size = size, .usage = @intCast(u32, vk.BUFFER_USAGE_TRANSFER_DST_BIT) | usage, }; try convert(vez.createBuffer(base.getDevice(), vez.MEMORY_NO_ALLOCATION, &bufferCreateInfo, &self.handle)); // Allocate memory for the buffer. var memRequirements: vk.MemoryRequirements = undefined; vk.getBufferMemoryRequirements(base.getDevice(), self.handle, &memRequirements); self.size = memRequirements.size; var allocInfo = vk.MemoryAllocateInfo{ .allocationSize = memRequirements.size, .memoryTypeIndex = findMemoryType(base.getPhysicalDevice(), memRequirements.memoryTypeBits, vk.MEMORY_PROPERTY_HOST_VISIBLE_BIT | vk.MEMORY_PROPERTY_HOST_COHERENT_BIT), }; try convert(vk.allocateMemory(base.getDevice(), &allocInfo, null, &self.memory)); // Bind the memory to the buffer. try convert(vk.bindBufferMemory(base.getDevice(), self.handle, self.memory, 0)); } pub fn load(self: @This(), data: anytype) !void { const T = @typeInfo(@TypeOf(data)).Pointer.child; std.debug.assert(data.len * @sizeOf(T) <= self.size); var pData: [*]u8 = undefined; try convert(vk.mapMemory(base.getDevice(), self.memory, 0, self.size, 0, @ptrCast(*?*c_void, &pData))); const src = std.mem.sliceAsBytes(data); std.mem.copy(u8, pData[0..src.len], src); vk.unmapMemory(base.getDevice(), self.memory); } pub fn deinit(self: @This(), device: vk.Device) void { vez.destroyBuffer(device, self.handle); vk.freeMemory(device, self.memory, null); } }; fn findMemoryType(physicalDevice: vk.PhysicalDevice, typeFilter: u32, properties: vk.MemoryPropertyFlags) u32 { var memProperties: vk.PhysicalDeviceMemoryProperties = undefined; vk.getPhysicalDeviceMemoryProperties(physicalDevice, &memProperties); var i: u5 = 0; const mask: u32 = 1; while (i < memProperties.memoryTypeCount) : (i += 1) { if (typeFilter & (mask << i) != 0 and (memProperties.memoryTypes[i].propertyFlags & properties) == properties) return i; } return 0; } pub const Image = struct { texture: vk.Image = null, view: vk.ImageView = null, sampler: vk.Sampler = null, width: u32 = 0, height: u32 = 0, pub fn init(self: *@This(), createInfo: vez.ImageCreateInfo, filter: vk.Filter, addressMode: vk.SamplerAddressMode) VulkanError!void { self.width = createInfo.extent.width; self.height = createInfo.extent.height; try convert(vez.createImage(base.getDevice(), vez.MEMORY_GPU_ONLY, &createInfo, &self.texture)); // Create the image view for binding the texture as a resource. var imageViewCreateInfo = vez.ImageViewCreateInfo{ .image = self.texture, .viewType = .IMAGE_VIEW_TYPE_2D, .format = createInfo.format, .subresourceRange = .{ .layerCount = 1, .levelCount = 1, .baseMipLevel = 0, .baseArrayLayer = 0 }, // defaults }; try convert(vez.createImageView(base.getDevice(), &imageViewCreateInfo, &self.view)); const samplerInfo = vez.SamplerCreateInfo{ .magFilter = filter, // default? .minFilter = filter, // default? .mipmapMode = .SAMPLER_MIPMAP_MODE_LINEAR, // default? .addressModeU = addressMode, // default? .addressModeV = addressMode, // default? .addressModeW = addressMode, // default? .unnormalizedCoordinates = 0, .borderColor = .BORDER_COLOR_INT_OPAQUE_BLACK, }; try convert(vez.createSampler(base.getDevice(), &samplerInfo, &self.sampler)); } pub fn cmdBind(self: @This(), set: u32, binding: u32) void { vez.cmdBindImageView(self.view, self.sampler, set, binding, 0); // self.sampler } pub fn deinit(self: @This(), device: vk.Device) void { vez.destroyImageView(device, self.view); vez.destroyImage(device, self.texture); vez.destroySampler(device, self.sampler); } };
src/utils.zig
const std = @import("std"); const absInt = std.math.absInt; const min = std.math.min; const parseInt = std.fmt.parseInt; const print = std.debug.print; const sort = std.sort; const testing = std.testing; const tokenize = std.mem.tokenize; const input = @embedFile("./input.txt"); const size = 1000; pub fn main() anyerror!void { print("--- Part One ---\n", .{}); print("Result: {d}\n", .{part1()}); print("--- Part Two ---\n", .{}); print("Result: {d}\n", .{part2()}); } /// /// --- Part One --- /// fn part1() !i32 { var crab_positions = try readCrabPositions(); sort.sort(i32, &crab_positions, {}, comptime sort.asc(i32)); var median: i32 = crab_positions[size / 2]; var fuel: i32 = 0; for (crab_positions) |p| { fuel += try absInt(p - median); } return fuel; } test "day07.part1" { @setEvalBranchQuota(200_000); try testing.expectEqual(347011, comptime try part1()); } /// /// --- Part Two --- /// fn part2() !i32 { var crab_positions = try readCrabPositions(); var sum: i32 = 0; for (crab_positions) |p| { sum += p; } const mean_floor = @divFloor(sum, size); const mean_ceil = mean_floor + 1; var total_fuel_floor: i32 = 0; var total_fuel_ceil: i32 = 0; for (crab_positions) |p| { const fuel_floor = try absInt(p - mean_floor); total_fuel_floor += @divFloor(((fuel_floor + 1) * fuel_floor), 2); const fuel_ceil = try absInt(p - mean_ceil); total_fuel_ceil += @divFloor(((fuel_ceil + 1) * fuel_ceil), 2); } return min(total_fuel_floor, total_fuel_ceil); } test "day07.part2" { @setEvalBranchQuota(200_000); try testing.expectEqual(98363777, comptime try part2()); } /// /// readCrabPositions reads the input file and returns a sorted array of crab positions /// fn readCrabPositions() ![size]i32 { var crab_positions: [size]i32 = undefined; var positions = tokenize(u8, input, "\n,"); var i: usize = 0; while (positions.next()) |pos| : (i += 1) { crab_positions[i] = try parseInt(i32, pos, 10); } return crab_positions; }
src/day07/day07.zig
const builtin = @import("builtin"); pub const WINDOW = u32; pub const PIXMAP = u32; pub const GCONTEXT = u32; pub const REGION = u32; pub const CRTC = u32; pub const SyncFence = u32; pub const EventID = u32; pub const DRAWABLE = extern union { window: WINDOW, pixmap: PIXMAP, }; pub const ATOM = u32; pub const VISUALID = u32; pub const VISUALTYPE = extern enum(u8) { StaticGray = 0, GrayScale = 1, StaticColor = 2, PseudoColor = 3, TrueColor = 4, DirectColor = 5, }; pub const COLORMAP = u32; pub const KEYCODE = u8; pub const BuiltinAtom = enum(u32) { PRIMARY = 1, SECONDARY = 2, ARC = 3, ATOM = 4, BITMAP = 5, CARDINAL = 6, COLORMAP = 7, CURSOR = 8, INTEGER = 19, PIXMAP = 20, POINT = 21, STRING = 31, VISUALID = 32, WINDOW = 33, WM_COMMAND = 34, WM_HINTS = 35, WM_CLIENT_MACHINE = 36, WM_ICON_NAME = 37, WM_ICON_SIZE = 38, WM_NAME = 39, WM_NORMAL_HINTS = 40, WM_SIZE_HINTS = 41, WM_ZOOM_HINTS = 42, WM_CLASS = 67, WM_TRANSIENT_FOR = 68, // Todo: more }; // Setup pub const SetupRequest = extern struct { byte_order: u8 = if (builtin.endian == .Little) 0x6c else 0x42, pad0: u8 = 0, proto_major: u16 = 11, proto_minor: u16 = 0, auth_proto_name_len: u16 = 0, auth_proto_data_len: u16 = 0, pad1: u16 = 0, }; pub const SetupResponseHeader = extern struct { status: u8, reason_length: u8, protocol_major_version: u16, protocol_minor_version: u16, length: u16, }; pub const SetupAccepted = extern struct { release_number: u32, resource_id_base: u32, resource_id_mask: u32, motion_buffer_size: u32, vendor_len: u16, maximum_request_length: u16, roots_len: u8, pixmap_formats_len: u8, image_byte_order: u8, bitmap_format_bit_order: u8, bitmap_format_scanline_unit: u8, bitmap_format_scanline_pad: u8, min_keycode: u8, max_keycode: u8, pad0: [4]u8, }; pub const PixmapFormat = extern struct { depth: u8, bits_per_pixel: u8, scanline_pad: u8, pad0: u8, pad1: u32, }; pub const Screen = extern struct { root: WINDOW, default_colormap: u32, white_pixel: u32, black_pixel: u32, current_input_masks: u32, width_in_pixels: u16, height_in_pixels: u16, width_in_millimeters: u16, height_in_millimeters: u16, min_installed_maps: u16, max_installed_maps: u16, root_visual_id: VISUALID, backing_stores: u8, save_unders: u8, root_depth: u8, allowed_depths_len: u8, }; pub const Depth = extern struct { depth: u8, pad0: u8, visual_count: u16, pad1: u32, }; pub const Visual = extern struct { id: VISUALID, class: VISUALTYPE, bits_per_rgb: u8, colormap_entries: u16, red_mask: u32, green_mask: u32, blue_mask: u32, pad0: u32, }; // Events pub const XEventCode = extern enum(u8) { Error = 0, Reply = 1, KeyPress = 2, KeyRelease = 3, ButtonPress = 4, ButtonRelease = 5, MotionNotify = 6, EnterNotify = 7, LeaveNotify = 8, FocusIn = 9, FocusOut = 10, KeymapNotify = 11, Expose = 12, GraphicsExposure = 13, NoExposure = 14, VisibilityNotify = 15, CreateNotify = 16, DestroyNotify = 17, UnmapNotify = 18, MapNotify = 19, MapRequest = 20, ReparentNotify = 21, ConfigureNotify = 22, ConfigureRequest = 23, GravityNotify = 24, ResizeRequest = 25, CirculateNotify = 26, CirculateRequest = 27, PropertyNotify = 28, SelectionClear = 29, SelectionRequest = 30, SelectionNotify = 31, ColormapNotify = 32, ClientMessage = 33, MappingNotify = 34, GenericEvent = 35, _, }; pub const XErrorCode = extern enum(u8) { Request = 1, Value = 2, Window = 3, Pixmap = 4, Atom = 5, Cursor = 6, Font = 7, Match = 8, Drawable = 9, Access = 10, Alloc = 11, Colormap = 12, GContext = 13, IDChoice = 14, Name = 15, Length = 16, Implementation = 17, _, }; pub const XEventError = extern struct { type: u8, code: XErrorCode, seqence_number: u16, resource_id: u32, minor_code: u16, major_code: u8, pad0: u8, pad1: [5]u32, }; pub const ConfigureNotify = extern struct { code: u8, pad0: u8, seqnum: u16, event_window: WINDOW, window: WINDOW, above_sibling: u32, x: u16, y: u16, width: u16, height: u16, border_width: u16, override_redirect: u8, pad1: [5]u8, }; pub const DestroyNotify = extern struct { code: u8, pad0: u8, seqnum: u16, event_window: WINDOW, window: WINDOW, pad1: [20]u8, }; pub const Expose = extern struct { code: u8, pad0: u8, seqnum: u16, window: WINDOW, x: u16, y: u16, width: u16, height: u16, pad1: [14]u8, }; // Requests / Replies pub const QueryExtensionRequest = extern struct { opcode: u8 = 98, pad0: u8 = 0, length_request: u16, length_name: u16, pad1: u16 = 0, // + name }; pub const QueryExtensionReply = extern struct { opcode: u8, pad0: u8, seqence_number: u16, reply_length: u32, present: u8, major_opcode: u8, first_event: u8, first_error: u8, pad1: [20]u8, }; pub const CreateWindow = extern struct { opcode: u8 = 1, depth: u8, request_length: u16, id: WINDOW, parent: WINDOW, x: u16, y: u16, width: u16, height: u16, border_width: u16 = 0, class: u16 = 1, visual: VISUALID, mask: u32, }; pub const CWBackgroundPixmap: u32 = 0x00000001; pub const CWBackgroundPixel: u32 = 0x00000002; pub const CWBorderPixmap: u32 = 0x00000004; pub const CWBorderPixel: u32 = 0x00000008; pub const CWBitGravity: u32 = 0x00000010; pub const CWWinGravity: u32 = 0x00000020; pub const CWBackingStores: u32 = 0x00000040; pub const CWBackingPlanes: u32 = 0x00000080; pub const CWBackingPixel: u32 = 0x00000100; pub const CWOverrideRedirect: u32 = 0x00000200; pub const CWSaveUnder: u32 = 0x00000400; pub const CWEventMask: u32 = 0x00000800; pub const CWDoNotPropagateMask: u32 = 0x00001000; pub const CWColormap: u32 = 0x00002000; pub const CWCursor: u32 = 0x00004000; pub const EventKeyPress: u32 = 0x00000001; pub const EventKeyRelease: u32 = 0x00000002; pub const EventButtonPress: u32 = 0x00000004; pub const EventButtonRelease: u32 = 0x00000008; pub const EventEnterWindow: u32 = 0x00000010; pub const EventLeaveWindow: u32 = 0x00000020; pub const EventPointerMotion: u32 = 0x00000040; pub const EventPointerMotionHint: u32 = 0x00000080; pub const EventButton1Motion: u32 = 0x00000100; pub const EventButton2Motion: u32 = 0x00000200; pub const EventButton3Motion: u32 = 0x00000400; pub const EventButton4Motion: u32 = 0x00000800; pub const EventButton5Motion: u32 = 0x00001000; pub const EventButtonMotion: u32 = 0x00002000; pub const EventKeymapState: u32 = 0x00004000; pub const EventExposure: u32 = 0x00008000; pub const EventVisibilityChange: u32 = 0x00010000; pub const EventStructureNotify: u32 = 0x00020000; pub const EventResizeRedirect: u32 = 0x00040000; pub const EventSubstructureNotify: u32 = 0x00080000; pub const EventSubstructureRedirect: u32 = 0x00100000; pub const EventFocusChange: u32 = 0x00200000; pub const EventPropertyChange: u32 = 0x00400000; pub const EventColormapChange: u32 = 0x00800000; pub const EventOwnerGrabButton: u32 = 0x01000000; pub const DestroyWindow = extern struct { request_type: u8 = 4, pad0: u8 = 0, length: u16 = 8 >> 2, id: WINDOW, }; pub const MapWindow = extern struct { request_type: u8 = 8, pad0: u8 = 0, length: u16 = 8 >> 2, id: WINDOW, }; pub const UnmapWindow = extern struct { request_type: u8 = 10, pad0: u8 = 0, length: u16 = 8 >> 2, id: WINDOW, }; pub const ChangeProperty = extern struct { request_type: u8 = 18, mode: u8 = 0, request_length: u16, window: WINDOW, property: u32, property_type: u32, format: u8, pad0: [3]u8 = [3]u8{ 0, 0, 0 }, length: u32, }; pub const DeleteProperty = extern struct { request_type: u8 = 19, pad0: u8 = 0, request_length: u16 = 3, window: u32, property: u32, }; pub const SizeHints = extern struct { flags: u32 = 0, pad0: [4]u32 = [_]u32{0} ** 4, min: [2]u32 = [2]u32{ 0, 0 }, max: [2]u32 = [2]u32{ 0, 0 }, inc: [2]u32 = [2]u32{ 0, 0 }, aspect_min: [2]u32 = [2]u32{ 0, 0 }, aspect_max: [2]u32 = [2]u32{ 0, 0 }, base: [2]u32 = [2]u32{ 0, 0 }, win_gravity: u32 = 0, }; pub const MotifHints = extern struct { flags: u32, functions: u32, decorations: u32, input_mode: i32, status: u32, }; pub const CreatePixmap = extern struct { request_type: u8 = 53, depth: u8, request_length: u16 = 4, pid: PIXMAP, drawable: DRAWABLE, width: u16, height: u16, }; pub const FreePixmap = extern struct { request_type: u8 = 54, pad0: u8 = 0, request_length: u16 = 2, pixmap: u32, }; pub const CreateGC = extern struct { request_type: u8 = 55, unsued: u8 = 0, request_length: u16, cid: GCONTEXT, drawable: DRAWABLE, bitmask: u32, }; pub const FreeGC = extern struct { request_type: u8 = 60, unsued: u8 = 0, request_length: u16 = 2, gc: GCONTEXT, }; pub const CopyArea = extern struct { request_type: u8 = 62, pad0: u8 = 0, request_length: u16 = 7, src_drawable: DRAWABLE, dst_drawable: DRAWABLE, gc: GCONTEXT, src_x: u16, src_y: u16, dst_x: u16, dst_y: u16, width: u16, height: u16, }; pub const PutImage = extern struct { request_type: u8 = 72, format: u8 = 2, request_length: u16, drawable: DRAWABLE, gc: u32, width: u16, height: u16, dst: [2]u16, left_pad: u8 = 0, depth: u8 = 24, pad0: [2]u8 = [2]u8{ 0, 0 }, }; pub const PutImageBig = extern struct { request_type: u8 = 72, format: u8 = 2, request_length_tag: u16 = 0, request_length: u32, drawable: DRAWABLE, gc: u32, width: u16, height: u16, dst: [2]u16, left_pad: u8 = 0, depth: u8 = 24, pad0: [2]u8 = [2]u8{ 0, 0 }, }; pub const InternAtom = extern struct { request_type: u8 = 16, if_exists: u8, request_length: u16, name_length: u16, pad0: u16 = 0, }; pub const InternAtomReply = extern struct { reply: u8, pad0: u8, seqence_number: u16, reply_length: u32, atom: u32, pad1: [20]u8, }; // BigRequests pub const BigReqEnable = extern struct { opcode: u8, pad0: u8 = 0, length_request: u16 = 1, }; pub const BigReqEnableReply = extern struct { opcode: u8, pad0: u8, seqence_number: u16, reply_length: u32, max_req_len: u32, pad1: u16, }; // RandR pub const RRQueryVersion = extern struct { opcode: u8, minor: u8 = 0, length_request: u16 = 3, version_major: u32, version_minor: u32, }; pub const RRQueryVersionReply = extern struct { opcode: u8, pad0: u8, seqence_number: u16, reply_length: u32, version_major: u32, version_minor: u32, }; pub const RRGetScreenResources = extern struct { opcode: u8, minor: u8 = 8, length_request: u16 = 2, window: u32, }; pub const RRGetScreenResourcesCurrent = extern struct { opcode: u8, minor: u8 = 25, length_request: u16 = 2, window: u32, }; pub const RRGetScreenResourcesReply = extern struct { opcode: u8, pad0: u8, seqence_number: u16, reply_length: u32, timestamp: u32, config_timestamp: u32, crtcs: u16, outputs: u16, modes: u16, names: u16, }; pub const ModeInfo = extern struct { id: u32, width: u16, height: u16, dot_clock: u32, hsync_start: u16, hsync_end: u16, htotal: u16, hscew: u16, vsync_start: u16, vsync_end: u16, vtotal: u16, name_len: u16, flags: u32, }; // XFixes pub const XFixesQueryVersion = extern struct { opcode: u8, minor: u8 = 0, length_request: u16 = 3, version_major: u32, version_minor: u32, }; pub const XFixesQueryVersionReply = extern struct { opcode: u8, pad0: u8, seqence_number: u16, reply_length: u32, version_major: u32, version_minor: u32, }; pub const CreateRegion = extern struct { opcode: u8, minor: u8 = 5, length_request: u16, region: REGION, }; pub const DestroyRegion = extern struct { opcode: u8, minor: u8 = 10, length_request: u16 = 2, region: REGION, }; pub const SetRegion = extern struct { opcode: u8, minor: u8 = 11, length_request: u16, region: REGION, }; // Present pub const PresentQueryVersion = extern struct { opcode: u8, minor: u8 = 0, length_request: u16 = 3, version_major: u32, version_minor: u32, }; pub const PresentPixmap = extern struct { opcode: u8, minor: u8 = 1, length: u16 = 18, window: WINDOW, pixmap: PIXMAP, serial: u32, valid_area: REGION, update_area: REGION, offset_x: i16 = 0, offset_y: i16 = 0, crtc: CRTC, wait_fence: SyncFence, idle_fence: SyncFence, options: u32, unused: u32 = 0, target_msc: u64, divisor: u64, remainder: u64, }; pub const PresentNotify = extern struct { window: WINDOW, serial: u32, }; pub const PresentSelectInput = extern struct { opcode: u8, minor: u8 = 3, length: u16 = 4, event_id: EventID, window: WINDOW, mask: u32, }; pub const PresentCompleteNotify = extern struct { type: u8 = 35, extension: u8, seqnum: u16, length: u32, evtype: u16 = 1, kind: u8, mode: u8, event_id: u32, window: u32, serial: u32, ust: u64, msc: u64, }; // MIT-SHM pub const MitShmQueryVersion = extern struct { opcode: u8, minor: u8 = 0, length_request: u16 = 1, }; // Generic Event pub const GenericEvent = extern struct { type: u8 = 35, extension: u8, seqnum: u16, length: u32, evtype: u16, pad0: u16, pad1: [5]u32, }; /// Event generated when a key/button is pressed/released /// or when the input device moves pub const InputDeviceEvent = extern struct { type: u8, detail: KEYCODE, sequence: u16, time: u32, root: WINDOW, event: WINDOW, child: WINDOW, root_x: i16, root_y: i16, event_x: i16, event_y: i16, state: u16, same_screen: u8, pad: u8, };
didot-zwl/zwl/src/x11/types.zig
const std = @import("std"); const Builder = @import("std").build.Builder; pub fn build(b: *Builder) 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 compile_all = b.option(bool, "compile-all", "Compiles all supported targets") orelse false; const mode = b.standardReleaseOptions(); const local_target = b.standardTargetOptions(.{}); const linux_amd64_t = std.zig.CrossTarget{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .gnu }; const linux_aarch64_t = std.zig.CrossTarget{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .gnu }; const windows_amd64_t = std.zig.CrossTarget{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu }; const windows_aarch64_t = std.zig.CrossTarget{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .gnu }; const macos_amd64_t = std.zig.CrossTarget{ .cpu_arch = .x86_64, .os_tag = .macos, .abi = .gnu }; const macos_aarch64_t = std.zig.CrossTarget{ .cpu_arch = .aarch64, .os_tag = .macos, .abi = .gnu }; // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const local = b.addExecutable("amanatsu", "src/main.zig"); const linux_amd64 = b.addExecutable("amanatsu-linux-amd64", "src/main.zig"); const linux_aarch64 = b.addExecutable("amanatsu-linux-aarch64", "src/main.zig"); const windows_amd64 = b.addExecutable("amanatsu-windows-amd64", "src/main.zig"); const windows_aarch64 = b.addExecutable("amanatsu-windows-aarch64", "src/main.zig"); const macos_amd64 = b.addExecutable("amanatsu-macos-amd64", "src/main.zig"); const macos_aarch64 = b.addExecutable("amanatsu-macos-aarch64", "src/main.zig"); if (compile_all) { linux_amd64.setBuildMode(mode); linux_amd64.setTarget(linux_amd64_t); linux_amd64.install(); linux_aarch64.setBuildMode(mode); linux_aarch64.setTarget(linux_aarch64_t); linux_aarch64.install(); windows_amd64.setBuildMode(mode); windows_amd64.setTarget(windows_amd64_t); windows_amd64.install(); windows_aarch64.setBuildMode(mode); windows_aarch64.setTarget(windows_aarch64_t); windows_aarch64.install(); macos_amd64.setBuildMode(mode); macos_amd64.setTarget(macos_amd64_t); macos_amd64.install(); macos_aarch64.setBuildMode(mode); macos_aarch64.setTarget(macos_aarch64_t); macos_aarch64.install(); } else { local.setBuildMode(mode); local.setTarget(local_target); local.install(); } const run_cmd = local.run(); run_cmd.step.dependOn(b.getInstallStep()); const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); }
build.zig
const std = @import("std"); const sdl = @import("./sdl.zig"); const core = @import("core"); const Rect = core.geometry.Rect; const Coord = core.geometry.Coord; const makeCoord = core.geometry.makeCoord; pub const version_string = @embedFile("../../zig-cache/version.txt"); pub const sprites = @import("../../zig-cache/spritesheet32.zig"); pub const large_sprites = @import("../../zig-cache/spritesheet200.zig"); pub const fonts = @import("../../zig-cache/fontsheet.zig"); var sprites_texture: *sdl.c.SDL_Texture = undefined; var large_sprites_texture: *sdl.c.SDL_Texture = undefined; var fonts_texture: *sdl.c.SDL_Texture = undefined; pub fn init(renderer: *sdl.Renderer) void { sprites_texture = loadTexture(renderer, sprites.buffer, sprites.width, sprites.height); large_sprites_texture = loadTexture(renderer, large_sprites.buffer, large_sprites.width, large_sprites.height); fonts_texture = loadTexture(renderer, fonts.buffer, fonts.width, fonts.height); } pub fn deinit() void { sdl.c.SDL_DestroyTexture(sprites_texture); sdl.c.SDL_DestroyTexture(large_sprites_texture); sdl.c.SDL_DestroyTexture(fonts_texture); } fn loadTexture(renderer: *sdl.Renderer, buffer: []const u8, width: i32, height: i32) *sdl.c.SDL_Texture { var texture: *sdl.c.SDL_Texture = sdl.c.SDL_CreateTexture(renderer, sdl.c.SDL_PIXELFORMAT_RGBA8888, sdl.c.SDL_TEXTUREACCESS_STATIC, width, height) orelse { std.debug.panic("SDL_CreateTexture failed: {c}\n", .{sdl.c.SDL_GetError()}); }; if (sdl.c.SDL_SetTextureBlendMode(texture, @intToEnum(sdl.c.SDL_BlendMode, sdl.c.SDL_BLENDMODE_BLEND)) != 0) { std.debug.panic("SDL_SetTextureBlendMode failed: {c}\n", .{sdl.c.SDL_GetError()}); } const pitch = width * 4; if (sdl.c.SDL_UpdateTexture(texture, 0, @ptrCast(?*const c_void, buffer.ptr), pitch) != 0) { std.debug.panic("SDL_UpdateTexture failed: {c}\n", .{sdl.c.SDL_GetError()}); } return texture; } pub fn renderTextScaled(renderer: *sdl.Renderer, text: []const u8, location: Coord, bold: bool, scale: i32) Coord { var lower_right = location; for (text) |c| { lower_right = renderChar(renderer, c, makeCoord(lower_right.x, location.y), bold, scale); } return lower_right; } pub fn getCharRect(c: u8, bold: bool) Rect { return (if (bold) fonts.console_bold else fonts.console)[c - ' ']; } fn renderChar(renderer: *sdl.Renderer, c: u8, location: Coord, bold: bool, scale: i32) Coord { std.debug.assert(scale > 0); const char_rect = getCharRect(c, bold); const dest = Rect{ .x = location.x, .y = location.y, .width = char_rect.width * scale, .height = char_rect.height * scale, }; const source_sdl = sdl.makeRect(char_rect); const dest_sdl = sdl.makeRect(dest); sdl.assertZero(sdl.SDL_RenderCopy(renderer, fonts_texture, &source_sdl, &dest_sdl)); return makeCoord(dest.x + dest.width, dest.y + dest.height); } pub fn renderSprite(renderer: *sdl.Renderer, sprite: Rect, location: Coord) void { const dest = Rect{ .x = location.x, .y = location.y, .width = sprite.width, .height = sprite.height, }; const source_sdl = sdl.makeRect(sprite); const dest_sdl = sdl.makeRect(dest); sdl.assertZero(sdl.SDL_RenderCopy(renderer, sprites_texture, &source_sdl, &dest_sdl)); } pub fn renderSpriteRotated(renderer: *sdl.Renderer, sprite: Rect, location: Coord, rotation: u3) void { const dest = Rect{ .x = location.x, .y = location.y, .width = sprite.width, .height = sprite.height, }; const source_sdl = sdl.makeRect(sprite); const dest_sdl = sdl.makeRect(dest); const angle = @intToFloat(f64, rotation) * 45.0; sdl.assertZero(sdl.SDL_RenderCopyEx(renderer, sprites_texture, &source_sdl, &dest_sdl, angle, null, sdl.c.SDL_FLIP_NONE)); } pub fn renderLargeSprite(renderer: *sdl.Renderer, large_sprite: Rect, location: Coord) void { const dest = Rect{ .x = location.x, .y = location.y, .width = large_sprite.width, .height = large_sprite.height, }; const source_sdl = sdl.makeRect(large_sprite); const dest_sdl = sdl.makeRect(dest); sdl.assertZero(sdl.SDL_RenderCopy(renderer, large_sprites_texture, &source_sdl, &dest_sdl)); }
src/gui/textures.zig
const std = @import("std"); const webgpu = @import("./webgpu.zig"); pub const ComputePipeline = struct { pub const VTable = struct { destroy_fn: fn(*ComputePipeline) void, get_bind_group_layout_fn: fn(*ComputePipeline, u32) ?*webgpu.BindGroupLayout, set_label_fn: fn(*ComputePipeline, [:0]const u8) void, }; __vtable: *const VTable, device: *webgpu.Device, pub inline fn destroy(compute_pipeline: *ComputePipeline) void { compute_pipeline.__vtable.destroy_fn(compute_pipeline); } pub inline fn getBindGroupLayout(compute_pipeline: *ComputePipeline, group_index: u32) ?*webgpu.BindGroupLayout { return compute_pipeline.__vtable.get_bind_group_layout_fn(compute_pipeline, group_index); } pub inline fn setLabel(compute_pipeline: *ComputePipeline, label: [:0]const u8) void { compute_pipeline.__vtable.set_label_fn(compute_pipeline, label); } }; pub const RenderPipeline = struct { pub const VTable = struct { destroy_fn: fn(*RenderPipeline) void, get_bind_group_layout_fn: fn(*RenderPipeline, u32) ?*webgpu.BindGroupLayout, set_label_fn: fn(*RenderPipeline, [:0]const u8) void, }; __vtable: *const VTable, device: *webgpu.Device, pub inline fn destroy(render_pipeline: *RenderPipeline) void { render_pipeline.__vtable.destroy_fn(render_pipeline); } pub inline fn setBindGroupLayout(render_pipeline: *RenderPipeline, group_index: u32) ?*webgpu.BindGroupLayout { return render_pipeline.__vtable.get_bind_group_layout_fn(render_pipeline, group_index); } pub inline fn setLabel(render_pipeline: *RenderPipeline, label: [:0]const u8) void { return render_pipeline.__vtable.set_label_fn(render_pipeline, label); } }; pub const ShaderModule = struct { pub const VTable = struct { destroy_fn: fn(*ShaderModule) void, get_compilation_info_fn: fn(*ShaderModule) GetCompilationInfoError!webgpu.CompilationInfo, set_label_fn: fn(*ShaderModule, [:0]const u8) void, }; __vtable: *const VTable, device: *webgpu.Device, pub inline fn destroy(shader_module: *ShaderModule) void { return shader_module.__vtable.destroy_fn(shader_module); } pub const GetCompilationInfoError = error { Failed, }; pub inline fn getCompilationInfo(shader_module: *ShaderModule) GetCompilationInfoError!webgpu.CompilationInfo { return shader_module.__vtable.get_compilation_info_fn(shader_module); } pub inline fn setLabel(shader_module: *ShaderModule, label: [:0]const u8) void { return shader_module.__vtable.set_label_fn(shader_module, label); } };
src/pipeline.zig
const std = @import("std"); const math = std.math; pub fn Vec(comptime S: usize, comptime T: type) type { return switch (S) { 2 => extern struct { x: T = 0, y: T = 0, const Self = @This(); pub usingnamespace VecCommonFns(S, T, @This()); pub fn init(x: T, y: T) @This() { return @This(){ .x = x, .y = y }; } pub fn orthogonal(self: @This()) @This() { return .{ .x = -self.y, .y = self.x }; } pub fn perpindicular(self: @This(), v: @This()) @This() { return .{ .x = -1 * (v.y - self.y), .y = v.x - self.x }; } pub fn rotate(self: @This(), radians: f32) @This() { return .{ .v = [_]T{ self.x * std.math.cos(radians) - self.y * std.math.sin(radians), self.y * std.math.cos(radians) + self.x * std.math.sin(radians), }, }; } pub fn angleToVec(radians: f32, length: f32) Vec2 { return .{ .x = math.cos(radians) * length, .y = math.sin(radians) * length }; } pub fn angleBetween(self: Vec2, to: Vec2) f32 { return math.atan2(f32, to.y - self.y, to.x - self.x); } pub fn sub(self: @This(), x: T, y: T) @This() { return self.subv(init(x, y)); } pub fn add(self: @This(), x: T, y: T) @This() { return self.addv(init(x, y)); } pub fn mul(self: @This(), x: T, y: T) @This() { return self.mulv(init(x, y)); } }, 3 => extern struct { x: T = 0, y: T = 0, z: T = 0, const Self = @This(); pub usingnamespace VecCommonFns(S, T, @This()); pub fn init(x: T, y: T, z: T) @This() { return @This(){ .x = x, .y = y, .z = z }; } pub fn cross(self: Self, other: Self) Self { return @This(){ .v = .{ self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x, }, }; } pub fn sub(self: @This(), x: T, y: T, z: T) @This() { return self.subv(init(x, y, z)); } pub fn add(self: @This(), x: T, y: T, z: T) @This() { return self.addv(init(x, y, z)); } pub fn mul(self: @This(), x: T, y: T, z: T) @This() { return self.mulv(init(x, y, z)); } }, 4 => extern struct { x: T = 0, y: T = 0, z: T = 0, w: T = 0, const Self = @This(); pub usingnamespace VecCommonFns(S, T, @This()); pub fn init(xv: T, yv: T, zv: T, wv: T) @This() { return @This(){ .v = .{ .x = xv, .y = yv, .z = zv, .w = wv } }; } pub fn sub(self: @This(), x: T, y: T, z: T, w: T) @This() { return self.subv(init(x, y, z, w)); } pub fn add(self: @This(), x: T, y: T, z: T, w: T) @This() { return self.addv(init(x, y, z, w)); } pub fn mul(self: @This(), x: T, y: T, z: T, w: T) @This() { return self.mulv(init(x, y, z, w)); } }, else => @compileError("Vec of size " ++ S ++ " is not supported"), }; } fn VecCommonFns(comptime S: usize, comptime T: type, comptime This: type) type { return struct { pub fn getField(this: This, comptime index: comptime_int) T { return switch (index) { 0 => this.x, 1 => this.y, 2 => this.z, 3 => this.w, else => @compileError("index out of bounds!"), }; } pub fn getFieldMut(this: *This, comptime index: comptime_int) *T { return switch (index) { 0 => &this.x, 1 => &this.y, 2 => &this.z, 3 => &this.w, else => @compileError("index out of bounds!"), }; } pub fn subv(self: This, other: This) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = self.getField(i) - other.getField(i); } return res; } pub fn addv(self: This, other: This) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = self.getField(i) + other.getField(i); } return res; } pub fn mulv(self: This, other: This) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = self.getField(i) * other.getField(i); } return res; } pub fn scale(self: This, scal: T) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = self.getField(i) * scal; } return res; } pub fn scaleDiv(self: This, scal: T) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = self.getField(i) / scal; } return res; } pub fn normalize(self: This) This { const mag = self.magnitude(); var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = self.getField(i) / mag; } return res; } pub fn maxComponentsv(self: This, other: This) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = std.math.max(self.getField(i), other.getField(i)); } return res; } pub fn minComponentsv(self: This, other: This) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = std.math.min(self.getField(i), other.getField(i)); } return res; } pub fn clampv(self: This, min: This, max: This) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = math.clamp(self.getField(i), min.getField(i), max.getField(i)); } return res; } pub fn magnitudeSq(self: This) T { var sum: T = 0; comptime var i = 0; inline while (i < S) : (i += 1) { sum += self.getField(i) * self.getField(i); } return sum; } pub fn magnitude(self: This) T { return std.math.sqrt(self.magnitudeSq()); } pub fn distanceSq(self: This, other: This) T { return self.subv(other).magnitudeSq(); } pub fn distance(self: This, other: This) T { return self.subv(other).magnitude(); } pub fn dotv(self: This, other: This) T { var sum: T = 0; comptime var i = 0; inline while (i < S) : (i += 1) { sum += self.getField(i) * other.getField(i); } return sum; } pub fn eql(self: This, other: This) bool { comptime var i = 0; inline while (i < S) : (i += 1) { if (self.getField(i) != other.getField(i)) { return false; } } return true; } pub fn floor(self: This) This { var res: This = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = @floor(self.getField(i)); } return res; } pub fn intToFloat(self: This, comptime F: type) Vec(S, F) { var res: Vec(S, F) = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = @intToFloat(F, self.getField(i)); } return res; } pub fn floatToInt(self: This, comptime I: type) Vec(S, I) { var res: Vec(S, I) = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = @floatToInt(I, self.getField(i)); } return res; } pub fn floatCast(self: This, comptime F: type) Vec(S, F) { var res: Vec(S, F) = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = @floatCast(F, self.getField(i)); } return res; } pub fn intCast(self: This, comptime I: type) Vec(S, I) { var res: Vec(S, I) = undefined; comptime var i = 0; inline while (i < S) : (i += 1) { res.getFieldMut(i).* = @intCast(I, self.getField(i)); } return res; } pub fn format(self: This, comptime fmt: []const u8, opt: std.fmt.FormatOptions, out: anytype) !void { _ = opt; _ = fmt; return switch (S) { 2 => std.fmt.format(out, "<{d}, {d}>", .{ self.x, self.y }), 3 => std.fmt.format(out, "<{d}, {d}, {d}>", .{ self.x, self.y, self.z }), else => @compileError("Format is unsupported for this vector size"), }; } }; } pub const Vec2f = Vec(2, f32); pub const Vec2i = Vec(2, i32); pub const Vec3f = Vec(3, f32); pub const Vec3i = Vec(3, i32); pub const vec2f = Vec2f.init; pub const vec2i = Vec2i.init; pub const vec3f = Vec3f.init; pub const vec3i = Vec3i.init; // For backwards compatibility pub const Vec2 = Vec2f; test "vec2 tests" { const v = Vec2{ .x = 1, .y = 5 }; const v2 = v.orthogonal(); const v_orth = Vec2{ .x = -5, .y = 1 }; std.testing.expectEqual(v2, v_orth); std.testing.expect(math.approxEq(f32, -2.55, v.angleBetween(v2), 0.01)); std.testing.expect(math.approxEq(f32, 52, v.distanceSq(v2), 0.01)); std.testing.expect(math.approxEq(f32, 7.21, v.distance(v2), 0.01)); std.testing.expect(math.approxEq(f32, -6, v.perpindicular(v2).y, 0.01)); }
gamekit/math/vec2.zig
usingnamespace std.os; const std = @import("../../../std.zig"); // instruction classes /// jmp mode in word width pub const JMP32 = 0x06; /// alu mode in double word width pub const ALU64 = 0x07; // ld/ldx fields /// double word (64-bit) pub const DW = 0x18; /// exclusive add pub const XADD = 0xc0; // alu/jmp fields /// mov reg to reg pub const MOV = 0xb0; /// sign extending arithmetic shift right */ pub const ARSH = 0xc0; // change endianness of a register /// flags for endianness conversion: pub const END = 0xd0; /// convert to little-endian */ pub const TO_LE = 0x00; /// convert to big-endian pub const TO_BE = 0x08; pub const FROM_LE = TO_LE; pub const FROM_BE = TO_BE; // jmp encodings /// jump != * pub const JNE = 0x50; /// LT is unsigned, '<' pub const JLT = 0xa0; /// LE is unsigned, '<=' * pub const JLE = 0xb0; /// SGT is signed '>', GT in x86 pub const JSGT = 0x60; /// SGE is signed '>=', GE in x86 pub const JSGE = 0x70; /// SLT is signed, '<' pub const JSLT = 0xc0; /// SLE is signed, '<=' pub const JSLE = 0xd0; /// function call pub const CALL = 0x80; /// function return pub const EXIT = 0x90; /// Flag for prog_attach command. If a sub-cgroup installs some bpf program, the /// program in this cgroup yields to sub-cgroup program. pub const F_ALLOW_OVERRIDE = 0x1; /// Flag for prog_attach command. If a sub-cgroup installs some bpf program, /// that cgroup program gets run in addition to the program in this cgroup. pub const F_ALLOW_MULTI = 0x2; /// Flag for prog_attach command. pub const F_REPLACE = 0x4; /// If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the verifier /// will perform strict alignment checking as if the kernel has been built with /// CONFIG_EFFICIENT_UNALIGNED_ACCESS not set, and NET_IP_ALIGN defined to 2. pub const F_STRICT_ALIGNMENT = 0x1; /// If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the verifier will /// allow any alignment whatsoever. On platforms with strict alignment /// requirements for loads ands stores (such as sparc and mips) the verifier /// validates that all loads and stores provably follow this requirement. This /// flag turns that checking and enforcement off. /// /// It is mostly used for testing when we want to validate the context and /// memory access aspects of the verifier, but because of an unaligned access /// the alignment check would trigger before the one we are interested in. pub const F_ANY_ALIGNMENT = 0x2; /// BPF_F_TEST_RND_HI32 is used in BPF_PROG_LOAD command for testing purpose. /// Verifier does sub-register def/use analysis and identifies instructions /// whose def only matters for low 32-bit, high 32-bit is never referenced later /// through implicit zero extension. Therefore verifier notifies JIT back-ends /// that it is safe to ignore clearing high 32-bit for these instructions. This /// saves some back-ends a lot of code-gen. However such optimization is not /// necessary on some arches, for example x86_64, arm64 etc, whose JIT back-ends /// hence hasn't used verifier's analysis result. But, we really want to have a /// way to be able to verify the correctness of the described optimization on /// x86_64 on which testsuites are frequently exercised. /// /// So, this flag is introduced. Once it is set, verifier will randomize high /// 32-bit for those instructions who has been identified as safe to ignore /// them. Then, if verifier is not doing correct analysis, such randomization /// will regress tests to expose bugs. pub const F_TEST_RND_HI32 = 0x4; /// When BPF ldimm64's insn[0].src_reg != 0 then this can have two extensions: /// insn[0].src_reg: BPF_PSEUDO_MAP_FD BPF_PSEUDO_MAP_VALUE /// insn[0].imm: map fd map fd /// insn[1].imm: 0 offset into value /// insn[0].off: 0 0 /// insn[1].off: 0 0 /// ldimm64 rewrite: address of map address of map[0]+offset /// verifier type: CONST_PTR_TO_MAP PTR_TO_MAP_VALUE pub const PSEUDO_MAP_FD = 1; pub const PSEUDO_MAP_VALUE = 2; /// when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative /// offset to another bpf function pub const PSEUDO_CALL = 1; /// flag for BPF_MAP_UPDATE_ELEM command. create new element or update existing pub const ANY = 0; /// flag for BPF_MAP_UPDATE_ELEM command. create new element if it didn't exist pub const NOEXIST = 1; /// flag for BPF_MAP_UPDATE_ELEM command. update existing element pub const EXIST = 2; /// flag for BPF_MAP_UPDATE_ELEM command. spin_lock-ed map_lookup/map_update pub const F_LOCK = 4; /// flag for BPF_MAP_CREATE command */ pub const BPF_F_NO_PREALLOC = 0x1; /// flag for BPF_MAP_CREATE command. Instead of having one common LRU list in /// the BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list which can /// scale and perform better. Note, the LRU nodes (including free nodes) cannot /// be moved across different LRU lists. pub const BPF_F_NO_COMMON_LRU = 0x2; /// flag for BPF_MAP_CREATE command. Specify numa node during map creation pub const BPF_F_NUMA_NODE = 0x4; /// flag for BPF_MAP_CREATE command. Flags for BPF object read access from /// syscall side pub const BPF_F_RDONLY = 0x8; /// flag for BPF_MAP_CREATE command. Flags for BPF object write access from /// syscall side pub const BPF_F_WRONLY = 0x10; /// flag for BPF_MAP_CREATE command. Flag for stack_map, store build_id+offset /// instead of pointer pub const BPF_F_STACK_BUILD_ID = 0x20; /// flag for BPF_MAP_CREATE command. Zero-initialize hash function seed. This /// should only be used for testing. pub const BPF_F_ZERO_SEED = 0x40; /// flag for BPF_MAP_CREATE command Flags for accessing BPF object from program /// side. pub const BPF_F_RDONLY_PROG = 0x80; /// flag for BPF_MAP_CREATE command. Flags for accessing BPF object from program /// side. pub const BPF_F_WRONLY_PROG = 0x100; /// flag for BPF_MAP_CREATE command. Clone map from listener for newly accepted /// socket pub const BPF_F_CLONE = 0x200; /// flag for BPF_MAP_CREATE command. Enable memory-mapping BPF map pub const BPF_F_MMAPABLE = 0x400; /// a single BPF instruction pub const Insn = packed struct { code: u8, dst: u4, src: u4, off: i16, imm: i32, /// r0 - r9 are general purpose 64-bit registers, r10 points to the stack /// frame pub const Reg = enum(u4) { r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10 }; const alu = 0x04; const jmp = 0x05; const mov = 0xb0; const k = 0; const exit_code = 0x90; // TODO: implement more factory functions for the other instructions /// load immediate value into a register pub fn load_imm(dst: Reg, imm: i32) Insn { return Insn{ .code = alu | mov | k, .dst = @enumToInt(dst), .src = 0, .off = 0, .imm = imm, }; } /// exit BPF program pub fn exit() Insn { return Insn{ .code = jmp | exit_code, .dst = 0, .src = 0, .off = 0, .imm = 0, }; } }; pub const Cmd = extern enum(usize) { map_create, map_lookup_elem, map_update_elem, map_delete_elem, map_get_next_key, prog_load, obj_pin, obj_get, prog_attach, prog_detach, prog_test_run, prog_get_next_id, map_get_next_id, prog_get_fd_by_id, map_get_fd_by_id, obj_get_info_by_fd, prog_query, raw_tracepoint_open, btf_load, btf_get_fd_by_id, task_fd_query, map_lookup_and_delete_elem, map_freeze, btf_get_next_id, map_lookup_batch, map_lookup_and_delete_batch, map_update_batch, map_delete_batch, link_create, link_update, link_get_fd_by_id, link_get_next_id, enable_stats, iter_create, link_detach, _, }; pub const MapType = extern enum(u32) { unspec, hash, array, prog_array, perf_event_array, percpu_hash, percpu_array, stack_trace, cgroup_array, lru_hash, lru_percpu_hash, lpm_trie, array_of_maps, hash_of_maps, devmap, sockmap, cpumap, xskmap, sockhash, cgroup_storage, reuseport_sockarray, percpu_cgroup_storage, queue, stack, sk_storage, devmap_hash, struct_ops, ringbuf, _, }; pub const ProgType = extern enum(u32) { unspec, socket_filter, kprobe, sched_cls, sched_act, tracepoint, xdp, perf_event, cgroup_skb, cgroup_sock, lwt_in, lwt_out, lwt_xmit, sock_ops, sk_skb, cgroup_device, sk_msg, raw_tracepoint, cgroup_sock_addr, lwt_seg6local, lirc_mode2, sk_reuseport, flow_dissector, cgroup_sysctl, raw_tracepoint_writable, cgroup_sockopt, tracing, struct_ops, ext, lsm, sk_lookup, }; pub const AttachType = extern enum(u32) { cgroup_inet_ingress, cgroup_inet_egress, cgroup_inet_sock_create, cgroup_sock_ops, sk_skb_stream_parser, sk_skb_stream_verdict, cgroup_device, sk_msg_verdict, cgroup_inet4_bind, cgroup_inet6_bind, cgroup_inet4_connect, cgroup_inet6_connect, cgroup_inet4_post_bind, cgroup_inet6_post_bind, cgroup_udp4_sendmsg, cgroup_udp6_sendmsg, lirc_mode2, flow_dissector, cgroup_sysctl, cgroup_udp4_recvmsg, cgroup_udp6_recvmsg, cgroup_getsockopt, cgroup_setsockopt, trace_raw_tp, trace_fentry, trace_fexit, modify_return, lsm_mac, trace_iter, cgroup_inet4_getpeername, cgroup_inet6_getpeername, cgroup_inet4_getsockname, cgroup_inet6_getsockname, xdp_devmap, cgroup_inet_sock_release, xdp_cpumap, sk_lookup, xdp, _, }; const obj_name_len = 16; /// struct used by Cmd.map_create command pub const MapCreateAttr = extern struct { /// one of MapType map_type: u32, /// size of key in bytes key_size: u32, /// size of value in bytes value_size: u32, /// max number of entries in a map max_entries: u32, /// .map_create related flags map_flags: u32, /// fd pointing to the inner map inner_map_fd: fd_t, /// numa node (effective only if MapCreateFlags.numa_node is set) numa_node: u32, map_name: [obj_name_len]u8, /// ifindex of netdev to create on map_ifindex: u32, /// fd pointing to a BTF type data btf_fd: fd_t, /// BTF type_id of the key btf_key_type_id: u32, /// BTF type_id of the value bpf_value_type_id: u32, /// BTF type_id of a kernel struct stored as the map value btf_vmlinux_value_type_id: u32, }; /// struct used by Cmd.map_*_elem commands pub const MapElemAttr = extern struct { map_fd: fd_t, key: u64, result: extern union { value: u64, next_key: u64, }, flags: u64, }; /// struct used by Cmd.map_*_batch commands pub const MapBatchAttr = extern struct { /// start batch, NULL to start from beginning in_batch: u64, /// output: next start batch out_batch: u64, keys: u64, values: u64, /// input/output: /// input: # of key/value elements /// output: # of filled elements count: u32, map_fd: fd_t, elem_flags: u64, flags: u64, }; /// struct used by Cmd.prog_load command pub const ProgLoadAttr = extern struct { /// one of ProgType prog_type: u32, insn_cnt: u32, insns: u64, license: u64, /// verbosity level of verifier log_level: u32, /// size of user buffer log_size: u32, /// user supplied buffer log_buf: u64, /// not used kern_version: u32, prog_flags: u32, prog_name: [obj_name_len]u8, /// ifindex of netdev to prep for. For some prog types expected attach /// type must be known at load time to verify attach type specific parts /// of prog (context accesses, allowed helpers, etc). prog_ifindex: u32, expected_attach_type: u32, /// fd pointing to BTF type data prog_btf_fd: fd_t, /// userspace bpf_func_info size func_info_rec_size: u32, func_info: u64, /// number of bpf_func_info records func_info_cnt: u32, /// userspace bpf_line_info size line_info_rec_size: u32, line_info: u64, /// number of bpf_line_info records line_info_cnt: u32, /// in-kernel BTF type id to attach to attact_btf_id: u32, /// 0 to attach to vmlinux attach_prog_id: u32, }; /// struct used by Cmd.obj_* commands pub const ObjAttr = extern struct { pathname: u64, bpf_fd: fd_t, file_flags: u32, }; /// struct used by Cmd.prog_attach/detach commands pub const ProgAttachAttr = extern struct { /// container object to attach to target_fd: fd_t, /// eBPF program to attach attach_bpf_fd: fd_t, attach_type: u32, attach_flags: u32, // TODO: BPF_F_REPLACE flags /// previously attached eBPF program to replace if .replace is used replace_bpf_fd: fd_t, }; /// struct used by Cmd.prog_test_run command pub const TestAttr = extern struct { prog_fd: fd_t, retval: u32, /// input: len of data_in data_size_in: u32, /// input/output: len of data_out. returns ENOSPC if data_out is too small. data_size_out: u32, data_in: u64, data_out: u64, repeat: u32, duration: u32, /// input: len of ctx_in ctx_size_in: u32, /// input/output: len of ctx_out. returns ENOSPC if ctx_out is too small. ctx_size_out: u32, ctx_in: u64, ctx_out: u64, }; /// struct used by Cmd.*_get_*_id commands pub const GetIdAttr = extern struct { id: extern union { start_id: u32, prog_id: u32, map_id: u32, btf_id: u32, link_id: u32, }, next_id: u32, open_flags: u32, }; /// struct used by Cmd.obj_get_info_by_fd command pub const InfoAttr = extern struct { bpf_fd: fd_t, info_len: u32, info: u64, }; /// struct used by Cmd.prog_query command pub const QueryAttr = extern struct { /// container object to query target_fd: fd_t, attach_type: u32, query_flags: u32, attach_flags: u32, prog_ids: u64, prog_cnt: u32, }; /// struct used by Cmd.raw_tracepoint_open command pub const RawTracepointAttr = extern struct { name: u64, prog_fd: fd_t, }; /// struct used by Cmd.btf_load command pub const BtfLoadAttr = extern struct { btf: u64, btf_log_buf: u64, btf_size: u32, btf_log_size: u32, btf_log_level: u32, }; pub const TaskFdQueryAttr = extern struct { /// input: pid pid: pid_t, /// input: fd fd: fd_t, /// input: flags flags: u32, /// input/output: buf len buf_len: u32, /// input/output: /// tp_name for tracepoint /// symbol for kprobe /// filename for uprobe buf: u64, /// output: prod_id prog_id: u32, /// output: BPF_FD_TYPE fd_type: u32, /// output: probe_offset probe_offset: u64, /// output: probe_addr probe_addr: u64, }; /// struct used by Cmd.link_create command pub const LinkCreateAttr = extern struct { /// eBPF program to attach prog_fd: fd_t, /// object to attach to target_fd: fd_t, attach_type: u32, /// extra flags flags: u32, }; /// struct used by Cmd.link_update command pub const LinkUpdateAttr = extern struct { link_fd: fd_t, /// new program to update link with new_prog_fd: fd_t, /// extra flags flags: u32, /// expected link's program fd, it is specified only if BPF_F_REPLACE is /// set in flags old_prog_fd: fd_t, }; /// struct used by Cmd.enable_stats command pub const EnableStatsAttr = extern struct { type: u32, }; /// struct used by Cmd.iter_create command pub const IterCreateAttr = extern struct { link_fd: fd_t, flags: u32, }; pub const Attr = extern union { map_create: MapCreateAttr, map_elem: MapElemAttr, map_batch: MapBatchAttr, prog_load: ProgLoadAttr, obj: ObjAttr, prog_attach: ProgAttachAttr, test_run: TestRunAttr, get_id: GetIdAttr, info: InfoAttr, query: QueryAttr, raw_tracepoint: RawTracepointAttr, btf_load: BtfLoadAttr, task_fd_query: TaskFdQueryAttr, link_create: LinkCreateAttr, link_update: LinkUpdateAttr, enable_stats: EnableStatsAttr, iter_create: IterCreateAttr, }; pub fn bpf(cmd: Cmd, attr: *Attr, size: u32) usize { return syscall3(.bpf, @enumToInt(cmd), @ptrToInt(attr), size); }
lib/std/os/bits/linux/bpf.zig
const std = @import("std"); const fs = std.fs; const io = std.io; const info = std.log.info; const print = std.debug.print; const fmt = std.fmt; const utils = @import("utils.zig"); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const Error = error{ NoDashInRule, NoSpaceInRule, NoColonInRule }; const Validator = struct { cnt_min: usize, cnt_max: usize, char: u8, pub fn init(rule_line: []const u8) anyerror!Validator { const min_until = std.mem.indexOf(u8, rule_line, "-") orelse return Error.NoDashInRule; const max_until = std.mem.indexOf(u8, rule_line, " ") orelse return Error.NoSpaceInRule; return Validator{ .cnt_min = try fmt.parseUnsigned(usize, rule_line[0..min_until], 10), .cnt_max = try fmt.parseUnsigned(usize, rule_line[min_until + 1 .. max_until], 10), .char = rule_line[max_until + 1], }; } pub fn valid_part1(self: Validator, password: []const u8) bool { var cnt: usize = 0; for (password) |pw_char| { if (pw_char == self.char) { cnt += 1; } } return cnt >= self.cnt_min and cnt <= self.cnt_max; } pub fn valid_part2(self: Validator, password: []const u8) bool { var cnt: usize = 0; var fst_contains: u32 = if (password[self.cnt_min] == self.char) 1 else 0; var scn_contains: u32 = if (password[self.cnt_max] == self.char) 1 else 0; return (fst_contains ^ scn_contains) == 1; } }; pub fn main() anyerror!void { // allocator defer _ = gpa.deinit(); var allo = &gpa.allocator; const input_lines = try utils.read_input_lines(allo, "./input1"); defer allo.free(input_lines); print("== got {} input lines ==\n", .{input_lines.len}); // business logic var i: usize = 0; var p1_valid_cnt: usize = 0; var p2_valid_cnt: usize = 0; for (input_lines) |line| { defer allo.free(line); const separator_at = std.mem.indexOf(u8, line, ":") orelse return Error.NoColonInRule; const rule_part = line[0..separator_at]; const pw_part = line[separator_at + 1 ..]; const validator = try Validator.init(rule_part); if (validator.valid_part1(pw_part)) { p1_valid_cnt += 1; } if (validator.valid_part2(pw_part)) { p2_valid_cnt += 1; } } print("p1 valid: {} p2 valid: {}\n", .{ p1_valid_cnt, p2_valid_cnt }); print("done!\n", .{}); }
day_02/src/main.zig
const std = @import("std"); const Elf32_Shdr = std.elf.Elf32_Shdr; const Elf32_Phdr = std.elf.Elf32_Phdr; const paging = @import("paging.zig"); const PageAlign = paging.PageAlign; const Page = paging.Page; const native_endian = @import("builtin").target.cpu.arch.endian(); pub fn print(out: anytype, buf: []const u8) !void { var elf_stream = std.io.StreamSource{ .const_buffer = std.io.fixedBufferStream(buf), }; const hdr = try std.elf.Header.read(&elf_stream); if (hdr.is_64) return error.Elf64; try out.print("Entrypoint: 0x{x:0>8}\n", .{hdr.entry}); try out.print("Sections:\n", .{}); try out.print("{s:<8} {s:<8} {s:<8}\n", .{ "Addr", "Off", "Size", }); var sections = SectionHeaderIterator(@TypeOf(elf_stream)){ .elf_header = hdr, .parse_source = elf_stream, }; while (try sections.next()) |*s| { try out.print("{}\n", .{fmtSectionHeader(s)}); } try out.print("Programs:\n", .{}); try out.print("{s:<8} {s:<8} {s:<8} {s:<8} {s:<8} {s:<8} {s:<3}\n", .{ "Type", "FileOff", "FileSz", "VAddr", "PAddr", "MemSz", "Flg", }); var programs = ProgramHeaderIterator(@TypeOf(elf_stream)){ .elf_header = hdr, .parse_source = elf_stream, }; while (try programs.next()) |*p| { try out.print("{}\n", .{fmtProgramHeader(p)}); } } pub const Program = struct { entry: u32, pages: []Page, }; pub fn load(allocator: *std.mem.Allocator, buf: []const u8) !Program { var pages = std.ArrayList(Page).init(allocator); defer pages.deinit(); var elf_stream = std.io.StreamSource{ .const_buffer = std.io.fixedBufferStream(buf), }; const hdr = try std.elf.Header.read(&elf_stream); if (hdr.is_64) return error.Elf64; var programs = ProgramHeaderIterator(@TypeOf(elf_stream)){ .elf_header = hdr, .parse_source = elf_stream, }; while (try programs.next()) |*p| { if (p.p_type == std.elf.PT_LOAD) { if (p.p_filesz >= PageAlign) return error.OutOfPage; var page = try allocator.allocAdvanced(u8, PageAlign, 4096, .at_least); // Copy data to page const off = p.p_vaddr & 0xfff; try elf_stream.seekableStream().seekTo(p.p_offset); try elf_stream.reader().readNoEof(page[off..off+p.p_filesz]); try pages.append(.{ .pmem = page[0..4096], .vaddr = p.p_vaddr & 0xffff_f000, .flags = p.p_flags, }); } } return Program{ .entry = @truncate(u32, hdr.entry), .pages = pages.toOwnedSlice(), }; } fn SectionHeaderIterator(ParseSource: anytype) type { return struct { elf_header: std.elf.Header, parse_source: ParseSource, index: usize = 0, pub fn next(self: *@This()) !?Elf32_Shdr { if (self.index >= self.elf_header.shnum) return null; defer self.index += 1; var shdr: Elf32_Shdr = undefined; const offset = self.elf_header.shoff + @sizeOf(@TypeOf(shdr)) * self.index; try self.parse_source.seekableStream().seekTo(offset); try self.parse_source.reader().readNoEof(std.mem.asBytes(&shdr)); if (self.elf_header.endian != native_endian) { @panic("ELF endianness does NOT match"); } return shdr; } }; } const SectionFormatter = struct { pub fn f( s: *const Elf32_Shdr, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype, ) !void { try writer.print("{x:0>8} {x:0>8} {x:0>8}", .{ s.sh_addr, s.sh_offset, s.sh_size, }); } }; fn fmtSectionHeader(s: *const Elf32_Shdr) std.fmt.Formatter(SectionFormatter.f) { return .{ .data = s }; } fn ProgramHeaderIterator(ParseSource: anytype) type { return struct { elf_header: std.elf.Header, parse_source: ParseSource, index: usize = 0, pub fn next(self: *@This()) !?std.elf.Elf32_Phdr { if (self.index >= self.elf_header.phnum) return null; defer self.index += 1; var phdr: std.elf.Elf32_Phdr = undefined; const offset = self.elf_header.phoff + @sizeOf(@TypeOf(phdr)) * self.index; try self.parse_source.seekableStream().seekTo(offset); try self.parse_source.reader().readNoEof(std.mem.asBytes(&phdr)); if (self.elf_header.endian != native_endian) { @panic("ELF endianness does NOT match"); } return phdr; } }; } const ProgramFormatter = struct { pub fn f( p: *const Elf32_Phdr, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype, ) !void { var flags: [3]u8 = .{'-'} ** 3; if (p.p_flags & std.elf.PF_R != 0) flags[0] = 'R'; if (p.p_flags & std.elf.PF_W != 0) flags[1] = 'W'; if (p.p_flags & std.elf.PF_X != 0) flags[2] = 'X'; try writer.print("{x:0>8} {x:0>8} {x:0>8} {x:0>8} {x:0>8} {x:0>8} {s}", .{ p.p_type, p.p_offset, p.p_filesz, p.p_vaddr, p.p_paddr, p.p_memsz, flags, }); } }; fn fmtProgramHeader(p: *const Elf32_Phdr) std.fmt.Formatter(ProgramFormatter.f) { return .{ .data = p }; }
src/utils/elf.zig
const std = @import("std"); const zwin32 = @import("zwin32"); const w = zwin32.base; const d3d12 = zwin32.d3d12; const hrPanic = zwin32.hrPanic; const hrPanicOnFail = zwin32.hrPanicOnFail; const zd3d12 = @import("zd3d12"); const common = @import("common"); const c = common.c; const vm = common.vectormath; const GuiRenderer = common.GuiRenderer; pub export const D3D12SDKVersion: u32 = 4; pub export const D3D12SDKPath: [*:0]const u8 = ".\\d3d12\\"; const content_dir = @import("build_options").content_dir; pub fn main() !void { const window_name = "zig-gamedev: triangle"; const window_width = 900; const window_height = 900; common.init(); defer common.deinit(); var gpa_allocator_state = std.heap.GeneralPurposeAllocator(.{}){}; defer { const leaked = gpa_allocator_state.deinit(); std.debug.assert(leaked == false); } const gpa_allocator = gpa_allocator_state.allocator(); var arena_allocator_state = std.heap.ArenaAllocator.init(gpa_allocator); defer arena_allocator_state.deinit(); const arena_allocator = arena_allocator_state.allocator(); const window = common.initWindow(gpa_allocator, window_name, window_width, window_height) catch unreachable; defer common.deinitWindow(gpa_allocator); var grfx = zd3d12.GraphicsContext.init(gpa_allocator, window); defer grfx.deinit(gpa_allocator); const pipeline = blk: { const input_layout_desc = [_]d3d12.INPUT_ELEMENT_DESC{ d3d12.INPUT_ELEMENT_DESC.init("POSITION", 0, .R32G32B32_FLOAT, 0, 0, .PER_VERTEX_DATA, 0), }; var pso_desc = d3d12.GRAPHICS_PIPELINE_STATE_DESC.initDefault(); pso_desc.DepthStencilState.DepthEnable = w.FALSE; pso_desc.InputLayout = .{ .pInputElementDescs = &input_layout_desc, .NumElements = input_layout_desc.len, }; pso_desc.RTVFormats[0] = .R8G8B8A8_UNORM; pso_desc.NumRenderTargets = 1; pso_desc.BlendState.RenderTarget[0].RenderTargetWriteMask = 0xf; pso_desc.PrimitiveTopologyType = .TRIANGLE; break :blk grfx.createGraphicsShaderPipeline( arena_allocator, &pso_desc, content_dir ++ "shaders/triangle.vs.cso", content_dir ++ "shaders/triangle.ps.cso", ); }; const vertex_buffer = grfx.createCommittedResource( .DEFAULT, d3d12.HEAP_FLAG_NONE, &d3d12.RESOURCE_DESC.initBuffer(3 * @sizeOf(vm.Vec3)), d3d12.RESOURCE_STATE_COPY_DEST, null, ) catch |err| hrPanic(err); const index_buffer = grfx.createCommittedResource( .DEFAULT, d3d12.HEAP_FLAG_NONE, &d3d12.RESOURCE_DESC.initBuffer(3 * @sizeOf(u32)), d3d12.RESOURCE_STATE_COPY_DEST, null, ) catch |err| hrPanic(err); grfx.beginFrame(); var gui = GuiRenderer.init(arena_allocator, &grfx, 1, content_dir); defer gui.deinit(&grfx); const upload_verts = grfx.allocateUploadBufferRegion(vm.Vec3, 3); upload_verts.cpu_slice[0] = vm.Vec3.init(-0.7, -0.7, 0.0); upload_verts.cpu_slice[1] = vm.Vec3.init(0.0, 0.7, 0.0); upload_verts.cpu_slice[2] = vm.Vec3.init(0.7, -0.7, 0.0); grfx.cmdlist.CopyBufferRegion( grfx.lookupResource(vertex_buffer).?, 0, upload_verts.buffer, upload_verts.buffer_offset, upload_verts.cpu_slice.len * @sizeOf(vm.Vec3), ); const upload_indices = grfx.allocateUploadBufferRegion(u32, 3); upload_indices.cpu_slice[0] = 0; upload_indices.cpu_slice[1] = 1; upload_indices.cpu_slice[2] = 2; grfx.cmdlist.CopyBufferRegion( grfx.lookupResource(index_buffer).?, 0, upload_indices.buffer, upload_indices.buffer_offset, upload_indices.cpu_slice.len * @sizeOf(u32), ); grfx.addTransitionBarrier(vertex_buffer, d3d12.RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER); grfx.addTransitionBarrier(index_buffer, d3d12.RESOURCE_STATE_INDEX_BUFFER); grfx.flushResourceBarriers(); grfx.endFrame(); grfx.finishGpuCommands(); var triangle_color = vm.Vec3.init(0.0, 1.0, 0.0); var stats = common.FrameStats.init(); while (true) { var message = std.mem.zeroes(w.user32.MSG); const has_message = w.user32.peekMessageA(&message, null, 0, 0, w.user32.PM_REMOVE) catch unreachable; if (has_message) { _ = w.user32.translateMessage(&message); _ = w.user32.dispatchMessageA(&message); if (message.message == w.user32.WM_QUIT) { break; } } else { stats.update(window, window_name); common.newImGuiFrame(stats.delta_time); c.igSetNextWindowPos(.{ .x = 10.0, .y = 10.0 }, c.ImGuiCond_FirstUseEver, .{ .x = 0.0, .y = 0.0 }); c.igSetNextWindowSize(c.ImVec2{ .x = 600.0, .y = 0.0 }, c.ImGuiCond_FirstUseEver); _ = c.igBegin( "Demo Settings", null, c.ImGuiWindowFlags_NoMove | c.ImGuiWindowFlags_NoResize | c.ImGuiWindowFlags_NoSavedSettings, ); _ = c.igColorEdit3("Triangle color", &triangle_color.c, c.ImGuiColorEditFlags_None); c.igEnd(); grfx.beginFrame(); const back_buffer = grfx.getBackBuffer(); grfx.addTransitionBarrier(back_buffer.resource_handle, d3d12.RESOURCE_STATE_RENDER_TARGET); grfx.flushResourceBarriers(); grfx.cmdlist.OMSetRenderTargets( 1, &[_]d3d12.CPU_DESCRIPTOR_HANDLE{back_buffer.descriptor_handle}, w.TRUE, null, ); grfx.cmdlist.ClearRenderTargetView( back_buffer.descriptor_handle, &[4]f32{ 0.2, 0.4, 0.8, 1.0 }, 0, null, ); grfx.setCurrentPipeline(pipeline); grfx.cmdlist.IASetPrimitiveTopology(.TRIANGLELIST); grfx.cmdlist.IASetVertexBuffers(0, 1, &[_]d3d12.VERTEX_BUFFER_VIEW{.{ .BufferLocation = grfx.lookupResource(vertex_buffer).?.GetGPUVirtualAddress(), .SizeInBytes = 3 * @sizeOf(vm.Vec3), .StrideInBytes = @sizeOf(vm.Vec3), }}); grfx.cmdlist.IASetIndexBuffer(&.{ .BufferLocation = grfx.lookupResource(index_buffer).?.GetGPUVirtualAddress(), .SizeInBytes = 3 * @sizeOf(u32), .Format = .R32_UINT, }); grfx.cmdlist.SetGraphicsRoot32BitConstant( 0, c.igColorConvertFloat4ToU32( .{ .x = triangle_color.c[0], .y = triangle_color.c[1], .z = triangle_color.c[2], .w = 1.0 }, ), 0, ); grfx.cmdlist.DrawIndexedInstanced(3, 1, 0, 0, 0); gui.draw(&grfx); grfx.addTransitionBarrier(back_buffer.resource_handle, d3d12.RESOURCE_STATE_PRESENT); grfx.flushResourceBarriers(); grfx.endFrame(); } } grfx.finishGpuCommands(); }
samples/triangle/src/triangle.zig
/// The function fiatP448AddcarryxU56 is an addition with carry. /// Postconditions: /// out1 = (arg1 + arg2 + arg3) mod 2^56 /// out2 = ⌊(arg1 + arg2 + arg3) / 2^56⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffff] /// out2: [0x0 ~> 0x1] fn fiatP448AddcarryxU56(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { const x1: u64 = ((@intCast(u64, arg1) + arg2) + arg3); const x2: u64 = (x1 & 0xffffffffffffff); const x3: u1 = @intCast(u1, (x1 >> 56)); out1.* = x2; out2.* = x3; } /// The function fiatP448SubborrowxU56 is a subtraction with borrow. /// Postconditions: /// out1 = (-arg1 + arg2 + -arg3) mod 2^56 /// out2 = -⌊(-arg1 + arg2 + -arg3) / 2^56⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffff] /// out2: [0x0 ~> 0x1] fn fiatP448SubborrowxU56(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { const x1: i64 = @intCast(i64, (@intCast(i128, @intCast(i64, (@intCast(i128, arg2) - @intCast(i128, arg1)))) - @intCast(i128, arg3))); const x2: i1 = @intCast(i1, (x1 >> 56)); const x3: u64 = @intCast(u64, (@intCast(i128, x1) & @intCast(i128, 0xffffffffffffff))); out1.* = x3; out2.* = @intCast(u1, (@intCast(i2, 0x0) - @intCast(i2, x2))); } /// The function fiatP448CmovznzU64 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 fiatP448CmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { const x1: u1 = (~(~arg1)); const x2: u64 = @intCast(u64, (@intCast(i128, @intCast(i1, (@intCast(i2, 0x0) - @intCast(i2, x1)))) & @intCast(i128, 0xffffffffffffffff))); const x3: u64 = ((x2 & arg3) | ((~x2) & arg2)); out1.* = x3; } /// The function fiatP448CarryMul multiplies two field elements and reduces the result. /// Postconditions: /// eval out1 mod m = (eval arg1 * eval arg2) mod m /// /// Input Bounds: /// arg1: [[0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000]] /// arg2: [[0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000]] /// Output Bounds: /// out1: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] pub fn fiatP448CarryMul(out1: *[8]u64, arg1: [8]u64, arg2: [8]u64) void { const x1: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[7]))); const x2: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[6]))); const x3: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[5]))); const x4: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[7]))); const x5: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[6]))); const x6: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[7]))); const x7: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[7]))); const x8: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[6]))); const x9: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[5]))); const x10: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[7]))); const x11: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[6]))); const x12: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[7]))); const x13: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[7]))); const x14: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[6]))); const x15: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[5]))); const x16: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[4]))); const x17: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[3]))); const x18: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[2]))); const x19: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[1]))); const x20: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[7]))); const x21: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[6]))); const x22: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[5]))); const x23: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[4]))); const x24: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[3]))); const x25: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[2]))); const x26: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[7]))); const x27: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[6]))); const x28: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[5]))); const x29: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[4]))); const x30: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[3]))); const x31: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[7]))); const x32: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[6]))); const x33: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[5]))); const x34: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[4]))); const x35: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[7]))); const x36: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[6]))); const x37: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[5]))); const x38: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[7]))); const x39: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[6]))); const x40: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[7]))); const x41: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[4]))); const x42: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[3]))); const x43: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[2]))); const x44: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[1]))); const x45: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[5]))); const x46: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[4]))); const x47: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[3]))); const x48: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[2]))); const x49: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[6]))); const x50: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[5]))); const x51: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[4]))); const x52: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[3]))); const x53: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[7]))); const x54: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[6]))); const x55: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[5]))); const x56: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[4]))); const x57: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[7]))); const x58: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[6]))); const x59: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[5]))); const x60: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[7]))); const x61: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[6]))); const x62: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[7]))); const x63: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, (arg2[0]))); const x64: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[1]))); const x65: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, (arg2[0]))); const x66: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[2]))); const x67: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[1]))); const x68: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, (arg2[0]))); const x69: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[3]))); const x70: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[2]))); const x71: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[1]))); const x72: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, (arg2[0]))); const x73: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[4]))); const x74: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[3]))); const x75: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[2]))); const x76: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[1]))); const x77: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg2[0]))); const x78: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[5]))); const x79: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[4]))); const x80: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[3]))); const x81: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[2]))); const x82: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[1]))); const x83: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg2[0]))); const x84: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[6]))); const x85: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[5]))); const x86: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[4]))); const x87: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[3]))); const x88: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[2]))); const x89: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[1]))); const x90: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg2[0]))); const x91: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg2[7]))); const x92: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg2[6]))); const x93: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg2[5]))); const x94: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg2[4]))); const x95: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg2[3]))); const x96: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg2[2]))); const x97: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg2[1]))); const x98: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg2[0]))); const x99: u128 = (x95 + (x88 + (x82 + (x77 + (x31 + (x27 + (x22 + x16))))))); const x100: u64 = @intCast(u64, (x99 >> 56)); const x101: u64 = @intCast(u64, (x99 & @intCast(u128, 0xffffffffffffff))); const x102: u128 = (x91 + (x84 + (x78 + (x73 + (x69 + (x66 + (x64 + (x63 + (x53 + (x49 + (x45 + x41))))))))))); const x103: u128 = (x92 + (x85 + (x79 + (x74 + (x70 + (x67 + (x65 + (x57 + (x54 + (x50 + (x46 + (x42 + (x13 + x7))))))))))))); const x104: u128 = (x93 + (x86 + (x80 + (x75 + (x71 + (x68 + (x60 + (x58 + (x55 + (x51 + (x47 + (x43 + (x20 + (x14 + (x10 + x8))))))))))))))); const x105: u128 = (x94 + (x87 + (x81 + (x76 + (x72 + (x62 + (x61 + (x59 + (x56 + (x52 + (x48 + (x44 + (x26 + (x21 + (x15 + (x12 + (x11 + x9))))))))))))))))); const x106: u128 = (x96 + (x89 + (x83 + (x35 + (x32 + (x28 + (x23 + (x17 + x1)))))))); const x107: u128 = (x97 + (x90 + (x38 + (x36 + (x33 + (x29 + (x24 + (x18 + (x4 + x2))))))))); const x108: u128 = (x98 + (x40 + (x39 + (x37 + (x34 + (x30 + (x25 + (x19 + (x6 + (x5 + x3)))))))))); const x109: u128 = (@intCast(u128, x100) + x105); const x110: u64 = @intCast(u64, (x102 >> 56)); const x111: u64 = @intCast(u64, (x102 & @intCast(u128, 0xffffffffffffff))); const x112: u128 = (x109 + @intCast(u128, x110)); const x113: u64 = @intCast(u64, (x112 >> 56)); const x114: u64 = @intCast(u64, (x112 & @intCast(u128, 0xffffffffffffff))); const x115: u128 = (x108 + @intCast(u128, x110)); const x116: u128 = (@intCast(u128, x113) + x104); const x117: u64 = @intCast(u64, (x115 >> 56)); const x118: u64 = @intCast(u64, (x115 & @intCast(u128, 0xffffffffffffff))); const x119: u128 = (@intCast(u128, x117) + x107); const x120: u64 = @intCast(u64, (x116 >> 56)); const x121: u64 = @intCast(u64, (x116 & @intCast(u128, 0xffffffffffffff))); const x122: u128 = (@intCast(u128, x120) + x103); const x123: u64 = @intCast(u64, (x119 >> 56)); const x124: u64 = @intCast(u64, (x119 & @intCast(u128, 0xffffffffffffff))); const x125: u128 = (@intCast(u128, x123) + x106); const x126: u64 = @intCast(u64, (x122 >> 56)); const x127: u64 = @intCast(u64, (x122 & @intCast(u128, 0xffffffffffffff))); const x128: u64 = (x126 + x111); const x129: u64 = @intCast(u64, (x125 >> 56)); const x130: u64 = @intCast(u64, (x125 & @intCast(u128, 0xffffffffffffff))); const x131: u64 = (x129 + x101); const x132: u64 = (x128 >> 56); const x133: u64 = (x128 & 0xffffffffffffff); const x134: u64 = (x131 >> 56); const x135: u64 = (x131 & 0xffffffffffffff); const x136: u64 = (x114 + x132); const x137: u64 = (x118 + x132); const x138: u64 = (x134 + x136); const x139: u1 = @intCast(u1, (x138 >> 56)); const x140: u64 = (x138 & 0xffffffffffffff); const x141: u64 = (@intCast(u64, x139) + x121); const x142: u1 = @intCast(u1, (x137 >> 56)); const x143: u64 = (x137 & 0xffffffffffffff); const x144: u64 = (@intCast(u64, x142) + x124); out1[0] = x143; out1[1] = x144; out1[2] = x130; out1[3] = x135; out1[4] = x140; out1[5] = x141; out1[6] = x127; out1[7] = x133; } /// The function fiatP448CarrySquare squares a field element and reduces the result. /// Postconditions: /// eval out1 mod m = (eval arg1 * eval arg1) mod m /// /// Input Bounds: /// arg1: [[0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000]] /// Output Bounds: /// out1: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] pub fn fiatP448CarrySquare(out1: *[8]u64, arg1: [8]u64) void { const x1: u64 = (arg1[7]); const x2: u64 = (arg1[7]); const x3: u64 = (x1 * 0x2); const x4: u64 = (x2 * 0x2); const x5: u64 = ((arg1[7]) * 0x2); const x6: u64 = (arg1[6]); const x7: u64 = (arg1[6]); const x8: u64 = (x6 * 0x2); const x9: u64 = (x7 * 0x2); const x10: u64 = ((arg1[6]) * 0x2); const x11: u64 = (arg1[5]); const x12: u64 = (arg1[5]); const x13: u64 = (x11 * 0x2); const x14: u64 = (x12 * 0x2); const x15: u64 = ((arg1[5]) * 0x2); const x16: u64 = (arg1[4]); const x17: u64 = (arg1[4]); const x18: u64 = ((arg1[4]) * 0x2); const x19: u64 = ((arg1[3]) * 0x2); const x20: u64 = ((arg1[2]) * 0x2); const x21: u64 = ((arg1[1]) * 0x2); const x22: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, x1)); const x23: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, x3)); const x24: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, x6)); const x25: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, x3)); const x26: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, x1)); const x27: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, x3)); const x28: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, x6)); const x29: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, x3)); const x30: u128 = (@intCast(u128, (arg1[7])) * @intCast(u128, x2)); const x31: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, x4)); const x32: u128 = (@intCast(u128, (arg1[6])) * @intCast(u128, x7)); const x33: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, x4)); const x34: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, x9)); const x35: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, x8)); const x36: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, x12)); const x37: u128 = (@intCast(u128, (arg1[5])) * @intCast(u128, x11)); const x38: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, x4)); const x39: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, x3)); const x40: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, x9)); const x41: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, x8)); const x42: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, x14)); const x43: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, x13)); const x44: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, x17)); const x45: u128 = (@intCast(u128, (arg1[4])) * @intCast(u128, x16)); const x46: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, x4)); const x47: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, x3)); const x48: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, x9)); const x49: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, x8)); const x50: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, x14)); const x51: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, x13)); const x52: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, x18)); const x53: u128 = (@intCast(u128, (arg1[3])) * @intCast(u128, (arg1[3]))); const x54: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, x4)); const x55: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, x3)); const x56: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, x9)); const x57: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, x8)); const x58: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, x15)); const x59: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, x18)); const x60: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, x19)); const x61: u128 = (@intCast(u128, (arg1[2])) * @intCast(u128, (arg1[2]))); const x62: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, x4)); const x63: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, x3)); const x64: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, x10)); const x65: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, x15)); const x66: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, x18)); const x67: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, x19)); const x68: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, x20)); const x69: u128 = (@intCast(u128, (arg1[1])) * @intCast(u128, (arg1[1]))); const x70: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, x5)); const x71: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, x10)); const x72: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, x15)); const x73: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, x18)); const x74: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, x19)); const x75: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, x20)); const x76: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, x21)); const x77: u128 = (@intCast(u128, (arg1[0])) * @intCast(u128, (arg1[0]))); const x78: u128 = (x74 + (x68 + (x38 + x34))); const x79: u64 = @intCast(u64, (x78 >> 56)); const x80: u64 = @intCast(u64, (x78 & @intCast(u128, 0xffffffffffffff))); const x81: u128 = (x70 + (x64 + (x58 + (x52 + (x39 + x35))))); const x82: u128 = (x71 + (x65 + (x59 + (x53 + (x47 + (x41 + (x37 + (x30 + x26)))))))); const x83: u128 = (x72 + (x66 + (x60 + (x55 + (x49 + (x43 + (x31 + x27))))))); const x84: u128 = (x73 + (x67 + (x63 + (x61 + (x57 + (x51 + (x45 + (x33 + (x32 + (x29 + x28)))))))))); const x85: u128 = (x75 + (x69 + (x46 + (x40 + (x36 + x22))))); const x86: u128 = (x76 + (x54 + (x48 + (x42 + x23)))); const x87: u128 = (x77 + (x62 + (x56 + (x50 + (x44 + (x25 + x24)))))); const x88: u128 = (@intCast(u128, x79) + x84); const x89: u64 = @intCast(u64, (x81 >> 56)); const x90: u64 = @intCast(u64, (x81 & @intCast(u128, 0xffffffffffffff))); const x91: u128 = (x88 + @intCast(u128, x89)); const x92: u64 = @intCast(u64, (x91 >> 56)); const x93: u64 = @intCast(u64, (x91 & @intCast(u128, 0xffffffffffffff))); const x94: u128 = (x87 + @intCast(u128, x89)); const x95: u128 = (@intCast(u128, x92) + x83); const x96: u64 = @intCast(u64, (x94 >> 56)); const x97: u64 = @intCast(u64, (x94 & @intCast(u128, 0xffffffffffffff))); const x98: u128 = (@intCast(u128, x96) + x86); const x99: u64 = @intCast(u64, (x95 >> 56)); const x100: u64 = @intCast(u64, (x95 & @intCast(u128, 0xffffffffffffff))); const x101: u128 = (@intCast(u128, x99) + x82); const x102: u64 = @intCast(u64, (x98 >> 56)); const x103: u64 = @intCast(u64, (x98 & @intCast(u128, 0xffffffffffffff))); const x104: u128 = (@intCast(u128, x102) + x85); const x105: u64 = @intCast(u64, (x101 >> 56)); const x106: u64 = @intCast(u64, (x101 & @intCast(u128, 0xffffffffffffff))); const x107: u64 = (x105 + x90); const x108: u64 = @intCast(u64, (x104 >> 56)); const x109: u64 = @intCast(u64, (x104 & @intCast(u128, 0xffffffffffffff))); const x110: u64 = (x108 + x80); const x111: u64 = (x107 >> 56); const x112: u64 = (x107 & 0xffffffffffffff); const x113: u64 = (x110 >> 56); const x114: u64 = (x110 & 0xffffffffffffff); const x115: u64 = (x93 + x111); const x116: u64 = (x97 + x111); const x117: u64 = (x113 + x115); const x118: u1 = @intCast(u1, (x117 >> 56)); const x119: u64 = (x117 & 0xffffffffffffff); const x120: u64 = (@intCast(u64, x118) + x100); const x121: u1 = @intCast(u1, (x116 >> 56)); const x122: u64 = (x116 & 0xffffffffffffff); const x123: u64 = (@intCast(u64, x121) + x103); out1[0] = x122; out1[1] = x123; out1[2] = x109; out1[3] = x114; out1[4] = x119; out1[5] = x120; out1[6] = x106; out1[7] = x112; } /// The function fiatP448Carry reduces a field element. /// Postconditions: /// eval out1 mod m = eval arg1 mod m /// /// Input Bounds: /// arg1: [[0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000]] /// Output Bounds: /// out1: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] pub fn fiatP448Carry(out1: *[8]u64, arg1: [8]u64) void { const x1: u64 = (arg1[3]); const x2: u64 = (arg1[7]); const x3: u64 = (x2 >> 56); const x4: u64 = (((x1 >> 56) + (arg1[4])) + x3); const x5: u64 = ((arg1[0]) + x3); const x6: u64 = ((x4 >> 56) + (arg1[5])); const x7: u64 = ((x5 >> 56) + (arg1[1])); const x8: u64 = ((x6 >> 56) + (arg1[6])); const x9: u64 = ((x7 >> 56) + (arg1[2])); const x10: u64 = ((x8 >> 56) + (x2 & 0xffffffffffffff)); const x11: u64 = ((x9 >> 56) + (x1 & 0xffffffffffffff)); const x12: u1 = @intCast(u1, (x10 >> 56)); const x13: u64 = ((x5 & 0xffffffffffffff) + @intCast(u64, x12)); const x14: u64 = (@intCast(u64, @intCast(u1, (x11 >> 56))) + ((x4 & 0xffffffffffffff) + @intCast(u64, x12))); const x15: u64 = (x13 & 0xffffffffffffff); const x16: u64 = (@intCast(u64, @intCast(u1, (x13 >> 56))) + (x7 & 0xffffffffffffff)); const x17: u64 = (x9 & 0xffffffffffffff); const x18: u64 = (x11 & 0xffffffffffffff); const x19: u64 = (x14 & 0xffffffffffffff); const x20: u64 = (@intCast(u64, @intCast(u1, (x14 >> 56))) + (x6 & 0xffffffffffffff)); const x21: u64 = (x8 & 0xffffffffffffff); const x22: u64 = (x10 & 0xffffffffffffff); out1[0] = x15; out1[1] = x16; out1[2] = x17; out1[3] = x18; out1[4] = x19; out1[5] = x20; out1[6] = x21; out1[7] = x22; } /// The function fiatP448Add adds two field elements. /// Postconditions: /// eval out1 mod m = (eval arg1 + eval arg2) mod m /// /// Input Bounds: /// arg1: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] /// arg2: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] /// Output Bounds: /// out1: [[0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000]] pub fn fiatP448Add(out1: *[8]u64, arg1: [8]u64, arg2: [8]u64) void { const x1: u64 = ((arg1[0]) + (arg2[0])); const x2: u64 = ((arg1[1]) + (arg2[1])); const x3: u64 = ((arg1[2]) + (arg2[2])); const x4: u64 = ((arg1[3]) + (arg2[3])); const x5: u64 = ((arg1[4]) + (arg2[4])); const x6: u64 = ((arg1[5]) + (arg2[5])); const x7: u64 = ((arg1[6]) + (arg2[6])); const x8: u64 = ((arg1[7]) + (arg2[7])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; out1[4] = x5; out1[5] = x6; out1[6] = x7; out1[7] = x8; } /// The function fiatP448Sub subtracts two field elements. /// Postconditions: /// eval out1 mod m = (eval arg1 - eval arg2) mod m /// /// Input Bounds: /// arg1: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] /// arg2: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] /// Output Bounds: /// out1: [[0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000]] pub fn fiatP448Sub(out1: *[8]u64, arg1: [8]u64, arg2: [8]u64) void { const x1: u64 = ((0x1fffffffffffffe + (arg1[0])) - (arg2[0])); const x2: u64 = ((0x1fffffffffffffe + (arg1[1])) - (arg2[1])); const x3: u64 = ((0x1fffffffffffffe + (arg1[2])) - (arg2[2])); const x4: u64 = ((0x1fffffffffffffe + (arg1[3])) - (arg2[3])); const x5: u64 = ((0x1fffffffffffffc + (arg1[4])) - (arg2[4])); const x6: u64 = ((0x1fffffffffffffe + (arg1[5])) - (arg2[5])); const x7: u64 = ((0x1fffffffffffffe + (arg1[6])) - (arg2[6])); const x8: u64 = ((0x1fffffffffffffe + (arg1[7])) - (arg2[7])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; out1[4] = x5; out1[5] = x6; out1[6] = x7; out1[7] = x8; } /// The function fiatP448Opp negates a field element. /// Postconditions: /// eval out1 mod m = -eval arg1 mod m /// /// Input Bounds: /// arg1: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] /// Output Bounds: /// out1: [[0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000]] pub fn fiatP448Opp(out1: *[8]u64, arg1: [8]u64) void { const x1: u64 = (0x1fffffffffffffe - (arg1[0])); const x2: u64 = (0x1fffffffffffffe - (arg1[1])); const x3: u64 = (0x1fffffffffffffe - (arg1[2])); const x4: u64 = (0x1fffffffffffffe - (arg1[3])); const x5: u64 = (0x1fffffffffffffc - (arg1[4])); const x6: u64 = (0x1fffffffffffffe - (arg1[5])); const x7: u64 = (0x1fffffffffffffe - (arg1[6])); const x8: u64 = (0x1fffffffffffffe - (arg1[7])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; out1[4] = x5; out1[5] = x6; out1[6] = x7; out1[7] = x8; } /// The function fiatP448Selectznz is a multi-limb conditional select. /// Postconditions: /// eval out1 = (if arg1 = 0 then eval arg2 else eval arg3) /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP448Selectznz(out1: *[8]u64, arg1: u1, arg2: [8]u64, arg3: [8]u64) void { var x1: u64 = undefined; fiatP448CmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); var x2: u64 = undefined; fiatP448CmovznzU64(&x2, arg1, (arg2[1]), (arg3[1])); var x3: u64 = undefined; fiatP448CmovznzU64(&x3, arg1, (arg2[2]), (arg3[2])); var x4: u64 = undefined; fiatP448CmovznzU64(&x4, arg1, (arg2[3]), (arg3[3])); var x5: u64 = undefined; fiatP448CmovznzU64(&x5, arg1, (arg2[4]), (arg3[4])); var x6: u64 = undefined; fiatP448CmovznzU64(&x6, arg1, (arg2[5]), (arg3[5])); var x7: u64 = undefined; fiatP448CmovznzU64(&x7, arg1, (arg2[6]), (arg3[6])); var x8: u64 = undefined; fiatP448CmovznzU64(&x8, arg1, (arg2[7]), (arg3[7])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; out1[4] = x5; out1[5] = x6; out1[6] = x7; out1[7] = x8; } /// The function fiatP448ToBytes serializes a field element to bytes in little-endian order. /// Postconditions: /// out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..55] /// /// Input Bounds: /// arg1: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] pub fn fiatP448ToBytes(out1: *[56]u8, arg1: [8]u64) void { var x1: u64 = undefined; var x2: u1 = undefined; fiatP448SubborrowxU56(&x1, &x2, 0x0, (arg1[0]), 0xffffffffffffff); var x3: u64 = undefined; var x4: u1 = undefined; fiatP448SubborrowxU56(&x3, &x4, x2, (arg1[1]), 0xffffffffffffff); var x5: u64 = undefined; var x6: u1 = undefined; fiatP448SubborrowxU56(&x5, &x6, x4, (arg1[2]), 0xffffffffffffff); var x7: u64 = undefined; var x8: u1 = undefined; fiatP448SubborrowxU56(&x7, &x8, x6, (arg1[3]), 0xffffffffffffff); var x9: u64 = undefined; var x10: u1 = undefined; fiatP448SubborrowxU56(&x9, &x10, x8, (arg1[4]), 0xfffffffffffffe); var x11: u64 = undefined; var x12: u1 = undefined; fiatP448SubborrowxU56(&x11, &x12, x10, (arg1[5]), 0xffffffffffffff); var x13: u64 = undefined; var x14: u1 = undefined; fiatP448SubborrowxU56(&x13, &x14, x12, (arg1[6]), 0xffffffffffffff); var x15: u64 = undefined; var x16: u1 = undefined; fiatP448SubborrowxU56(&x15, &x16, x14, (arg1[7]), 0xffffffffffffff); var x17: u64 = undefined; fiatP448CmovznzU64(&x17, x16, @intCast(u64, 0x0), 0xffffffffffffffff); var x18: u64 = undefined; var x19: u1 = undefined; fiatP448AddcarryxU56(&x18, &x19, 0x0, x1, (x17 & 0xffffffffffffff)); var x20: u64 = undefined; var x21: u1 = undefined; fiatP448AddcarryxU56(&x20, &x21, x19, x3, (x17 & 0xffffffffffffff)); var x22: u64 = undefined; var x23: u1 = undefined; fiatP448AddcarryxU56(&x22, &x23, x21, x5, (x17 & 0xffffffffffffff)); var x24: u64 = undefined; var x25: u1 = undefined; fiatP448AddcarryxU56(&x24, &x25, x23, x7, (x17 & 0xffffffffffffff)); var x26: u64 = undefined; var x27: u1 = undefined; fiatP448AddcarryxU56(&x26, &x27, x25, x9, (x17 & 0xfffffffffffffe)); var x28: u64 = undefined; var x29: u1 = undefined; fiatP448AddcarryxU56(&x28, &x29, x27, x11, (x17 & 0xffffffffffffff)); var x30: u64 = undefined; var x31: u1 = undefined; fiatP448AddcarryxU56(&x30, &x31, x29, x13, (x17 & 0xffffffffffffff)); var x32: u64 = undefined; var x33: u1 = undefined; fiatP448AddcarryxU56(&x32, &x33, x31, x15, (x17 & 0xffffffffffffff)); const x34: u8 = @intCast(u8, (x18 & @intCast(u64, 0xff))); const x35: u64 = (x18 >> 8); const x36: u8 = @intCast(u8, (x35 & @intCast(u64, 0xff))); const x37: u64 = (x35 >> 8); const x38: u8 = @intCast(u8, (x37 & @intCast(u64, 0xff))); const x39: u64 = (x37 >> 8); const x40: u8 = @intCast(u8, (x39 & @intCast(u64, 0xff))); const x41: u64 = (x39 >> 8); const x42: u8 = @intCast(u8, (x41 & @intCast(u64, 0xff))); const x43: u64 = (x41 >> 8); const x44: u8 = @intCast(u8, (x43 & @intCast(u64, 0xff))); const x45: u8 = @intCast(u8, (x43 >> 8)); const x46: u8 = @intCast(u8, (x20 & @intCast(u64, 0xff))); const x47: u64 = (x20 >> 8); const x48: u8 = @intCast(u8, (x47 & @intCast(u64, 0xff))); const x49: u64 = (x47 >> 8); const x50: u8 = @intCast(u8, (x49 & @intCast(u64, 0xff))); const x51: u64 = (x49 >> 8); const x52: u8 = @intCast(u8, (x51 & @intCast(u64, 0xff))); const x53: u64 = (x51 >> 8); const x54: u8 = @intCast(u8, (x53 & @intCast(u64, 0xff))); const x55: u64 = (x53 >> 8); const x56: u8 = @intCast(u8, (x55 & @intCast(u64, 0xff))); const x57: u8 = @intCast(u8, (x55 >> 8)); const x58: u8 = @intCast(u8, (x22 & @intCast(u64, 0xff))); const x59: u64 = (x22 >> 8); const x60: u8 = @intCast(u8, (x59 & @intCast(u64, 0xff))); const x61: u64 = (x59 >> 8); const x62: u8 = @intCast(u8, (x61 & @intCast(u64, 0xff))); const x63: u64 = (x61 >> 8); const x64: u8 = @intCast(u8, (x63 & @intCast(u64, 0xff))); const x65: u64 = (x63 >> 8); const x66: u8 = @intCast(u8, (x65 & @intCast(u64, 0xff))); const x67: u64 = (x65 >> 8); const x68: u8 = @intCast(u8, (x67 & @intCast(u64, 0xff))); const x69: u8 = @intCast(u8, (x67 >> 8)); const x70: u8 = @intCast(u8, (x24 & @intCast(u64, 0xff))); const x71: u64 = (x24 >> 8); const x72: u8 = @intCast(u8, (x71 & @intCast(u64, 0xff))); const x73: u64 = (x71 >> 8); const x74: u8 = @intCast(u8, (x73 & @intCast(u64, 0xff))); const x75: u64 = (x73 >> 8); const x76: u8 = @intCast(u8, (x75 & @intCast(u64, 0xff))); const x77: u64 = (x75 >> 8); const x78: u8 = @intCast(u8, (x77 & @intCast(u64, 0xff))); const x79: u64 = (x77 >> 8); const x80: u8 = @intCast(u8, (x79 & @intCast(u64, 0xff))); const x81: u8 = @intCast(u8, (x79 >> 8)); const x82: u8 = @intCast(u8, (x26 & @intCast(u64, 0xff))); const x83: u64 = (x26 >> 8); const x84: u8 = @intCast(u8, (x83 & @intCast(u64, 0xff))); const x85: u64 = (x83 >> 8); const x86: u8 = @intCast(u8, (x85 & @intCast(u64, 0xff))); const x87: u64 = (x85 >> 8); const x88: u8 = @intCast(u8, (x87 & @intCast(u64, 0xff))); const x89: u64 = (x87 >> 8); const x90: u8 = @intCast(u8, (x89 & @intCast(u64, 0xff))); const x91: u64 = (x89 >> 8); const x92: u8 = @intCast(u8, (x91 & @intCast(u64, 0xff))); const x93: u8 = @intCast(u8, (x91 >> 8)); const x94: u8 = @intCast(u8, (x28 & @intCast(u64, 0xff))); const x95: u64 = (x28 >> 8); const x96: u8 = @intCast(u8, (x95 & @intCast(u64, 0xff))); const x97: u64 = (x95 >> 8); const x98: u8 = @intCast(u8, (x97 & @intCast(u64, 0xff))); const x99: u64 = (x97 >> 8); const x100: u8 = @intCast(u8, (x99 & @intCast(u64, 0xff))); const x101: u64 = (x99 >> 8); const x102: u8 = @intCast(u8, (x101 & @intCast(u64, 0xff))); const x103: u64 = (x101 >> 8); const x104: u8 = @intCast(u8, (x103 & @intCast(u64, 0xff))); const x105: u8 = @intCast(u8, (x103 >> 8)); const x106: u8 = @intCast(u8, (x30 & @intCast(u64, 0xff))); const x107: u64 = (x30 >> 8); const x108: u8 = @intCast(u8, (x107 & @intCast(u64, 0xff))); const x109: u64 = (x107 >> 8); const x110: u8 = @intCast(u8, (x109 & @intCast(u64, 0xff))); const x111: u64 = (x109 >> 8); const x112: u8 = @intCast(u8, (x111 & @intCast(u64, 0xff))); const x113: u64 = (x111 >> 8); const x114: u8 = @intCast(u8, (x113 & @intCast(u64, 0xff))); const x115: u64 = (x113 >> 8); const x116: u8 = @intCast(u8, (x115 & @intCast(u64, 0xff))); const x117: u8 = @intCast(u8, (x115 >> 8)); const x118: u8 = @intCast(u8, (x32 & @intCast(u64, 0xff))); const x119: u64 = (x32 >> 8); const x120: u8 = @intCast(u8, (x119 & @intCast(u64, 0xff))); const x121: u64 = (x119 >> 8); const x122: u8 = @intCast(u8, (x121 & @intCast(u64, 0xff))); const x123: u64 = (x121 >> 8); const x124: u8 = @intCast(u8, (x123 & @intCast(u64, 0xff))); const x125: u64 = (x123 >> 8); const x126: u8 = @intCast(u8, (x125 & @intCast(u64, 0xff))); const x127: u64 = (x125 >> 8); const x128: u8 = @intCast(u8, (x127 & @intCast(u64, 0xff))); const x129: u8 = @intCast(u8, (x127 >> 8)); out1[0] = x34; out1[1] = x36; out1[2] = x38; out1[3] = x40; out1[4] = x42; out1[5] = x44; out1[6] = x45; out1[7] = x46; out1[8] = x48; out1[9] = x50; out1[10] = x52; out1[11] = x54; out1[12] = x56; out1[13] = x57; out1[14] = x58; out1[15] = x60; out1[16] = x62; out1[17] = x64; out1[18] = x66; out1[19] = x68; out1[20] = x69; out1[21] = x70; out1[22] = x72; out1[23] = x74; out1[24] = x76; out1[25] = x78; out1[26] = x80; out1[27] = x81; out1[28] = x82; out1[29] = x84; out1[30] = x86; out1[31] = x88; out1[32] = x90; out1[33] = x92; out1[34] = x93; out1[35] = x94; out1[36] = x96; out1[37] = x98; out1[38] = x100; out1[39] = x102; out1[40] = x104; out1[41] = x105; out1[42] = x106; out1[43] = x108; out1[44] = x110; out1[45] = x112; out1[46] = x114; out1[47] = x116; out1[48] = x117; out1[49] = x118; out1[50] = x120; out1[51] = x122; out1[52] = x124; out1[53] = x126; out1[54] = x128; out1[55] = x129; } /// The function fiatP448FromBytes deserializes a field element from bytes in little-endian order. /// Postconditions: /// eval out1 mod m = bytes_eval arg1 mod m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] /// Output Bounds: /// out1: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]] pub fn fiatP448FromBytes(out1: *[8]u64, arg1: [56]u8) void { const x1: u64 = (@intCast(u64, (arg1[55])) << 48); const x2: u64 = (@intCast(u64, (arg1[54])) << 40); const x3: u64 = (@intCast(u64, (arg1[53])) << 32); const x4: u64 = (@intCast(u64, (arg1[52])) << 24); const x5: u64 = (@intCast(u64, (arg1[51])) << 16); const x6: u64 = (@intCast(u64, (arg1[50])) << 8); const x7: u8 = (arg1[49]); const x8: u64 = (@intCast(u64, (arg1[48])) << 48); const x9: u64 = (@intCast(u64, (arg1[47])) << 40); const x10: u64 = (@intCast(u64, (arg1[46])) << 32); const x11: u64 = (@intCast(u64, (arg1[45])) << 24); const x12: u64 = (@intCast(u64, (arg1[44])) << 16); const x13: u64 = (@intCast(u64, (arg1[43])) << 8); const x14: u8 = (arg1[42]); const x15: u64 = (@intCast(u64, (arg1[41])) << 48); const x16: u64 = (@intCast(u64, (arg1[40])) << 40); const x17: u64 = (@intCast(u64, (arg1[39])) << 32); const x18: u64 = (@intCast(u64, (arg1[38])) << 24); const x19: u64 = (@intCast(u64, (arg1[37])) << 16); const x20: u64 = (@intCast(u64, (arg1[36])) << 8); const x21: u8 = (arg1[35]); const x22: u64 = (@intCast(u64, (arg1[34])) << 48); const x23: u64 = (@intCast(u64, (arg1[33])) << 40); const x24: u64 = (@intCast(u64, (arg1[32])) << 32); const x25: u64 = (@intCast(u64, (arg1[31])) << 24); const x26: u64 = (@intCast(u64, (arg1[30])) << 16); const x27: u64 = (@intCast(u64, (arg1[29])) << 8); const x28: u8 = (arg1[28]); const x29: u64 = (@intCast(u64, (arg1[27])) << 48); const x30: u64 = (@intCast(u64, (arg1[26])) << 40); const x31: u64 = (@intCast(u64, (arg1[25])) << 32); const x32: u64 = (@intCast(u64, (arg1[24])) << 24); const x33: u64 = (@intCast(u64, (arg1[23])) << 16); const x34: u64 = (@intCast(u64, (arg1[22])) << 8); const x35: u8 = (arg1[21]); const x36: u64 = (@intCast(u64, (arg1[20])) << 48); const x37: u64 = (@intCast(u64, (arg1[19])) << 40); const x38: u64 = (@intCast(u64, (arg1[18])) << 32); const x39: u64 = (@intCast(u64, (arg1[17])) << 24); const x40: u64 = (@intCast(u64, (arg1[16])) << 16); const x41: u64 = (@intCast(u64, (arg1[15])) << 8); const x42: u8 = (arg1[14]); const x43: u64 = (@intCast(u64, (arg1[13])) << 48); const x44: u64 = (@intCast(u64, (arg1[12])) << 40); const x45: u64 = (@intCast(u64, (arg1[11])) << 32); const x46: u64 = (@intCast(u64, (arg1[10])) << 24); const x47: u64 = (@intCast(u64, (arg1[9])) << 16); const x48: u64 = (@intCast(u64, (arg1[8])) << 8); const x49: u8 = (arg1[7]); const x50: u64 = (@intCast(u64, (arg1[6])) << 48); const x51: u64 = (@intCast(u64, (arg1[5])) << 40); const x52: u64 = (@intCast(u64, (arg1[4])) << 32); const x53: u64 = (@intCast(u64, (arg1[3])) << 24); const x54: u64 = (@intCast(u64, (arg1[2])) << 16); const x55: u64 = (@intCast(u64, (arg1[1])) << 8); const x56: u8 = (arg1[0]); const x57: u64 = (x55 + @intCast(u64, x56)); const x58: u64 = (x54 + x57); const x59: u64 = (x53 + x58); const x60: u64 = (x52 + x59); const x61: u64 = (x51 + x60); const x62: u64 = (x50 + x61); const x63: u64 = (x48 + @intCast(u64, x49)); const x64: u64 = (x47 + x63); const x65: u64 = (x46 + x64); const x66: u64 = (x45 + x65); const x67: u64 = (x44 + x66); const x68: u64 = (x43 + x67); const x69: u64 = (x41 + @intCast(u64, x42)); const x70: u64 = (x40 + x69); const x71: u64 = (x39 + x70); const x72: u64 = (x38 + x71); const x73: u64 = (x37 + x72); const x74: u64 = (x36 + x73); const x75: u64 = (x34 + @intCast(u64, x35)); const x76: u64 = (x33 + x75); const x77: u64 = (x32 + x76); const x78: u64 = (x31 + x77); const x79: u64 = (x30 + x78); const x80: u64 = (x29 + x79); const x81: u64 = (x27 + @intCast(u64, x28)); const x82: u64 = (x26 + x81); const x83: u64 = (x25 + x82); const x84: u64 = (x24 + x83); const x85: u64 = (x23 + x84); const x86: u64 = (x22 + x85); const x87: u64 = (x20 + @intCast(u64, x21)); const x88: u64 = (x19 + x87); const x89: u64 = (x18 + x88); const x90: u64 = (x17 + x89); const x91: u64 = (x16 + x90); const x92: u64 = (x15 + x91); const x93: u64 = (x13 + @intCast(u64, x14)); const x94: u64 = (x12 + x93); const x95: u64 = (x11 + x94); const x96: u64 = (x10 + x95); const x97: u64 = (x9 + x96); const x98: u64 = (x8 + x97); const x99: u64 = (x6 + @intCast(u64, x7)); const x100: u64 = (x5 + x99); const x101: u64 = (x4 + x100); const x102: u64 = (x3 + x101); const x103: u64 = (x2 + x102); const x104: u64 = (x1 + x103); out1[0] = x62; out1[1] = x68; out1[2] = x74; out1[3] = x80; out1[4] = x86; out1[5] = x92; out1[6] = x98; out1[7] = x104; }
fiat-zig/src/p448_solinas_64.zig
const std = @import("std"); const testing = std.testing; const log = std.log; const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const numtheory = @import("numtheory"); const inv_mod = numtheory.inv_mod; const Polynomial = @import("polynomial.zig").Polynomial; // only used for testing const Deck = @import("deck.zig").Deck; pub const InstructionTag = enum { deal_into, cut_n, deal_inc, }; pub const Instruction = union(InstructionTag) { const Self = @This(); deal_into: void, cut_n: i64, deal_inc: i64, pub fn invert(item: Self, len: i64) Self { switch (item) { .deal_into => { return item; }, .cut_n => { const n = item.cut_n; const val = blk: { if (n >= 0) { break :blk len - n; } else { break :blk -n; } }; return Instruction{ .cut_n = val }; }, .deal_inc => { const n = item.deal_inc; const val = inv_mod(n, len).?; return Instruction{ .deal_inc = val }; }, } } /// Compute (f_n * ... f_1)^{-1} = f_1^{-1} * ... f_n^{-1}. /// Caller must free result. pub fn invertMany(allocator: Allocator, instructions: []const Instruction, m: i64) ![]const Instruction { var result = try ArrayList(Instruction).initCapacity(allocator, instructions.len); if (instructions.len > 0) { var i: usize = instructions.len - 1; while (true) { result.appendAssumeCapacity(instructions[i].invert(m)); if (i == 0) break; i -= 1; } } return result.toOwnedSlice(); } pub fn toPolynomial(item: Self) Polynomial { switch (item) { .deal_into => { return Polynomial{ .a = -1, .b = -1 }; // -x-1 }, .cut_n => { const n = item.cut_n; return Polynomial{ .a = 1, .b = -n }; // x-n }, .deal_inc => { const n = item.deal_inc; return Polynomial{ .a = n, .b = 0 }; // n*x }, } } pub fn manyToPolynomial(instructions: []const Instruction, m: i64) Polynomial { // instructions: f0, ..., fk // polynomials: p0, ..., pk // result: pk * ... * p0 const len = instructions.len; const inst = instructions[len - 1]; var poly = inst.toPolynomial(); // start with last poly if (len >= 2) { var i: usize = len - 2; while (true) { const item = instructions[i]; const curPoly = item.toPolynomial(); poly = poly.composeWith(curPoly, m); if (i == 0) { break; } i -= 1; } } return poly; } }; test "manyToPolynomial" { const instructions = [_]Instruction{ Instruction{ .cut_n = 6 }, Instruction{ .deal_inc = 7 }, Instruction{ .deal_into = {} }, }; const m = 10; const poly = Instruction.manyToPolynomial(instructions[0..], m); { var deck = try Deck.init(testing.allocator, m); defer deck.deinit(); try deck.apply_instructions(instructions[0..]); var i: usize = 0; while (i < m) : (i += 1) { try testing.expectEqual(deck.find_card(i).?, @intCast(usize, poly.eval(@intCast(i64, i), m))); } } } test "manyToPolynomial 2" { const instructions = [_]Instruction{ Instruction{ .deal_into = {} }, Instruction{ .cut_n = 8 }, Instruction{ .deal_inc = 7 }, Instruction{ .cut_n = 8 }, Instruction{ .cut_n = -4 }, Instruction{ .deal_inc = 7 }, Instruction{ .cut_n = 3 }, Instruction{ .deal_inc = 9 }, Instruction{ .deal_inc = 3 }, Instruction{ .cut_n = -1 }, }; const m = 10; const poly = Instruction.manyToPolynomial(instructions[0..], m); { var deck = try Deck.init(testing.allocator, 10); defer deck.deinit(); try deck.apply_instructions(instructions[0..]); var i: usize = 0; while (i < m) : (i += 1) { try testing.expectEqual(deck.find_card(i).?, @intCast(usize, poly.eval(@intCast(i64, i), m))); } } } test "invertMany simple" { const instructions = [_]Instruction{ Instruction{ .deal_inc = 7 }, }; const p = 10; const inv_instructions = try Instruction.invertMany(testing.allocator, instructions[0..], p); defer testing.allocator.free(inv_instructions); const f = Instruction.manyToPolynomial(instructions[0..], p); const g = Instruction.manyToPolynomial(inv_instructions, p); log.debug("f: {s}, g: {s}", .{ f, g }); { const id = f.composeWith(g, p); log.debug("id: {s}", .{id}); try testing.expectEqual(@as(i64, 1), id.a); try testing.expectEqual(@as(i64, 0), id.b); } { const id = g.composeWith(f, p); try testing.expectEqual(@as(i64, 1), id.a); try testing.expectEqual(@as(i64, 0), id.b); } } test "invertMany" { const instructions = [_]Instruction{ Instruction{ .deal_into = {} }, Instruction{ .cut_n = 8 }, Instruction{ .deal_inc = 7 }, Instruction{ .cut_n = 8 }, Instruction{ .cut_n = -4 }, Instruction{ .deal_inc = 7 }, Instruction{ .cut_n = 3 }, Instruction{ .deal_inc = 9 }, Instruction{ .deal_inc = 3 }, Instruction{ .cut_n = -1 }, }; const p = 10; const inv_instructions = try Instruction.invertMany(testing.allocator, instructions[0..], p); defer testing.allocator.free(inv_instructions); const f = Instruction.manyToPolynomial(instructions[0..], p); const g = Instruction.manyToPolynomial(inv_instructions, p); log.debug("f: {s}, g: {s}", .{ f, g }); { const id = f.composeWith(g, p); log.debug("id: {s}", .{id}); try testing.expectEqual(@as(i64, 1), id.a); try testing.expectEqual(@as(i64, 0), id.b); } { const id = g.composeWith(f, p); try testing.expectEqual(@as(i64, 1), id.a); try testing.expectEqual(@as(i64, 0), id.b); } }
day22/src/instruction.zig
const std = @import("std"); const builtin = @import("builtin"); const io = std.io; const os = std.os; const windows = os.windows; const posix = os.posix; const FOREGROUND_BLACK = u16(0); const FOREGROUND_BLUE = u16(1); const FOREGROUND_GREEN = u16(2); const FOREGROUND_AQUA= u16(3); const FOREGROUND_RED = u16(4); const FOREGROUND_PURPLE = u16(5); const FOREGROUND_YELLOW = u16(6); const FOREGROUND_WHITE = u16(7); const FOREGROUND_INTENSITY = u16(8); const BACKGROUND_BLACK = FOREGROUND_BLACK << 4; const BACKGROUND_BLUE = FOREGROUND_BLUE << 4; const BACKGROUND_GREEN = FOREGROUND_GREEN << 4; const BACKGROUND_AQUA= FOREGROUND_AQUA << 4; const BACKGROUND_RED = FOREGROUND_RED << 4; const BACKGROUND_PURPLE = FOREGROUND_PURPLE << 4; const BACKGROUND_YELLOW = FOREGROUND_YELLOW << 4; const BACKGROUND_WHITE = FOREGROUND_WHITE << 4; const BACKGROUND_INTENSITY = FOREGROUND_INTENSITY << 4; // const COMMON_LVB_REVERSE_VIDEO = 0x4000; // const COMMON_LVB_UNDERSCORE = 0x8000; const OutStream = os.File.OutStream; pub const Color = enum.{ Black, Blue, Green, Aqua, Red, Purple, Yellow, White, }; pub const Attribute = enum.{ Bright, Reversed, Underlined, }; pub const Mode = enum.{ ForeGround, BackGround, }; pub const ColoredOutStream = struct.{ const Self = @This(); const Error = error.{ InvalidMode, }; default_attrs: u16, current_attrs: u16, background: u16, foreground: u16, file: os.File, file_stream: OutStream, out_stream: ?*OutStream.Stream, pub fn new(file: os.File) Self { // TODO handle error var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; _ = windows.GetConsoleScreenBufferInfo(file.handle, &info); return Self.{ .file = file, .file_stream = file.outStream(), .out_stream = null, .default_attrs = info.wAttributes, .current_attrs = 0, .background = info.wAttributes & 0xff00, .foreground = info.wAttributes & 0x00ff, }; } // can't be done in `new` because of no copy-elision pub fn outStream(self: *Self) *OutStream.Stream { if (self.out_stream) |out_stream| { return out_stream; } else { self.out_stream = &self.file_stream.stream; return self.out_stream.?; } } fn setAttributeWindows(self: *Self, attr: Attribute, mode: ?Mode) !void { if (mode == null and attr == Attribute.Bright) { return error.InvalidMode; } self.current_attrs ^= switch (attr) { Attribute.Bright => switch (mode.?) { Mode.ForeGround => FOREGROUND_INTENSITY, Mode.BackGround => BACKGROUND_INTENSITY, }, // these dont work without [this](https://docs.microsoft.com/en-us/windows/console/console-screen-buffers) // Attribute.Reversed => COMMON_LVB_REVERSE_VIDEO, // Attribute.Underlined => COMMON_LVB_UNDERSCORE, else => 0, }; // TODO handle errors _ = windows.SetConsoleTextAttribute(self.file.handle, self.current_attrs | self.foreground | self.background); } pub fn setAttribute(self: *Self, attr: Attribute, mode: ?Mode) !void { if (builtin.os == builtin.Os.windows and !os.supportsAnsiEscapeCodes(self.file.handle)) { try self.setAttributeWindows(attr, mode); } else { var out = self.outStream(); if (mode == null and attr == Attribute.Bright) { return error.InvalidMode; } switch (attr) { Attribute.Bright => try out.write("\x1b[1m"), Attribute.Underlined => try out.write("\x1b[4m"), Attribute.Reversed => try out.write("\x1b[7m"), } } } fn setColorWindows(self: *Self, color: Color, mode: Mode) void { switch (mode) { Mode.ForeGround => { self.foreground = switch (color) { Color.Black => FOREGROUND_BLACK, Color.Blue => FOREGROUND_BLUE, Color.Green => FOREGROUND_GREEN, Color.Aqua => FOREGROUND_AQUA, Color.Red => FOREGROUND_RED, Color.Purple => FOREGROUND_PURPLE, Color.Yellow => FOREGROUND_YELLOW, Color.White => FOREGROUND_WHITE, }; }, Mode.BackGround => { self.background = switch (color) { Color.Black => BACKGROUND_BLACK, Color.Blue => BACKGROUND_BLUE, Color.Green => BACKGROUND_GREEN, Color.Aqua => BACKGROUND_AQUA, Color.Red => BACKGROUND_RED, Color.Purple => BACKGROUND_PURPLE, Color.Yellow => BACKGROUND_YELLOW, Color.White => BACKGROUND_WHITE, }; }, } // TODO handle errors _ = windows.SetConsoleTextAttribute(self.file.handle, self.current_attrs | self.foreground | self.background); } pub fn setColor(self: *Self, color: Color, mode: Mode, attributes: ?[]const Attribute) !void { if (attributes) |attrs| { for (attrs) |attr| { try self.setAttribute(attr, mode); } } if (builtin.os == builtin.Os.windows and !os.supportsAnsiEscapeCodes(self.file.handle)) { self.setColorWindows(color, mode); } else { var out = self.outStream(); switch (mode) { Mode.ForeGround => switch (color) { Color.Black => try out.write("\x1b[30m"), Color.Red => try out.write("\x1b[31m"), Color.Green => try out.write("\x1b[32m"), Color.Yellow => try out.write("\x1b[33m"), Color.Blue => try out.write("\x1b[34m"), Color.Purple => try out.write("\x1b[35m"), Color.Aqua => try out.write("\x1b[36m"), Color.White => try out.write("\x1b[37m"), }, Mode.BackGround => switch (color) { Color.Black => try out.write("\x1b[40m"), Color.Red => try out.write("\x1b[41m"), Color.Green => try out.write("\x1b[42m"), Color.Yellow => try out.write("\x1b[43m"), Color.Blue => try out.write("\x1b[44m"), Color.Purple => try out.write("\x1b[45m"), Color.Aqua => try out.write("\x1b[46m"), Color.White => try out.write("\x1b[47m"), } } } } pub fn reset(self: *Self) !void { if (builtin.os == builtin.Os.windows and !os.supportsAnsiEscapeCodes(self.file.handle)) { // TODO handle errors _ = windows.SetConsoleTextAttribute(self.file.handle, self.default_attrs); } else { var out = self.outStream(); try out.write("\x1b[0m"); } self.current_attrs = self.default_attrs; } }; test "ColoredOutStream" { const attrs = []Attribute.{ Attribute.Bright, Attribute.Underlined }; var color_stream = ColoredOutStream.new(try io.getStdOut()); defer color_stream.reset() catch {}; var stdout = color_stream.outStream(); try color_stream.setColor(Color.Red, Mode.ForeGround, attrs); try stdout.print("\nhi\n"); os.time.sleep(1000000000); try stdout.print("hey\n"); os.time.sleep(1000000000); try stdout.print("hello\n"); os.time.sleep(1000000000); try stdout.print("greetings\n"); os.time.sleep(1000000000); try stdout.print("salutations\n"); os.time.sleep(1000000000); try stdout.print("goodbye\n"); os.time.sleep(1000000000); }
src/index.zig
const std = @import("std"); const log = std.log; const math = std.math; const assert = std.debug.assert; const cuda = @import("cudaz"); const cu = cuda.cu; const png = @import("png.zig"); const utils = @import("utils.zig"); const kernels = @import("hw2_pure_kernel.zig"); const Mat3 = kernels.Mat3; const Mat2Float = kernels.Mat2Float; const resources_dir = "resources/hw2_resources/"; const Rgb24 = png.Rgb24; const Gray8 = png.Grayscale8; pub fn main() anyerror!void { log.info("***** HW2 ******", .{}); var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){}; const alloc = general_purpose_allocator.allocator(); const args = try std.process.argsAlloc(alloc); defer std.process.argsFree(alloc, args); var stream = try cuda.Stream.init(0); defer stream.deinit(); const img = try png.Image.fromFilePath(alloc, resources_dir ++ "cinque_terre_small.png"); defer img.deinit(); log.info("Loaded {}", .{img}); var d_img = try cuda.allocAndCopy(Rgb24, img.px.rgb24); defer cuda.free(d_img); var d_out = try cuda.alloc(Rgb24, img.width * img.height); defer cuda.free(d_out); // const gaussianBlur = try cuda.FnStruct("gaussianBlur", kernels.gaussianBlur).init(); const d_filter = Mat2Float{ .data = (try cuda.allocAndCopy(f32, &blurFilter())).ptr, .shape = [_]i32{ blur_kernel_width, blur_kernel_width }, }; defer cuda.free(d_filter.data[0..@intCast(usize, d_filter.shape[0])]); var img_mat = Mat3{ .data = std.mem.sliceAsBytes(d_img).ptr, .shape = [3]i32{ @intCast(i32, img.height), @intCast(i32, img.width), 3 }, }; var grid3D = cuda.Grid.init3D(img.height, img.width, 3, 32, 32, 1); var timer = cuda.GpuTimer.start(&stream); const gaussianBlurVerbose = try cuda.FnStruct("gaussianBlurVerbose", kernels.gaussianBlurVerbose).init(); try gaussianBlurVerbose.launch( &stream, grid3D, .{ img_mat.data, img_mat.shape[0], img_mat.shape[1], d_filter.data[0 .. blur_kernel_width * blur_kernel_width], @intCast(i32, blur_kernel_width), std.mem.sliceAsBytes(d_out).ptr, }, ); const blur_args = kernels.GaussianBlurArgs{ .img = img_mat, .filter = d_filter.data[0 .. blur_kernel_width * blur_kernel_width], .filter_width = @intCast(i32, blur_kernel_width), .output = std.mem.sliceAsBytes(d_out).ptr, }; log.info("arg.img.data={*}", .{blur_args.img.data}); log.info("arg.img.shape={any}", .{blur_args.img.shape}); log.info("arg.filter={*}", .{blur_args.filter}); log.info("arg.filter_width={}", .{blur_args.filter_width}); log.info("arg.output={*}", .{blur_args.output}); const gaussianBlurStruct = try cuda.FnStruct("gaussianBlurStruct", kernels.gaussianBlurStruct).init(); try gaussianBlurStruct.launch( &stream, grid3D, .{blur_args}, ); stream.synchronize(); const gaussianBlur = try cuda.FnStruct("gaussianBlur", kernels.gaussianBlur).init(); try gaussianBlur.launch( &stream, grid3D, .{ img_mat, d_filter, std.mem.sliceAsBytes(d_out), }, ); timer.stop(); try cuda.memcpyDtoH(Rgb24, img.px.rgb24, d_out); try img.writeToFilePath(resources_dir ++ "output.png"); try utils.validate_output(alloc, resources_dir, 2.0); } const blur_kernel_width: i32 = 9; fn blurFilter() [blur_kernel_width * blur_kernel_width]f32 { const blurKernelSigma = 2.0; // create and fill the filter we will convolve with var filter: [blur_kernel_width * blur_kernel_width]f32 = undefined; var filterSum: f32 = 0.0; // for normalization const halfWidth: i8 = @divTrunc(blur_kernel_width, 2); var r: i8 = -halfWidth; while (r <= halfWidth) : (r += 1) { var c: i8 = -halfWidth; while (c <= halfWidth) : (c += 1) { const filterValue: f32 = math.exp(-@intToFloat(f32, c * c + r * r) / (2.0 * blurKernelSigma * blurKernelSigma)); filter[@intCast(usize, (r + halfWidth) * blur_kernel_width + c + halfWidth)] = filterValue; filterSum += filterValue; } } const normalizationFactor = 1.0 / filterSum; var result: f32 = 0.0; for (filter) |*v| { v.* *= normalizationFactor; result += v.*; } return filter; }
CS344/src/hw2_pure.zig
const std = @import("std"); const zp = @import("zplay"); const TextureUnit = zp.graphics.common.Texture.TextureUnit; const SimpleRenderer = zp.graphics.@"3d".SimpleRenderer; const Camera = zp.graphics.@"3d".Camera; const Model = zp.graphics.@"3d".Model; const TextureCube = zp.graphics.texture.TextureCube; const Skybox = zp.graphics.@"3d".Skybox; const Material = zp.graphics.@"3d".Material; const dig = zp.deps.dig; const alg = zp.deps.alg; const Vec2 = alg.Vec2; const Vec3 = alg.Vec3; const Vec4 = alg.Vec4; const Mat4 = alg.Mat4; var skybox: Skybox = undefined; var cubemap: TextureCube = undefined; var skybox_material: Material = undefined; var simple_renderer: SimpleRenderer = undefined; var wireframe_mode = false; var merge_meshes = true; var vsync_mode = false; var dog: Model = undefined; var girl: Model = undefined; var helmet: Model = undefined; var total_vertices: u32 = undefined; var total_meshes: u32 = undefined; var face_culling: bool = false; var camera = Camera.fromPositionAndTarget( Vec3.new(0, 0, 3), Vec3.zero(), null, ); fn init(ctx: *zp.Context) anyerror!void { std.log.info("game init", .{}); // init imgui try dig.init(ctx.window); // create renderer simple_renderer = SimpleRenderer.init(); // load scene loadScene(); // enable depth test ctx.graphics.toggleCapability(.depth_test, true); } fn loop(ctx: *zp.Context) void { while (ctx.pollEvent()) |e| { if (e == .mouse_event and dig.getIO().*.WantCaptureMouse) { _ = dig.processEvent(e); continue; } switch (e) { .window_event => |we| { switch (we.data) { .resized => |size| { ctx.graphics.setViewport(0, 0, size.width, size.height); }, else => {}, } }, .keyboard_event => |key| { if (key.trigger_type == .up) { switch (key.scan_code) { .escape => ctx.kill(), .f1 => ctx.toggleFullscreeen(null), .m => ctx.toggleRelativeMouseMode(null), .f => { if (wireframe_mode) { wireframe_mode = false; } else { wireframe_mode = true; } ctx.graphics.setPolygonMode(if (wireframe_mode) .line else .fill); }, else => {}, } } }, .mouse_event => |me| { switch (me.data) { .wheel => |scroll| { camera.zoom -= @intToFloat(f32, scroll.scroll_y); if (camera.zoom < 1) { camera.zoom = 1; } if (camera.zoom > 45) { camera.zoom = 45; } }, else => {}, } }, .quit_event => ctx.kill(), else => {}, } } var width: u32 = undefined; var height: u32 = undefined; ctx.getWindowSize(&width, &height); // start drawing ctx.graphics.clear(true, true, false, [_]f32{ 0.2, 0.3, 0.3, 1.0 }); const projection = Mat4.perspective( camera.zoom, @intToFloat(f32, width) / @intToFloat(f32, height), 0.1, 100, ); var renderer = simple_renderer.renderer(); renderer.begin(); dog.render( renderer, Mat4.fromTranslate(Vec3.new(-2.0, -0.7, 0)) .scale(Vec3.set(0.7)) .mult(Mat4.fromRotation(ctx.tick * 50, Vec3.up())), projection, camera, null, null, ) catch unreachable; girl.render( renderer, Mat4.fromTranslate(Vec3.new(2.0, -1.2, 0)) .scale(Vec3.set(0.7)) .mult(Mat4.fromRotation(ctx.tick * 100, Vec3.up())), projection, camera, null, null, ) catch unreachable; helmet.render( renderer, Mat4.fromTranslate(Vec3.new(0.0, 0, 0)) .scale(Vec3.set(0.7)) .mult(Mat4.fromRotation(ctx.tick * 10, Vec3.up())), projection, camera, null, null, ) catch unreachable; renderer.end(); // skybox skybox.draw(&ctx.graphics, projection, camera, skybox_material); // settings dig.beginFrame(); { dig.setNextWindowPos( .{ .x = @intToFloat(f32, width) - 30, .y = 50 }, .{ .cond = dig.c.ImGuiCond_Always, .pivot = .{ .x = 1, .y = 0 }, }, ); if (dig.begin( "control", null, dig.c.ImGuiWindowFlags_NoMove | dig.c.ImGuiWindowFlags_NoResize | dig.c.ImGuiWindowFlags_AlwaysAutoResize, )) { var buf: [32]u8 = undefined; dig.text(std.fmt.bufPrintZ(&buf, "FPS: {d:.2}", .{dig.getIO().*.Framerate}) catch unreachable); dig.text(std.fmt.bufPrintZ(&buf, "ms/frame: {d:.2}", .{ctx.delta_tick * 1000}) catch unreachable); dig.text(std.fmt.bufPrintZ(&buf, "Total Vertices: {d}", .{total_vertices}) catch unreachable); dig.text(std.fmt.bufPrintZ(&buf, "Total Meshes: {d}", .{total_meshes}) catch unreachable); dig.separator(); if (dig.checkbox("wireframe", &wireframe_mode)) { ctx.graphics.setPolygonMode(if (wireframe_mode) .line else .fill); } if (dig.checkbox("vsync", &vsync_mode)) { ctx.graphics.setVsyncMode(vsync_mode); } if (dig.checkbox("face culling", &face_culling)) { ctx.graphics.toggleCapability(.cull_face, face_culling); } if (dig.checkbox("merge meshes", &merge_meshes)) { loadScene(); } } dig.end(); const S = struct { const MAX_SIZE = 20000; var data = std.ArrayList(Vec2).init(std.testing.allocator); var offset: u32 = 0; var history: f32 = 10; var interval: f32 = 0; var count: f32 = 0; }; S.interval += ctx.delta_tick; S.count += 1; if (S.interval > 0.1) { var mpf = S.interval / S.count; if (S.data.items.len < S.MAX_SIZE) { S.data.append(Vec2.new(ctx.tick, mpf)) catch unreachable; } else { S.data.items[S.offset] = Vec2.new(ctx.tick, mpf); S.offset = (S.offset + 1) % S.MAX_SIZE; } S.interval = 0; S.count = 0; } const plot = dig.ext.plot; if (dig.begin("monitor", null, 0)) { _ = dig.sliderFloat("History", &S.history, 1, 30, .{}); plot.setNextPlotLimitsX(ctx.tick - S.history, ctx.tick, dig.c.ImGuiCond_Always); plot.setNextPlotLimitsY(0, 0.02, .{}); if (plot.beginPlot("milliseconds per frame", .{})) { if (S.data.items.len > 0) { plot.plotLine_PtrPtr( "line", f32, &S.data.items[0].x, &S.data.items[0].y, @intCast(u32, S.data.items.len), .{ .offset = @intCast(c_int, S.offset) }, ); } plot.endPlot(); } } dig.end(); } dig.endFrame(); } fn loadScene() void { const S = struct { var loaded = false; }; if (S.loaded) { dog.deinit(); girl.deinit(); helmet.deinit(); } // allocate skybox skybox = Skybox.init(); cubemap = TextureCube.fromFilePath( std.testing.allocator, "assets/skybox/right.jpg", "assets/skybox/left.jpg", "assets/skybox/top.jpg", "assets/skybox/bottom.jpg", "assets/skybox/front.jpg", "assets/skybox/back.jpg", ) catch unreachable; skybox_material = Material.init(.{ .single_cubemap = cubemap }); // load models total_vertices = 0; total_meshes = 0; dog = Model.fromGLTF(std.testing.allocator, "assets/dog.gltf", merge_meshes, null) catch unreachable; girl = Model.fromGLTF(std.testing.allocator, "assets/girl.glb", merge_meshes, null) catch unreachable; helmet = Model.fromGLTF(std.testing.allocator, "assets/SciFiHelmet/SciFiHelmet.gltf", merge_meshes, null) catch unreachable; for (dog.meshes.items) |m| { total_vertices += @intCast(u32, m.positions.items.len); total_meshes += 1; } for (girl.meshes.items) |m| { total_vertices += @intCast(u32, m.positions.items.len); total_meshes += 1; } for (helmet.meshes.items) |m| { total_vertices += @intCast(u32, m.positions.items.len); total_meshes += 1; } // allocate texture units var unit: i32 = 0; for (dog.materials.items) |m| { unit = m.allocTextureUnit(unit); } for (girl.materials.items) |m| { unit = m.allocTextureUnit(unit); } for (helmet.materials.items) |m| { unit = m.allocTextureUnit(unit); } _ = skybox_material.allocTextureUnit(unit); S.loaded = true; } 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, .width = 1600, .height = 900, .enable_vsync = false, }); }
examples/gltf_demo.zig
const std = @import("std"); const lib = @import("lib/lib.zig"); const TangleStep = lib.TangleStep; pub fn build(b: *std.build.Builder) !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. b.setPreferredReleaseMode(.ReleaseSafe); const mode = b.standardReleaseOptions(); const exe = b.addExecutable("zangle", "src/main.zig"); const fmt_check_step = &b.addSystemCommand(&.{ "zig", "fmt", "--check", "--ast-check", "src", "lib" }).step; exe.addPackagePath("lib", "lib/lib.zig"); exe.step.dependOn(fmt_check_step); exe.setTarget(target); exe.setBuildMode(mode); exe.install(); const wa = b.addSharedLibrary("zangle", "lib/wasm.zig", .unversioned); wa.step.dependOn(fmt_check_step); wa.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); wa.setBuildMode(mode); wa.install(); const tangle = TangleStep.create(b); tangle.addFile("README.md"); const t_exe = b.addExecutableSource("zangle", tangle.getFileSource("src/main.zig")); t_exe.addPackage(.{ .name = "lib", .path = tangle.getFileSource("lib/lib.zig"), }); const tangle_test_step = b.step("test-step", "Test compiling zangle using the build step"); tangle_test_step.dependOn(&tangle.step); tangle_test_step.dependOn(&b.addInstallArtifact(t_exe).step); const run_cmd = exe.run(); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); const test_cmd = b.addTest("lib/lib.zig"); const test_main_cmd = b.addTest("src/main.zig"); const test_step = b.step("test", "Run unit tests"); test_step.dependOn(fmt_check_step); test_step.dependOn(&test_cmd.step); test_step.dependOn(&test_main_cmd.step); }
build.zig
const std = @import("std"); const ArrayList = std.ArrayList; const gpu = @import("gpu"); const App = @import("main.zig").App; const zm = @import("zmath"); const UVData = @import("atlas.zig").UVData; const Vec2 = @Vector(2, f32); pub const Vertex = struct { pos: @Vector(4, f32), uv: Vec2, }; const VERTEX_ATTRIBUTES = [_]gpu.VertexAttribute{ .{ .format = .float32x4, .offset = @offsetOf(Vertex, "pos"), .shader_location = 0 }, .{ .format = .float32x2, .offset = @offsetOf(Vertex, "uv"), .shader_location = 1 }, }; pub const VERTEX_BUFFER_LAYOUT = gpu.VertexBufferLayout{ .array_stride = @sizeOf(Vertex), .step_mode = .vertex, .attribute_count = VERTEX_ATTRIBUTES.len, .attributes = &VERTEX_ATTRIBUTES, }; pub const VertexUniform = struct { mat: zm.Mat, }; const GkurveType = enum(u32) { concave = 0, convex = 1, filled = 2, }; pub const FragUniform = struct { type: GkurveType = .filled, // Padding for struct alignment to 16 bytes (minimum in WebGPU uniform). padding: @Vector(3, f32) = undefined, blend_color: @Vector(4, f32) = @Vector(4, f32){ 1, 1, 1, 1 }, }; pub fn equilateralTriangle(app: *App, position: Vec2, scale: f32, uniform: FragUniform, uv_data: UVData) !void { const triangle_height = scale * @sqrt(0.75); try app.vertices.appendSlice(&[3]Vertex{ .{ .pos = .{ position[0] + scale / 2, position[1] + triangle_height, 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 0.5, 1 } }, .{ .pos = .{ position[0], position[1], 0, 1 }, .uv = uv_data.bottom_left }, .{ .pos = .{ position[0] + scale, position[1], 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 1, 0 } }, }); try app.fragment_uniform_list.append(uniform); app.update_vertex_buffer = true; app.update_frag_uniform_buffer = true; } pub fn quad(app: *App, position: Vec2, scale: Vec2, uniform: FragUniform, uv_data: UVData) !void { const bottom_right_uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 1, 0 }; const up_left_uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 0, 1 }; const up_right_uv = uv_data.bottom_left + uv_data.width_and_height; try app.vertices.appendSlice(&[6]Vertex{ .{ .pos = .{ position[0], position[1] + scale[1], 0, 1 }, .uv = up_left_uv }, .{ .pos = .{ position[0], position[1], 0, 1 }, .uv = uv_data.bottom_left }, .{ .pos = .{ position[0] + scale[0], position[1], 0, 1 }, .uv = bottom_right_uv }, .{ .pos = .{ position[0] + scale[0], position[1] + scale[1], 0, 1 }, .uv = up_right_uv }, .{ .pos = .{ position[0], position[1] + scale[1], 0, 1 }, .uv = up_left_uv }, .{ .pos = .{ position[0] + scale[0], position[1], 0, 1 }, .uv = bottom_right_uv }, }); try app.fragment_uniform_list.appendSlice(&.{ uniform, uniform }); app.update_vertex_buffer = true; app.update_frag_uniform_buffer = true; } pub fn circle(app: *App, position: Vec2, radius: f32, blend_color: @Vector(4, f32), uv_data: UVData) !void { const low_mid = Vertex{ .pos = .{ position[0], position[1] - radius, 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 0.5, 0 }, }; const high_mid = Vertex{ .pos = .{ position[0], position[1] + radius, 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 0.5, 1 }, }; const mid_left = Vertex{ .pos = .{ position[0] - radius, position[1], 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 0, 0.5 }, }; const mid_right = Vertex{ .pos = .{ position[0] + radius, position[1], 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 1, 0.5 }, }; const p = 0.95 * radius; const high_right = Vertex{ .pos = .{ position[0] + p, position[1] + p, 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 1, 0.75 }, }; const high_left = Vertex{ .pos = .{ position[0] - p, position[1] + p, 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 0, 0.75 }, }; const low_right = Vertex{ .pos = .{ position[0] + p, position[1] - p, 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 1, 0.25 }, }; const low_left = Vertex{ .pos = .{ position[0] - p, position[1] - p, 0, 1 }, .uv = uv_data.bottom_left + uv_data.width_and_height * Vec2{ 0, 0.25 }, }; try app.vertices.appendSlice(&[_]Vertex{ low_mid, mid_right, high_mid, high_mid, mid_left, low_mid, low_right, mid_right, low_mid, high_right, high_mid, mid_right, high_left, mid_left, high_mid, low_left, low_mid, mid_left, }); try app.fragment_uniform_list.appendSlice(&[_]FragUniform{ .{ .type = .filled, .blend_color = blend_color, }, .{ .type = .filled, .blend_color = blend_color, }, .{ .type = .convex, .blend_color = blend_color, }, .{ .type = .convex, .blend_color = blend_color, }, .{ .type = .convex, .blend_color = blend_color, }, .{ .type = .convex, .blend_color = blend_color, }, }); app.update_vertex_buffer = true; app.update_frag_uniform_buffer = true; }
examples/gkurve/draw.zig
const std = @import("std"); const print = std.debug.print; const util = @import("util.zig"); const gpa = util.gpa; const data = @embedFile("../data/day20.txt"); const Image = struct { key : std.StaticBitSet(512), payload : std.DynamicBitSet, infinitePixelIndex : usize, pub fn deinit(me : *@This()) void { me.payload.deinit(); } pub fn initEmpty(allocator : *std.mem.Allocator) !@This() { return Image { .key = std.StaticBitSet(512).initEmpty(), .payload = try std.DynamicBitSet.initEmpty(0, allocator), .infinitePixelIndex = 0, }; } pub fn setKey(me : *@This(), key: []const u8) !void { std.debug.assert(key.len == 512); for (key) |c, i| { if (c == '#') { me.key.set(i); } else { // We set the initial infinite pixel index to any dark region of the key // because we know from the input that the infinite region is initially // all dark. me.infinitePixelIndex = i; } } } pub fn addRow(me : *@This(), row : []const u8) !void { const offset = me.payload.capacity(); try me.payload.resize(me.payload.capacity() + row.len, false); for (row) |c, i| { if (c == '#') { me.payload.set(offset + i); } } } // Calculate whether a is in the range [offset..(offset + width)) fn inBounds(a : usize, offset : i32, width : usize) bool { if (offset < 0) { const poffset = @intCast(usize, -offset); if (a < poffset) { return false; } else { return (a - poffset) < width; } } else { return (a + @intCast(usize, offset)) < width; } } fn doOffset(a : usize, o : i32) usize { if (o < 0) { return a - @intCast(usize, -o); } else { return a + @intCast(usize, o); } } fn lookupKeyIndex(me : *const @This(), infinitePixel : bool, newWidth : usize, x : usize, y : usize) usize { var values = [9]bool { infinitePixel, infinitePixel, infinitePixel, infinitePixel, infinitePixel, infinitePixel, infinitePixel, infinitePixel, infinitePixel}; const originalWidth = newWidth - 4; var index : usize = 0; var yOffset : i32 = -3; while (yOffset <= -1) : (yOffset += 1) { var xOffset : i32 = -3; while (xOffset <= -1) : (xOffset += 1) { if (inBounds(x, xOffset, originalWidth) and inBounds(y, yOffset, originalWidth)) { values[index] = me.payload.isSet(doOffset(y, yOffset) * originalWidth + doOffset(x, xOffset)); } index += 1; } } var result : usize = 0; for (values) |v| { result <<= 1; if (v) { result |= 1; } } return result; } pub fn dump(me : *const @This()) void { const width = std.math.sqrt(me.payload.capacity()); var y : usize = 0; while (y < width) : (y += 1) { var x : usize = 0; while (x < width) : (x += 1) { const c : u8 = if (me.payload.isSet(y * width + x)) '#' else '.'; print("{c}", .{c}); } print("\n", .{}); } } pub fn enhance(me : *@This()) !void { // First thing we need to do is increase our image canvas to account for // the new pixels. const originalWidth = std.math.sqrt(me.payload.capacity()); // the 'interesting' region of the infinite image occurs 2 pixels in each // direction beyond our original image. const newWidth = 2 + originalWidth + 2; const newSize = newWidth * newWidth; const infinitePixel = me.key.isSet(me.infinitePixelIndex); // Set the infinite pixel index. This pixel index is the value that the rest // of the infinite image would be, assuming that it starts as dark pixels // (as the problem described). 9 dark pixels will map to the 0'th key in the // input (which cheekily in my input is #), and 9 light pixels will map to // the last index (which cheekily in my input is 0). This means that the // index of the infinite region can flip between lit/dark pixels on each // enhance, gross! me.infinitePixelIndex = if (infinitePixel) me.key.capacity() - 1 else 0; const newInfinitePixel = me.key.isSet(me.infinitePixelIndex); var new = if (newInfinitePixel) try std.DynamicBitSet.initFull(newSize, me.payload.allocator) else try std.DynamicBitSet.initEmpty(newSize, me.payload.allocator); { var y : usize = 0; while (y < newWidth) : (y += 1) { var x : usize = 0; while (x < newWidth) : (x += 1) { const keyIndex = me.lookupKeyIndex(infinitePixel, newWidth, x, y); const value = me.key.isSet(keyIndex); new.setValue(y * newWidth + x, value); } } } me.payload.deinit(); me.payload = new; } pub fn count(me : *const @This()) usize { std.debug.assert(!me.key.isSet(me.infinitePixelIndex)); return me.payload.count(); } }; pub fn parseInput(input : []const u8) !Image { var image = try Image.initEmpty(gpa); var iterator = std.mem.tokenize(input, "\r\n"); try image.setKey(iterator.next().?); while (iterator.next()) |line| { try image.addRow(line); } return image; } pub fn main() !void { var timer = try std.time.Timer.start(); var image = try parseInput(data); defer { image.deinit(); } var index : u32 = 0; while (index < 50) : (index += 1) { if (index == 2) { print("🎁 Lit after 2: {}\n", .{image.count()}); print("Day 20 - part 01 took {:15}ns\n", .{timer.lap()}); timer.reset(); } try image.enhance(); } print("🎁 Lit after 50: {}\n", .{image.count()}); print("Day 20 - part 02 took {:15}ns\n", .{timer.lap()}); print("❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️\n", .{}); } test "example" { const input = \\..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..# \\ \\#..#. \\#.... \\##..# \\..#.. \\..### ; var image = try parseInput(input); defer { image.deinit(); } var index : u32 = 0; while (index < 50) : (index += 1) { if (index == 2) { try std.testing.expect(image.count() == 35); } try image.enhance(); } try std.testing.expect(image.count() == 3351); }
src/day20.zig
usingnamespace @import("psptypes.zig"); pub const PSPPowerCB = extern enum(u32) { Battpower = 0x0000007f, BatteryExist = 0x00000080, BatteryLow = 0x00000100, ACPower = 0x00001000, Suspending = 0x00010000, Resuming = 0x00020000, ResumeComplete = 0x00040000, Standby = 0x00080000, HoldSwitch = 0x40000000, PowerSwitch = 0x80000000, }; pub const PSPPowerTick = extern enum(u32) { All = 0, Suspend = 1, Display = 6 }; pub const powerCallback_t = ?fn (c_int, c_int) callconv(.C) void; // Register Power Callback Function // // @param slot - slot of the callback in the list, 0 to 15, pass -1 to get an auto assignment. // @param cbid - callback id from calling sceKernelCreateCallback // // @return 0 on success, the slot number if -1 is passed, < 0 on error. pub extern fn scePowerRegisterCallback(slot: c_int, cbid: SceUID) c_int; pub fn powerRegisterCallback(slot: c_int, cbid: SceUID) !i32 { var res = scePowerRegisterCallback(slot, cbid); if (res < 0) { return error.Unexpected; } return res; } // Unregister Power Callback Function // // @param slot - slot of the callback // // @return 0 on success, < 0 on error. pub extern fn scePowerUnregisterCallback(slot: c_int) c_int; pub fn powerUnregisterCallback(slot: c_int) !void { var res = scePowerUnregisterCallback(slot); if (res < 0) { return error.Unexpected; } } // Check if unit is plugged in // // @return 1 if plugged in, 0 if not plugged in, < 0 on error. pub extern fn scePowerIsPowerOnline() c_int; pub fn powerIsPowerOnline() !bool { var res = scePowerIsPowerOnline(); if (res < 0) { return error.Unexpected; } return res == 1; } // Check if a battery is present // // @return 1 if battery present, 0 if battery not present, < 0 on error. pub extern fn scePowerIsBatteryExist() c_int; pub fn powerIsBatteryExist() !bool { var res = scePowerIsBatteryExist(); if (res < 0) { return error.Unexpected; } return res == 1; } // Check if the battery is charging // // @return 1 if battery charging, 0 if battery not charging, < 0 on error. pub extern fn scePowerIsBatteryCharging() c_int; pub fn powerIsBatteryCharging() !bool { var res = scePowerIsBatteryCharging(); if (res < 0) { return error.Unexpected; } return res == 1; } // Get the status of the battery charging pub extern fn scePowerGetBatteryChargingStatus() c_int; // Check if the battery is low // // @return 1 if the battery is low, 0 if the battery is not low, < 0 on error. pub extern fn scePowerIsLowBattery() c_int; pub fn powerIsLowBattery() !bool { var res = scePowerIsLowBattery(); if (res < 0) { return error.Unexpected; } return res == 1; } // Get battery life as integer percent // // @return Battery charge percentage (0-100), < 0 on error. pub extern fn scePowerGetBatteryLifePercent() c_int; pub fn powerGetBatteryLifePercent() !i32 { var res = scePowerGetBatteryLifePercent(); if (res < 0) { return error.Unexpected; } return res; } // Get battery life as time // // @return Battery life in minutes, < 0 on error. pub extern fn scePowerGetBatteryLifeTime() c_int; pub fn powerGetBatteryLifeTime() !i32 { var res = scePowerGetBatteryLifeTime(); if (res < 0) { return error.Unexpected; } return res; } // Get temperature of the battery pub extern fn scePowerGetBatteryTemp() c_int; // Get battery volt level pub extern fn scePowerGetBatteryVolt() c_int; // Set CPU Frequency // @param cpufreq - new CPU frequency, valid values are 1 - 333 pub extern fn scePowerSetCpuClockFrequency(cpufreq: c_int) c_int; // Set Bus Frequency // @param busfreq - new BUS frequency, valid values are 1 - 167 pub extern fn scePowerSetBusClockFrequency(busfreq: c_int) c_int; // Alias for scePowerGetCpuClockFrequencyInt // @return frequency as int pub extern fn scePowerGetCpuClockFrequency() c_int; // Get CPU Frequency as Integer // @return frequency as int pub extern fn scePowerGetCpuClockFrequencyInt() c_int; // Get CPU Frequency as Float // @return frequency as float pub extern fn scePowerGetCpuClockFrequencyFloat() f32; // Alias for scePowerGetBusClockFrequencyInt // @return frequency as int pub extern fn scePowerGetBusClockFrequency() c_int; // Get Bus fequency as Integer // @return frequency as int pub extern fn scePowerGetBusClockFrequencyInt() c_int; // Get Bus frequency as Float // @return frequency as float pub extern fn scePowerGetBusClockFrequencyFloat() f32; // Set Clock Frequencies // // @param pllfreq - pll frequency, valid from 19-333 // @param cpufreq - cpu frequency, valid from 1-333 // @param busfreq - bus frequency, valid from 1-167 // // and: // // cpufreq <= pllfreq // busfreq*2 <= pllfreq // pub extern fn scePowerSetClockFrequency(pllfreq: c_int, cpufreq: c_int, busfreq: c_int) c_int; // Lock power switch // // Note: if the power switch is toggled while locked // it will fire immediately after being unlocked. // // @param unknown - pass 0 // // @return 0 on success, < 0 on error. pub extern fn scePowerLock(unknown: c_int) c_int; pub fn powerLock(unknown: c_int) !void { var res = scePowerLock(unknown); if (res < 0) { return error.Unexpected; } } // Unlock power switch // // @param unknown - pass 0 // // @return 0 on success, < 0 on error. pub extern fn scePowerUnlock(unknown: c_int) c_int; pub fn powerUnlock(unknown: c_int) !void { var res = scePowerUnlock(unknown); if (res < 0) { return error.Unexpected; } } // Generate a power tick, preventing unit from // powering off and turning off display. // // @param type - Either PSP_POWER_TICK_ALL, PSP_POWER_TICK_SUSPEND or PSP_POWER_TICK_DISPLAY // // @return 0 on success, < 0 on error. pub extern fn scePowerTick(typec: c_int) c_int; pub fn powerTick(typec: PSPPowerTick) !void { var res = scePowerTick(@enumToInt(typec)); if (res < 0) { return error.Unexpected; } } // Get Idle timer pub extern fn scePowerGetIdleTimer() c_int; // Enable Idle timer // // @param unknown - pass 0 pub extern fn scePowerIdleTimerEnable(unknown: c_int) c_int; // Disable Idle timer // // @param unknown - pass 0 pub extern fn scePowerIdleTimerDisable(unknown: c_int) c_int; // Request the PSP to go into standby // // @return 0 always pub extern fn scePowerRequestStandby() c_int; // Request the PSP to go into suspend // // @return 0 always pub extern fn scePowerRequestSuspend() c_int;
src/psp/sdk/psppower.zig
const std = @import("std"); const SParser = @import("SParser.zig"); const Expr = SParser.Expr; const TextIterator = SParser.TextIterator; pub const Error = error{ TopLevelIndent, IndentMismatch, } || SParser.Error; pub fn parseAll(iter: *TextIterator, gpa: std.mem.Allocator) !Expr.Root { var arena = std.heap.ArenaAllocator.init(gpa); errdefer arena.deinit(); var exprs = std.ArrayList(Expr).init(arena.allocator()); while (!iter.eof()) { if (try mayParseTopOne(iter, arena.allocator())) |expr| try exprs.append(expr); } return Expr.Root{ .val = .{ .val = .{ .list = exprs.toOwnedSlice() } }, .arena = arena }; } fn notEol(cp: u21) bool { return cp != '\n'; } fn isPadding(cp: u21) bool { return notEol(cp) and TextIterator.isSpace(cp); } inline fn isIndented(str: []const u8) bool { return str.len > 0 and (str.len != 1 or str[0] != '\r'); } fn readPadding(iter: *TextIterator) ?[]const u8 { const indent = iter.readWhile(isPadding); if (iter.peek().scalar != ';') return indent; // Full line comment iter.skip(); std.debug.assert(iter.peek().scalar == ';'); iter.skip(); _ = iter.readWhile(notEol); return null; } fn parseIndent(iter: *TextIterator) []const u8 { while (true) { if (readPadding(iter)) |indent| { if (!iter.eol()) return indent; } iter.skip(); } } pub fn mayParseTopOne(iter: *TextIterator, arena: std.mem.Allocator) !?Expr { if (isIndented(parseIndent(iter))) return error.TopLevelIndent; if (try mayParseOne(iter, arena, "")) |ei| { if (ei.next_indent.len != 0) return error.IndentMismatch; return ei.expr; } return null; } const ExprIndent = struct { expr: Expr, next_indent: []const u8 }; fn mayParseOne(iter: *TextIterator, alloc: std.mem.Allocator, my_indent: []const u8) SParser.Error!?ExprIndent { if (iter.eof()) return null; //TODO: special blocks like \\ const left = (try SParser.mayParseOne(iter, alloc)) orelse return null; var exprs = std.ArrayList(Expr).init(alloc); while (true) { _ = readPadding(iter); if (iter.eof() or iter.eol()) break; if (try SParser.mayParseOne(iter, alloc)) |next| { if (exprs.items.len == 0) try exprs.append(left); try exprs.append(next); } } iter.skip(); var next_indent = parseIndent(iter); if (next_indent.len > my_indent.len and std.mem.startsWith(u8, next_indent, my_indent)) { const child_indent = next_indent; while (std.mem.eql(u8, next_indent, child_indent)) { if (try mayParseOne(iter, alloc, child_indent)) |ei| { if (exprs.items.len == 0) try exprs.append(left); try exprs.append(ei.expr); next_indent = ei.next_indent; } } } return ExprIndent{ .expr = if (exprs.items.len == 0) left else Expr{ .at = .{ .offset = left.at.?.offset, .len = exprs.items[exprs.items.len - 1].at.?.end() - left.at.?.offset }, .val = .{ .list = exprs.toOwnedSlice() } }, .next_indent = next_indent }; } /// https://github.com/ziglang/zig/issues/4437 inline fn expectEqual(expected: anytype, actual: anytype) !void { return std.testing.expectEqual(@as(@TypeOf(actual), expected), actual); } test "empty" { var iter = TextIterator.unsafeInit(""); const empty = try parseAll(&iter, std.testing.failing_allocator); try expectEqual(0, empty.list().len); } test "skip spaces" { var iter = try TextIterator.init("\n() (;b ;) \r\n;; comment\n( )"); const root = try parseAll(&iter, std.testing.allocator); defer root.deinit(); const two = root.list(); try expectEqual(2, two.len); try std.testing.expect(two[1].val == .list); try expectEqual(0, two[1].val.list.len); try expectEqual(24, two[1].at.?.offset); try expectEqual(4, two[1].at.?.len); } test "strings" { var iter = try TextIterator.init( \\"a\n\t\r\\b\'\"c\64\u{65}" \\$id \\$"still id" ); const root = try parseAll(&iter, std.testing.allocator); defer root.deinit(); const str = root.list(); try expectEqual(3, str.len); try std.testing.expectEqualStrings("a\n\t\r\\b\'\"cde", str[0].val.string); try std.testing.expectEqualStrings("id", str[1].val.id); try std.testing.expectEqualStrings("still id", str[2].val.id); } test "infix" { var iter = try TextIterator.init( \\{} \\{a} \\{b a c} \\{a + b + c} ); const root = try parseAll(&iter, std.testing.allocator); defer root.deinit(); const infix = root.list(); try expectEqual(4, infix.len); for (infix) |list| { try std.testing.expect(list.val == .list); for (list.val.list) |kv| try std.testing.expect(kv.val == .keyword); } try expectEqual(0, infix[0].val.list.len); try expectEqual(1, infix[1].val.list.len); try expectEqual(3, infix[2].val.list.len); try std.testing.expectEqualStrings("a", infix[2].val.list[0].val.keyword); try std.testing.expectEqualStrings("b", infix[2].val.list[1].val.keyword); try std.testing.expectEqualStrings("c", infix[2].val.list[2].val.keyword); try expectEqual(4, infix[3].val.list.len); try std.testing.expectEqualStrings("+", infix[3].val.list[0].val.keyword); try std.testing.expectEqualStrings("a", infix[3].val.list[1].val.keyword); try std.testing.expectEqualStrings("b", infix[3].val.list[2].val.keyword); try std.testing.expectEqualStrings("c", infix[3].val.list[3].val.keyword); } test "neoteric" { var iter = try TextIterator.init( \\a (b) \\a(b) \\a{c b} ); const root = try parseAll(&iter, std.testing.allocator); defer root.deinit(); const neoteric = root.list(); try expectEqual(3, neoteric.len); for (neoteric) |list| { try std.testing.expect(list.val == .list); try expectEqual(2, list.val.list.len); try std.testing.expectEqualStrings("a", list.val.list[0].val.keyword); } try expectEqual(1, neoteric[0].val.list[1].val.list.len); try std.testing.expectEqualStrings("b", neoteric[1].val.list[1].val.keyword); try expectEqual(2, neoteric[2].val.list[1].val.list.len); try std.testing.expectEqualStrings("b", neoteric[2].val.list[1].val.list[0].val.keyword); } test "Expr.format" { var iter = TextIterator.unsafeInit("a ($b) \"c\" d"); const root = try parseAll(&iter, std.testing.allocator); defer root.deinit(); const exprs = root.list(); try expectEqual(1, exprs.len); try std.testing.expectFmt( \\(a ($b) "c" d) , "{}", .{exprs[0]}); try std.testing.expectFmt( \\(a \\ ($b) \\ "c" \\ d) , "{tree}", .{exprs[0]}); try std.testing.expectFmt( \\a \\ $b \\ "c" d , "{sweet}", .{exprs[0]}); } test "Error.TopLevelIndent" { var iter = TextIterator.unsafeInit(" 42"); const err = parseAll(&iter, std.testing.failing_allocator); try std.testing.expectError(Error.TopLevelIndent, err); try expectEqual(3, iter.cur.?.offset); } test "Error.IndentMismatch" { var iter = TextIterator.unsafeInit( \\top \\ (2;; \\) \\ 1 ); const err = parseAll(&iter, std.testing.allocator); try std.testing.expectError(Error.IndentMismatch, err); try expectEqual(14, iter.cur.?.offset); } test "Error.InvalidUtf8 Surrogate" { var iter = TextIterator.unsafeInit( \\"\u{d842}" ); const err = parseAll(&iter, std.testing.allocator); try std.testing.expectError(Error.InvalidUtf8, err); try expectEqual(8, iter.cur.?.offset); } test "Error.InvalidUtf8 Overflow" { var iter = TextIterator.unsafeInit( \\"\u{AAAAAAAAAAAAAAAAAAAAAAAAA}" ); const err = parseAll(&iter, std.testing.allocator); try std.testing.expectError(Error.InvalidUtf8, err); try expectEqual(9, iter.cur.?.offset); } test "Error.UnexpectedCharacter" { var iter = TextIterator.unsafeInit( \\"\error" ); const err = parseAll(&iter, std.testing.allocator); try std.testing.expectError(Error.UnexpectedCharacter, err); try expectEqual(3, iter.cur.?.offset); }
src/SweetParser.zig
const std = @import("std"); const u = @import("util.zig"); pub const Expr = @import("Expr.zig"); pub const TextIterator = @import("TextIterator.zig"); pub fn parseAll(iter: *TextIterator, gpa: std.mem.Allocator) Error!Expr.Root { var arena = std.heap.ArenaAllocator.init(gpa); errdefer arena.deinit(); var exprs = std.ArrayList(Expr).init(arena.allocator()); while (!iter.eof()) { if (try mayParseOne(iter, arena.allocator())) |expr| try exprs.append(expr); } return .{ .val = .{ .val = .{ .list = exprs.toOwnedSlice() } }, .arena = arena }; } /// Does not skip block comments fn skipSpaces(iter: *TextIterator) !void { while (true) { _ = iter.readWhile(TextIterator.isSpace); if (iter.peek().scalar != ';') break; iter.skip(); if (iter.peek().scalar != ';') return error.UnexpectedCharacter; iter.skip(); _ = iter.readWhile(struct { fn pred(cp: u21) bool { return cp != '\n'; } }.pred); } } pub const Error = error{ UnexpectedEndOfFile, UnexpectedCharacter, OutOfMemory, InvalidUtf8, }; fn mayParseOneBlock(iter: *TextIterator, alloc: std.mem.Allocator, infix: bool) Error!?std.ArrayList(Expr) { const open: u21 = if (infix) '{' else '('; const close: u21 = if (infix) '}' else ')'; std.debug.assert(iter.peek().scalar == open); iter.skip(); if (iter.peek().scalar == ';') { // Block comment iter.skip(); while (iter.peek().scalar != close) { if (iter.eof()) return error.UnexpectedEndOfFile; _ = iter.readWhile(struct { fn pred(cp: u21) bool { return cp != ';'; } }.pred); iter.skip(); } iter.skip(); return null; } // List try skipSpaces(iter); var list = std.ArrayList(Expr).init(alloc); while (iter.peek().scalar != close) { if (iter.eof()) return error.UnexpectedEndOfFile; if (try mayParseOne(iter, alloc)) |expr| try list.append(expr); try skipSpaces(iter); } iter.skip(); if (infix) transformInfix(&list); return list; } inline fn digit(c: u21) !u8 { const t = @truncate(u8, c); return switch (c) { '0'...'9' => t - '0', 'A'...'F' => t - 'A' + 10, 'a'...'f' => t - 'a' + 10, else => error.UnexpectedCharacter, }; } inline fn nextScalar(iter: *TextIterator) !u21 { const cp = iter.next() orelse return error.UnexpectedEndOfFile; return cp.scalar; } inline fn mayParseOneVal(iter: *TextIterator, alloc: std.mem.Allocator) Error!?Expr.Val { const infix = iter.peek().scalar == '{'; if (iter.peek().scalar == '(' or infix) { return if (try mayParseOneBlock(iter, alloc, infix)) |list| Expr.Val{ .list = list.items } else null; } else { // String const dollared = iter.peek().scalar == '$'; if (dollared) iter.skip(); var str = std.ArrayList(u8).init(alloc); const quoted = iter.peek().scalar == '"'; if (quoted) { iter.skip(); while (iter.peek().scalar != '"') { if (iter.eof()) return error.UnexpectedEndOfFile; if (iter.peek().scalar == '\\') { const n = try nextScalar(iter); switch (n) { 't' => try str.append('\t'), 'n' => try str.append('\n'), 'r' => try str.append('\r'), '"' => try str.append('"'), '\'' => try str.append('\''), '\\' => try str.append('\\'), 'u' => { if ((try nextScalar(iter)) != '{') return error.UnexpectedCharacter; // hexnum var cp: u21 = try digit(try nextScalar(iter)); while (true) { var c = try nextScalar(iter); if (c == '}') break; if (c == '_') c = try nextScalar(iter); cp = std.math.mul(u21, cp, 16) catch return error.InvalidUtf8; cp = std.math.add(u21, cp, try digit(c)) catch return error.InvalidUtf8; } var buf: [4]u8 = undefined; const len = std.unicode.utf8Encode(cp, &buf) catch return error.InvalidUtf8; try str.appendSlice(buf[0..len]); }, else => { const m = try nextScalar(iter); try str.append((try digit(n)) * 16 + try digit(m)); }, } } else { try str.appendSlice(iter.peek().bytes); } iter.skip(); } iter.skip(); } else { const slice = iter.readWhile(struct { fn pred(cp: u21) bool { return switch (cp) { ';', '(', ')', '{', '}', '[', ']' => false, else => !TextIterator.isSpace(cp), }; } }.pred); if (slice.len == 0) return error.UnexpectedCharacter; try str.appendSlice(slice); } const text = str.toOwnedSlice(); if (dollared) { return Expr.Val{ .id = try u.toTxt(text) }; } else if (quoted) { return Expr.Val{ .string = text }; } else return Expr.Val{ .keyword = text }; } } pub fn mayParseOne(iter: *TextIterator, arena: std.mem.Allocator) Error!?Expr { try skipSpaces(iter); const at_offset = iter.peek().offset; const left = if (try mayParseOneVal(iter, arena)) |val| Expr{ .at = .{ .offset = at_offset, .len = iter.peek().offset - at_offset }, .val = val } else return null; // Partial neoteric-expression if (iter.peek().scalar == '{') { const list = try arena.alloc(Expr, 2); list[0] = left; list[1] = (try mayParseOne(iter, arena)).?; // Always infix list return Expr{ .at = .{ .offset = at_offset, .len = iter.peek().offset - at_offset }, .val = .{ .list = list } }; } else if (iter.peek().scalar == '(') { var exprs = (try mayParseOneBlock(iter, arena, false)) orelse return left; try exprs.insert(0, left); return Expr{ .at = .{ .offset = at_offset, .len = iter.peek().offset - at_offset }, .val = .{ .list = exprs.toOwnedSlice() } }; } return left; } inline fn transformInfix(list: *std.ArrayList(Expr)) void { const es = list.items; if (es.len < 2) return; std.mem.swap(Expr, &es[0], &es[1]); if (es.len < 5 or es.len % 2 != 1) return; const op = es[0]; var i: usize = 3; while (i < es.len) : (i += 2) { if (!op.val.shallowEql(es[i].val)) return; } i = 3; while (i < list.items.len - 1) : (i += 1) { _ = list.orderedRemove(i); } }
src/SParser.zig
const std = @import("std"); const builtin = @import("builtin"); pub const pkg = std.build.Pkg{ .name = "curl", .source = .{ .path = srcPath() ++ "/curl.zig" }, }; const Options = struct { openssl_includes: []const []const u8, nghttp2_includes: []const []const u8, zlib_includes: []const []const u8, }; pub fn addPackage(step: *std.build.LibExeObjStep) void { step.addPackage(pkg); step.addIncludeDir(srcPath() ++ "/vendor/include/curl"); } pub fn create( b: *std.build.Builder, target: std.zig.CrossTarget, mode: std.builtin.Mode, opts: Options, ) !*std.build.LibExeObjStep { const lib = b.addStaticLibrary("curl", null); lib.setTarget(target); lib.setBuildMode(mode); const alloc = b.allocator; // See config.status or lib/curl_config.h for generated defines from configure. var c_flags = std.ArrayList([]const u8).init(alloc); try c_flags.appendSlice(&.{ // Indicates that we're building the lib not the tools. "-DBUILDING_LIBCURL", // Hides libcurl internal symbols (hide all symbols that aren't officially external). "-DCURL_HIDDEN_SYMBOLS", "-DCURL_STATICLIB", "-DNGHTTP2_STATICLIB=1", "-Wno-system-headers", }); if (target.getOsTag() == .linux or target.getOsTag() == .macos or target.getOsTag() == .windows) { // Will make sources include curl_config.h in ./lib/curl try c_flags.append("-DHAVE_CONFIG_H"); } if (target.getOsTag() == .linux) { // cpu-machine-OS // eg. x86_64-pc-linux-gnu const os_flag = try std.fmt.allocPrint(alloc, "-DOS={s}-pc-{s}-{s}", .{ @tagName(target.getCpuArch()), @tagName(target.getOsTag()), @tagName(target.getAbi()), }); try c_flags.appendSlice(&.{ "-DTARGET_LINUX", "-pthread", "-Werror-implicit-function-declaration", "-fvisibility=hidden", // Move to curl_config. os_flag, }); } const c_files = &[_][]const u8{ // Copied from curl/lib/Makefile.inc (LIB_CFILES) "altsvc.c", "amigaos.c", "asyn-ares.c", "asyn-thread.c", "base64.c", "bufref.c", "c-hyper.c", "conncache.c", "connect.c", "content_encoding.c", "cookie.c", "curl_addrinfo.c", "curl_ctype.c", "curl_des.c", "curl_endian.c", "curl_fnmatch.c", "curl_get_line.c", "curl_gethostname.c", "curl_gssapi.c", "curl_memrchr.c", "curl_multibyte.c", "curl_ntlm_core.c", "curl_ntlm_wb.c", "curl_path.c", "curl_range.c", "curl_rtmp.c", "curl_sasl.c", "curl_sspi.c", "curl_threads.c", "dict.c", "doh.c", "dotdot.c", "dynbuf.c", "easy.c", "easygetopt.c", "easyoptions.c", "escape.c", "file.c", "fileinfo.c", "formdata.c", "ftp.c", "ftplistparser.c", "getenv.c", "getinfo.c", "gopher.c", "hash.c", "hmac.c", "hostasyn.c", "hostcheck.c", "hostip.c", "hostip4.c", "hostip6.c", "hostsyn.c", "hsts.c", "http.c", "http2.c", "http_chunks.c", "http_digest.c", "http_negotiate.c", "http_ntlm.c", "http_proxy.c", "http_aws_sigv4.c", "idn_win32.c", "if2ip.c", "imap.c", "inet_ntop.c", "inet_pton.c", "krb5.c", "ldap.c", "llist.c", "md4.c", "md5.c", "memdebug.c", "mime.c", "mprintf.c", "mqtt.c", "multi.c", "netrc.c", "non-ascii.c", "nonblock.c", "openldap.c", "parsedate.c", "pingpong.c", "pop3.c", "progress.c", "psl.c", "rand.c", "rename.c", "rtsp.c", "select.c", "sendf.c", "setopt.c", "sha256.c", "share.c", "slist.c", "smb.c", "smtp.c", "socketpair.c", "socks.c", "socks_gssapi.c", "socks_sspi.c", "speedcheck.c", "splay.c", "strcase.c", "strdup.c", "strerror.c", "strtok.c", "strtoofft.c", "system_win32.c", "telnet.c", "tftp.c", "timeval.c", "transfer.c", "url.c", "urlapi.c", "version.c", "version_win32.c", "warnless.c", "wildcard.c", "x509asn1.c", // Copied from curl/lib/Makefile.inc (LIB_VAUTH_CFILES) "vauth/cleartext.c", "vauth/cram.c", "vauth/digest.c", "vauth/digest_sspi.c", "vauth/gsasl.c", "vauth/krb5_gssapi.c", "vauth/krb5_sspi.c", "vauth/ntlm.c", "vauth/ntlm_sspi.c", "vauth/oauth2.c", "vauth/spnego_gssapi.c", "vauth/spnego_sspi.c", "vauth/vauth.c", // Copied from curl/lib/Makefile.inc (LIB_VTLS_CFILES) "vtls/bearssl.c", "vtls/gskit.c", "vtls/gtls.c", "vtls/keylog.c", "vtls/mbedtls.c", "vtls/mbedtls_threadlock.c", "vtls/mesalink.c", "vtls/nss.c", "vtls/openssl.c", "vtls/rustls.c", "vtls/schannel.c", "vtls/schannel_verify.c", "vtls/sectransp.c", "vtls/vtls.c", "vtls/wolfssl.c", }; for (c_files) |file| { const path = b.fmt("{s}/vendor/lib/{s}", .{ srcPath(), file }); lib.addCSourceFile(path, c_flags.items); } // lib.disable_sanitize_c = true; lib.linkLibC(); if (target.getOsTag() == .linux) { lib.addIncludeDir(fromRoot(b, "linux")); } else if (target.getOsTag() == .macos) { lib.addIncludeDir(fromRoot(b, "macos")); } else if (target.getOsTag() == .windows) { lib.addIncludeDir(fromRoot(b, "windows")); } lib.addIncludeDir(fromRoot(b, "vendor/include")); lib.addIncludeDir(fromRoot(b, "vendor/lib")); for (opts.openssl_includes) |path| { lib.addIncludeDir(path); } for (opts.nghttp2_includes) |path| { lib.addIncludeDir(path); } for (opts.zlib_includes) |path| { lib.addIncludeDir(path); } if (builtin.os.tag == .macos and target.getOsTag() == .macos) { if (!target.isNativeOs()) { lib.setLibCFile(std.build.FileSource.relative("./lib/macos.libc")); lib.addFrameworkDir("/System/Library/Frameworks"); } lib.linkFramework("SystemConfiguration"); } return lib; } pub const LinkOptions = struct { lib_path: ?[]const u8 = null, }; pub fn buildAndLink(step: *std.build.LibExeObjStep, opts: LinkOptions) void { const b = step.builder; if (opts.lib_path) |path| { linkLibPath(step, path); } else { const lib = create(b, step.target, step.build_mode, .{ // Use the same openssl config so curl knows what features it has. .openssl_includes = &.{ srcPath() ++ "/../openssl/include", srcPath() ++ "/../openssl/vendor/include", }, .nghttp2_includes = &.{ srcPath() ++ "/../nghttp2/vendor/lib/includes", }, .zlib_includes = &.{ srcPath() ++ "/../zlib/vendor", }, }) catch unreachable; linkLib(step, lib); } } pub fn linkLib(step: *std.build.LibExeObjStep, lib: *std.build.LibExeObjStep) void { linkDeps(step); step.linkLibrary(lib); } pub fn linkLibPath(step: *std.build.LibExeObjStep, path: []const u8) void { linkDeps(step); step.addAssemblyFile(path); } fn linkDeps(step: *std.build.LibExeObjStep) void { if (builtin.os.tag == .macos and step.target.isNativeOs()) { step.linkFramework("SystemConfiguration"); } else if (step.target.getOsTag() == .windows and step.target.getAbi() == .gnu) { step.linkSystemLibrary("crypt32"); } } fn srcPath() []const u8 { return (std.fs.path.dirname(@src().file) orelse unreachable); } fn fromRoot(b: *std.build.Builder, rel_path: []const u8) []const u8 { return std.fs.path.resolve(b.allocator, &.{ srcPath(), rel_path }) catch unreachable; }
lib/curl/lib.zig
const std = @import("std"); const stdx = @import("stdx.zig"); const builtin = @import("builtin"); const curl = @import("curl"); const uv = @import("uv"); const Curl = curl.Curl; const CurlM = curl.CurlM; const CurlSH = curl.CurlSH; const log = stdx.log.scoped(.http); const EventDispatcher = @import("events.zig").EventDispatcher; // NOTES: // Debugging tls handshake: "openssl s_client -connect 127.0.0.1:3000" Useful options: -prexit -debug -msg // Curl also has tracing: "curl --trace /dev/stdout https://127.0.0.1:3000" // Generating a self-signed localhost certificate: "openssl req -x509 -days 3650 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config <( printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")" // Testing http2 upgrade: "curl http://127.0.0.1:3000/hello -v --http2" // Testing http2 direct: "curl http://127.0.0.1:3000/hello -v --http2-prior-knowledge" // It's useful to turn on CURLOPT_VERBOSE to see request/response along with log statements in this file. /// Log curl requests in debug mode. const CurlVerbose = false and builtin.mode == .Debug; // Dedicated curl handle for synchronous requests. Reuse for connection pool. var curl_h: Curl = undefined; // Async curl handle. curl_multi_socket let's us set up async with uv. var share: CurlSH = undefined; var curlm: CurlM = undefined; pub var curlm_uvloop: *uv.uv_loop_t = undefined; // This is set later when uv loop is available. pub var dispatcher: EventDispatcher = undefined; // Only one timer is needed for the curlm handle. var timer: uv.uv_timer_t = undefined; var timer_inited = false; // Use heap for handles since hashmap can grow. var galloc: std.mem.Allocator = undefined; var sock_handles: std.AutoHashMap(std.os.socket_t, *SockHandle) = undefined; const SockHandle = struct { const Self = @This(); // First field on purpose so we can pass into uv and cast back. poll: uv.uv_poll_t, polling_readable: bool, polling_writable: bool, sockfd: std.os.socket_t, // There is a bug (first noticed in MacOS) where CURL will call socketfunction // before opensocketfunction for internal use: https://github.com/curl/curl/issues/5747 // Those onSocket callbacks should not affect perform logic on the user request, // but we should go through the motions of handling POLL_IN and then POLL_REMOVE in handleInternalSocket. // The "ready" field tells us when a sockfd is ready to perform logic on the user request. // onOpenSocket will set to ready to true and onCloseSocket will set it to false. ready: bool, // Whether the sockfd is closed and waiting to be cleaned up. sockfd_closed: bool, // Number of active requests using this sock fd. // This is heavily used by HTTP2 requests. // Once this becomes 0, start to close this handle. num_active_reqs: u32, /// During the uv closing state, onOpenSocket may request to reuse the same sockfd again. /// This flag will skip destroying the handle on uv closed callback. skip_destroy_on_uv_close: bool, pub fn init(self: *Self, sockfd: std.os.socket_t) void { self.* = .{ .poll = undefined, .polling_readable = false, .polling_writable = false, .sockfd = sockfd, .ready = false, .num_active_reqs = 0, .sockfd_closed = false, .skip_destroy_on_uv_close = false, }; const c_sockfd = if (builtin.os.tag == .windows) @ptrToInt(sockfd) else sockfd; const res = uv.uv_poll_init_socket(curlm_uvloop, &self.poll, c_sockfd); uv.assertNoError(res); } fn checkToDeinit(self: *Self) void { // Only start cleanup if sockfd was closed and there are no more active reqs. // Otherwise, let the last req trigger the cleanup. if (self.sockfd_closed and self.num_active_reqs == 0) { uv.uv_close(@ptrCast(*uv.uv_handle_t, &self.poll), onUvClosePoll); } } }; pub fn init(alloc: std.mem.Allocator) void { if (!curl.inited) { @panic("expected curl to be inited"); } curl_h = Curl.init(); // TODO: Look into what scenarios share should be used. share = CurlSH.init(); _ = share.setOption(curl.CURLSHOPT_SHARE, curl.CURL_LOCK_DATA_SSL_SESSION); _ = share.setOption(curl.CURLSHOPT_SHARE, curl.CURL_LOCK_DATA_CONNECT); curlm = CurlM.init(); _ = curlm.setOption(curl.CURLMOPT_MAX_TOTAL_CONNECTIONS, @intCast(c_long, 0)); // Prefer reusing existing http2 connections. _ = curlm.setOption(curl.CURLMOPT_PIPELINING, curl.CURLPIPE_MULTIPLEX); _ = curlm.setOption(curl.CURLMOPT_MAX_CONCURRENT_STREAMS, @intCast(c_long, 1000)); _ = curlm.setOption(curl.CURLMOPT_SOCKETFUNCTION, onSocket); _ = curlm.setOption(curl.CURLMOPT_TIMERFUNCTION, onCurlSetTimer); // _ = curlm.setOption(curl.CURLMOPT_PUSHFUNCTION, onCurlPush); sock_handles = std.AutoHashMap(std.os.socket_t, *SockHandle).init(alloc); galloc = alloc; } pub fn deinit() void { curl_h.deinit(); curlm.deinit(); share.deinit(); // Sock Handles that were only used for internal curl ops will still remain since // they wouldn't be picked up by closesocketfunction. var iter = sock_handles.valueIterator(); while (iter.next()) |it| { if (!it.*.ready) { galloc.destroy(it.*); } else { @panic("Did not expect a user socket handle."); } } sock_handles.deinit(); timer_inited = false; } pub const RequestMethod = enum { Head, Get, Post, Put, Delete, }; pub const ContentType = enum { Json, FormData, }; pub const RequestOptions = struct { method: RequestMethod = .Get, keep_connection: bool = false, content_type: ?ContentType = null, body: ?[]const u8 = null, /// In seconds. 0 timeout = no timeout timeout: u32 = 30, headers: ?std.StringHashMap([]const u8) = null, // If cert file is not provided, the default for the operating system will be used. cert_file: ?[]const u8 = null, }; const IndexSlice = struct { start: usize, end: usize, }; pub const Response = struct { status_code: u32, // Allocated memory. headers: []const Header, header: []const u8, body: []const u8, pub fn deinit(self: Response, alloc: std.mem.Allocator) void { alloc.free(self.headers); alloc.free(self.header); alloc.free(self.body); } }; pub const Header = struct { key: IndexSlice, value: IndexSlice, }; fn onOpenSocket(client_ptr: ?*anyopaque, purpose: curl.curlsocktype, addr: *curl.curl_sockaddr) callconv(.C) curl.curl_socket_t { _ = client_ptr; _ = purpose; // log.debug("onOpenSocket", .{}); // This is what curl does by default. const sockfd = std.os.socket(@intCast(u32, addr.family), @intCast(u32, addr.socktype), @intCast(u32, addr.protocol)) catch { return curl.CURL_SOCKET_BAD; }; // Get or create a new SockHandle. const entry = sock_handles.getOrPut(sockfd) catch unreachable; if (!entry.found_existing) { entry.value_ptr.* = galloc.create(SockHandle) catch unreachable; entry.value_ptr.*.init(sockfd); } else { if (entry.value_ptr.*.sockfd_closed) { // Since the handle still exists and the sockfd is in a closed state, // it means the uv_close on the poll hasn't finished yet. Finish the closing with a uv_run. // Set skip_destroy_on_uv_close so the uv_close callback doesn't remove the handle. entry.value_ptr.*.skip_destroy_on_uv_close = true; _ = uv.uv_run(curlm_uvloop, uv.UV_RUN_NOWAIT); // Reinit a closed sockfd handle. entry.value_ptr.*.init(sockfd); } } // Mark as ready, any onSocket callback from now on is related to the request. entry.value_ptr.*.ready = true; const c_sockfd = if (builtin.os.tag == .windows) @ptrToInt(sockfd) else sockfd; return c_sockfd; } fn onCloseSocket(client_ptr: ?*anyopaque, sockfd: curl.curl_socket_t) callconv(.C) c_int { _ = client_ptr; // log.debug("onCloseSocket", .{}); // Close the sockfd. const cross_sockfd = if (builtin.os.tag == .windows) @intToPtr(std.os.socket_t, sockfd) else sockfd; std.os.closeSocket(cross_sockfd); const sock_h = sock_handles.get(cross_sockfd).?; sock_h.sockfd_closed = true; sock_h.checkToDeinit(); return 0; } fn onUvTimer(ptr: [*c]uv.uv_timer_t) callconv(.C) void { // log.debug("on uv timer", .{}); _ = ptr; // socketAction can spend a lot of time doing synchronous ssl handshake. lib/multi.c: protocol_connect -> ossl_connect_nonblocking // Curl can optimize by reusing connections and ssl sessions but if a new request handle was started too quickly it will be a // cache miss and continue doing a fresh connection. Setting CURLOPT_PIPEWAIT on each request handle addresses this issue. var running_handles: c_int = undefined; const res = curlm.socketAction(curl.CURL_SOCKET_TIMEOUT, 0, &running_handles); CurlM.assertNoError(res); checkDone(); } fn onCurlSetTimer(cm: *curl.CURLM, timeout_ms: c_long, user_ptr: *anyopaque) callconv(.C) c_int { // log.debug("set timer {}", .{timeout_ms}); _ = user_ptr; _ = cm; if (timeout_ms == -1) { const res = uv.uv_timer_stop(&timer); uv.assertNoError(res); } else { dispatcher.startTimer(&timer, @intCast(u32, timeout_ms), onUvTimer); } return 0; } const AsyncRequestHandle = struct { const Self = @This(); alloc: std.mem.Allocator, ch: Curl, attached_to_sockfd: bool, sock_fd: std.os.socket_t, status_code: u32, header_ctx: HeaderContext, buf: std.ArrayList(u8), // Closure of callback. // TODO: Don't own the callback context. cb_ctx: *anyopaque, cb_ctx_size: u32, success_cb: fn (ctx: *anyopaque, Response) void, failure_cb: fn (ctx: *anyopaque, err_code: u32) void, fn success(self: *Self) void { const resp = Response{ .status_code = self.status_code, .headers = self.header_ctx.headers_buf.toOwnedSlice(), .header = self.header_ctx.header_data_buf.toOwnedSlice(), .body = self.buf.toOwnedSlice(), }; self.success_cb(self.cb_ctx, resp); } fn fail(self: *Self, err_code: u32) void { self.failure_cb(self.cb_ctx, err_code); } fn deinit(self: Self) void { const res = curlm.removeHandle(self.ch); CurlM.assertNoError(res); self.ch.deinit(); self.alloc.free(@ptrCast([*]u8, self.cb_ctx)[0..self.cb_ctx_size]); self.header_ctx.headers_buf.deinit(); self.header_ctx.header_data_buf.deinit(); self.buf.deinit(); } fn destroy(self: *Self) void { self.deinit(); self.alloc.destroy(self); } }; fn onUvPolled(ptr: [*c]uv.uv_poll_t, status: c_int, events: c_int) callconv(.C) void { // log.debug("uv polled {} {}", .{status, events}); if (status != 0) { // flags = CURL_CSELECT_ERR; log.debug("uv_poll_cb: {s}", .{uv.uv_strerror(status)}); unreachable; } var flags: c_int = 0; if (events & uv.UV_READABLE > 0) { flags |= curl.CURL_CSELECT_IN; } if (events & uv.UV_WRITABLE > 0) { flags |= curl.CURL_CSELECT_OUT; } if (flags == 0) { unreachable; } const sock_h = @ptrCast(*SockHandle, ptr); var running_handles: c_int = undefined; const c_sockfd = if (builtin.os.tag == .windows) @ptrToInt(sock_h.sockfd) else sock_h.sockfd; const res = curlm.socketAction(c_sockfd, flags, &running_handles); CurlM.assertNoError(res); checkDone(); } fn onUvClosePoll(ptr: [*c]uv.uv_handle_t) callconv(.C) void { // log.debug("uv close poll", .{}); const sock_h = @ptrCast(*SockHandle, ptr); if (!sock_h.skip_destroy_on_uv_close) { _ = sock_handles.remove(sock_h.sockfd); galloc.destroy(sock_h); } } fn onCurlPush(parent: *curl.CURL, h: *curl.CURL, num_headers: usize, headers: *curl.curl_pushheaders, userp: ?*anyopaque) callconv(.C) c_int { _ = parent; _ = h; _ = num_headers; _ = headers; _ = userp; return curl.CURL_PUSH_OK; } fn handleInternalSocket(sock_h: *SockHandle, action: c_int) void { // log.debug("internal curl socket {} {*}", .{action, sock_h}); _ = sock_h; // Nop for now. switch (action) { curl.CURL_POLL_IN => { }, curl.CURL_POLL_REMOVE => { }, else => unreachable, } } fn onSocket(_h: *curl.CURL, sock_fd: curl.curl_socket_t, action: c_int, user_ptr: *anyopaque, socket_ptr: ?*anyopaque) callconv(.C) c_int { // log.debug("curl socket {} {} {*}", .{sock_fd, action, socket_ptr}); _ = user_ptr; _ = socket_ptr; const cross_sockfd = if (builtin.os.tag == .windows) @intToPtr(std.os.socket_t, sock_fd) else sock_fd; const entry = sock_handles.getOrPut(cross_sockfd) catch unreachable; if (!entry.found_existing) { entry.value_ptr.* = galloc.create(SockHandle) catch unreachable; entry.value_ptr.*.init(cross_sockfd); } else { if (entry.value_ptr.*.sockfd_closed) { @panic("Did not expect to reuse closed sockfd"); } } const sock_h = entry.value_ptr.*; // Check if this callback is for an internal Curl io. const for_internal_use = !sock_h.ready; if (for_internal_use) { handleInternalSocket(sock_h, action); return 0; } const h = Curl{ .handle = _h }; var ptr: *anyopaque = undefined; var cres = h.getInfo(curl.CURLINFO_PRIVATE, &ptr); Curl.assertNoError(cres); const req = stdx.mem.ptrCastAlign(*AsyncRequestHandle, ptr); const S = struct { // Attaches a sock to a request only once. fn attachSock(sock_h_: *SockHandle, req_: *AsyncRequestHandle) void { if (!req_.attached_to_sockfd) { req_.sock_fd = sock_h_.sockfd; req_.attached_to_sockfd = true; sock_h_.num_active_reqs += 1; } } }; switch (action) { curl.CURL_POLL_IN => { S.attachSock(sock_h, req); if (!sock_h.polling_readable) { const res = uv.uv_poll_start(&sock_h.poll, uv.UV_READABLE, onUvPolled); uv.assertNoError(res); sock_h.polling_readable = true; } }, curl.CURL_POLL_OUT => { S.attachSock(sock_h, req); if (!sock_h.polling_writable) { const res = uv.uv_poll_start(&sock_h.poll, uv.UV_WRITABLE, onUvPolled); uv.assertNoError(res); sock_h.polling_writable = true; } }, curl.CURL_POLL_INOUT => { S.attachSock(sock_h, req); if (!sock_h.polling_readable or !sock_h.polling_writable) { const res = uv.uv_poll_start(&sock_h.poll, uv.UV_WRITABLE | uv.UV_READABLE, onUvPolled); uv.assertNoError(res); sock_h.polling_readable = true; sock_h.polling_writable = true; } }, curl.CURL_POLL_REMOVE => { // log.debug("request poll remove {}", .{sock_fd}); // This does not mean that curl wants to close the connection, // It could mean it wants to just reset the polling state. const res = uv.uv_poll_stop(&sock_h.poll); sock_h.polling_readable = false; sock_h.polling_writable = false; uv.assertNoError(res); }, else => unreachable, } return 0; } const HeaderContext = struct { headers_buf: std.ArrayList(Header), header_data_buf: std.ArrayList(u8), }; fn checkDone() void { var num_remaining_msgs: c_int = 1; while (num_remaining_msgs > 0) { var mb_msg = curlm.infoRead(&num_remaining_msgs); if (mb_msg) |info| { switch (info.msg) { curl.CURLMSG_DONE => { // [curl] WARNING: The data the returned pointer points to will not survive calling // curl_multi_cleanup, curl_multi_remove_handle or curl_easy_cleanup. const ch = Curl{ .handle = info.easy_handle.? }; var ptr: *anyopaque = undefined; _ = ch.getInfo(curl.CURLINFO_PRIVATE, &ptr); const req = stdx.mem.ptrCastAlign(*AsyncRequestHandle, ptr); // Get status code. var http_code: u64 = 0; _ = ch.getInfo(curl.CURLINFO_RESPONSE_CODE, &http_code); req.status_code = @intCast(u32, http_code); // The request might not have received an onSocket callback so it has no attachment to a sockfd. // eg. Can't connect to host. if (req.attached_to_sockfd) { const sock_h = sock_handles.get(req.sock_fd).?; sock_h.num_active_reqs -= 1; sock_h.checkToDeinit(); } // Once checkDone reports a request is done, // invoke the success/failure cb and destroy the request. if (info.data.result == curl.CURLE_OK) { req.success(); } else { req.fail(info.data.result); } req.destroy(); }, else => { unreachable; } } } } } pub fn requestAsync( alloc: std.mem.Allocator, url: []const u8, opts: RequestOptions, _ctx: anytype, success_cb: fn (*anyopaque, Response) void, failure_cb: fn (*anyopaque, err_code: u32) void, ) !void { const S = struct { fn writeBody(read_buf: [*]u8, item_size: usize, nitems: usize, user_data: *std.ArrayList(u8)) callconv(.C) usize { const write_buf = user_data; const read_size = item_size * nitems; write_buf.appendSlice(read_buf[0..read_size]) catch unreachable; return read_size; } fn writeHeader(read_buf: [*]u8, item_size: usize, nitems: usize, ctx: *HeaderContext) usize { const read_size = item_size * nitems; const header = read_buf[0..read_size]; const start = ctx.header_data_buf.items.len; ctx.header_data_buf.appendSlice(header) catch unreachable; if (std.mem.indexOfScalar(u8, header, ':')) |idx| { const val = std.mem.trim(u8, ctx.header_data_buf.items[start+idx+1..], " \r\n"); const val_start = @ptrToInt(val.ptr) - @ptrToInt(ctx.header_data_buf.items.ptr); ctx.headers_buf.append(.{ .key = .{ .start = start, .end = start + idx }, .value = .{ .start = val_start, .end = val_start + val.len }, }) catch unreachable; } return read_size; } }; var c_url = std.cstr.addNullByte(alloc, url) catch unreachable; defer alloc.free(c_url); // Currently we create a new CURL handle per request. const ch = Curl.init(); var header_list: ?*curl.curl_slist = null; defer curl.curl_slist_free_all(header_list); try setCurlOptions(alloc, ch, c_url, &header_list, opts); ch.mustSetOption(curl.CURLOPT_WRITEFUNCTION, S.writeBody); ch.mustSetOption(curl.CURLOPT_HEADERFUNCTION, S.writeHeader); const ctx = alloc.create(@TypeOf(_ctx)) catch unreachable; ctx.* = _ctx; var req = alloc.create(AsyncRequestHandle) catch unreachable; req.* = .{ .alloc = alloc, .ch = ch, .attached_to_sockfd = false, .sock_fd = undefined, .cb_ctx = ctx, .cb_ctx_size = @sizeOf(@TypeOf(_ctx)), .success_cb = success_cb, .failure_cb = failure_cb, .status_code = undefined, .header_ctx = .{ .headers_buf = std.ArrayList(Header).initCapacity(alloc, 10) catch unreachable, .header_data_buf = std.ArrayList(u8).initCapacity(alloc, 5e2) catch unreachable, }, .buf = std.ArrayList(u8).initCapacity(alloc, 4e3) catch unreachable, }; ch.mustSetOption(curl.CURLOPT_PRIVATE, req); ch.mustSetOption(curl.CURLOPT_WRITEDATA, &req.buf); ch.mustSetOption(curl.CURLOPT_HEADERDATA, &req.header_ctx); ch.mustSetOption(curl.CURLOPT_OPENSOCKETFUNCTION, onOpenSocket); ch.mustSetOption(curl.CURLOPT_OPENSOCKETDATA, req); ch.mustSetOption(curl.CURLOPT_CLOSESOCKETFUNCTION, onCloseSocket); // If two requests start concurrently, prefer waiting for one to finish connecting to reuse the same connection. For HTTP2. ch.mustSetOption(curl.CURLOPT_PIPEWAIT, @intCast(c_long, 1)); // ch.mustSetOption(curl.CURLOPT_SHARE, &share); // ch.mustsetOption(curl.CURLOPT_NOSIGNAL, @intCast(c_long, 1)); // Loads the timer on demand. // Only one timer is needed for all requests. if (!timer_inited) { var res = uv.uv_timer_init(curlm_uvloop, &timer); uv.assertNoError(res); timer_inited = true; } // Add handle starts the request and triggers onCurlSetTimer synchronously. // Subsequent socketAction calls also synchronously call onCurlSetTimer and onSocket, however if two sockets are ready // onSocket will be called twice so the only way to attach a ctx is through the CURL handle's private opt. const res = curlm.addHandle(req.ch); if (res != curl.CURLM_OK) { return error.RequestFailed; } // log.debug("added request handle", .{}); // For debugging with no uv poller thread: // _ = uv.uv_run(curlm_uvloop, uv.UV_RUN_DEFAULT); var http_code: u64 = 0; _ = ch.getInfo(curl.CURLINFO_RESPONSE_CODE, &http_code); } pub fn request(alloc: std.mem.Allocator, url: []const u8, opts: RequestOptions) !Response { const S = struct { fn writeBody(read_buf: [*]u8, item_size: usize, nitems: usize, user_data: *std.ArrayList(u8)) callconv(.C) usize { const write_buf = user_data; const read_size = item_size * nitems; write_buf.appendSlice(read_buf[0..read_size]) catch unreachable; return read_size; } fn writeHeader(read_buf: [*]u8, item_size: usize, nitems: usize, ctx: *HeaderContext) usize { const read_size = item_size * nitems; const header = read_buf[0..read_size]; const start = ctx.header_data_buf.items.len; ctx.header_data_buf.appendSlice(header) catch unreachable; if (std.mem.indexOfScalar(u8, header, ':')) |idx| { const val = std.mem.trim(u8, ctx.header_data_buf.items[start+idx+1..], " \r\n"); const val_start = @ptrToInt(val.ptr) - @ptrToInt(ctx.header_data_buf.items.ptr); ctx.headers_buf.append(.{ .key = .{ .start = start, .end = start + idx }, .value = .{ .start = val_start, .end = val_start + val.len }, }) catch unreachable; } return read_size; } }; var header_ctx = HeaderContext{ .headers_buf = std.ArrayList(Header).initCapacity(alloc, 10) catch unreachable, .header_data_buf = std.ArrayList(u8).initCapacity(alloc, 5e2) catch unreachable, }; defer { header_ctx.headers_buf.deinit(); header_ctx.header_data_buf.deinit(); } var buf = std.ArrayList(u8).initCapacity(alloc, 4e3) catch unreachable; defer buf.deinit(); var c_url = std.cstr.addNullByte(alloc, url) catch unreachable; defer alloc.free(c_url); var header_list: ?*curl.curl_slist = null; defer curl.curl_slist_free_all(header_list); try setCurlOptions(alloc, curl_h, c_url, &header_list, opts); curl_h.mustSetOption(curl.CURLOPT_WRITEFUNCTION, S.writeBody); curl_h.mustSetOption(curl.CURLOPT_WRITEDATA, &buf); curl_h.mustSetOption(curl.CURLOPT_HEADERFUNCTION, S.writeHeader); curl_h.mustSetOption(curl.CURLOPT_HEADERDATA, &header_ctx); const res = curl_h.perform(); if (res != curl.CURLE_OK) { // log.debug("Request failed: {s}", .{Curl.getStrError(res)}); return error.RequestFailed; } var http_code: u64 = 0; _ = curl_h.getInfo(curl.CURLINFO_RESPONSE_CODE, &http_code); return Response{ .status_code = @intCast(u32, http_code), .headers = header_ctx.headers_buf.toOwnedSlice(), .header = header_ctx.header_data_buf.toOwnedSlice(), .body = buf.toOwnedSlice(), }; } fn setCurlOptions(alloc: std.mem.Allocator, ch: Curl, url: [:0]const u8, header_list: *?*curl.curl_slist, opts: RequestOptions) !void { if (CurlVerbose) { ch.mustSetOption(curl.CURLOPT_VERBOSE, @intCast(c_int, 1)); } ch.mustSetOption(curl.CURLOPT_URL, url.ptr); ch.mustSetOption(curl.CURLOPT_SSL_VERIFYPEER, @intCast(c_long, 1)); ch.mustSetOption(curl.CURLOPT_SSL_VERIFYHOST, @intCast(c_long, 1)); if (opts.cert_file) |cert_file| { const c_str = try std.fmt.allocPrint(alloc, "{s}\u{0}", .{ cert_file }); defer alloc.free(c_str); ch.mustSetOption(curl.CURLOPT_CAINFO, c_str.ptr); } else { switch (builtin.os.tag) { .linux => { ch.mustSetOption(curl.CURLOPT_CAINFO, "/etc/ssl/certs/ca-certificates.crt"); }, .macos => { ch.mustSetOption(curl.CURLOPT_CAINFO, "/etc/ssl/cert.pem"); }, .windows => { const mask: c_long = curl.CURLSSLOPT_NATIVE_CA; ch.mustSetOption(curl.CURLOPT_SSL_OPTIONS, mask); }, else => {}, } } switch (builtin.os.tag) { .linux, .macos => { ch.mustSetOption(curl.CURLOPT_CAPATH, "/etc/ssl/certs"); }, else => {}, } // TODO: Expose timeout as ms and use CURLOPT_TIMEOUT_MS ch.mustSetOption(curl.CURLOPT_TIMEOUT, @intCast(c_long, opts.timeout)); ch.mustSetOption(curl.CURLOPT_ACCEPT_ENCODING, "gzip, deflate, br"); if (opts.keep_connection) { ch.mustSetOption(curl.CURLOPT_FORBID_REUSE, @intCast(c_long, 0)); } else { ch.mustSetOption(curl.CURLOPT_FORBID_REUSE, @intCast(c_long, 1)); } // HTTP2 is far more efficient since curl deprecated HTTP1 pipelining. (Must have built curl with nghttp2) ch.mustSetOption(curl.CURLOPT_HTTP_VERSION, curl.CURL_HTTP_VERSION_2_0); switch (opts.method) { .Get => ch.mustSetOption(curl.CURLOPT_CUSTOMREQUEST, "GET"), .Post => ch.mustSetOption(curl.CURLOPT_CUSTOMREQUEST, "POST"), else => return error.UnsupportedMethod, } if (opts.content_type) |content_type| { switch (content_type) { .Json => header_list.* = curl.curl_slist_append(header_list.*, "content-type: application/json"), .FormData => header_list.* = curl.curl_slist_append(header_list.*, "content-type: application/x-www-form-urlencoded"), } } // Custom headers. if (opts.headers) |headers| { var iter = headers.iterator(); while (iter.next()) |entry| { const c_str = try std.fmt.allocPrint(alloc, "{s}: {s}\u{0}", .{ entry.key_ptr.*, entry.value_ptr.* }); defer alloc.free(c_str); header_list.* = curl.curl_slist_append(header_list.*, c_str.ptr); } } ch.mustSetOption(curl.CURLOPT_HTTPHEADER, header_list.*); if (opts.body) |body| { ch.mustSetOption(curl.CURLOPT_POSTFIELDSIZE, @intCast(c_long, body.len)); ch.mustSetOption(curl.CURLOPT_POSTFIELDS, body.ptr); } }
stdx/http.zig
pub const ArrayHashMap = array_hash_map.ArrayHashMap; pub const ArrayHashMapUnmanaged = array_hash_map.ArrayHashMapUnmanaged; pub const ArrayList = @import("array_list.zig").ArrayList; pub const ArrayListAligned = @import("array_list.zig").ArrayListAligned; pub const ArrayListAlignedUnmanaged = @import("array_list.zig").ArrayListAlignedUnmanaged; pub const ArrayListSentineled = @import("array_list_sentineled.zig").ArrayListSentineled; pub const ArrayListUnmanaged = @import("array_list.zig").ArrayListUnmanaged; pub const AutoArrayHashMap = array_hash_map.AutoArrayHashMap; pub const AutoArrayHashMapUnmanaged = array_hash_map.AutoArrayHashMapUnmanaged; pub const AutoHashMap = hash_map.AutoHashMap; pub const AutoHashMapUnmanaged = hash_map.AutoHashMapUnmanaged; pub const AutoResetEvent = @import("auto_reset_event.zig").AutoResetEvent; pub const BufMap = @import("buf_map.zig").BufMap; pub const BufSet = @import("buf_set.zig").BufSet; pub const ChildProcess = @import("child_process.zig").ChildProcess; pub const ComptimeStringMap = @import("comptime_string_map.zig").ComptimeStringMap; pub const DynLib = @import("dynamic_library.zig").DynLib; pub const HashMap = hash_map.HashMap; pub const HashMapUnmanaged = hash_map.HashMapUnmanaged; pub const mutex = @import("mutex.zig"); pub const Mutex = mutex.Mutex; pub const PackedIntArray = @import("packed_int_array.zig").PackedIntArray; pub const PackedIntArrayEndian = @import("packed_int_array.zig").PackedIntArrayEndian; pub const PackedIntSlice = @import("packed_int_array.zig").PackedIntSlice; pub const PackedIntSliceEndian = @import("packed_int_array.zig").PackedIntSliceEndian; pub const PriorityQueue = @import("priority_queue.zig").PriorityQueue; pub const Progress = @import("Progress.zig"); pub const ResetEvent = @import("reset_event.zig").ResetEvent; pub const SemanticVersion = @import("SemanticVersion.zig"); pub const SinglyLinkedList = @import("linked_list.zig").SinglyLinkedList; pub const SpinLock = @import("spinlock.zig").SpinLock; pub const StringHashMap = hash_map.StringHashMap; pub const StringHashMapUnmanaged = hash_map.StringHashMapUnmanaged; pub const StringArrayHashMap = array_hash_map.StringArrayHashMap; pub const StringArrayHashMapUnmanaged = array_hash_map.StringArrayHashMapUnmanaged; pub const TailQueue = @import("linked_list.zig").TailQueue; pub const Target = @import("target.zig").Target; pub const Thread = @import("thread.zig").Thread; pub const array_hash_map = @import("array_hash_map.zig"); pub const atomic = @import("atomic.zig"); pub const base64 = @import("base64.zig"); pub const build = @import("build.zig"); pub const builtin = @import("builtin.zig"); pub const c = @import("c.zig"); pub const coff = @import("coff.zig"); pub const compress = @import("compress.zig"); pub const crypto = @import("crypto.zig"); pub const cstr = @import("cstr.zig"); pub const debug = @import("debug.zig"); pub const dwarf = @import("dwarf.zig"); pub const elf = @import("elf.zig"); pub const event = @import("event.zig"); pub const fifo = @import("fifo.zig"); pub const fmt = @import("fmt.zig"); pub const fs = @import("fs.zig"); pub const hash = @import("hash.zig"); pub const hash_map = @import("hash_map.zig"); pub const heap = @import("heap.zig"); pub const io = @import("io.zig"); pub const json = @import("json.zig"); pub const leb = @import("leb128.zig"); pub const log = @import("log.zig"); pub const macho = @import("macho.zig"); pub const math = @import("math.zig"); pub const mem = @import("mem.zig"); pub const meta = @import("meta.zig"); pub const net = @import("net.zig"); pub const os = @import("os.zig"); pub const once = @import("once.zig").once; pub const packed_int_array = @import("packed_int_array.zig"); pub const pdb = @import("pdb.zig"); pub const process = @import("process.zig"); pub const rand = @import("rand.zig"); pub const sort = @import("sort.zig"); pub const ascii = @import("ascii.zig"); pub const testing = @import("testing.zig"); pub const time = @import("time.zig"); pub const unicode = @import("unicode.zig"); pub const valgrind = @import("valgrind.zig"); pub const zig = @import("zig.zig"); pub const start = @import("start.zig"); // This forces the start.zig file to be imported, and the comptime logic inside that // file decides whether to export any appropriate start symbols. comptime { _ = start; } test "" { testing.refAllDecls(@This()); }
lib/std/std.zig
const std = @import("std"); const llvm = @import("llvm.zig"); pub const ArchOsAbi = struct { arch: std.Target.Cpu.Arch, os: std.Target.Os.Tag, abi: std.Target.Abi, }; pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .aarch64_be, .os = .linux, .abi = .gnu }, .{ .arch = .aarch64_be, .os = .linux, .abi = .musl }, .{ .arch = .aarch64_be, .os = .windows, .abi = .gnu }, .{ .arch = .aarch64, .os = .linux, .abi = .gnu }, .{ .arch = .aarch64, .os = .linux, .abi = .musl }, .{ .arch = .aarch64, .os = .windows, .abi = .gnu }, .{ .arch = .armeb, .os = .linux, .abi = .gnueabi }, .{ .arch = .armeb, .os = .linux, .abi = .gnueabihf }, .{ .arch = .armeb, .os = .linux, .abi = .musleabi }, .{ .arch = .armeb, .os = .linux, .abi = .musleabihf }, .{ .arch = .armeb, .os = .windows, .abi = .gnu }, .{ .arch = .arm, .os = .linux, .abi = .gnueabi }, .{ .arch = .arm, .os = .linux, .abi = .gnueabihf }, .{ .arch = .arm, .os = .linux, .abi = .musleabi }, .{ .arch = .arm, .os = .linux, .abi = .musleabihf }, .{ .arch = .arm, .os = .windows, .abi = .gnu }, .{ .arch = .i386, .os = .linux, .abi = .gnu }, .{ .arch = .i386, .os = .linux, .abi = .musl }, .{ .arch = .i386, .os = .windows, .abi = .gnu }, .{ .arch = .mips64el, .os = .linux, .abi = .gnuabi64 }, .{ .arch = .mips64el, .os = .linux, .abi = .gnuabin32 }, .{ .arch = .mips64el, .os = .linux, .abi = .musl }, .{ .arch = .mips64, .os = .linux, .abi = .gnuabi64 }, .{ .arch = .mips64, .os = .linux, .abi = .gnuabin32 }, .{ .arch = .mips64, .os = .linux, .abi = .musl }, .{ .arch = .mipsel, .os = .linux, .abi = .gnu }, .{ .arch = .mipsel, .os = .linux, .abi = .musl }, .{ .arch = .mips, .os = .linux, .abi = .gnu }, .{ .arch = .mips, .os = .linux, .abi = .musl }, .{ .arch = .powerpc64le, .os = .linux, .abi = .gnu }, .{ .arch = .powerpc64le, .os = .linux, .abi = .musl }, .{ .arch = .powerpc64, .os = .linux, .abi = .gnu }, .{ .arch = .powerpc64, .os = .linux, .abi = .musl }, .{ .arch = .powerpc, .os = .linux, .abi = .gnu }, .{ .arch = .powerpc, .os = .linux, .abi = .musl }, .{ .arch = .riscv64, .os = .linux, .abi = .gnu }, .{ .arch = .riscv64, .os = .linux, .abi = .musl }, .{ .arch = .s390x, .os = .linux, .abi = .gnu }, .{ .arch = .s390x, .os = .linux, .abi = .musl }, .{ .arch = .sparc, .os = .linux, .abi = .gnu }, .{ .arch = .sparcv9, .os = .linux, .abi = .gnu }, .{ .arch = .wasm32, .os = .freestanding, .abi = .musl }, .{ .arch = .x86_64, .os = .linux, .abi = .gnu }, .{ .arch = .x86_64, .os = .linux, .abi = .gnux32 }, .{ .arch = .x86_64, .os = .linux, .abi = .musl }, .{ .arch = .x86_64, .os = .windows, .abi = .gnu }, .{ .arch = .x86_64, .os = .macos, .abi = .gnu }, }; pub fn libCGenericName(target: std.Target) [:0]const u8 { switch (target.os.tag) { .windows => return "mingw", .macos, .ios, .tvos, .watchos => return "darwin", else => {}, } switch (target.abi) { .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32, => return "glibc", .musl, .musleabi, .musleabihf, .none, => return "musl", .code16, .eabi, .eabihf, .android, .msvc, .itanium, .cygnus, .coreclr, .simulator, .macabi, => unreachable, } } pub fn archMuslName(arch: std.Target.Cpu.Arch) [:0]const u8 { switch (arch) { .aarch64, .aarch64_be => return "aarch64", .arm, .armeb => return "arm", .mips, .mipsel => return "mips", .mips64el, .mips64 => return "mips64", .powerpc => return "powerpc", .powerpc64, .powerpc64le => return "powerpc64", .s390x => return "s390x", .i386 => return "i386", .x86_64 => return "x86_64", .riscv64 => return "riscv64", .wasm32, .wasm64 => return "wasm", else => unreachable, } } pub fn canBuildLibC(target: std.Target) bool { for (available_libcs) |libc| { if (target.cpu.arch == libc.arch and target.os.tag == libc.os and target.abi == libc.abi) { return true; } } return false; } pub fn cannotDynamicLink(target: std.Target) bool { return switch (target.os.tag) { .freestanding, .other => true, else => false, }; } /// On Darwin, we always link libSystem which contains libc. /// Similarly on FreeBSD and NetBSD we always link system libc /// since this is the stable syscall interface. pub fn osRequiresLibC(target: std.Target) bool { return switch (target.os.tag) { .freebsd, .netbsd, .dragonfly, .openbsd, .macos, .ios, .watchos, .tvos => true, else => false, }; } pub fn libcNeedsLibUnwind(target: std.Target) bool { return switch (target.os.tag) { .macos, .ios, .watchos, .tvos, .freestanding, => false, .windows => target.abi != .msvc, else => true, }; } pub fn requiresPIE(target: std.Target) bool { return target.isAndroid() or target.isDarwin() or target.os.tag == .openbsd; } /// This function returns whether non-pic code is completely invalid on the given target. pub fn requiresPIC(target: std.Target, linking_libc: bool) bool { return target.isAndroid() or target.os.tag == .windows or target.os.tag == .uefi or osRequiresLibC(target) or (linking_libc and target.isGnuLibC()); } /// This is not whether the target supports Position Independent Code, but whether the -fPIC /// C compiler argument is valid to Clang. pub fn supports_fpic(target: std.Target) bool { return target.os.tag != .windows; } pub fn libc_needs_crti_crtn(target: std.Target) bool { return !(target.cpu.arch.isRISCV() or target.isAndroid() or target.os.tag == .openbsd); } pub fn isSingleThreaded(target: std.Target) bool { return target.isWasm(); } /// Valgrind supports more, but Zig does not support them yet. pub fn hasValgrindSupport(target: std.Target) bool { switch (target.cpu.arch) { .x86_64 => { return target.os.tag == .linux or target.isDarwin() or target.os.tag == .solaris or (target.os.tag == .windows and target.abi != .msvc); }, else => return false, } } pub fn supportsStackProbing(target: std.Target) bool { return target.os.tag != .windows and target.os.tag != .uefi and (target.cpu.arch == .i386 or target.cpu.arch == .x86_64); } pub fn osToLLVM(os_tag: std.Target.Os.Tag) llvm.OSType { return switch (os_tag) { .freestanding, .other => .UnknownOS, .windows, .uefi => .Win32, .ananas => .Ananas, .cloudabi => .CloudABI, .dragonfly => .DragonFly, .freebsd => .FreeBSD, .fuchsia => .Fuchsia, .ios => .IOS, .kfreebsd => .KFreeBSD, .linux => .Linux, .lv2 => .Lv2, .macos => .MacOSX, .netbsd => .NetBSD, .openbsd => .OpenBSD, .solaris => .Solaris, .haiku => .Haiku, .minix => .Minix, .rtems => .RTEMS, .nacl => .NaCl, .cnk => .CNK, .aix => .AIX, .cuda => .CUDA, .nvcl => .NVCL, .amdhsa => .AMDHSA, .ps4 => .PS4, .elfiamcu => .ELFIAMCU, .tvos => .TvOS, .watchos => .WatchOS, .mesa3d => .Mesa3D, .contiki => .Contiki, .amdpal => .AMDPAL, .hermit => .HermitCore, .hurd => .Hurd, .wasi => .WASI, .emscripten => .Emscripten, }; } pub fn archToLLVM(arch_tag: std.Target.Cpu.Arch) llvm.ArchType { return switch (arch_tag) { .arm => .arm, .armeb => .armeb, .aarch64 => .aarch64, .aarch64_be => .aarch64_be, .aarch64_32 => .aarch64_32, .arc => .arc, .avr => .avr, .bpfel => .bpfel, .bpfeb => .bpfeb, .hexagon => .hexagon, .mips => .mips, .mipsel => .mipsel, .mips64 => .mips64, .mips64el => .mips64el, .msp430 => .msp430, .powerpc => .ppc, .powerpc64 => .ppc64, .powerpc64le => .ppc64le, .r600 => .r600, .amdgcn => .amdgcn, .riscv32 => .riscv32, .riscv64 => .riscv64, .sparc => .sparc, .sparcv9 => .sparcv9, .sparcel => .sparcel, .s390x => .systemz, .tce => .tce, .tcele => .tcele, .thumb => .thumb, .thumbeb => .thumbeb, .i386 => .x86, .x86_64 => .x86_64, .xcore => .xcore, .nvptx => .nvptx, .nvptx64 => .nvptx64, .le32 => .le32, .le64 => .le64, .amdil => .amdil, .amdil64 => .amdil64, .hsail => .hsail, .hsail64 => .hsail64, .spir => .spir, .spir64 => .spir64, .kalimba => .kalimba, .shave => .shave, .lanai => .lanai, .wasm32 => .wasm32, .wasm64 => .wasm64, .renderscript32 => .renderscript32, .renderscript64 => .renderscript64, .ve => .ve, .spu_2 => .UnknownArch, }; } fn eqlIgnoreCase(ignore_case: bool, a: []const u8, b: []const u8) bool { if (ignore_case) { return std.ascii.eqlIgnoreCase(a, b); } else { return std.mem.eql(u8, a, b); } } pub fn is_libc_lib_name(target: std.Target, name: []const u8) bool { const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; if (eqlIgnoreCase(ignore_case, name, "c")) return true; if (target.isMinGW()) { if (eqlIgnoreCase(ignore_case, name, "m")) return true; return false; } if (target.abi.isGnu() or target.abi.isMusl() or target.os.tag.isDarwin()) { if (eqlIgnoreCase(ignore_case, name, "m")) return true; if (eqlIgnoreCase(ignore_case, name, "rt")) return true; if (eqlIgnoreCase(ignore_case, name, "pthread")) return true; if (eqlIgnoreCase(ignore_case, name, "crypt")) return true; if (eqlIgnoreCase(ignore_case, name, "util")) return true; if (eqlIgnoreCase(ignore_case, name, "xnet")) return true; if (eqlIgnoreCase(ignore_case, name, "resolv")) return true; if (eqlIgnoreCase(ignore_case, name, "dl")) return true; if (eqlIgnoreCase(ignore_case, name, "util")) return true; } if (target.os.tag.isDarwin() and eqlIgnoreCase(ignore_case, name, "System")) return true; return false; } pub fn is_libcpp_lib_name(target: std.Target, name: []const u8) bool { const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; return eqlIgnoreCase(ignore_case, name, "c++") or eqlIgnoreCase(ignore_case, name, "stdc++") or eqlIgnoreCase(ignore_case, name, "c++abi"); } pub fn hasDebugInfo(target: std.Target) bool { return !target.cpu.arch.isWasm(); }
src/target.zig
pub const TAG_padding = 0x00; pub const TAG_array_type = 0x01; pub const TAG_class_type = 0x02; pub const TAG_entry_point = 0x03; pub const TAG_enumeration_type = 0x04; pub const TAG_formal_parameter = 0x05; pub const TAG_imported_declaration = 0x08; pub const TAG_label = 0x0a; pub const TAG_lexical_block = 0x0b; pub const TAG_member = 0x0d; pub const TAG_pointer_type = 0x0f; pub const TAG_reference_type = 0x10; pub const TAG_compile_unit = 0x11; pub const TAG_string_type = 0x12; pub const TAG_structure_type = 0x13; pub const TAG_subroutine_type = 0x15; pub const TAG_typedef = 0x16; pub const TAG_union_type = 0x17; pub const TAG_unspecified_parameters = 0x18; pub const TAG_variant = 0x19; pub const TAG_common_block = 0x1a; pub const TAG_common_inclusion = 0x1b; pub const TAG_inheritance = 0x1c; pub const TAG_inlined_subroutine = 0x1d; pub const TAG_module = 0x1e; pub const TAG_ptr_to_member_type = 0x1f; pub const TAG_set_type = 0x20; pub const TAG_subrange_type = 0x21; pub const TAG_with_stmt = 0x22; pub const TAG_access_declaration = 0x23; pub const TAG_base_type = 0x24; pub const TAG_catch_block = 0x25; pub const TAG_const_type = 0x26; pub const TAG_constant = 0x27; pub const TAG_enumerator = 0x28; pub const TAG_file_type = 0x29; pub const TAG_friend = 0x2a; pub const TAG_namelist = 0x2b; pub const TAG_namelist_item = 0x2c; pub const TAG_packed_type = 0x2d; pub const TAG_subprogram = 0x2e; pub const TAG_template_type_param = 0x2f; pub const TAG_template_value_param = 0x30; pub const TAG_thrown_type = 0x31; pub const TAG_try_block = 0x32; pub const TAG_variant_part = 0x33; pub const TAG_variable = 0x34; pub const TAG_volatile_type = 0x35; // DWARF 3 pub const TAG_dwarf_procedure = 0x36; pub const TAG_restrict_type = 0x37; pub const TAG_interface_type = 0x38; pub const TAG_namespace = 0x39; pub const TAG_imported_module = 0x3a; pub const TAG_unspecified_type = 0x3b; pub const TAG_partial_unit = 0x3c; pub const TAG_imported_unit = 0x3d; pub const TAG_condition = 0x3f; pub const TAG_shared_type = 0x40; // DWARF 4 pub const TAG_type_unit = 0x41; pub const TAG_rvalue_reference_type = 0x42; pub const TAG_template_alias = 0x43; pub const TAG_lo_user = 0x4080; pub const TAG_hi_user = 0xffff; // SGI/MIPS Extensions. pub const DW_TAG_MIPS_loop = 0x4081; // HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz . pub const TAG_HP_array_descriptor = 0x4090; pub const TAG_HP_Bliss_field = 0x4091; pub const TAG_HP_Bliss_field_set = 0x4092; // GNU extensions. pub const TAG_format_label = 0x4101; // For FORTRAN 77 and Fortran 90. pub const TAG_function_template = 0x4102; // For C++. pub const TAG_class_template = 0x4103; //For C++. pub const TAG_GNU_BINCL = 0x4104; pub const TAG_GNU_EINCL = 0x4105; // Template template parameter. // See http://gcc.gnu.org/wiki/TemplateParmsDwarf . pub const TAG_GNU_template_template_param = 0x4106; // Template parameter pack extension = specified at // http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates // The values of these two TAGS are in the DW_TAG_GNU_* space until the tags // are properly part of DWARF 5. pub const TAG_GNU_template_parameter_pack = 0x4107; pub const TAG_GNU_formal_parameter_pack = 0x4108; // The GNU call site extension = specified at // http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open . // The values of these two TAGS are in the DW_TAG_GNU_* space until the tags // are properly part of DWARF 5. pub const TAG_GNU_call_site = 0x4109; pub const TAG_GNU_call_site_parameter = 0x410a; // Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf. pub const TAG_upc_shared_type = 0x8765; pub const TAG_upc_strict_type = 0x8766; pub const TAG_upc_relaxed_type = 0x8767; // PGI (STMicroelectronics; extensions. No documentation available. pub const TAG_PGI_kanji_type = 0xA000; pub const TAG_PGI_interface_block = 0xA020; pub const FORM_addr = 0x01; pub const FORM_block2 = 0x03; pub const FORM_block4 = 0x04; pub const FORM_data2 = 0x05; pub const FORM_data4 = 0x06; pub const FORM_data8 = 0x07; pub const FORM_string = 0x08; pub const FORM_block = 0x09; pub const FORM_block1 = 0x0a; pub const FORM_data1 = 0x0b; pub const FORM_flag = 0x0c; pub const FORM_sdata = 0x0d; pub const FORM_strp = 0x0e; pub const FORM_udata = 0x0f; pub const FORM_ref_addr = 0x10; pub const FORM_ref1 = 0x11; pub const FORM_ref2 = 0x12; pub const FORM_ref4 = 0x13; pub const FORM_ref8 = 0x14; pub const FORM_ref_udata = 0x15; pub const FORM_indirect = 0x16; pub const FORM_sec_offset = 0x17; pub const FORM_exprloc = 0x18; pub const FORM_flag_present = 0x19; pub const FORM_ref_sig8 = 0x20; // Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission. pub const FORM_GNU_addr_index = 0x1f01; pub const FORM_GNU_str_index = 0x1f02; // Extensions for DWZ multifile. // See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open . pub const FORM_GNU_ref_alt = 0x1f20; pub const FORM_GNU_strp_alt = 0x1f21; pub const AT_sibling = 0x01; pub const AT_location = 0x02; pub const AT_name = 0x03; pub const AT_ordering = 0x09; pub const AT_subscr_data = 0x0a; pub const AT_byte_size = 0x0b; pub const AT_bit_offset = 0x0c; pub const AT_bit_size = 0x0d; pub const AT_element_list = 0x0f; pub const AT_stmt_list = 0x10; pub const AT_low_pc = 0x11; pub const AT_high_pc = 0x12; pub const AT_language = 0x13; pub const AT_member = 0x14; pub const AT_discr = 0x15; pub const AT_discr_value = 0x16; pub const AT_visibility = 0x17; pub const AT_import = 0x18; pub const AT_string_length = 0x19; pub const AT_common_reference = 0x1a; pub const AT_comp_dir = 0x1b; pub const AT_const_value = 0x1c; pub const AT_containing_type = 0x1d; pub const AT_default_value = 0x1e; pub const AT_inline = 0x20; pub const AT_is_optional = 0x21; pub const AT_lower_bound = 0x22; pub const AT_producer = 0x25; pub const AT_prototyped = 0x27; pub const AT_return_addr = 0x2a; pub const AT_start_scope = 0x2c; pub const AT_bit_stride = 0x2e; pub const AT_upper_bound = 0x2f; pub const AT_abstract_origin = 0x31; pub const AT_accessibility = 0x32; pub const AT_address_class = 0x33; pub const AT_artificial = 0x34; pub const AT_base_types = 0x35; pub const AT_calling_convention = 0x36; pub const AT_count = 0x37; pub const AT_data_member_location = 0x38; pub const AT_decl_column = 0x39; pub const AT_decl_file = 0x3a; pub const AT_decl_line = 0x3b; pub const AT_declaration = 0x3c; pub const AT_discr_list = 0x3d; pub const AT_encoding = 0x3e; pub const AT_external = 0x3f; pub const AT_frame_base = 0x40; pub const AT_friend = 0x41; pub const AT_identifier_case = 0x42; pub const AT_macro_info = 0x43; pub const AT_namelist_items = 0x44; pub const AT_priority = 0x45; pub const AT_segment = 0x46; pub const AT_specification = 0x47; pub const AT_static_link = 0x48; pub const AT_type = 0x49; pub const AT_use_location = 0x4a; pub const AT_variable_parameter = 0x4b; pub const AT_virtuality = 0x4c; pub const AT_vtable_elem_location = 0x4d; // DWARF 3 values. pub const AT_allocated = 0x4e; pub const AT_associated = 0x4f; pub const AT_data_location = 0x50; pub const AT_byte_stride = 0x51; pub const AT_entry_pc = 0x52; pub const AT_use_UTF8 = 0x53; pub const AT_extension = 0x54; pub const AT_ranges = 0x55; pub const AT_trampoline = 0x56; pub const AT_call_column = 0x57; pub const AT_call_file = 0x58; pub const AT_call_line = 0x59; pub const AT_description = 0x5a; pub const AT_binary_scale = 0x5b; pub const AT_decimal_scale = 0x5c; pub const AT_small = 0x5d; pub const AT_decimal_sign = 0x5e; pub const AT_digit_count = 0x5f; pub const AT_picture_string = 0x60; pub const AT_mutable = 0x61; pub const AT_threads_scaled = 0x62; pub const AT_explicit = 0x63; pub const AT_object_pointer = 0x64; pub const AT_endianity = 0x65; pub const AT_elemental = 0x66; pub const AT_pure = 0x67; pub const AT_recursive = 0x68; // DWARF 4. pub const AT_signature = 0x69; pub const AT_main_subprogram = 0x6a; pub const AT_data_bit_offset = 0x6b; pub const AT_const_expr = 0x6c; pub const AT_enum_class = 0x6d; pub const AT_linkage_name = 0x6e; pub const AT_lo_user = 0x2000; // Implementation-defined range start. pub const AT_hi_user = 0x3fff; // Implementation-defined range end. // SGI/MIPS extensions. pub const AT_MIPS_fde = 0x2001; pub const AT_MIPS_loop_begin = 0x2002; pub const AT_MIPS_tail_loop_begin = 0x2003; pub const AT_MIPS_epilog_begin = 0x2004; pub const AT_MIPS_loop_unroll_factor = 0x2005; pub const AT_MIPS_software_pipeline_depth = 0x2006; pub const AT_MIPS_linkage_name = 0x2007; pub const AT_MIPS_stride = 0x2008; pub const AT_MIPS_abstract_name = 0x2009; pub const AT_MIPS_clone_origin = 0x200a; pub const AT_MIPS_has_inlines = 0x200b; // HP extensions. pub const AT_HP_block_index = 0x2000; pub const AT_HP_unmodifiable = 0x2001; // Same as DW_AT_MIPS_fde. pub const AT_HP_prologue = 0x2005; // Same as DW_AT_MIPS_loop_unroll. pub const AT_HP_epilogue = 0x2008; // Same as DW_AT_MIPS_stride. pub const AT_HP_actuals_stmt_list = 0x2010; pub const AT_HP_proc_per_section = 0x2011; pub const AT_HP_raw_data_ptr = 0x2012; pub const AT_HP_pass_by_reference = 0x2013; pub const AT_HP_opt_level = 0x2014; pub const AT_HP_prof_version_id = 0x2015; pub const AT_HP_opt_flags = 0x2016; pub const AT_HP_cold_region_low_pc = 0x2017; pub const AT_HP_cold_region_high_pc = 0x2018; pub const AT_HP_all_variables_modifiable = 0x2019; pub const AT_HP_linkage_name = 0x201a; pub const AT_HP_prof_flags = 0x201b; // In comp unit of procs_info for -g. pub const AT_HP_unit_name = 0x201f; pub const AT_HP_unit_size = 0x2020; pub const AT_HP_widened_byte_size = 0x2021; pub const AT_HP_definition_points = 0x2022; pub const AT_HP_default_location = 0x2023; pub const AT_HP_is_result_param = 0x2029; // GNU extensions. pub const AT_sf_names = 0x2101; pub const AT_src_info = 0x2102; pub const AT_mac_info = 0x2103; pub const AT_src_coords = 0x2104; pub const AT_body_begin = 0x2105; pub const AT_body_end = 0x2106; pub const AT_GNU_vector = 0x2107; // Thread-safety annotations. // See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation . pub const AT_GNU_guarded_by = 0x2108; pub const AT_GNU_pt_guarded_by = 0x2109; pub const AT_GNU_guarded = 0x210a; pub const AT_GNU_pt_guarded = 0x210b; pub const AT_GNU_locks_excluded = 0x210c; pub const AT_GNU_exclusive_locks_required = 0x210d; pub const AT_GNU_shared_locks_required = 0x210e; // One-definition rule violation detection. // See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo . pub const AT_GNU_odr_signature = 0x210f; // Template template argument name. // See http://gcc.gnu.org/wiki/TemplateParmsDwarf . pub const AT_GNU_template_name = 0x2110; // The GNU call site extension. // See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open . pub const AT_GNU_call_site_value = 0x2111; pub const AT_GNU_call_site_data_value = 0x2112; pub const AT_GNU_call_site_target = 0x2113; pub const AT_GNU_call_site_target_clobbered = 0x2114; pub const AT_GNU_tail_call = 0x2115; pub const AT_GNU_all_tail_call_sites = 0x2116; pub const AT_GNU_all_call_sites = 0x2117; pub const AT_GNU_all_source_call_sites = 0x2118; // Section offset into .debug_macro section. pub const AT_GNU_macros = 0x2119; // Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission. pub const AT_GNU_dwo_name = 0x2130; pub const AT_GNU_dwo_id = 0x2131; pub const AT_GNU_ranges_base = 0x2132; pub const AT_GNU_addr_base = 0x2133; pub const AT_GNU_pubnames = 0x2134; pub const AT_GNU_pubtypes = 0x2135; // VMS extensions. pub const AT_VMS_rtnbeg_pd_address = 0x2201; // GNAT extensions. // GNAT descriptive type. // See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . pub const AT_use_GNAT_descriptive_type = 0x2301; pub const AT_GNAT_descriptive_type = 0x2302; // UPC extension. pub const AT_upc_threads_scaled = 0x3210; // PGI (STMicroelectronics) extensions. pub const AT_PGI_lbase = 0x3a00; pub const AT_PGI_soffset = 0x3a01; pub const AT_PGI_lstride = 0x3a02; pub const OP_addr = 0x03; pub const OP_deref = 0x06; pub const OP_const1u = 0x08; pub const OP_const1s = 0x09; pub const OP_const2u = 0x0a; pub const OP_const2s = 0x0b; pub const OP_const4u = 0x0c; pub const OP_const4s = 0x0d; pub const OP_const8u = 0x0e; pub const OP_const8s = 0x0f; pub const OP_constu = 0x10; pub const OP_consts = 0x11; pub const OP_dup = 0x12; pub const OP_drop = 0x13; pub const OP_over = 0x14; pub const OP_pick = 0x15; pub const OP_swap = 0x16; pub const OP_rot = 0x17; pub const OP_xderef = 0x18; pub const OP_abs = 0x19; pub const OP_and = 0x1a; pub const OP_div = 0x1b; pub const OP_minus = 0x1c; pub const OP_mod = 0x1d; pub const OP_mul = 0x1e; pub const OP_neg = 0x1f; pub const OP_not = 0x20; pub const OP_or = 0x21; pub const OP_plus = 0x22; pub const OP_plus_uconst = 0x23; pub const OP_shl = 0x24; pub const OP_shr = 0x25; pub const OP_shra = 0x26; pub const OP_xor = 0x27; pub const OP_bra = 0x28; pub const OP_eq = 0x29; pub const OP_ge = 0x2a; pub const OP_gt = 0x2b; pub const OP_le = 0x2c; pub const OP_lt = 0x2d; pub const OP_ne = 0x2e; pub const OP_skip = 0x2f; pub const OP_lit0 = 0x30; pub const OP_lit1 = 0x31; pub const OP_lit2 = 0x32; pub const OP_lit3 = 0x33; pub const OP_lit4 = 0x34; pub const OP_lit5 = 0x35; pub const OP_lit6 = 0x36; pub const OP_lit7 = 0x37; pub const OP_lit8 = 0x38; pub const OP_lit9 = 0x39; pub const OP_lit10 = 0x3a; pub const OP_lit11 = 0x3b; pub const OP_lit12 = 0x3c; pub const OP_lit13 = 0x3d; pub const OP_lit14 = 0x3e; pub const OP_lit15 = 0x3f; pub const OP_lit16 = 0x40; pub const OP_lit17 = 0x41; pub const OP_lit18 = 0x42; pub const OP_lit19 = 0x43; pub const OP_lit20 = 0x44; pub const OP_lit21 = 0x45; pub const OP_lit22 = 0x46; pub const OP_lit23 = 0x47; pub const OP_lit24 = 0x48; pub const OP_lit25 = 0x49; pub const OP_lit26 = 0x4a; pub const OP_lit27 = 0x4b; pub const OP_lit28 = 0x4c; pub const OP_lit29 = 0x4d; pub const OP_lit30 = 0x4e; pub const OP_lit31 = 0x4f; pub const OP_reg0 = 0x50; pub const OP_reg1 = 0x51; pub const OP_reg2 = 0x52; pub const OP_reg3 = 0x53; pub const OP_reg4 = 0x54; pub const OP_reg5 = 0x55; pub const OP_reg6 = 0x56; pub const OP_reg7 = 0x57; pub const OP_reg8 = 0x58; pub const OP_reg9 = 0x59; pub const OP_reg10 = 0x5a; pub const OP_reg11 = 0x5b; pub const OP_reg12 = 0x5c; pub const OP_reg13 = 0x5d; pub const OP_reg14 = 0x5e; pub const OP_reg15 = 0x5f; pub const OP_reg16 = 0x60; pub const OP_reg17 = 0x61; pub const OP_reg18 = 0x62; pub const OP_reg19 = 0x63; pub const OP_reg20 = 0x64; pub const OP_reg21 = 0x65; pub const OP_reg22 = 0x66; pub const OP_reg23 = 0x67; pub const OP_reg24 = 0x68; pub const OP_reg25 = 0x69; pub const OP_reg26 = 0x6a; pub const OP_reg27 = 0x6b; pub const OP_reg28 = 0x6c; pub const OP_reg29 = 0x6d; pub const OP_reg30 = 0x6e; pub const OP_reg31 = 0x6f; pub const OP_breg0 = 0x70; pub const OP_breg1 = 0x71; pub const OP_breg2 = 0x72; pub const OP_breg3 = 0x73; pub const OP_breg4 = 0x74; pub const OP_breg5 = 0x75; pub const OP_breg6 = 0x76; pub const OP_breg7 = 0x77; pub const OP_breg8 = 0x78; pub const OP_breg9 = 0x79; pub const OP_breg10 = 0x7a; pub const OP_breg11 = 0x7b; pub const OP_breg12 = 0x7c; pub const OP_breg13 = 0x7d; pub const OP_breg14 = 0x7e; pub const OP_breg15 = 0x7f; pub const OP_breg16 = 0x80; pub const OP_breg17 = 0x81; pub const OP_breg18 = 0x82; pub const OP_breg19 = 0x83; pub const OP_breg20 = 0x84; pub const OP_breg21 = 0x85; pub const OP_breg22 = 0x86; pub const OP_breg23 = 0x87; pub const OP_breg24 = 0x88; pub const OP_breg25 = 0x89; pub const OP_breg26 = 0x8a; pub const OP_breg27 = 0x8b; pub const OP_breg28 = 0x8c; pub const OP_breg29 = 0x8d; pub const OP_breg30 = 0x8e; pub const OP_breg31 = 0x8f; pub const OP_regx = 0x90; pub const OP_fbreg = 0x91; pub const OP_bregx = 0x92; pub const OP_piece = 0x93; pub const OP_deref_size = 0x94; pub const OP_xderef_size = 0x95; pub const OP_nop = 0x96; // DWARF 3 extensions. pub const OP_push_object_address = 0x97; pub const OP_call2 = 0x98; pub const OP_call4 = 0x99; pub const OP_call_ref = 0x9a; pub const OP_form_tls_address = 0x9b; pub const OP_call_frame_cfa = 0x9c; pub const OP_bit_piece = 0x9d; // DWARF 4 extensions. pub const OP_implicit_value = 0x9e; pub const OP_stack_value = 0x9f; pub const OP_lo_user = 0xe0; // Implementation-defined range start. pub const OP_hi_user = 0xff; // Implementation-defined range end. // GNU extensions. pub const OP_GNU_push_tls_address = 0xe0; // The following is for marking variables that are uninitialized. pub const OP_GNU_uninit = 0xf0; pub const OP_GNU_encoded_addr = 0xf1; // The GNU implicit pointer extension. // See http://www.dwarfstd.org/ShowIssue.php?issue=100831.1&type=open . pub const OP_GNU_implicit_pointer = 0xf2; // The GNU entry value extension. // See http://www.dwarfstd.org/ShowIssue.php?issue=100909.1&type=open . pub const OP_GNU_entry_value = 0xf3; // The GNU typed stack extension. // See http://www.dwarfstd.org/doc/040408.1.html . pub const OP_GNU_const_type = 0xf4; pub const OP_GNU_regval_type = 0xf5; pub const OP_GNU_deref_type = 0xf6; pub const OP_GNU_convert = 0xf7; pub const OP_GNU_reinterpret = 0xf9; // The GNU parameter ref extension. pub const OP_GNU_parameter_ref = 0xfa; // Extension for Fission. See http://gcc.gnu.org/wiki/DebugFission. pub const OP_GNU_addr_index = 0xfb; pub const OP_GNU_const_index = 0xfc; // HP extensions. pub const OP_HP_unknown = 0xe0; // Ouch, the same as GNU_push_tls_address. pub const OP_HP_is_value = 0xe1; pub const OP_HP_fltconst4 = 0xe2; pub const OP_HP_fltconst8 = 0xe3; pub const OP_HP_mod_range = 0xe4; pub const OP_HP_unmod_range = 0xe5; pub const OP_HP_tls = 0xe6; // PGI (STMicroelectronics) extensions. pub const OP_PGI_omp_thread_num = 0xf8; pub const ATE_void = 0x0; pub const ATE_address = 0x1; pub const ATE_boolean = 0x2; pub const ATE_complex_float = 0x3; pub const ATE_float = 0x4; pub const ATE_signed = 0x5; pub const ATE_signed_char = 0x6; pub const ATE_unsigned = 0x7; pub const ATE_unsigned_char = 0x8; // DWARF 3. pub const ATE_imaginary_float = 0x9; pub const ATE_packed_decimal = 0xa; pub const ATE_numeric_string = 0xb; pub const ATE_edited = 0xc; pub const ATE_signed_fixed = 0xd; pub const ATE_unsigned_fixed = 0xe; pub const ATE_decimal_float = 0xf; // DWARF 4. pub const ATE_UTF = 0x10; pub const ATE_lo_user = 0x80; pub const ATE_hi_user = 0xff; // HP extensions. pub const ATE_HP_float80 = 0x80; // Floating-point (80 bit). pub const ATE_HP_complex_float80 = 0x81; // Complex floating-point (80 bit). pub const ATE_HP_float128 = 0x82; // Floating-point (128 bit). pub const ATE_HP_complex_float128 = 0x83; // Complex fp (128 bit). pub const ATE_HP_floathpintel = 0x84; // Floating-point (82 bit IA64). pub const ATE_HP_imaginary_float80 = 0x85; pub const ATE_HP_imaginary_float128 = 0x86; pub const ATE_HP_VAX_float = 0x88; // F or G floating. pub const ATE_HP_VAX_float_d = 0x89; // D floating. pub const ATE_HP_packed_decimal = 0x8a; // Cobol. pub const ATE_HP_zoned_decimal = 0x8b; // Cobol. pub const ATE_HP_edited = 0x8c; // Cobol. pub const ATE_HP_signed_fixed = 0x8d; // Cobol. pub const ATE_HP_unsigned_fixed = 0x8e; // Cobol. pub const ATE_HP_VAX_complex_float = 0x8f; // F or G floating complex. pub const ATE_HP_VAX_complex_float_d = 0x90; // D floating complex. pub const CFA_advance_loc = 0x40; pub const CFA_offset = 0x80; pub const CFA_restore = 0xc0; pub const CFA_nop = 0x00; pub const CFA_set_loc = 0x01; pub const CFA_advance_loc1 = 0x02; pub const CFA_advance_loc2 = 0x03; pub const CFA_advance_loc4 = 0x04; pub const CFA_offset_extended = 0x05; pub const CFA_restore_extended = 0x06; pub const CFA_undefined = 0x07; pub const CFA_same_value = 0x08; pub const CFA_register = 0x09; pub const CFA_remember_state = 0x0a; pub const CFA_restore_state = 0x0b; pub const CFA_def_cfa = 0x0c; pub const CFA_def_cfa_register = 0x0d; pub const CFA_def_cfa_offset = 0x0e; // DWARF 3. pub const CFA_def_cfa_expression = 0x0f; pub const CFA_expression = 0x10; pub const CFA_offset_extended_sf = 0x11; pub const CFA_def_cfa_sf = 0x12; pub const CFA_def_cfa_offset_sf = 0x13; pub const CFA_val_offset = 0x14; pub const CFA_val_offset_sf = 0x15; pub const CFA_val_expression = 0x16; pub const CFA_lo_user = 0x1c; pub const CFA_hi_user = 0x3f; // SGI/MIPS specific. pub const CFA_MIPS_advance_loc8 = 0x1d; // GNU extensions. pub const CFA_GNU_window_save = 0x2d; pub const CFA_GNU_args_size = 0x2e; pub const CFA_GNU_negative_offset_extended = 0x2f; pub const CHILDREN_no = 0x00; pub const CHILDREN_yes = 0x01; pub const LNS_extended_op = 0x00; pub const LNS_copy = 0x01; pub const LNS_advance_pc = 0x02; pub const LNS_advance_line = 0x03; pub const LNS_set_file = 0x04; pub const LNS_set_column = 0x05; pub const LNS_negate_stmt = 0x06; pub const LNS_set_basic_block = 0x07; pub const LNS_const_add_pc = 0x08; pub const LNS_fixed_advance_pc = 0x09; pub const LNS_set_prologue_end = 0x0a; pub const LNS_set_epilogue_begin = 0x0b; pub const LNS_set_isa = 0x0c; pub const LNE_end_sequence = 0x01; pub const LNE_set_address = 0x02; pub const LNE_define_file = 0x03; pub const LNE_set_discriminator = 0x04; pub const LNE_lo_user = 0x80; pub const LNE_hi_user = 0xff;
std/dwarf.zig
const std = @import("../std.zig"); const builtin = @import("builtin"); const assert = std.debug.assert; const testing = std.testing; const mem = std.mem; const Loop = std.event.Loop; /// Thread-safe async/await lock. /// Functions which are waiting for the lock are suspended, and /// are resumed when the lock is released, in order. /// Allows only one actor to hold the lock. /// TODO: make this API also work in blocking I/O mode. pub const Lock = struct { mutex: std.Thread.Mutex = std.Thread.Mutex{}, head: usize = UNLOCKED, const UNLOCKED = 0; const LOCKED = 1; const global_event_loop = Loop.instance orelse @compileError("std.event.Lock currently only works with event-based I/O"); const Waiter = struct { // forced Waiter alignment to ensure it doesn't clash with LOCKED next: ?*Waiter align(2), tail: *Waiter, node: Loop.NextTickNode, }; pub fn initLocked() Lock { return Lock{ .head = LOCKED }; } pub fn acquire(self: *Lock) Held { const held = self.mutex.acquire(); // self.head transitions from multiple stages depending on the value: // UNLOCKED -> LOCKED: // acquire Lock ownership when theres no waiters // LOCKED -> <Waiter head ptr>: // Lock is already owned, enqueue first Waiter // <head ptr> -> <head ptr>: // Lock is owned with pending waiters. Push our waiter to the queue. if (self.head == UNLOCKED) { self.head = LOCKED; held.release(); return Held{ .lock = self }; } var waiter: Waiter = undefined; waiter.next = null; waiter.tail = &waiter; const head = switch (self.head) { UNLOCKED => unreachable, LOCKED => null, else => @intToPtr(*Waiter, self.head), }; if (head) |h| { h.tail.next = &waiter; h.tail = &waiter; } else { self.head = @ptrToInt(&waiter); } suspend { waiter.node = Loop.NextTickNode{ .prev = undefined, .next = undefined, .data = @frame(), }; held.release(); } return Held{ .lock = self }; } pub const Held = struct { lock: *Lock, pub fn release(self: Held) void { const waiter = blk: { const held = self.lock.mutex.acquire(); defer held.release(); // self.head goes through the reverse transition from acquire(): // <head ptr> -> <new head ptr>: // pop a waiter from the queue to give Lock ownership when theres still others pending // <head ptr> -> LOCKED: // pop the laster waiter from the queue, while also giving it lock ownership when awaken // LOCKED -> UNLOCKED: // last lock owner releases lock while no one else is waiting for it switch (self.lock.head) { UNLOCKED => { unreachable; // Lock unlocked while unlocking }, LOCKED => { self.lock.head = UNLOCKED; break :blk null; }, else => { const waiter = @intToPtr(*Waiter, self.lock.head); self.lock.head = if (waiter.next == null) LOCKED else @ptrToInt(waiter.next); if (waiter.next) |next| next.tail = waiter.tail; break :blk waiter; }, } }; if (waiter) |w| { global_event_loop.onNextTick(&w.node); } } }; }; test "std.event.Lock" { if (!std.io.is_async) return error.SkipZigTest; // TODO https://github.com/ziglang/zig/issues/1908 if (builtin.single_threaded) return error.SkipZigTest; // TODO https://github.com/ziglang/zig/issues/3251 if (builtin.os.tag == .freebsd) return error.SkipZigTest; var lock = Lock{}; testLock(&lock); const expected_result = [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len; try testing.expectEqualSlices(i32, &expected_result, &shared_test_data); } fn testLock(lock: *Lock) void { var handle1 = async lockRunner(lock); var handle2 = async lockRunner(lock); var handle3 = async lockRunner(lock); await handle1; await handle2; await handle3; } var shared_test_data = [1]i32{0} ** 10; var shared_test_index: usize = 0; fn lockRunner(lock: *Lock) void { Lock.global_event_loop.yield(); var i: usize = 0; while (i < shared_test_data.len) : (i += 1) { const handle = lock.acquire(); defer handle.release(); shared_test_index = 0; while (shared_test_index < shared_test_data.len) : (shared_test_index += 1) { shared_test_data[shared_test_index] = shared_test_data[shared_test_index] + 1; } } }
lib/std/event/lock.zig
usingnamespace @import("../engine/engine.zig"); const Literal = @import("../parser/literal.zig").Literal; const LiteralValue = @import("../parser/literal.zig").LiteralValue; const MapTo = @import("mapto.zig").MapTo; const MapToValue = @import("mapto.zig").MapToValue; const std = @import("std"); const testing = std.testing; const mem = std.mem; pub fn SequenceAmbiguousContext(comptime Payload: type, comptime Value: type) type { return []const *Parser(Payload, Value); } /// Represents a sequence of parsed values. /// /// In the case of a non-ambiguous grammar, a `SequenceAmbiguous` combinator will yield: /// /// ``` /// SequenceAmbiguousValue{ /// node: value1, /// next: ResultStream(SequenceAmbiguousValue{ /// node: value2, /// next: ..., /// }) /// } /// ``` /// /// In the case of an ambiguous grammar, it would yield streams with potentially multiple values /// (each representing one possible parse path / interpretation of the grammar): /// /// ``` /// SequenceAmbiguousValue{ /// node: value1, /// next: ResultStream( /// SequenceAmbiguousValue{ /// node: value2variant1, /// next: ..., /// }, /// SequenceAmbiguousValue{ /// node: value2variant2, /// next: ..., /// }, /// ) /// } /// ``` /// pub fn SequenceAmbiguousValue(comptime Value: type) type { return struct { node: Result(Value), next: *ResultStream(Result(@This())), pub fn deinit(self: *const @This(), allocator: *mem.Allocator) void { self.next.deinit(); self.node.deinit(allocator); allocator.destroy(self.next); } pub fn flatten(self: *const @This(), allocator: *mem.Allocator, subscriber: ParserPosKey, path: ParserPath) Error!ResultStream(Result(Value)) { var dst = try ResultStream(Result(Value)).init(allocator, subscriber); try self.flatten_into(&dst, allocator, subscriber, path); dst.close(); // TODO(slimsag): why does deferring this not work? return dst; } pub fn flatten_into(self: *const @This(), dst: *ResultStream(Result(Value)), allocator: *mem.Allocator, subscriber: ParserPosKey, path: ParserPath) Error!void { try dst.add(self.node.toUnowned()); var sub = self.next.subscribe(subscriber, path, Result(SequenceAmbiguousValue(Value)).initError(0, "matches only the empty language")); nosuspend { while (sub.next()) |next_path| { switch (next_path.result) { .err => try dst.add(Result(Value).initError(next_path.offset, next_path.result.err)), else => try next_path.result.value.flatten_into(dst, allocator, subscriber, path), } } } } }; } /// Matches the `input` parsers sequentially. The parsers must produce the same data type (use /// MapTo, if needed.) /// /// The `input` parsers must remain alive for as long as the `SequenceAmbiguous` parser will be used. pub fn SequenceAmbiguous(comptime Payload: type, comptime Value: type) type { return struct { parser: Parser(Payload, SequenceAmbiguousValue(Value)) = Parser(Payload, SequenceAmbiguousValue(Value)).init(parse, nodeName, deinit), input: SequenceAmbiguousContext(Payload, Value), const Self = @This(); pub fn init(input: SequenceAmbiguousContext(Payload, Value)) Self { return Self{ .input = input }; } pub fn deinit(parser: *Parser(Payload, SequenceAmbiguousValue(Value)), allocator: *mem.Allocator) void { const self = @fieldParentPtr(Self, "parser", parser); for (self.input) |child_parser| { child_parser.deinit(allocator); } } pub fn nodeName(parser: *const Parser(Payload, SequenceAmbiguousValue(Value)), node_name_cache: *std.AutoHashMap(usize, ParserNodeName)) Error!u64 { const self = @fieldParentPtr(Self, "parser", parser); var v = std.hash_map.hashString("SequenceAmbiguous"); for (self.input) |in_parser| { v +%= try in_parser.nodeName(node_name_cache); } return v; } pub fn parse(parser: *const Parser(Payload, SequenceAmbiguousValue(Value)), in_ctx: *const Context(Payload, SequenceAmbiguousValue(Value))) callconv(.Async) Error!void { const self = @fieldParentPtr(Self, "parser", parser); var ctx = in_ctx.with(self.input); defer ctx.results.close(); if (self.input.len == 0) { return; } // For a sequence of input parsers [A, B, C], each one may produce multiple different // possible parser paths (valid interpretations of the same input state) in the case of // an ambiguous grammar. For example, the sequence of parsers [A, B, C] where each // produces 2 possible parser paths (e.g. A1, A2) we need to emit: // // stream( // (A1, stream( // (B1, stream( // (C1, None), // (C2, None), // )), // (B2, stream( // (C1, None), // (C2, None), // )), // )), // (A2, stream( // (B1, stream( // (C1, None), // (C2, None), // )), // (B2, stream( // (C1, None), // (C2, None), // )), // )), // ) // // This call to `SequenceAmbiguous.parse` is only responsible for emitting the top level // (A1, A2) and invoking SequenceAmbiguous(next) to produce the associated `stream()` for those // parse states. const child_node_name = try self.input[0].nodeName(&in_ctx.memoizer.node_name_cache); var child_ctx = try in_ctx.initChild(Value, child_node_name, ctx.offset); defer child_ctx.deinitChild(); if (!child_ctx.existing_results) try self.input[0].parse(&child_ctx); // For every top-level value (A1, A2 in our example above.) var sub = child_ctx.subscribe(); while (sub.next()) |top_level| { switch (top_level.result) { .err => { try ctx.results.add(Result(SequenceAmbiguousValue(Value)).initError(top_level.offset, top_level.result.err)); continue; }, else => { // We got a non-error top-level value (e.g. A1, A2). // Now get the stream that continues down this path (i.e. the stream // associated with A1, A2.) var path_results = try ctx.allocator.create(ResultStream(Result(SequenceAmbiguousValue(Value)))); path_results.* = try ResultStream(Result(SequenceAmbiguousValue(Value))).init(ctx.allocator, ctx.key); var path = SequenceAmbiguous(Payload, Value).init(self.input[1..]); const path_node_name = try path.parser.nodeName(&in_ctx.memoizer.node_name_cache); var path_ctx = try in_ctx.initChild(SequenceAmbiguousValue(Value), path_node_name, top_level.offset); defer path_ctx.deinitChild(); if (!path_ctx.existing_results) try path.parser.parse(&path_ctx); var path_results_sub = path_ctx.subscribe(); while (path_results_sub.next()) |next| { try path_results.add(next.toUnowned()); } path_results.close(); // Emit our top-level value tuple (e.g. (A1, stream(...)) try ctx.results.add(Result(SequenceAmbiguousValue(Value)).init(top_level.offset, .{ .node = top_level.toUnowned(), .next = path_results, })); }, } } } }; } test "sequence" { nosuspend { const allocator = testing.allocator; const Payload = void; const ctx = try Context(Payload, SequenceAmbiguousValue(LiteralValue)).init(allocator, "abc123abc456_123abc", {}); defer ctx.deinit(); var seq = SequenceAmbiguous(Payload, LiteralValue).init(&.{ (&Literal(Payload).init("abc").parser).ref(), (&Literal(Payload).init("123ab").parser).ref(), (&Literal(Payload).init("c45").parser).ref(), (&Literal(Payload).init("6").parser).ref(), }); try seq.parser.parse(&ctx); var sub = ctx.subscribe(); var list = sub.next(); try testing.expect(sub.next() == null); // stream closed // first element try testing.expectEqual(@as(usize, 3), list.?.offset); try testing.expectEqual(@as(usize, 3), list.?.result.value.node.offset); // flatten the nested multi-dimensional array, since our grammar above is not ambiguous // this is fine to do and makes testing far easier. var flattened = try list.?.result.value.flatten(allocator, ctx.key, ctx.path); defer flattened.deinit(); var flat = flattened.subscribe(ctx.key, ctx.path, Result(LiteralValue).initError(ctx.offset, "matches only the empty language")); try testing.expectEqual(@as(usize, 3), flat.next().?.offset); try testing.expectEqual(@as(usize, 8), flat.next().?.offset); try testing.expectEqual(@as(usize, 11), flat.next().?.offset); try testing.expectEqual(@as(usize, 12), flat.next().?.offset); try testing.expect(flat.next() == null); // stream closed } }
src/combn/combinator/sequence_ambiguous.zig
const pike = @import("pike"); const zap = @import("zap"); const std = @import("std"); const net = std.net; const log = std.log.scoped(.apple_pie); const req = @import("request.zig"); const resp = @import("response.zig"); const Request = req.Request; const Response = resp.Response; const os = std.os; /// Alias for an atomic queue of Clients const Clients = std.atomic.Queue(*Client); /// User API function signature of a request handler pub const RequestHandler = fn handle(*Response, Request) callconv(.Async) anyerror!void; /// Represents a peer that is connected to our server const Client = struct { /// The socket its connected through socket: pike.Socket, /// The address of the peer address: net.Address, /// Wrapper run function as Zap's runtime enforces us to not return any errors fn run(server: *Server, notifier: *const pike.Notifier, socket: pike.Socket, address: net.Address) void { inlineRun(server, notifier, socket, address) catch |err| { log.err("An error occured while handling a request: {}", .{@errorName(err)}); }; } /// Inner inlined function that runs the actual client logic /// First yields to the Zap runtime to give control back to frame owner. /// Secondly, creates a new client and sets up its resources (including cleanup) /// Finally, it starts the client loop (keep-alive) and parses the incoming requests /// and then calls the user provided request handler. fn inlineRun( server: *Server, notifier: *const pike.Notifier, socket: pike.Socket, address: net.Address, ) !void { zap.runtime.yield(); var client = Client{ .socket = socket, .address = address }; var node = Clients.Node{ .data = &client }; server.clients.put(&node); defer if (server.clients.remove(&node)) { client.socket.deinit(); }; try client.socket.registerTo(notifier); // we allocate the body and allocate a buffer for our response to save syscalls var arena = std.heap.ArenaAllocator.init(server.gpa); defer arena.deinit(); // max byte size per stack before we allocate more memory const buffer_size: usize = 4096; var stack_allocator = std.heap.stackFallback(buffer_size, &arena.allocator); while (true) { const parsed_request = req.parse( stack_allocator.get(), client.socket.reader(), buffer_size, ) catch |err| switch (err) { // not an error, client disconnected req.ParseError.EndOfStream => return, else => return err, }; // create on the stack and allow the user to write to its writer var body = std.ArrayList(u8).init(stack_allocator.get()); defer body.deinit(); var response = Response{ .headers = resp.Headers.init(stack_allocator.get()), .socket_writer = std.io.bufferedWriter( resp.SocketWriter{ .handle = &client.socket }, ), .is_flushed = false, .body = body.writer(), }; if (parsed_request.protocol == .http1_1 and parsed_request.host == null) { return response.writeHeader(.BadRequest); } // async runtime functions require a stack // provides a 100kb stack var stack: [100 * 1024]u8 align(16) = undefined; try nosuspend await @asyncCall(&stack, {}, server.handler, .{ &response, parsed_request }); if (!response.is_flushed) try response.flush(); if (parsed_request.should_close) return; // close connection } } }; const Server = struct { socket: pike.Socket, clients: Clients, frame: @Frame(run), handler: RequestHandler, gpa: *std.mem.Allocator, /// Initializes a new `pike.Socket` and creates a new `Server` object fn init(gpa: *std.mem.Allocator, handler: RequestHandler) !Server { var socket = try pike.Socket.init(os.AF_INET, os.SOCK_STREAM, os.IPPROTO_TCP, 0); errdefer socket.deinit(); try socket.set(.reuse_address, true); return Server{ .socket = socket, .clients = Clients.init(), .frame = undefined, .handler = handler, .gpa = gpa, }; } /// First disconnects its socket to close all connections, /// secondly awaits itself to ensure its finished state and then cleansup /// any remaining clients fn deinit(self: *Server) void { self.socket.deinit(); await self.frame; while (self.clients.get()) |node| { node.data.socket.deinit(); } } /// Binds the socket to the address and registers itself to the `notifier` fn start(self: *Server, notifier: *const pike.Notifier, address: net.Address) !void { try self.socket.bind(address); try self.socket.listen(128); try self.socket.registerTo(notifier); self.frame = async self.run(notifier); } /// Enters the listener loop and awaits for new connections /// On new connection spawns a task on Zap's runtime to create a `Client` fn run(self: *Server, notifier: *const pike.Notifier) callconv(.Async) void { while (true) { var conn = self.socket.accept() catch |err| switch (err) { error.SocketNotListening, error.OperationCancelled, => return, else => { log.err("Server - socket.accept(): {}", .{@errorName(err)}); continue; }, }; zap.runtime.spawn(.{}, Client.run, .{ self, notifier, conn.socket, conn.address }) catch |err| { log.err("Server - runtime.spawn(): {}", .{@errorName(err)}); continue; }; } } }; /// Creates a new server and starts listening for new connections. /// On connection, parses its request and sends it to the given `handler` pub fn listenAndServe(gpa: *std.mem.Allocator, address: net.Address, handler: RequestHandler) !void { try pike.init(); defer pike.deinit(); var signal = try pike.Signal.init(.{ .interrupt = true }); try try zap.runtime.run(.{}, serve, .{ gpa, &signal, address, handler }); } /// Creates event listener, notifier and registers the signal handler and event handler to the notifier /// Finally, creates a new server object and starts listening to new connections fn serve(gpa: *std.mem.Allocator, signal: *pike.Signal, address: net.Address, handler: RequestHandler) !void { defer signal.deinit(); var event = try pike.Event.init(); defer event.deinit(); const notifier = try pike.Notifier.init(); defer notifier.deinit(); try event.registerTo(&notifier); var stopped = false; var server = try Server.init(gpa, handler); defer server.deinit(); try server.start(&notifier, address); var frame = async awaitSignal(signal, &event, &stopped, &server); while (!stopped) { try notifier.poll(1_000_000); } try nosuspend await frame; defer log.info("Apple pie has been shutdown", .{}); } /// Awaits for a signal to be provided for shutdown fn awaitSignal(signal: *pike.Signal, event: *pike.Event, stopped: *bool, server: *Server) !void { defer { stopped.* = true; event.post() catch {}; } try signal.wait(); }
src/server.zig
pub const PKEY_PIDSTR_MAX = @as(u32, 10); //-------------------------------------------------------------------------------- // Section: Types (61) //-------------------------------------------------------------------------------- pub const PROPERTYKEY = extern struct { fmtid: Guid, pid: u32, }; const CLSID_InMemoryPropertyStore_Value = Guid.initString("9a02e012-6303-4e1e-b9a1-630f802592c5"); pub const CLSID_InMemoryPropertyStore = &CLSID_InMemoryPropertyStore_Value; const CLSID_InMemoryPropertyStoreMarshalByValue_Value = Guid.initString("d4ca0e2d-6da7-4b75-a97c-5f306f0eaedc"); pub const CLSID_InMemoryPropertyStoreMarshalByValue = &CLSID_InMemoryPropertyStoreMarshalByValue_Value; const CLSID_PropertySystem_Value = Guid.initString("b8967f85-58ae-4f46-9fb2-5d7904798f4b"); pub const CLSID_PropertySystem = &CLSID_PropertySystem_Value; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IInitializeWithFile_Value = Guid.initString("b7d14566-0509-4cce-a71f-0a554233bd9b"); pub const IID_IInitializeWithFile = &IID_IInitializeWithFile_Value; pub const IInitializeWithFile = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Initialize: fn( self: *const IInitializeWithFile, pszFilePath: ?[*:0]const u16, grfMode: 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 IInitializeWithFile_Initialize(self: *const T, pszFilePath: ?[*:0]const u16, grfMode: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInitializeWithFile.VTable, self.vtable).Initialize(@ptrCast(*const IInitializeWithFile, self), pszFilePath, grfMode); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IInitializeWithStream_Value = Guid.initString("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"); pub const IID_IInitializeWithStream = &IID_IInitializeWithStream_Value; pub const IInitializeWithStream = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Initialize: fn( self: *const IInitializeWithStream, pstream: ?*IStream, grfMode: 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 IInitializeWithStream_Initialize(self: *const T, pstream: ?*IStream, grfMode: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IInitializeWithStream.VTable, self.vtable).Initialize(@ptrCast(*const IInitializeWithStream, self), pstream, grfMode); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IPropertyStore_Value = Guid.initString("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99"); pub const IID_IPropertyStore = &IID_IPropertyStore_Value; pub const IPropertyStore = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetCount: fn( self: *const IPropertyStore, cProps: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAt: fn( self: *const IPropertyStore, iProp: u32, pkey: ?*PROPERTYKEY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetValue: fn( self: *const IPropertyStore, key: ?*const PROPERTYKEY, pv: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetValue: fn( self: *const IPropertyStore, key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Commit: fn( self: *const IPropertyStore, ) 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 IPropertyStore_GetCount(self: *const T, cProps: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStore.VTable, self.vtable).GetCount(@ptrCast(*const IPropertyStore, self), cProps); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStore_GetAt(self: *const T, iProp: u32, pkey: ?*PROPERTYKEY) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStore.VTable, self.vtable).GetAt(@ptrCast(*const IPropertyStore, self), iProp, pkey); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStore_GetValue(self: *const T, key: ?*const PROPERTYKEY, pv: ?*PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStore.VTable, self.vtable).GetValue(@ptrCast(*const IPropertyStore, self), key, pv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStore_SetValue(self: *const T, key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStore.VTable, self.vtable).SetValue(@ptrCast(*const IPropertyStore, self), key, propvar); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStore_Commit(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStore.VTable, self.vtable).Commit(@ptrCast(*const IPropertyStore, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_INamedPropertyStore_Value = Guid.initString("71604b0f-97b0-4764-8577-2f13e98a1422"); pub const IID_INamedPropertyStore = &IID_INamedPropertyStore_Value; pub const INamedPropertyStore = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetNamedValue: fn( self: *const INamedPropertyStore, pszName: ?[*:0]const u16, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetNamedValue: fn( self: *const INamedPropertyStore, pszName: ?[*:0]const u16, propvar: ?*const PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetNameCount: fn( self: *const INamedPropertyStore, pdwCount: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetNameAt: fn( self: *const INamedPropertyStore, iProp: u32, pbstrName: ?*?BSTR, ) 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 INamedPropertyStore_GetNamedValue(self: *const T, pszName: ?[*:0]const u16, ppropvar: ?*PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const INamedPropertyStore.VTable, self.vtable).GetNamedValue(@ptrCast(*const INamedPropertyStore, self), pszName, ppropvar); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn INamedPropertyStore_SetNamedValue(self: *const T, pszName: ?[*:0]const u16, propvar: ?*const PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const INamedPropertyStore.VTable, self.vtable).SetNamedValue(@ptrCast(*const INamedPropertyStore, self), pszName, propvar); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn INamedPropertyStore_GetNameCount(self: *const T, pdwCount: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const INamedPropertyStore.VTable, self.vtable).GetNameCount(@ptrCast(*const INamedPropertyStore, self), pdwCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn INamedPropertyStore_GetNameAt(self: *const T, iProp: u32, pbstrName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const INamedPropertyStore.VTable, self.vtable).GetNameAt(@ptrCast(*const INamedPropertyStore, self), iProp, pbstrName); } };} pub usingnamespace MethodMixin(@This()); }; pub const GETPROPERTYSTOREFLAGS = enum(i32) { DEFAULT = 0, HANDLERPROPERTIESONLY = 1, READWRITE = 2, TEMPORARY = 4, FASTPROPERTIESONLY = 8, OPENSLOWITEM = 16, DELAYCREATION = 32, BESTEFFORT = 64, NO_OPLOCK = 128, PREFERQUERYPROPERTIES = 256, EXTRINSICPROPERTIES = 512, EXTRINSICPROPERTIESONLY = 1024, VOLATILEPROPERTIES = 2048, VOLATILEPROPERTIESONLY = 4096, MASK_VALID = 8191, }; pub const GPS_DEFAULT = GETPROPERTYSTOREFLAGS.DEFAULT; pub const GPS_HANDLERPROPERTIESONLY = GETPROPERTYSTOREFLAGS.HANDLERPROPERTIESONLY; pub const GPS_READWRITE = GETPROPERTYSTOREFLAGS.READWRITE; pub const GPS_TEMPORARY = GETPROPERTYSTOREFLAGS.TEMPORARY; pub const GPS_FASTPROPERTIESONLY = GETPROPERTYSTOREFLAGS.FASTPROPERTIESONLY; pub const GPS_OPENSLOWITEM = GETPROPERTYSTOREFLAGS.OPENSLOWITEM; pub const GPS_DELAYCREATION = GETPROPERTYSTOREFLAGS.DELAYCREATION; pub const GPS_BESTEFFORT = GETPROPERTYSTOREFLAGS.BESTEFFORT; pub const GPS_NO_OPLOCK = GETPROPERTYSTOREFLAGS.NO_OPLOCK; pub const GPS_PREFERQUERYPROPERTIES = GETPROPERTYSTOREFLAGS.PREFERQUERYPROPERTIES; pub const GPS_EXTRINSICPROPERTIES = GETPROPERTYSTOREFLAGS.EXTRINSICPROPERTIES; pub const GPS_EXTRINSICPROPERTIESONLY = GETPROPERTYSTOREFLAGS.EXTRINSICPROPERTIESONLY; pub const GPS_VOLATILEPROPERTIES = GETPROPERTYSTOREFLAGS.VOLATILEPROPERTIES; pub const GPS_VOLATILEPROPERTIESONLY = GETPROPERTYSTOREFLAGS.VOLATILEPROPERTIESONLY; pub const GPS_MASK_VALID = GETPROPERTYSTOREFLAGS.MASK_VALID; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IObjectWithPropertyKey_Value = Guid.initString("fc0ca0a7-c316-4fd2-9031-3e628e6d4f23"); pub const IID_IObjectWithPropertyKey = &IID_IObjectWithPropertyKey_Value; pub const IObjectWithPropertyKey = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetPropertyKey: fn( self: *const IObjectWithPropertyKey, key: ?*const PROPERTYKEY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyKey: fn( self: *const IObjectWithPropertyKey, pkey: ?*PROPERTYKEY, ) 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 IObjectWithPropertyKey_SetPropertyKey(self: *const T, key: ?*const PROPERTYKEY) callconv(.Inline) HRESULT { return @ptrCast(*const IObjectWithPropertyKey.VTable, self.vtable).SetPropertyKey(@ptrCast(*const IObjectWithPropertyKey, self), key); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IObjectWithPropertyKey_GetPropertyKey(self: *const T, pkey: ?*PROPERTYKEY) callconv(.Inline) HRESULT { return @ptrCast(*const IObjectWithPropertyKey.VTable, self.vtable).GetPropertyKey(@ptrCast(*const IObjectWithPropertyKey, self), pkey); } };} pub usingnamespace MethodMixin(@This()); }; pub const PKA_FLAGS = enum(i32) { SET = 0, APPEND = 1, DELETE = 2, }; pub const PKA_SET = PKA_FLAGS.SET; pub const PKA_APPEND = PKA_FLAGS.APPEND; pub const PKA_DELETE = PKA_FLAGS.DELETE; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyChange_Value = Guid.initString("f917bc8a-1bba-4478-a245-1bde03eb9431"); pub const IID_IPropertyChange = &IID_IPropertyChange_Value; pub const IPropertyChange = extern struct { pub const VTable = extern struct { base: IObjectWithPropertyKey.VTable, ApplyToPropVariant: fn( self: *const IPropertyChange, propvarIn: ?*const PROPVARIANT, ppropvarOut: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IObjectWithPropertyKey.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyChange_ApplyToPropVariant(self: *const T, propvarIn: ?*const PROPVARIANT, ppropvarOut: ?*PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyChange.VTable, self.vtable).ApplyToPropVariant(@ptrCast(*const IPropertyChange, self), propvarIn, ppropvarOut); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyChangeArray_Value = Guid.initString("380f5cad-1b5e-42f2-805d-637fd392d31e"); pub const IID_IPropertyChangeArray = &IID_IPropertyChangeArray_Value; pub const IPropertyChangeArray = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetCount: fn( self: *const IPropertyChangeArray, pcOperations: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAt: fn( self: *const IPropertyChangeArray, iIndex: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, InsertAt: fn( self: *const IPropertyChangeArray, iIndex: u32, ppropChange: ?*IPropertyChange, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Append: fn( self: *const IPropertyChangeArray, ppropChange: ?*IPropertyChange, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AppendOrReplace: fn( self: *const IPropertyChangeArray, ppropChange: ?*IPropertyChange, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveAt: fn( self: *const IPropertyChangeArray, iIndex: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, IsKeyInArray: fn( self: *const IPropertyChangeArray, key: ?*const PROPERTYKEY, ) 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 IPropertyChangeArray_GetCount(self: *const T, pcOperations: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyChangeArray.VTable, self.vtable).GetCount(@ptrCast(*const IPropertyChangeArray, self), pcOperations); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyChangeArray_GetAt(self: *const T, iIndex: u32, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyChangeArray.VTable, self.vtable).GetAt(@ptrCast(*const IPropertyChangeArray, self), iIndex, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyChangeArray_InsertAt(self: *const T, iIndex: u32, ppropChange: ?*IPropertyChange) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyChangeArray.VTable, self.vtable).InsertAt(@ptrCast(*const IPropertyChangeArray, self), iIndex, ppropChange); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyChangeArray_Append(self: *const T, ppropChange: ?*IPropertyChange) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyChangeArray.VTable, self.vtable).Append(@ptrCast(*const IPropertyChangeArray, self), ppropChange); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyChangeArray_AppendOrReplace(self: *const T, ppropChange: ?*IPropertyChange) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyChangeArray.VTable, self.vtable).AppendOrReplace(@ptrCast(*const IPropertyChangeArray, self), ppropChange); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyChangeArray_RemoveAt(self: *const T, iIndex: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyChangeArray.VTable, self.vtable).RemoveAt(@ptrCast(*const IPropertyChangeArray, self), iIndex); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyChangeArray_IsKeyInArray(self: *const T, key: ?*const PROPERTYKEY) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyChangeArray.VTable, self.vtable).IsKeyInArray(@ptrCast(*const IPropertyChangeArray, self), key); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyStoreCapabilities_Value = Guid.initString("c8e2d566-186e-4d49-bf41-6909ead56acc"); pub const IID_IPropertyStoreCapabilities = &IID_IPropertyStoreCapabilities_Value; pub const IPropertyStoreCapabilities = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, IsPropertyWritable: fn( self: *const IPropertyStoreCapabilities, key: ?*const PROPERTYKEY, ) 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 IPropertyStoreCapabilities_IsPropertyWritable(self: *const T, key: ?*const PROPERTYKEY) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStoreCapabilities.VTable, self.vtable).IsPropertyWritable(@ptrCast(*const IPropertyStoreCapabilities, self), key); } };} pub usingnamespace MethodMixin(@This()); }; pub const PSC_STATE = enum(i32) { NORMAL = 0, NOTINSOURCE = 1, DIRTY = 2, READONLY = 3, }; pub const PSC_NORMAL = PSC_STATE.NORMAL; pub const PSC_NOTINSOURCE = PSC_STATE.NOTINSOURCE; pub const PSC_DIRTY = PSC_STATE.DIRTY; pub const PSC_READONLY = PSC_STATE.READONLY; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyStoreCache_Value = Guid.initString("3017056d-9a91-4e90-937d-746c72abbf4f"); pub const IID_IPropertyStoreCache = &IID_IPropertyStoreCache_Value; pub const IPropertyStoreCache = extern struct { pub const VTable = extern struct { base: IPropertyStore.VTable, GetState: fn( self: *const IPropertyStoreCache, key: ?*const PROPERTYKEY, pstate: ?*PSC_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetValueAndState: fn( self: *const IPropertyStoreCache, key: ?*const PROPERTYKEY, ppropvar: ?*PROPVARIANT, pstate: ?*PSC_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetState: fn( self: *const IPropertyStoreCache, key: ?*const PROPERTYKEY, state: PSC_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetValueAndState: fn( self: *const IPropertyStoreCache, key: ?*const PROPERTYKEY, ppropvar: ?*const PROPVARIANT, state: PSC_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPropertyStore.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStoreCache_GetState(self: *const T, key: ?*const PROPERTYKEY, pstate: ?*PSC_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStoreCache.VTable, self.vtable).GetState(@ptrCast(*const IPropertyStoreCache, self), key, pstate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStoreCache_GetValueAndState(self: *const T, key: ?*const PROPERTYKEY, ppropvar: ?*PROPVARIANT, pstate: ?*PSC_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStoreCache.VTable, self.vtable).GetValueAndState(@ptrCast(*const IPropertyStoreCache, self), key, ppropvar, pstate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStoreCache_SetState(self: *const T, key: ?*const PROPERTYKEY, state: PSC_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStoreCache.VTable, self.vtable).SetState(@ptrCast(*const IPropertyStoreCache, self), key, state); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStoreCache_SetValueAndState(self: *const T, key: ?*const PROPERTYKEY, ppropvar: ?*const PROPVARIANT, state: PSC_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStoreCache.VTable, self.vtable).SetValueAndState(@ptrCast(*const IPropertyStoreCache, self), key, ppropvar, state); } };} pub usingnamespace MethodMixin(@This()); }; pub const PROPENUMTYPE = enum(i32) { DISCRETEVALUE = 0, RANGEDVALUE = 1, DEFAULTVALUE = 2, ENDRANGE = 3, }; pub const PET_DISCRETEVALUE = PROPENUMTYPE.DISCRETEVALUE; pub const PET_RANGEDVALUE = PROPENUMTYPE.RANGEDVALUE; pub const PET_DEFAULTVALUE = PROPENUMTYPE.DEFAULTVALUE; pub const PET_ENDRANGE = PROPENUMTYPE.ENDRANGE; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyEnumType_Value = Guid.initString("11e1fbf9-2d56-4a6b-8db3-7cd193a471f2"); pub const IID_IPropertyEnumType = &IID_IPropertyEnumType_Value; pub const IPropertyEnumType = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetEnumType: fn( self: *const IPropertyEnumType, penumtype: ?*PROPENUMTYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetValue: fn( self: *const IPropertyEnumType, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetRangeMinValue: fn( self: *const IPropertyEnumType, ppropvarMin: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetRangeSetValue: fn( self: *const IPropertyEnumType, ppropvarSet: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDisplayText: fn( self: *const IPropertyEnumType, ppszDisplay: ?*?PWSTR, ) 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 IPropertyEnumType_GetEnumType(self: *const T, penumtype: ?*PROPENUMTYPE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumType.VTable, self.vtable).GetEnumType(@ptrCast(*const IPropertyEnumType, self), penumtype); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyEnumType_GetValue(self: *const T, ppropvar: ?*PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumType.VTable, self.vtable).GetValue(@ptrCast(*const IPropertyEnumType, self), ppropvar); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyEnumType_GetRangeMinValue(self: *const T, ppropvarMin: ?*PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumType.VTable, self.vtable).GetRangeMinValue(@ptrCast(*const IPropertyEnumType, self), ppropvarMin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyEnumType_GetRangeSetValue(self: *const T, ppropvarSet: ?*PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumType.VTable, self.vtable).GetRangeSetValue(@ptrCast(*const IPropertyEnumType, self), ppropvarSet); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyEnumType_GetDisplayText(self: *const T, ppszDisplay: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumType.VTable, self.vtable).GetDisplayText(@ptrCast(*const IPropertyEnumType, self), ppszDisplay); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.1' const IID_IPropertyEnumType2_Value = Guid.initString("9b6e051c-5ddd-4321-9070-fe2acb55e794"); pub const IID_IPropertyEnumType2 = &IID_IPropertyEnumType2_Value; pub const IPropertyEnumType2 = extern struct { pub const VTable = extern struct { base: IPropertyEnumType.VTable, GetImageReference: fn( self: *const IPropertyEnumType2, ppszImageRes: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPropertyEnumType.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyEnumType2_GetImageReference(self: *const T, ppszImageRes: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumType2.VTable, self.vtable).GetImageReference(@ptrCast(*const IPropertyEnumType2, self), ppszImageRes); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyEnumTypeList_Value = Guid.initString("a99400f4-3d84-4557-94ba-1242fb2cc9a6"); pub const IID_IPropertyEnumTypeList = &IID_IPropertyEnumTypeList_Value; pub const IPropertyEnumTypeList = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetCount: fn( self: *const IPropertyEnumTypeList, pctypes: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAt: fn( self: *const IPropertyEnumTypeList, itype: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetConditionAt: fn( self: *const IPropertyEnumTypeList, nIndex: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FindMatchingIndex: fn( self: *const IPropertyEnumTypeList, propvarCmp: ?*const PROPVARIANT, pnIndex: ?*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 IPropertyEnumTypeList_GetCount(self: *const T, pctypes: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumTypeList.VTable, self.vtable).GetCount(@ptrCast(*const IPropertyEnumTypeList, self), pctypes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyEnumTypeList_GetAt(self: *const T, itype: u32, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumTypeList.VTable, self.vtable).GetAt(@ptrCast(*const IPropertyEnumTypeList, self), itype, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyEnumTypeList_GetConditionAt(self: *const T, nIndex: u32, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumTypeList.VTable, self.vtable).GetConditionAt(@ptrCast(*const IPropertyEnumTypeList, self), nIndex, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyEnumTypeList_FindMatchingIndex(self: *const T, propvarCmp: ?*const PROPVARIANT, pnIndex: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyEnumTypeList.VTable, self.vtable).FindMatchingIndex(@ptrCast(*const IPropertyEnumTypeList, self), propvarCmp, pnIndex); } };} pub usingnamespace MethodMixin(@This()); }; pub const PROPDESC_TYPE_FLAGS = enum(i32) { DEFAULT = 0, MULTIPLEVALUES = 1, ISINNATE = 2, ISGROUP = 4, CANGROUPBY = 8, CANSTACKBY = 16, ISTREEPROPERTY = 32, INCLUDEINFULLTEXTQUERY = 64, ISVIEWABLE = 128, ISQUERYABLE = 256, CANBEPURGED = 512, SEARCHRAWVALUE = 1024, DONTCOERCEEMPTYSTRINGS = 2048, ALWAYSINSUPPLEMENTALSTORE = 4096, ISSYSTEMPROPERTY = -2147483648, MASK_ALL = -2147475457, }; pub const PDTF_DEFAULT = PROPDESC_TYPE_FLAGS.DEFAULT; pub const PDTF_MULTIPLEVALUES = PROPDESC_TYPE_FLAGS.MULTIPLEVALUES; pub const PDTF_ISINNATE = PROPDESC_TYPE_FLAGS.ISINNATE; pub const PDTF_ISGROUP = PROPDESC_TYPE_FLAGS.ISGROUP; pub const PDTF_CANGROUPBY = PROPDESC_TYPE_FLAGS.CANGROUPBY; pub const PDTF_CANSTACKBY = PROPDESC_TYPE_FLAGS.CANSTACKBY; pub const PDTF_ISTREEPROPERTY = PROPDESC_TYPE_FLAGS.ISTREEPROPERTY; pub const PDTF_INCLUDEINFULLTEXTQUERY = PROPDESC_TYPE_FLAGS.INCLUDEINFULLTEXTQUERY; pub const PDTF_ISVIEWABLE = PROPDESC_TYPE_FLAGS.ISVIEWABLE; pub const PDTF_ISQUERYABLE = PROPDESC_TYPE_FLAGS.ISQUERYABLE; pub const PDTF_CANBEPURGED = PROPDESC_TYPE_FLAGS.CANBEPURGED; pub const PDTF_SEARCHRAWVALUE = PROPDESC_TYPE_FLAGS.SEARCHRAWVALUE; pub const PDTF_DONTCOERCEEMPTYSTRINGS = PROPDESC_TYPE_FLAGS.DONTCOERCEEMPTYSTRINGS; pub const PDTF_ALWAYSINSUPPLEMENTALSTORE = PROPDESC_TYPE_FLAGS.ALWAYSINSUPPLEMENTALSTORE; pub const PDTF_ISSYSTEMPROPERTY = PROPDESC_TYPE_FLAGS.ISSYSTEMPROPERTY; pub const PDTF_MASK_ALL = PROPDESC_TYPE_FLAGS.MASK_ALL; pub const PROPDESC_VIEW_FLAGS = enum(i32) { DEFAULT = 0, CENTERALIGN = 1, RIGHTALIGN = 2, BEGINNEWGROUP = 4, FILLAREA = 8, SORTDESCENDING = 16, SHOWONLYIFPRESENT = 32, SHOWBYDEFAULT = 64, SHOWINPRIMARYLIST = 128, SHOWINSECONDARYLIST = 256, HIDELABEL = 512, HIDDEN = 2048, CANWRAP = 4096, MASK_ALL = 7167, }; pub const PDVF_DEFAULT = PROPDESC_VIEW_FLAGS.DEFAULT; pub const PDVF_CENTERALIGN = PROPDESC_VIEW_FLAGS.CENTERALIGN; pub const PDVF_RIGHTALIGN = PROPDESC_VIEW_FLAGS.RIGHTALIGN; pub const PDVF_BEGINNEWGROUP = PROPDESC_VIEW_FLAGS.BEGINNEWGROUP; pub const PDVF_FILLAREA = PROPDESC_VIEW_FLAGS.FILLAREA; pub const PDVF_SORTDESCENDING = PROPDESC_VIEW_FLAGS.SORTDESCENDING; pub const PDVF_SHOWONLYIFPRESENT = PROPDESC_VIEW_FLAGS.SHOWONLYIFPRESENT; pub const PDVF_SHOWBYDEFAULT = PROPDESC_VIEW_FLAGS.SHOWBYDEFAULT; pub const PDVF_SHOWINPRIMARYLIST = PROPDESC_VIEW_FLAGS.SHOWINPRIMARYLIST; pub const PDVF_SHOWINSECONDARYLIST = PROPDESC_VIEW_FLAGS.SHOWINSECONDARYLIST; pub const PDVF_HIDELABEL = PROPDESC_VIEW_FLAGS.HIDELABEL; pub const PDVF_HIDDEN = PROPDESC_VIEW_FLAGS.HIDDEN; pub const PDVF_CANWRAP = PROPDESC_VIEW_FLAGS.CANWRAP; pub const PDVF_MASK_ALL = PROPDESC_VIEW_FLAGS.MASK_ALL; pub const PROPDESC_DISPLAYTYPE = enum(i32) { STRING = 0, NUMBER = 1, BOOLEAN = 2, DATETIME = 3, ENUMERATED = 4, }; pub const PDDT_STRING = PROPDESC_DISPLAYTYPE.STRING; pub const PDDT_NUMBER = PROPDESC_DISPLAYTYPE.NUMBER; pub const PDDT_BOOLEAN = PROPDESC_DISPLAYTYPE.BOOLEAN; pub const PDDT_DATETIME = PROPDESC_DISPLAYTYPE.DATETIME; pub const PDDT_ENUMERATED = PROPDESC_DISPLAYTYPE.ENUMERATED; pub const PROPDESC_GROUPING_RANGE = enum(i32) { DISCRETE = 0, ALPHANUMERIC = 1, SIZE = 2, DYNAMIC = 3, DATE = 4, PERCENT = 5, ENUMERATED = 6, }; pub const PDGR_DISCRETE = PROPDESC_GROUPING_RANGE.DISCRETE; pub const PDGR_ALPHANUMERIC = PROPDESC_GROUPING_RANGE.ALPHANUMERIC; pub const PDGR_SIZE = PROPDESC_GROUPING_RANGE.SIZE; pub const PDGR_DYNAMIC = PROPDESC_GROUPING_RANGE.DYNAMIC; pub const PDGR_DATE = PROPDESC_GROUPING_RANGE.DATE; pub const PDGR_PERCENT = PROPDESC_GROUPING_RANGE.PERCENT; pub const PDGR_ENUMERATED = PROPDESC_GROUPING_RANGE.ENUMERATED; pub const PROPDESC_FORMAT_FLAGS = enum(i32) { DEFAULT = 0, PREFIXNAME = 1, FILENAME = 2, ALWAYSKB = 4, RESERVED_RIGHTTOLEFT = 8, SHORTTIME = 16, LONGTIME = 32, HIDETIME = 64, SHORTDATE = 128, LONGDATE = 256, HIDEDATE = 512, RELATIVEDATE = 1024, USEEDITINVITATION = 2048, READONLY = 4096, NOAUTOREADINGORDER = 8192, }; pub const PDFF_DEFAULT = PROPDESC_FORMAT_FLAGS.DEFAULT; pub const PDFF_PREFIXNAME = PROPDESC_FORMAT_FLAGS.PREFIXNAME; pub const PDFF_FILENAME = PROPDESC_FORMAT_FLAGS.FILENAME; pub const PDFF_ALWAYSKB = PROPDESC_FORMAT_FLAGS.ALWAYSKB; pub const PDFF_RESERVED_RIGHTTOLEFT = PROPDESC_FORMAT_FLAGS.RESERVED_RIGHTTOLEFT; pub const PDFF_SHORTTIME = PROPDESC_FORMAT_FLAGS.SHORTTIME; pub const PDFF_LONGTIME = PROPDESC_FORMAT_FLAGS.LONGTIME; pub const PDFF_HIDETIME = PROPDESC_FORMAT_FLAGS.HIDETIME; pub const PDFF_SHORTDATE = PROPDESC_FORMAT_FLAGS.SHORTDATE; pub const PDFF_LONGDATE = PROPDESC_FORMAT_FLAGS.LONGDATE; pub const PDFF_HIDEDATE = PROPDESC_FORMAT_FLAGS.HIDEDATE; pub const PDFF_RELATIVEDATE = PROPDESC_FORMAT_FLAGS.RELATIVEDATE; pub const PDFF_USEEDITINVITATION = PROPDESC_FORMAT_FLAGS.USEEDITINVITATION; pub const PDFF_READONLY = PROPDESC_FORMAT_FLAGS.READONLY; pub const PDFF_NOAUTOREADINGORDER = PROPDESC_FORMAT_FLAGS.NOAUTOREADINGORDER; pub const PROPDESC_SORTDESCRIPTION = enum(i32) { GENERAL = 0, A_Z = 1, LOWEST_HIGHEST = 2, SMALLEST_BIGGEST = 3, OLDEST_NEWEST = 4, }; pub const PDSD_GENERAL = PROPDESC_SORTDESCRIPTION.GENERAL; pub const PDSD_A_Z = PROPDESC_SORTDESCRIPTION.A_Z; pub const PDSD_LOWEST_HIGHEST = PROPDESC_SORTDESCRIPTION.LOWEST_HIGHEST; pub const PDSD_SMALLEST_BIGGEST = PROPDESC_SORTDESCRIPTION.SMALLEST_BIGGEST; pub const PDSD_OLDEST_NEWEST = PROPDESC_SORTDESCRIPTION.OLDEST_NEWEST; pub const PROPDESC_RELATIVEDESCRIPTION_TYPE = enum(i32) { GENERAL = 0, DATE = 1, SIZE = 2, COUNT = 3, REVISION = 4, LENGTH = 5, DURATION = 6, SPEED = 7, RATE = 8, RATING = 9, PRIORITY = 10, }; pub const PDRDT_GENERAL = PROPDESC_RELATIVEDESCRIPTION_TYPE.GENERAL; pub const PDRDT_DATE = PROPDESC_RELATIVEDESCRIPTION_TYPE.DATE; pub const PDRDT_SIZE = PROPDESC_RELATIVEDESCRIPTION_TYPE.SIZE; pub const PDRDT_COUNT = PROPDESC_RELATIVEDESCRIPTION_TYPE.COUNT; pub const PDRDT_REVISION = PROPDESC_RELATIVEDESCRIPTION_TYPE.REVISION; pub const PDRDT_LENGTH = PROPDESC_RELATIVEDESCRIPTION_TYPE.LENGTH; pub const PDRDT_DURATION = PROPDESC_RELATIVEDESCRIPTION_TYPE.DURATION; pub const PDRDT_SPEED = PROPDESC_RELATIVEDESCRIPTION_TYPE.SPEED; pub const PDRDT_RATE = PROPDESC_RELATIVEDESCRIPTION_TYPE.RATE; pub const PDRDT_RATING = PROPDESC_RELATIVEDESCRIPTION_TYPE.RATING; pub const PDRDT_PRIORITY = PROPDESC_RELATIVEDESCRIPTION_TYPE.PRIORITY; pub const PROPDESC_AGGREGATION_TYPE = enum(i32) { DEFAULT = 0, FIRST = 1, SUM = 2, AVERAGE = 3, DATERANGE = 4, UNION = 5, MAX = 6, MIN = 7, }; pub const PDAT_DEFAULT = PROPDESC_AGGREGATION_TYPE.DEFAULT; pub const PDAT_FIRST = PROPDESC_AGGREGATION_TYPE.FIRST; pub const PDAT_SUM = PROPDESC_AGGREGATION_TYPE.SUM; pub const PDAT_AVERAGE = PROPDESC_AGGREGATION_TYPE.AVERAGE; pub const PDAT_DATERANGE = PROPDESC_AGGREGATION_TYPE.DATERANGE; pub const PDAT_UNION = PROPDESC_AGGREGATION_TYPE.UNION; pub const PDAT_MAX = PROPDESC_AGGREGATION_TYPE.MAX; pub const PDAT_MIN = PROPDESC_AGGREGATION_TYPE.MIN; pub const PROPDESC_CONDITION_TYPE = enum(i32) { NONE = 0, STRING = 1, SIZE = 2, DATETIME = 3, BOOLEAN = 4, NUMBER = 5, }; pub const PDCOT_NONE = PROPDESC_CONDITION_TYPE.NONE; pub const PDCOT_STRING = PROPDESC_CONDITION_TYPE.STRING; pub const PDCOT_SIZE = PROPDESC_CONDITION_TYPE.SIZE; pub const PDCOT_DATETIME = PROPDESC_CONDITION_TYPE.DATETIME; pub const PDCOT_BOOLEAN = PROPDESC_CONDITION_TYPE.BOOLEAN; pub const PDCOT_NUMBER = PROPDESC_CONDITION_TYPE.NUMBER; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyDescription_Value = Guid.initString("6f79d558-3e96-4549-a1d1-7d75d2288814"); pub const IID_IPropertyDescription = &IID_IPropertyDescription_Value; pub const IPropertyDescription = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetPropertyKey: fn( self: *const IPropertyDescription, pkey: ?*PROPERTYKEY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetCanonicalName: fn( self: *const IPropertyDescription, ppszName: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyType: fn( self: *const IPropertyDescription, pvartype: ?*u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDisplayName: fn( self: *const IPropertyDescription, ppszName: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetEditInvitation: fn( self: *const IPropertyDescription, ppszInvite: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetTypeFlags: fn( self: *const IPropertyDescription, mask: PROPDESC_TYPE_FLAGS, ppdtFlags: ?*PROPDESC_TYPE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetViewFlags: fn( self: *const IPropertyDescription, ppdvFlags: ?*PROPDESC_VIEW_FLAGS, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultColumnWidth: fn( self: *const IPropertyDescription, pcxChars: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDisplayType: fn( self: *const IPropertyDescription, pdisplaytype: ?*PROPDESC_DISPLAYTYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetColumnState: fn( self: *const IPropertyDescription, pcsFlags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetGroupingRange: fn( self: *const IPropertyDescription, pgr: ?*PROPDESC_GROUPING_RANGE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetRelativeDescriptionType: fn( self: *const IPropertyDescription, prdt: ?*PROPDESC_RELATIVEDESCRIPTION_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetRelativeDescription: fn( self: *const IPropertyDescription, propvar1: ?*const PROPVARIANT, propvar2: ?*const PROPVARIANT, ppszDesc1: ?*?PWSTR, ppszDesc2: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetSortDescription: fn( self: *const IPropertyDescription, psd: ?*PROPDESC_SORTDESCRIPTION, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetSortDescriptionLabel: fn( self: *const IPropertyDescription, fDescending: BOOL, ppszDescription: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAggregationType: fn( self: *const IPropertyDescription, paggtype: ?*PROPDESC_AGGREGATION_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetConditionType: fn( self: *const IPropertyDescription, pcontype: ?*PROPDESC_CONDITION_TYPE, popDefault: ?*CONDITION_OPERATION, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetEnumTypeList: fn( self: *const IPropertyDescription, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CoerceToCanonicalValue: fn( self: *const IPropertyDescription, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FormatForDisplay: fn( self: *const IPropertyDescription, propvar: ?*const PROPVARIANT, pdfFlags: PROPDESC_FORMAT_FLAGS, ppszDisplay: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, IsValueCanonical: fn( self: *const IPropertyDescription, propvar: ?*const PROPVARIANT, ) 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 IPropertyDescription_GetPropertyKey(self: *const T, pkey: ?*PROPERTYKEY) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetPropertyKey(@ptrCast(*const IPropertyDescription, self), pkey); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetCanonicalName(self: *const T, ppszName: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetCanonicalName(@ptrCast(*const IPropertyDescription, self), ppszName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetPropertyType(self: *const T, pvartype: ?*u16) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetPropertyType(@ptrCast(*const IPropertyDescription, self), pvartype); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetDisplayName(self: *const T, ppszName: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetDisplayName(@ptrCast(*const IPropertyDescription, self), ppszName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetEditInvitation(self: *const T, ppszInvite: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetEditInvitation(@ptrCast(*const IPropertyDescription, self), ppszInvite); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetTypeFlags(self: *const T, mask: PROPDESC_TYPE_FLAGS, ppdtFlags: ?*PROPDESC_TYPE_FLAGS) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetTypeFlags(@ptrCast(*const IPropertyDescription, self), mask, ppdtFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetViewFlags(self: *const T, ppdvFlags: ?*PROPDESC_VIEW_FLAGS) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetViewFlags(@ptrCast(*const IPropertyDescription, self), ppdvFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetDefaultColumnWidth(self: *const T, pcxChars: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetDefaultColumnWidth(@ptrCast(*const IPropertyDescription, self), pcxChars); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetDisplayType(self: *const T, pdisplaytype: ?*PROPDESC_DISPLAYTYPE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetDisplayType(@ptrCast(*const IPropertyDescription, self), pdisplaytype); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetColumnState(self: *const T, pcsFlags: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetColumnState(@ptrCast(*const IPropertyDescription, self), pcsFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetGroupingRange(self: *const T, pgr: ?*PROPDESC_GROUPING_RANGE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetGroupingRange(@ptrCast(*const IPropertyDescription, self), pgr); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetRelativeDescriptionType(self: *const T, prdt: ?*PROPDESC_RELATIVEDESCRIPTION_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetRelativeDescriptionType(@ptrCast(*const IPropertyDescription, self), prdt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetRelativeDescription(self: *const T, propvar1: ?*const PROPVARIANT, propvar2: ?*const PROPVARIANT, ppszDesc1: ?*?PWSTR, ppszDesc2: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetRelativeDescription(@ptrCast(*const IPropertyDescription, self), propvar1, propvar2, ppszDesc1, ppszDesc2); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetSortDescription(self: *const T, psd: ?*PROPDESC_SORTDESCRIPTION) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetSortDescription(@ptrCast(*const IPropertyDescription, self), psd); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetSortDescriptionLabel(self: *const T, fDescending: BOOL, ppszDescription: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetSortDescriptionLabel(@ptrCast(*const IPropertyDescription, self), fDescending, ppszDescription); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetAggregationType(self: *const T, paggtype: ?*PROPDESC_AGGREGATION_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetAggregationType(@ptrCast(*const IPropertyDescription, self), paggtype); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetConditionType(self: *const T, pcontype: ?*PROPDESC_CONDITION_TYPE, popDefault: ?*CONDITION_OPERATION) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetConditionType(@ptrCast(*const IPropertyDescription, self), pcontype, popDefault); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_GetEnumTypeList(self: *const T, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).GetEnumTypeList(@ptrCast(*const IPropertyDescription, self), riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_CoerceToCanonicalValue(self: *const T, ppropvar: ?*PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).CoerceToCanonicalValue(@ptrCast(*const IPropertyDescription, self), ppropvar); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_FormatForDisplay(self: *const T, propvar: ?*const PROPVARIANT, pdfFlags: PROPDESC_FORMAT_FLAGS, ppszDisplay: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).FormatForDisplay(@ptrCast(*const IPropertyDescription, self), propvar, pdfFlags, ppszDisplay); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription_IsValueCanonical(self: *const T, propvar: ?*const PROPVARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription.VTable, self.vtable).IsValueCanonical(@ptrCast(*const IPropertyDescription, self), propvar); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.1' const IID_IPropertyDescription2_Value = Guid.initString("57d2eded-5062-400e-b107-5dae79fe57a6"); pub const IID_IPropertyDescription2 = &IID_IPropertyDescription2_Value; pub const IPropertyDescription2 = extern struct { pub const VTable = extern struct { base: IPropertyDescription.VTable, GetImageReferenceForValue: fn( self: *const IPropertyDescription2, propvar: ?*const PROPVARIANT, ppszImageRes: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPropertyDescription.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescription2_GetImageReferenceForValue(self: *const T, propvar: ?*const PROPVARIANT, ppszImageRes: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescription2.VTable, self.vtable).GetImageReferenceForValue(@ptrCast(*const IPropertyDescription2, self), propvar, ppszImageRes); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyDescriptionAliasInfo_Value = Guid.initString("f67104fc-2af9-46fd-b32d-243c1404f3d1"); pub const IID_IPropertyDescriptionAliasInfo = &IID_IPropertyDescriptionAliasInfo_Value; pub const IPropertyDescriptionAliasInfo = extern struct { pub const VTable = extern struct { base: IPropertyDescription.VTable, GetSortByAlias: fn( self: *const IPropertyDescriptionAliasInfo, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAdditionalSortByAliases: fn( self: *const IPropertyDescriptionAliasInfo, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPropertyDescription.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescriptionAliasInfo_GetSortByAlias(self: *const T, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionAliasInfo.VTable, self.vtable).GetSortByAlias(@ptrCast(*const IPropertyDescriptionAliasInfo, self), riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescriptionAliasInfo_GetAdditionalSortByAliases(self: *const T, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionAliasInfo.VTable, self.vtable).GetAdditionalSortByAliases(@ptrCast(*const IPropertyDescriptionAliasInfo, self), riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; pub const PROPDESC_SEARCHINFO_FLAGS = enum(i32) { DEFAULT = 0, ININVERTEDINDEX = 1, ISCOLUMN = 2, ISCOLUMNSPARSE = 4, ALWAYSINCLUDE = 8, USEFORTYPEAHEAD = 16, }; pub const PDSIF_DEFAULT = PROPDESC_SEARCHINFO_FLAGS.DEFAULT; pub const PDSIF_ININVERTEDINDEX = PROPDESC_SEARCHINFO_FLAGS.ININVERTEDINDEX; pub const PDSIF_ISCOLUMN = PROPDESC_SEARCHINFO_FLAGS.ISCOLUMN; pub const PDSIF_ISCOLUMNSPARSE = PROPDESC_SEARCHINFO_FLAGS.ISCOLUMNSPARSE; pub const PDSIF_ALWAYSINCLUDE = PROPDESC_SEARCHINFO_FLAGS.ALWAYSINCLUDE; pub const PDSIF_USEFORTYPEAHEAD = PROPDESC_SEARCHINFO_FLAGS.USEFORTYPEAHEAD; pub const PROPDESC_COLUMNINDEX_TYPE = enum(i32) { NONE = 0, ONDISK = 1, INMEMORY = 2, ONDEMAND = 3, ONDISKALL = 4, ONDISKVECTOR = 5, }; pub const PDCIT_NONE = PROPDESC_COLUMNINDEX_TYPE.NONE; pub const PDCIT_ONDISK = PROPDESC_COLUMNINDEX_TYPE.ONDISK; pub const PDCIT_INMEMORY = PROPDESC_COLUMNINDEX_TYPE.INMEMORY; pub const PDCIT_ONDEMAND = PROPDESC_COLUMNINDEX_TYPE.ONDEMAND; pub const PDCIT_ONDISKALL = PROPDESC_COLUMNINDEX_TYPE.ONDISKALL; pub const PDCIT_ONDISKVECTOR = PROPDESC_COLUMNINDEX_TYPE.ONDISKVECTOR; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyDescriptionSearchInfo_Value = Guid.initString("078f91bd-29a2-440f-924e-46a291524520"); pub const IID_IPropertyDescriptionSearchInfo = &IID_IPropertyDescriptionSearchInfo_Value; pub const IPropertyDescriptionSearchInfo = extern struct { pub const VTable = extern struct { base: IPropertyDescription.VTable, GetSearchInfoFlags: fn( self: *const IPropertyDescriptionSearchInfo, ppdsiFlags: ?*PROPDESC_SEARCHINFO_FLAGS, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetColumnIndexType: fn( self: *const IPropertyDescriptionSearchInfo, ppdciType: ?*PROPDESC_COLUMNINDEX_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetProjectionString: fn( self: *const IPropertyDescriptionSearchInfo, ppszProjection: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetMaxSize: fn( self: *const IPropertyDescriptionSearchInfo, pcbMaxSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPropertyDescription.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescriptionSearchInfo_GetSearchInfoFlags(self: *const T, ppdsiFlags: ?*PROPDESC_SEARCHINFO_FLAGS) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionSearchInfo.VTable, self.vtable).GetSearchInfoFlags(@ptrCast(*const IPropertyDescriptionSearchInfo, self), ppdsiFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescriptionSearchInfo_GetColumnIndexType(self: *const T, ppdciType: ?*PROPDESC_COLUMNINDEX_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionSearchInfo.VTable, self.vtable).GetColumnIndexType(@ptrCast(*const IPropertyDescriptionSearchInfo, self), ppdciType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescriptionSearchInfo_GetProjectionString(self: *const T, ppszProjection: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionSearchInfo.VTable, self.vtable).GetProjectionString(@ptrCast(*const IPropertyDescriptionSearchInfo, self), ppszProjection); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescriptionSearchInfo_GetMaxSize(self: *const T, pcbMaxSize: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionSearchInfo.VTable, self.vtable).GetMaxSize(@ptrCast(*const IPropertyDescriptionSearchInfo, self), pcbMaxSize); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.1' const IID_IPropertyDescriptionRelatedPropertyInfo_Value = Guid.initString("507393f4-2a3d-4a60-b59e-d9c75716c2dd"); pub const IID_IPropertyDescriptionRelatedPropertyInfo = &IID_IPropertyDescriptionRelatedPropertyInfo_Value; pub const IPropertyDescriptionRelatedPropertyInfo = extern struct { pub const VTable = extern struct { base: IPropertyDescription.VTable, GetRelatedProperty: fn( self: *const IPropertyDescriptionRelatedPropertyInfo, pszRelationshipName: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPropertyDescription.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescriptionRelatedPropertyInfo_GetRelatedProperty(self: *const T, pszRelationshipName: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionRelatedPropertyInfo.VTable, self.vtable).GetRelatedProperty(@ptrCast(*const IPropertyDescriptionRelatedPropertyInfo, self), pszRelationshipName, riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; pub const PROPDESC_ENUMFILTER = enum(i32) { ALL = 0, SYSTEM = 1, NONSYSTEM = 2, VIEWABLE = 3, QUERYABLE = 4, INFULLTEXTQUERY = 5, COLUMN = 6, }; pub const PDEF_ALL = PROPDESC_ENUMFILTER.ALL; pub const PDEF_SYSTEM = PROPDESC_ENUMFILTER.SYSTEM; pub const PDEF_NONSYSTEM = PROPDESC_ENUMFILTER.NONSYSTEM; pub const PDEF_VIEWABLE = PROPDESC_ENUMFILTER.VIEWABLE; pub const PDEF_QUERYABLE = PROPDESC_ENUMFILTER.QUERYABLE; pub const PDEF_INFULLTEXTQUERY = PROPDESC_ENUMFILTER.INFULLTEXTQUERY; pub const PDEF_COLUMN = PROPDESC_ENUMFILTER.COLUMN; // TODO: this type is limited to platform 'windows5.1.2600' const IID_IPropertySystem_Value = Guid.initString("ca724e8a-c3e6-442b-88a4-6fb0db8035a3"); pub const IID_IPropertySystem = &IID_IPropertySystem_Value; pub const IPropertySystem = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetPropertyDescription: fn( self: *const IPropertySystem, propkey: ?*const PROPERTYKEY, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyDescriptionByName: fn( self: *const IPropertySystem, pszCanonicalName: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyDescriptionListFromString: fn( self: *const IPropertySystem, pszPropList: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumeratePropertyDescriptions: fn( self: *const IPropertySystem, filterOn: PROPDESC_ENUMFILTER, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FormatForDisplay: fn( self: *const IPropertySystem, key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, pdff: PROPDESC_FORMAT_FLAGS, pszText: [*:0]u16, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FormatForDisplayAlloc: fn( self: *const IPropertySystem, key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, pdff: PROPDESC_FORMAT_FLAGS, ppszDisplay: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RegisterPropertySchema: fn( self: *const IPropertySystem, pszPath: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnregisterPropertySchema: fn( self: *const IPropertySystem, pszPath: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RefreshPropertySchema: fn( self: *const IPropertySystem, ) 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 IPropertySystem_GetPropertyDescription(self: *const T, propkey: ?*const PROPERTYKEY, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).GetPropertyDescription(@ptrCast(*const IPropertySystem, self), propkey, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertySystem_GetPropertyDescriptionByName(self: *const T, pszCanonicalName: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).GetPropertyDescriptionByName(@ptrCast(*const IPropertySystem, self), pszCanonicalName, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertySystem_GetPropertyDescriptionListFromString(self: *const T, pszPropList: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).GetPropertyDescriptionListFromString(@ptrCast(*const IPropertySystem, self), pszPropList, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertySystem_EnumeratePropertyDescriptions(self: *const T, filterOn: PROPDESC_ENUMFILTER, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).EnumeratePropertyDescriptions(@ptrCast(*const IPropertySystem, self), filterOn, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertySystem_FormatForDisplay(self: *const T, key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, pdff: PROPDESC_FORMAT_FLAGS, pszText: [*:0]u16, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).FormatForDisplay(@ptrCast(*const IPropertySystem, self), key, propvar, pdff, pszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertySystem_FormatForDisplayAlloc(self: *const T, key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, pdff: PROPDESC_FORMAT_FLAGS, ppszDisplay: ?*?PWSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).FormatForDisplayAlloc(@ptrCast(*const IPropertySystem, self), key, propvar, pdff, ppszDisplay); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertySystem_RegisterPropertySchema(self: *const T, pszPath: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).RegisterPropertySchema(@ptrCast(*const IPropertySystem, self), pszPath); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertySystem_UnregisterPropertySchema(self: *const T, pszPath: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).UnregisterPropertySchema(@ptrCast(*const IPropertySystem, self), pszPath); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertySystem_RefreshPropertySchema(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystem.VTable, self.vtable).RefreshPropertySchema(@ptrCast(*const IPropertySystem, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyDescriptionList_Value = Guid.initString("1f9fc1d0-c39b-4b26-817f-011967d3440e"); pub const IID_IPropertyDescriptionList = &IID_IPropertyDescriptionList_Value; pub const IPropertyDescriptionList = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetCount: fn( self: *const IPropertyDescriptionList, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAt: fn( self: *const IPropertyDescriptionList, iElem: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) 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 IPropertyDescriptionList_GetCount(self: *const T, pcElem: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionList.VTable, self.vtable).GetCount(@ptrCast(*const IPropertyDescriptionList, self), pcElem); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyDescriptionList_GetAt(self: *const T, iElem: u32, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyDescriptionList.VTable, self.vtable).GetAt(@ptrCast(*const IPropertyDescriptionList, self), iElem, riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPropertyStoreFactory_Value = Guid.initString("bc110b6d-57e8-4148-a9c6-91015ab2f3a5"); pub const IID_IPropertyStoreFactory = &IID_IPropertyStoreFactory_Value; pub const IPropertyStoreFactory = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetPropertyStore: fn( self: *const IPropertyStoreFactory, flags: GETPROPERTYSTOREFLAGS, pUnkFactory: ?*IUnknown, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyStoreForKeys: fn( self: *const IPropertyStoreFactory, rgKeys: ?*const PROPERTYKEY, cKeys: u32, flags: GETPROPERTYSTOREFLAGS, riid: ?*const Guid, ppv: ?*?*anyopaque, ) 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 IPropertyStoreFactory_GetPropertyStore(self: *const T, flags: GETPROPERTYSTOREFLAGS, pUnkFactory: ?*IUnknown, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStoreFactory.VTable, self.vtable).GetPropertyStore(@ptrCast(*const IPropertyStoreFactory, self), flags, pUnkFactory, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyStoreFactory_GetPropertyStoreForKeys(self: *const T, rgKeys: ?*const PROPERTYKEY, cKeys: u32, flags: GETPROPERTYSTOREFLAGS, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyStoreFactory.VTable, self.vtable).GetPropertyStoreForKeys(@ptrCast(*const IPropertyStoreFactory, self), rgKeys, cKeys, flags, riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IDelayedPropertyStoreFactory_Value = Guid.initString("40d4577f-e237-4bdb-bd69-58f089431b6a"); pub const IID_IDelayedPropertyStoreFactory = &IID_IDelayedPropertyStoreFactory_Value; pub const IDelayedPropertyStoreFactory = extern struct { pub const VTable = extern struct { base: IPropertyStoreFactory.VTable, GetDelayedPropertyStore: fn( self: *const IDelayedPropertyStoreFactory, flags: GETPROPERTYSTOREFLAGS, dwStoreId: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPropertyStoreFactory.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDelayedPropertyStoreFactory_GetDelayedPropertyStore(self: *const T, flags: GETPROPERTYSTOREFLAGS, dwStoreId: u32, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDelayedPropertyStoreFactory.VTable, self.vtable).GetDelayedPropertyStore(@ptrCast(*const IDelayedPropertyStoreFactory, self), flags, dwStoreId, riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; pub const _PERSIST_SPROPSTORE_FLAGS = enum(i32) { DEFAULT = 0, READONLY = 1, TREAT_NEW_VALUES_AS_DIRTY = 2, }; pub const FPSPS_DEFAULT = _PERSIST_SPROPSTORE_FLAGS.DEFAULT; pub const FPSPS_READONLY = _PERSIST_SPROPSTORE_FLAGS.READONLY; pub const FPSPS_TREAT_NEW_VALUES_AS_DIRTY = _PERSIST_SPROPSTORE_FLAGS.TREAT_NEW_VALUES_AS_DIRTY; pub const SERIALIZEDPROPSTORAGE = extern struct { placeholder: usize, // TODO: why is this type empty? }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_IPersistSerializedPropStorage_Value = Guid.initString("e318ad57-0aa0-450f-aca5-6fab7103d917"); pub const IID_IPersistSerializedPropStorage = &IID_IPersistSerializedPropStorage_Value; pub const IPersistSerializedPropStorage = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetFlags: fn( self: *const IPersistSerializedPropStorage, flags: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetPropertyStorage: fn( self: *const IPersistSerializedPropStorage, // TODO: what to do with BytesParamIndex 1? psps: ?*SERIALIZEDPROPSTORAGE, cb: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyStorage: fn( self: *const IPersistSerializedPropStorage, ppsps: ?*?*SERIALIZEDPROPSTORAGE, pcb: ?*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 IPersistSerializedPropStorage_SetFlags(self: *const T, flags: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistSerializedPropStorage.VTable, self.vtable).SetFlags(@ptrCast(*const IPersistSerializedPropStorage, self), flags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistSerializedPropStorage_SetPropertyStorage(self: *const T, psps: ?*SERIALIZEDPROPSTORAGE, cb: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistSerializedPropStorage.VTable, self.vtable).SetPropertyStorage(@ptrCast(*const IPersistSerializedPropStorage, self), psps, cb); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistSerializedPropStorage_GetPropertyStorage(self: *const T, ppsps: ?*?*SERIALIZEDPROPSTORAGE, pcb: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistSerializedPropStorage.VTable, self.vtable).GetPropertyStorage(@ptrCast(*const IPersistSerializedPropStorage, self), ppsps, pcb); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.1' const IID_IPersistSerializedPropStorage2_Value = Guid.initString("77effa68-4f98-4366-ba72-573b3d880571"); pub const IID_IPersistSerializedPropStorage2 = &IID_IPersistSerializedPropStorage2_Value; pub const IPersistSerializedPropStorage2 = extern struct { pub const VTable = extern struct { base: IPersistSerializedPropStorage.VTable, GetPropertyStorageSize: fn( self: *const IPersistSerializedPropStorage2, pcb: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyStorageBuffer: fn( self: *const IPersistSerializedPropStorage2, // TODO: what to do with BytesParamIndex 1? psps: ?*SERIALIZEDPROPSTORAGE, cb: u32, pcbWritten: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IPersistSerializedPropStorage.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistSerializedPropStorage2_GetPropertyStorageSize(self: *const T, pcb: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistSerializedPropStorage2.VTable, self.vtable).GetPropertyStorageSize(@ptrCast(*const IPersistSerializedPropStorage2, self), pcb); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPersistSerializedPropStorage2_GetPropertyStorageBuffer(self: *const T, psps: ?*SERIALIZEDPROPSTORAGE, cb: u32, pcbWritten: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPersistSerializedPropStorage2.VTable, self.vtable).GetPropertyStorageBuffer(@ptrCast(*const IPersistSerializedPropStorage2, self), psps, cb, pcbWritten); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IPropertySystemChangeNotify_Value = Guid.initString("fa955fd9-38be-4879-a6ce-824cf52d609f"); pub const IID_IPropertySystemChangeNotify = &IID_IPropertySystemChangeNotify_Value; pub const IPropertySystemChangeNotify = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SchemaRefreshed: fn( self: *const IPropertySystemChangeNotify, ) 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 IPropertySystemChangeNotify_SchemaRefreshed(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertySystemChangeNotify.VTable, self.vtable).SchemaRefreshed(@ptrCast(*const IPropertySystemChangeNotify, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows6.0.6000' const IID_ICreateObject_Value = Guid.initString("75121952-e0d0-43e5-9380-1d80483acf72"); pub const IID_ICreateObject = &IID_ICreateObject_Value; pub const ICreateObject = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, CreateObject: fn( self: *const ICreateObject, clsid: ?*const Guid, pUnkOuter: ?*IUnknown, riid: ?*const Guid, ppv: ?*?*anyopaque, ) 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 ICreateObject_CreateObject(self: *const T, clsid: ?*const Guid, pUnkOuter: ?*IUnknown, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const ICreateObject.VTable, self.vtable).CreateObject(@ptrCast(*const ICreateObject, self), clsid, pUnkOuter, riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; pub const PSTIME_FLAGS = enum(i32) { UTC = 0, LOCAL = 1, }; pub const PSTF_UTC = PSTIME_FLAGS.UTC; pub const PSTF_LOCAL = PSTIME_FLAGS.LOCAL; pub const PROPVAR_COMPARE_UNIT = enum(i32) { DEFAULT = 0, SECOND = 1, MINUTE = 2, HOUR = 3, DAY = 4, MONTH = 5, YEAR = 6, }; pub const PVCU_DEFAULT = PROPVAR_COMPARE_UNIT.DEFAULT; pub const PVCU_SECOND = PROPVAR_COMPARE_UNIT.SECOND; pub const PVCU_MINUTE = PROPVAR_COMPARE_UNIT.MINUTE; pub const PVCU_HOUR = PROPVAR_COMPARE_UNIT.HOUR; pub const PVCU_DAY = PROPVAR_COMPARE_UNIT.DAY; pub const PVCU_MONTH = PROPVAR_COMPARE_UNIT.MONTH; pub const PVCU_YEAR = PROPVAR_COMPARE_UNIT.YEAR; pub const PROPVAR_COMPARE_FLAGS = enum(i32) { DEFAULT = 0, TREATEMPTYASGREATERTHAN = 1, USESTRCMP = 2, USESTRCMPC = 4, USESTRCMPI = 8, USESTRCMPIC = 16, DIGITSASNUMBERS_CASESENSITIVE = 32, }; pub const PVCF_DEFAULT = PROPVAR_COMPARE_FLAGS.DEFAULT; pub const PVCF_TREATEMPTYASGREATERTHAN = PROPVAR_COMPARE_FLAGS.TREATEMPTYASGREATERTHAN; pub const PVCF_USESTRCMP = PROPVAR_COMPARE_FLAGS.USESTRCMP; pub const PVCF_USESTRCMPC = PROPVAR_COMPARE_FLAGS.USESTRCMPC; pub const PVCF_USESTRCMPI = PROPVAR_COMPARE_FLAGS.USESTRCMPI; pub const PVCF_USESTRCMPIC = PROPVAR_COMPARE_FLAGS.USESTRCMPIC; pub const PVCF_DIGITSASNUMBERS_CASESENSITIVE = PROPVAR_COMPARE_FLAGS.DIGITSASNUMBERS_CASESENSITIVE; pub const PROPVAR_CHANGE_FLAGS = enum(i32) { DEFAULT = 0, NOVALUEPROP = 1, ALPHABOOL = 2, NOUSEROVERRIDE = 4, LOCALBOOL = 8, NOHEXSTRING = 16, }; pub const PVCHF_DEFAULT = PROPVAR_CHANGE_FLAGS.DEFAULT; pub const PVCHF_NOVALUEPROP = PROPVAR_CHANGE_FLAGS.NOVALUEPROP; pub const PVCHF_ALPHABOOL = PROPVAR_CHANGE_FLAGS.ALPHABOOL; pub const PVCHF_NOUSEROVERRIDE = PROPVAR_CHANGE_FLAGS.NOUSEROVERRIDE; pub const PVCHF_LOCALBOOL = PROPVAR_CHANGE_FLAGS.LOCALBOOL; pub const PVCHF_NOHEXSTRING = PROPVAR_CHANGE_FLAGS.NOHEXSTRING; pub const DRAWPROGRESSFLAGS = enum(i32) { NONE = 0, MARQUEE = 1, MARQUEE_COMPLETE = 2, ERROR = 4, WARNING = 8, STOPPED = 16, }; pub const DPF_NONE = DRAWPROGRESSFLAGS.NONE; pub const DPF_MARQUEE = DRAWPROGRESSFLAGS.MARQUEE; pub const DPF_MARQUEE_COMPLETE = DRAWPROGRESSFLAGS.MARQUEE_COMPLETE; pub const DPF_ERROR = DRAWPROGRESSFLAGS.ERROR; pub const DPF_WARNING = DRAWPROGRESSFLAGS.WARNING; pub const DPF_STOPPED = DRAWPROGRESSFLAGS.STOPPED; pub const SYNC_TRANSFER_STATUS = enum(i32) { NONE = 0, NEEDSUPLOAD = 1, NEEDSDOWNLOAD = 2, TRANSFERRING = 4, PAUSED = 8, HASERROR = 16, FETCHING_METADATA = 32, USER_REQUESTED_REFRESH = 64, HASWARNING = 128, EXCLUDED = 256, INCOMPLETE = 512, PLACEHOLDER_IFEMPTY = 1024, }; pub const STS_NONE = SYNC_TRANSFER_STATUS.NONE; pub const STS_NEEDSUPLOAD = SYNC_TRANSFER_STATUS.NEEDSUPLOAD; pub const STS_NEEDSDOWNLOAD = SYNC_TRANSFER_STATUS.NEEDSDOWNLOAD; pub const STS_TRANSFERRING = SYNC_TRANSFER_STATUS.TRANSFERRING; pub const STS_PAUSED = SYNC_TRANSFER_STATUS.PAUSED; pub const STS_HASERROR = SYNC_TRANSFER_STATUS.HASERROR; pub const STS_FETCHING_METADATA = SYNC_TRANSFER_STATUS.FETCHING_METADATA; pub const STS_USER_REQUESTED_REFRESH = SYNC_TRANSFER_STATUS.USER_REQUESTED_REFRESH; pub const STS_HASWARNING = SYNC_TRANSFER_STATUS.HASWARNING; pub const STS_EXCLUDED = SYNC_TRANSFER_STATUS.EXCLUDED; pub const STS_INCOMPLETE = SYNC_TRANSFER_STATUS.INCOMPLETE; pub const STS_PLACEHOLDER_IFEMPTY = SYNC_TRANSFER_STATUS.PLACEHOLDER_IFEMPTY; pub const PLACEHOLDER_STATES = enum(i32) { NONE = 0, MARKED_FOR_OFFLINE_AVAILABILITY = 1, FULL_PRIMARY_STREAM_AVAILABLE = 2, CREATE_FILE_ACCESSIBLE = 4, CLOUDFILE_PLACEHOLDER = 8, DEFAULT = 7, ALL = 15, }; pub const PS_NONE = PLACEHOLDER_STATES.NONE; pub const PS_MARKED_FOR_OFFLINE_AVAILABILITY = PLACEHOLDER_STATES.MARKED_FOR_OFFLINE_AVAILABILITY; pub const PS_FULL_PRIMARY_STREAM_AVAILABLE = PLACEHOLDER_STATES.FULL_PRIMARY_STREAM_AVAILABLE; pub const PS_CREATE_FILE_ACCESSIBLE = PLACEHOLDER_STATES.CREATE_FILE_ACCESSIBLE; pub const PS_CLOUDFILE_PLACEHOLDER = PLACEHOLDER_STATES.CLOUDFILE_PLACEHOLDER; pub const PS_DEFAULT = PLACEHOLDER_STATES.DEFAULT; pub const PS_ALL = PLACEHOLDER_STATES.ALL; pub const PROPERTYUI_NAME_FLAGS = enum(i32) { DEFAULT = 0, MNEMONIC = 1, }; pub const PUIFNF_DEFAULT = PROPERTYUI_NAME_FLAGS.DEFAULT; pub const PUIFNF_MNEMONIC = PROPERTYUI_NAME_FLAGS.MNEMONIC; pub const PROPERTYUI_FLAGS = enum(i32) { DEFAULT = 0, RIGHTALIGN = 1, NOLABELININFOTIP = 2, }; pub const PUIF_DEFAULT = PROPERTYUI_FLAGS.DEFAULT; pub const PUIF_RIGHTALIGN = PROPERTYUI_FLAGS.RIGHTALIGN; pub const PUIF_NOLABELININFOTIP = PROPERTYUI_FLAGS.NOLABELININFOTIP; pub const PROPERTYUI_FORMAT_FLAGS = enum(i32) { DEFAULT = 0, RIGHTTOLEFT = 1, SHORTFORMAT = 2, NOTIME = 4, FRIENDLYDATE = 8, }; pub const PUIFFDF_DEFAULT = PROPERTYUI_FORMAT_FLAGS.DEFAULT; pub const PUIFFDF_RIGHTTOLEFT = PROPERTYUI_FORMAT_FLAGS.RIGHTTOLEFT; pub const PUIFFDF_SHORTFORMAT = PROPERTYUI_FORMAT_FLAGS.SHORTFORMAT; pub const PUIFFDF_NOTIME = PROPERTYUI_FORMAT_FLAGS.NOTIME; pub const PUIFFDF_FRIENDLYDATE = PROPERTYUI_FORMAT_FLAGS.FRIENDLYDATE; // TODO: this type is limited to platform 'windows5.0' const IID_IPropertyUI_Value = Guid.initString("757a7d9f-919a-4118-99d7-dbb208c8cc66"); pub const IID_IPropertyUI = &IID_IPropertyUI_Value; pub const IPropertyUI = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, ParsePropertyName: fn( self: *const IPropertyUI, pszName: ?[*:0]const u16, pfmtid: ?*Guid, ppid: ?*u32, pchEaten: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetCannonicalName: fn( self: *const IPropertyUI, fmtid: ?*const Guid, pid: u32, pwszText: [*:0]u16, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDisplayName: fn( self: *const IPropertyUI, fmtid: ?*const Guid, pid: u32, flags: PROPERTYUI_NAME_FLAGS, pwszText: [*:0]u16, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyDescription: fn( self: *const IPropertyUI, fmtid: ?*const Guid, pid: u32, pwszText: [*:0]u16, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultWidth: fn( self: *const IPropertyUI, fmtid: ?*const Guid, pid: u32, pcxChars: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFlags: fn( self: *const IPropertyUI, fmtid: ?*const Guid, pid: u32, pflags: ?*PROPERTYUI_FLAGS, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FormatForDisplay: fn( self: *const IPropertyUI, fmtid: ?*const Guid, pid: u32, ppropvar: ?*const PROPVARIANT, puiff: PROPERTYUI_FORMAT_FLAGS, pwszText: [*:0]u16, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetHelpInfo: fn( self: *const IPropertyUI, fmtid: ?*const Guid, pid: u32, pwszHelpFile: [*:0]u16, cch: u32, puHelpID: ?*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 IPropertyUI_ParsePropertyName(self: *const T, pszName: ?[*:0]const u16, pfmtid: ?*Guid, ppid: ?*u32, pchEaten: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyUI.VTable, self.vtable).ParsePropertyName(@ptrCast(*const IPropertyUI, self), pszName, pfmtid, ppid, pchEaten); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyUI_GetCannonicalName(self: *const T, fmtid: ?*const Guid, pid: u32, pwszText: [*:0]u16, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyUI.VTable, self.vtable).GetCannonicalName(@ptrCast(*const IPropertyUI, self), fmtid, pid, pwszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyUI_GetDisplayName(self: *const T, fmtid: ?*const Guid, pid: u32, flags: PROPERTYUI_NAME_FLAGS, pwszText: [*:0]u16, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyUI.VTable, self.vtable).GetDisplayName(@ptrCast(*const IPropertyUI, self), fmtid, pid, flags, pwszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyUI_GetPropertyDescription(self: *const T, fmtid: ?*const Guid, pid: u32, pwszText: [*:0]u16, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyUI.VTable, self.vtable).GetPropertyDescription(@ptrCast(*const IPropertyUI, self), fmtid, pid, pwszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyUI_GetDefaultWidth(self: *const T, fmtid: ?*const Guid, pid: u32, pcxChars: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyUI.VTable, self.vtable).GetDefaultWidth(@ptrCast(*const IPropertyUI, self), fmtid, pid, pcxChars); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyUI_GetFlags(self: *const T, fmtid: ?*const Guid, pid: u32, pflags: ?*PROPERTYUI_FLAGS) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyUI.VTable, self.vtable).GetFlags(@ptrCast(*const IPropertyUI, self), fmtid, pid, pflags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyUI_FormatForDisplay(self: *const T, fmtid: ?*const Guid, pid: u32, ppropvar: ?*const PROPVARIANT, puiff: PROPERTYUI_FORMAT_FLAGS, pwszText: [*:0]u16, cchText: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyUI.VTable, self.vtable).FormatForDisplay(@ptrCast(*const IPropertyUI, self), fmtid, pid, ppropvar, puiff, pwszText, cchText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPropertyUI_GetHelpInfo(self: *const T, fmtid: ?*const Guid, pid: u32, pwszHelpFile: [*:0]u16, cch: u32, puHelpID: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPropertyUI.VTable, self.vtable).GetHelpInfo(@ptrCast(*const IPropertyUI, self), fmtid, pid, pwszHelpFile, cch, puHelpID); } };} pub usingnamespace MethodMixin(@This()); }; pub const PDOPSTATUS = enum(i32) { RUNNING = 1, PAUSED = 2, CANCELLED = 3, STOPPED = 4, ERRORS = 5, }; pub const PDOPS_RUNNING = PDOPSTATUS.RUNNING; pub const PDOPS_PAUSED = PDOPSTATUS.PAUSED; pub const PDOPS_CANCELLED = PDOPSTATUS.CANCELLED; pub const PDOPS_STOPPED = PDOPSTATUS.STOPPED; pub const PDOPS_ERRORS = PDOPSTATUS.ERRORS; pub const SYNC_ENGINE_STATE_FLAGS = enum(i32) { NONE = 0, SERVICE_QUOTA_NEARING_LIMIT = 1, SERVICE_QUOTA_EXCEEDED_LIMIT = 2, AUTHENTICATION_ERROR = 4, PAUSED_DUE_TO_METERED_NETWORK = 8, PAUSED_DUE_TO_DISK_SPACE_FULL = 16, PAUSED_DUE_TO_CLIENT_POLICY = 32, PAUSED_DUE_TO_SERVICE_POLICY = 64, SERVICE_UNAVAILABLE = 128, PAUSED_DUE_TO_USER_REQUEST = 256, ALL_FLAGS = 511, }; pub const SESF_NONE = SYNC_ENGINE_STATE_FLAGS.NONE; pub const SESF_SERVICE_QUOTA_NEARING_LIMIT = SYNC_ENGINE_STATE_FLAGS.SERVICE_QUOTA_NEARING_LIMIT; pub const SESF_SERVICE_QUOTA_EXCEEDED_LIMIT = SYNC_ENGINE_STATE_FLAGS.SERVICE_QUOTA_EXCEEDED_LIMIT; pub const SESF_AUTHENTICATION_ERROR = SYNC_ENGINE_STATE_FLAGS.AUTHENTICATION_ERROR; pub const SESF_PAUSED_DUE_TO_METERED_NETWORK = SYNC_ENGINE_STATE_FLAGS.PAUSED_DUE_TO_METERED_NETWORK; pub const SESF_PAUSED_DUE_TO_DISK_SPACE_FULL = SYNC_ENGINE_STATE_FLAGS.PAUSED_DUE_TO_DISK_SPACE_FULL; pub const SESF_PAUSED_DUE_TO_CLIENT_POLICY = SYNC_ENGINE_STATE_FLAGS.PAUSED_DUE_TO_CLIENT_POLICY; pub const SESF_PAUSED_DUE_TO_SERVICE_POLICY = SYNC_ENGINE_STATE_FLAGS.PAUSED_DUE_TO_SERVICE_POLICY; pub const SESF_SERVICE_UNAVAILABLE = SYNC_ENGINE_STATE_FLAGS.SERVICE_UNAVAILABLE; pub const SESF_PAUSED_DUE_TO_USER_REQUEST = SYNC_ENGINE_STATE_FLAGS.PAUSED_DUE_TO_USER_REQUEST; pub const SESF_ALL_FLAGS = SYNC_ENGINE_STATE_FLAGS.ALL_FLAGS; pub const PROPPRG = packed struct { flPrg: u16, flPrgInit: u16, achTitle: [30]CHAR, achCmdLine: [128]CHAR, achWorkDir: [64]CHAR, wHotKey: u16, achIconFile: [80]CHAR, wIconIndex: u16, dwEnhModeFlags: u32, dwRealModeFlags: u32, achOtherFile: [80]CHAR, achPIFFile: [260]CHAR, }; //-------------------------------------------------------------------------------- // Section: Functions (227) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows8.0' pub extern "PROPSYS" fn PropVariantToWinRTPropertyValue( propvar: ?*const PROPVARIANT, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "PROPSYS" fn WinRTPropertyValueToPropVariant( punkPropertyValue: ?*IUnknown, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "PROPSYS" fn PSFormatForDisplay( propkey: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, pdfFlags: PROPDESC_FORMAT_FLAGS, pwszText: [*:0]u16, cchText: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "PROPSYS" fn PSFormatForDisplayAlloc( key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, pdff: PROPDESC_FORMAT_FLAGS, ppszDisplay: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "PROPSYS" fn PSFormatPropertyValue( pps: ?*IPropertyStore, ppd: ?*IPropertyDescription, pdff: PROPDESC_FORMAT_FLAGS, ppszDisplay: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSGetImageReferenceForValue( propkey: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, ppszImageRes: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSStringFromPropertyKey( pkey: ?*const PROPERTYKEY, psz: [*:0]u16, cch: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSPropertyKeyFromString( pszString: ?[*:0]const u16, pkey: ?*PROPERTYKEY, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCreateMemoryPropertyStore( riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCreateDelayedMultiplexPropertyStore( flags: GETPROPERTYSTOREFLAGS, pdpsf: ?*IDelayedPropertyStoreFactory, rgStoreIds: [*]const u32, cStores: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCreateMultiplexPropertyStore( prgpunkStores: [*]?*IUnknown, cStores: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCreatePropertyChangeArray( rgpropkey: ?[*]const PROPERTYKEY, rgflags: ?[*]const PKA_FLAGS, rgpropvar: ?[*]const PROPVARIANT, cChanges: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCreateSimplePropertyChange( flags: PKA_FLAGS, key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetPropertyDescription( propkey: ?*const PROPERTYKEY, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetPropertyDescriptionByName( pszCanonicalName: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSLookupPropertyHandlerCLSID( pszFilePath: ?[*:0]const u16, pclsid: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetItemPropertyHandler( punkItem: ?*IUnknown, fReadWrite: BOOL, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetItemPropertyHandlerWithCreateObject( punkItem: ?*IUnknown, fReadWrite: BOOL, punkCreateObject: ?*IUnknown, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetPropertyValue( pps: ?*IPropertyStore, ppd: ?*IPropertyDescription, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSSetPropertyValue( pps: ?*IPropertyStore, ppd: ?*IPropertyDescription, propvar: ?*const PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSRegisterPropertySchema( pszPath: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSUnregisterPropertySchema( pszPath: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSRefreshPropertySchema( ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSEnumeratePropertyDescriptions( filterOn: PROPDESC_ENUMFILTER, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetPropertyKeyFromName( pszName: ?[*:0]const u16, ppropkey: ?*PROPERTYKEY, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetNameFromPropertyKey( propkey: ?*const PROPERTYKEY, ppszCanonicalName: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCoerceToCanonicalValue( key: ?*const PROPERTYKEY, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetPropertyDescriptionListFromString( pszPropList: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCreatePropertyStoreFromPropertySetStorage( ppss: ?*IPropertySetStorage, grfMode: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCreatePropertyStoreFromObject( punk: ?*IUnknown, grfMode: u32, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSCreateAdapterFromPropertyStore( pps: ?*IPropertyStore, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetPropertySystem( riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetPropertyFromPropertyStorage( // TODO: what to do with BytesParamIndex 1? psps: ?*SERIALIZEDPROPSTORAGE, cb: u32, rpkey: ?*const PROPERTYKEY, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PSGetNamedPropertyFromPropertyStorage( // TODO: what to do with BytesParamIndex 1? psps: ?*SERIALIZEDPROPSTORAGE, cb: u32, pszName: ?[*:0]const u16, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadType( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, @"var": ?*VARIANT, type: u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadStr( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: [*:0]u16, characterCount: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadStrAlloc( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadBSTR( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteStr( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteBSTR( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadInt( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteInt( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadSHORT( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteSHORT( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadLONG( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteLONG( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadDWORD( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteDWORD( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadBOOL( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteBOOL( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadPOINTL( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*POINTL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WritePOINTL( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*const POINTL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadPOINTS( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*POINTS, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WritePOINTS( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*const POINTS, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadRECTL( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*RECTL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteRECTL( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*const RECTL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadStream( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*?*IStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteStream( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*IStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_Delete( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadULONGLONG( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*u64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteULONGLONG( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: u64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadUnknown( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteUnknown( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, punk: ?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadGUID( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WriteGUID( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*const Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_ReadPropertyKey( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*PROPERTYKEY, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "PROPSYS" fn PSPropertyBag_WritePropertyKey( propBag: ?*IPropertyBag, propName: ?[*:0]const u16, value: ?*const PROPERTYKEY, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromResource( hinst: ?HINSTANCE, id: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromBuffer( // TODO: what to do with BytesParamIndex 1? pv: ?*const anyopaque, cb: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromCLSID( clsid: ?*const Guid, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromGUIDAsString( guid: ?*const Guid, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromFileTime( pftIn: ?*const FILETIME, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromPropVariantVectorElem( propvarIn: ?*const PROPVARIANT, iElem: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantVectorFromPropVariant( propvarSingle: ?*const PROPVARIANT, ppropvarVector: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromStrRet( pstrret: ?*STRRET, pidl: ?*ITEMIDLIST, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromBooleanVector( prgf: ?[*]const BOOL, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromInt16Vector( prgn: ?[*]const i16, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromUInt16Vector( prgn: ?[*:0]const u16, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromInt32Vector( prgn: ?[*]const i32, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromUInt32Vector( prgn: ?[*]const u32, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromInt64Vector( prgn: ?[*]const i64, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromUInt64Vector( prgn: ?[*]const u64, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromDoubleVector( prgn: ?[*]const f64, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromFileTimeVector( prgft: ?[*]const FILETIME, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromStringVector( prgsz: ?[*]?PWSTR, cElems: u32, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitPropVariantFromStringAsVector( psz: ?[*:0]const u16, ppropvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToBooleanWithDefault( propvarIn: ?*const PROPVARIANT, fDefault: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt16WithDefault( propvarIn: ?*const PROPVARIANT, iDefault: i16, ) callconv(@import("std").os.windows.WINAPI) i16; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt16WithDefault( propvarIn: ?*const PROPVARIANT, uiDefault: u16, ) callconv(@import("std").os.windows.WINAPI) u16; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt32WithDefault( propvarIn: ?*const PROPVARIANT, lDefault: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt32WithDefault( propvarIn: ?*const PROPVARIANT, ulDefault: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt64WithDefault( propvarIn: ?*const PROPVARIANT, llDefault: i64, ) callconv(@import("std").os.windows.WINAPI) i64; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt64WithDefault( propvarIn: ?*const PROPVARIANT, ullDefault: u64, ) callconv(@import("std").os.windows.WINAPI) u64; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToDoubleWithDefault( propvarIn: ?*const PROPVARIANT, dblDefault: f64, ) callconv(@import("std").os.windows.WINAPI) f64; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToStringWithDefault( propvarIn: ?*const PROPVARIANT, pszDefault: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) ?PWSTR; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToBoolean( propvarIn: ?*const PROPVARIANT, pfRet: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt16( propvarIn: ?*const PROPVARIANT, piRet: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt16( propvarIn: ?*const PROPVARIANT, puiRet: ?*u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt32( propvarIn: ?*const PROPVARIANT, plRet: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt32( propvarIn: ?*const PROPVARIANT, pulRet: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt64( propvarIn: ?*const PROPVARIANT, pllRet: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt64( propvarIn: ?*const PROPVARIANT, pullRet: ?*u64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToDouble( propvarIn: ?*const PROPVARIANT, pdblRet: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToBuffer( propvar: ?*const PROPVARIANT, // TODO: what to do with BytesParamIndex 2? pv: ?*anyopaque, cb: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToString( propvar: ?*const PROPVARIANT, psz: [*:0]u16, cch: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToGUID( propvar: ?*const PROPVARIANT, pguid: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToStringAlloc( propvar: ?*const PROPVARIANT, ppszOut: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToBSTR( propvar: ?*const PROPVARIANT, pbstrOut: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToStrRet( propvar: ?*const PROPVARIANT, pstrret: ?*STRRET, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToFileTime( propvar: ?*const PROPVARIANT, pstfOut: PSTIME_FLAGS, pftOut: ?*FILETIME, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetElementCount( propvar: ?*const PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToBooleanVector( propvar: ?*const PROPVARIANT, prgf: [*]BOOL, crgf: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt16Vector( propvar: ?*const PROPVARIANT, prgn: [*]i16, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt16Vector( propvar: ?*const PROPVARIANT, prgn: [*:0]u16, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt32Vector( propvar: ?*const PROPVARIANT, prgn: [*]i32, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt32Vector( propvar: ?*const PROPVARIANT, prgn: [*]u32, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt64Vector( propvar: ?*const PROPVARIANT, prgn: [*]i64, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt64Vector( propvar: ?*const PROPVARIANT, prgn: [*]u64, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToDoubleVector( propvar: ?*const PROPVARIANT, prgn: [*]f64, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToFileTimeVector( propvar: ?*const PROPVARIANT, prgft: [*]FILETIME, crgft: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToStringVector( propvar: ?*const PROPVARIANT, prgsz: [*]?PWSTR, crgsz: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToBooleanVectorAlloc( propvar: ?*const PROPVARIANT, pprgf: ?*?*BOOL, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt16VectorAlloc( propvar: ?*const PROPVARIANT, pprgn: ?*?*i16, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt16VectorAlloc( propvar: ?*const PROPVARIANT, pprgn: ?*?*u16, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt32VectorAlloc( propvar: ?*const PROPVARIANT, pprgn: ?*?*i32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt32VectorAlloc( propvar: ?*const PROPVARIANT, pprgn: ?*?*u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToInt64VectorAlloc( propvar: ?*const PROPVARIANT, pprgn: ?*?*i64, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToUInt64VectorAlloc( propvar: ?*const PROPVARIANT, pprgn: ?*?*u64, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToDoubleVectorAlloc( propvar: ?*const PROPVARIANT, pprgn: ?*?*f64, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToFileTimeVectorAlloc( propvar: ?*const PROPVARIANT, pprgft: ?*?*FILETIME, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantToStringVectorAlloc( propvar: ?*const PROPVARIANT, pprgsz: ?*?*?PWSTR, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetBooleanElem( propvar: ?*const PROPVARIANT, iElem: u32, pfVal: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetInt16Elem( propvar: ?*const PROPVARIANT, iElem: u32, pnVal: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetUInt16Elem( propvar: ?*const PROPVARIANT, iElem: u32, pnVal: ?*u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetInt32Elem( propvar: ?*const PROPVARIANT, iElem: u32, pnVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetUInt32Elem( propvar: ?*const PROPVARIANT, iElem: u32, pnVal: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetInt64Elem( propvar: ?*const PROPVARIANT, iElem: u32, pnVal: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetUInt64Elem( propvar: ?*const PROPVARIANT, iElem: u32, pnVal: ?*u64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetDoubleElem( propvar: ?*const PROPVARIANT, iElem: u32, pnVal: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetFileTimeElem( propvar: ?*const PROPVARIANT, iElem: u32, pftVal: ?*FILETIME, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantGetStringElem( propvar: ?*const PROPVARIANT, iElem: u32, ppszVal: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn ClearPropVariantArray( rgPropVar: [*]PROPVARIANT, cVars: u32, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantCompareEx( propvar1: ?*const PROPVARIANT, propvar2: ?*const PROPVARIANT, unit: PROPVAR_COMPARE_UNIT, flags: PROPVAR_COMPARE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn PropVariantChangeType( ppropvarDest: ?*PROPVARIANT, propvarSrc: ?*const PROPVARIANT, flags: PROPVAR_CHANGE_FLAGS, vt: u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "PROPSYS" fn PropVariantToVariant( pPropVar: ?*const PROPVARIANT, pVar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "PROPSYS" fn VariantToPropVariant( pVar: ?*const VARIANT, pPropVar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromResource( hinst: ?HINSTANCE, id: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromBuffer( // TODO: what to do with BytesParamIndex 1? pv: ?*const anyopaque, cb: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromGUIDAsString( guid: ?*const Guid, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromFileTime( pft: ?*const FILETIME, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromFileTimeArray( prgft: ?[*]const FILETIME, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromStrRet( pstrret: ?*STRRET, pidl: ?*ITEMIDLIST, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromVariantArrayElem( varIn: ?*const VARIANT, iElem: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromBooleanArray( prgf: [*]const BOOL, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromInt16Array( prgn: [*]const i16, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromUInt16Array( prgn: [*:0]const u16, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromInt32Array( prgn: [*]const i32, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromUInt32Array( prgn: [*]const u32, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromInt64Array( prgn: [*]const i64, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromUInt64Array( prgn: [*]const u64, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromDoubleArray( prgn: [*]const f64, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn InitVariantFromStringArray( prgsz: [*]?PWSTR, cElems: u32, pvar: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToBooleanWithDefault( varIn: ?*const VARIANT, fDefault: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt16WithDefault( varIn: ?*const VARIANT, iDefault: i16, ) callconv(@import("std").os.windows.WINAPI) i16; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt16WithDefault( varIn: ?*const VARIANT, uiDefault: u16, ) callconv(@import("std").os.windows.WINAPI) u16; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt32WithDefault( varIn: ?*const VARIANT, lDefault: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt32WithDefault( varIn: ?*const VARIANT, ulDefault: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt64WithDefault( varIn: ?*const VARIANT, llDefault: i64, ) callconv(@import("std").os.windows.WINAPI) i64; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt64WithDefault( varIn: ?*const VARIANT, ullDefault: u64, ) callconv(@import("std").os.windows.WINAPI) u64; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToDoubleWithDefault( varIn: ?*const VARIANT, dblDefault: f64, ) callconv(@import("std").os.windows.WINAPI) f64; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToStringWithDefault( varIn: ?*const VARIANT, pszDefault: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) ?PWSTR; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToBoolean( varIn: ?*const VARIANT, pfRet: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt16( varIn: ?*const VARIANT, piRet: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt16( varIn: ?*const VARIANT, puiRet: ?*u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt32( varIn: ?*const VARIANT, plRet: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt32( varIn: ?*const VARIANT, pulRet: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt64( varIn: ?*const VARIANT, pllRet: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt64( varIn: ?*const VARIANT, pullRet: ?*u64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToDouble( varIn: ?*const VARIANT, pdblRet: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToBuffer( varIn: ?*const VARIANT, // TODO: what to do with BytesParamIndex 2? pv: ?*anyopaque, cb: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToGUID( varIn: ?*const VARIANT, pguid: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToString( varIn: ?*const VARIANT, pszBuf: [*:0]u16, cchBuf: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToStringAlloc( varIn: ?*const VARIANT, ppszBuf: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToDosDateTime( varIn: ?*const VARIANT, pwDate: ?*u16, pwTime: ?*u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToStrRet( varIn: ?*const VARIANT, pstrret: ?*STRRET, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToFileTime( varIn: ?*const VARIANT, stfOut: PSTIME_FLAGS, pftOut: ?*FILETIME, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetElementCount( varIn: ?*const VARIANT, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToBooleanArray( @"var": ?*const VARIANT, prgf: [*]BOOL, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt16Array( @"var": ?*const VARIANT, prgn: [*]i16, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt16Array( @"var": ?*const VARIANT, prgn: [*:0]u16, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt32Array( @"var": ?*const VARIANT, prgn: [*]i32, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt32Array( @"var": ?*const VARIANT, prgn: [*]u32, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt64Array( @"var": ?*const VARIANT, prgn: [*]i64, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt64Array( @"var": ?*const VARIANT, prgn: [*]u64, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToDoubleArray( @"var": ?*const VARIANT, prgn: [*]f64, crgn: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToStringArray( @"var": ?*const VARIANT, prgsz: [*]?PWSTR, crgsz: u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToBooleanArrayAlloc( @"var": ?*const VARIANT, pprgf: ?*?*BOOL, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt16ArrayAlloc( @"var": ?*const VARIANT, pprgn: ?*?*i16, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt16ArrayAlloc( @"var": ?*const VARIANT, pprgn: ?*?*u16, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt32ArrayAlloc( @"var": ?*const VARIANT, pprgn: ?*?*i32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt32ArrayAlloc( @"var": ?*const VARIANT, pprgn: ?*?*u32, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToInt64ArrayAlloc( @"var": ?*const VARIANT, pprgn: ?*?*i64, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToUInt64ArrayAlloc( @"var": ?*const VARIANT, pprgn: ?*?*u64, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToDoubleArrayAlloc( @"var": ?*const VARIANT, pprgn: ?*?*f64, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantToStringArrayAlloc( @"var": ?*const VARIANT, pprgsz: ?*?*?PWSTR, pcElem: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetBooleanElem( @"var": ?*const VARIANT, iElem: u32, pfVal: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetInt16Elem( @"var": ?*const VARIANT, iElem: u32, pnVal: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetUInt16Elem( @"var": ?*const VARIANT, iElem: u32, pnVal: ?*u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetInt32Elem( @"var": ?*const VARIANT, iElem: u32, pnVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetUInt32Elem( @"var": ?*const VARIANT, iElem: u32, pnVal: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetInt64Elem( @"var": ?*const VARIANT, iElem: u32, pnVal: ?*i64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetUInt64Elem( @"var": ?*const VARIANT, iElem: u32, pnVal: ?*u64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetDoubleElem( @"var": ?*const VARIANT, iElem: u32, pnVal: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantGetStringElem( @"var": ?*const VARIANT, iElem: u32, ppszVal: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn ClearVariantArray( pvars: [*]VARIANT, cvars: u32, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "PROPSYS" fn VariantCompare( var1: ?*const VARIANT, var2: ?*const VARIANT, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "SHELL32" fn SHGetPropertyStoreFromIDList( pidl: ?*ITEMIDLIST, flags: GETPROPERTYSTOREFLAGS, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "SHELL32" fn SHGetPropertyStoreFromParsingName( pszPath: ?[*:0]const u16, pbc: ?*IBindCtx, flags: GETPROPERTYSTOREFLAGS, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "SHELL32" fn SHAddDefaultPropertiesByExt( pszExt: ?[*:0]const u16, pPropStore: ?*IPropertyStore, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.0' pub extern "SHELL32" fn PifMgr_OpenProperties( pszApp: ?[*:0]const u16, pszPIF: ?[*:0]const u16, hInf: u32, flOpt: u32, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows5.0' pub extern "SHELL32" fn PifMgr_GetProperties( hProps: ?HANDLE, pszGroup: ?[*:0]const u8, // TODO: what to do with BytesParamIndex 3? lpProps: ?*anyopaque, cbProps: i32, flOpt: u32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "SHELL32" fn PifMgr_SetProperties( hProps: ?HANDLE, pszGroup: ?[*:0]const u8, // TODO: what to do with BytesParamIndex 3? lpProps: ?*const anyopaque, cbProps: i32, flOpt: u32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "SHELL32" fn PifMgr_CloseProperties( hProps: ?HANDLE, flOpt: u32, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows5.0' pub extern "SHELL32" fn SHPropStgCreate( psstg: ?*IPropertySetStorage, fmtid: ?*const Guid, pclsid: ?*const Guid, grfFlags: u32, grfMode: u32, dwDisposition: u32, ppstg: ?*?*IPropertyStorage, puCodePage: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "SHELL32" fn SHPropStgReadMultiple( pps: ?*IPropertyStorage, uCodePage: u32, cpspec: u32, rgpspec: [*]const PROPSPEC, rgvar: ?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "SHELL32" fn SHPropStgWriteMultiple( pps: ?*IPropertyStorage, puCodePage: ?*u32, cpspec: u32, rgpspec: [*]const PROPSPEC, rgvar: [*]PROPVARIANT, propidNameFirst: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.1' pub extern "SHELL32" fn SHGetPropertyStoreForWindow( hwnd: ?HWND, riid: ?*const Guid, ppv: ?*?*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 (26) //-------------------------------------------------------------------------------- const Guid = @import("../../zig.zig").Guid; const BOOL = @import("../../foundation.zig").BOOL; const BSTR = @import("../../foundation.zig").BSTR; const CHAR = @import("../../foundation.zig").CHAR; const CONDITION_OPERATION = @import("../../system/search/common.zig").CONDITION_OPERATION; const FILETIME = @import("../../foundation.zig").FILETIME; const HANDLE = @import("../../foundation.zig").HANDLE; const HINSTANCE = @import("../../foundation.zig").HINSTANCE; const HRESULT = @import("../../foundation.zig").HRESULT; const HWND = @import("../../foundation.zig").HWND; const IBindCtx = @import("../../system/com.zig").IBindCtx; const IPropertyBag = @import("../../system/com/structured_storage.zig").IPropertyBag; const IPropertySetStorage = @import("../../system/com/structured_storage.zig").IPropertySetStorage; const IPropertyStorage = @import("../../system/com/structured_storage.zig").IPropertyStorage; const IStream = @import("../../system/com.zig").IStream; const ITEMIDLIST = @import("../../ui/shell/common.zig").ITEMIDLIST; const IUnknown = @import("../../system/com.zig").IUnknown; const POINTL = @import("../../foundation.zig").POINTL; const POINTS = @import("../../foundation.zig").POINTS; const PROPSPEC = @import("../../system/com/structured_storage.zig").PROPSPEC; const PROPVARIANT = @import("../../system/com/structured_storage.zig").PROPVARIANT; const PSTR = @import("../../foundation.zig").PSTR; const PWSTR = @import("../../foundation.zig").PWSTR; const RECTL = @import("../../foundation.zig").RECTL; const STRRET = @import("../../ui/shell/common.zig").STRRET; 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/ui/shell/properties_system.zig
pub const BITCOUNT = struct { //! ``` //! const cmd = BITCOUNT.init("test", BITCOUNT.Bounds{ .Slice = .{ .start = -2, .end = -1 } }); //! ``` key: []const u8, bounds: Bounds = .FullString, pub fn init(key: []const u8, bounds: Bounds) BITCOUNT { return .{ .key = key, .bounds = bounds }; } pub fn validate(self: Self) !void { if (self.key.len == 0) return error.EmptyKeyName; } pub const RedisCommand = struct { pub fn serialize(self: BITCOUNT, comptime rootSerializer: type, msg: anytype) !void { return rootSerializer.serializeCommand(msg, .{ "BITCOUNT", self.key, self.bounds }); } }; pub const Bounds = union(enum) { FullString, Slice: struct { start: isize, end: isize, }, pub const RedisArguments = struct { pub fn count(self: Bounds) usize { return switch (self) { .FullString => 0, .Slice => 2, }; } pub fn serialize(self: Bounds, comptime rootSerializer: type, msg: anytype) !void { switch (self) { .FullString => {}, .Slice => |slice| { try rootSerializer.serializeArgument(msg, isize, slice.start); try rootSerializer.serializeArgument(msg, isize, slice.end); }, } } }; }; }; test "example" { const cmd = BITCOUNT.init("test", BITCOUNT.Bounds{ .Slice = .{ .start = -2, .end = -1 } }); } test "serializer" { const std = @import("std"); const serializer = @import("../../serializer.zig").CommandSerializer; var correctBuf: [1000]u8 = undefined; var correctMsg = std.io.fixedBufferStream(correctBuf[0..]); var testBuf: [1000]u8 = undefined; var testMsg = std.io.fixedBufferStream(testBuf[0..]); { correctMsg.reset(); testMsg.reset(); try serializer.serializeCommand( testMsg.outStream(), BITCOUNT.init("mykey", BITCOUNT.Bounds{ .Slice = .{ .start = 1, .end = 10 } }), ); try serializer.serializeCommand( correctMsg.outStream(), .{ "BITCOUNT", "mykey", 1, 10 }, ); std.testing.expectEqualSlices(u8, correctMsg.getWritten(), testMsg.getWritten()); } }
src/commands/strings/bitcount.zig
const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const testing = std.testing; /// The set of languages supported. pub const Language = enum { English, }; const line_delimiter = switch (builtin.os.tag) { .windows => "\r\n", else => "\n", }; /// Creates a WordList from the input data for the language provided. fn readWordList(data: []const u8) [2048][]const u8 { var words: [2048][]const u8 = undefined; var iter = std.mem.tokenize(u8, data, line_delimiter); var i: usize = 0; while (iter.next()) |line| { words[i] = line; i += 1; } return words; } const data_english = @embedFile("wordlist_english.txt"); const WORD_BITS = 11; /// A Mnemonic can encode a byte array called entropy into a "mnemonic sentence", a group of easy to remember words. /// See https://en.bitcoin.it/wiki/BIP_0039 /// /// The type T must an array of u8, of either length 16, 20, 24, 28, 32. /// Initialize with `init`. pub fn Mnemonic(comptime T: type) type { comptime assert(std.meta.trait.isIndexable(T)); // Compute the entropy bits at comptime since we know the type slices we're getting. const entropy_bits = @typeInfo(T).Array.len * 8; const checksum_mask: u8 = switch (entropy_bits) { 128 => 0xF0, // 4 bits 160 => 0xF8, // 5 bits 192 => 0xFC, // 6 bits 224 => 0xFE, // 7 bits 256 => 0xFF, // 8 bits else => { @compileError("Expected array of u8 of either length [16, 20, 24, 28, 32], found " ++ @typeName(T)); }, }; const checksum_length = entropy_bits / 32; const nb_words = (entropy_bits + checksum_length) / WORD_BITS; return struct { const Self = @This(); allocator: std.mem.Allocator, words: [2048][]const u8, pub fn init(allocator: std.mem.Allocator, language: Language) !Self { return Self{ .allocator = allocator, .words = switch (language) { .English => readWordList(data_english), }, }; } pub fn deinit(self: *Self) void { _ = self; } /// Encodes entropy into a mnemonic sentence. pub fn encode(self: *Self, entropy: T) ![]const u8 { // compute sha256 checksum // var checksum_buf: [std.crypto.hash.sha2.Sha256.digest_length]u8 = undefined; std.crypto.hash.sha2.Sha256.hash(&entropy, &checksum_buf, .{}); const checksum = @truncate(u8, checksum_buf[0] & checksum_mask); // append checksum to entropy const new_entropy = try std.mem.concat(self.allocator, u8, &[_][]const u8{ &entropy, &[_]u8{checksum}, }); defer self.allocator.free(new_entropy); // generate the mnemonic sentence // var buffer = std.ArrayList(u8).init(self.allocator); defer buffer.deinit(); var i: usize = 0; while (i < nb_words) { if (i > 0) { try buffer.appendSlice(" "); } const idx = extractIndex(new_entropy, i); try buffer.appendSlice(self.words[idx]); i += 1; } return buffer.toOwnedSlice(); } }; } /// Returns the index into the word list for the word at word_pos. fn extractIndex(data: []const u8, word_pos: usize) usize { var pos: usize = 0; var end: usize = 0; var value: usize = 0; pos = word_pos * WORD_BITS; end = pos + WORD_BITS; // This function works by iterating over the bits in the range applicable for the word at word_pos. // // For example, the second word (index 1) will need these bits: // - start = 1 * 11 // - end = start + 11 // // For each position in this range, we fetch the corresponding bit value and write the value to the // output value integer. // // To follow up the example above, the loop would iterate other two bytes: // data[1] and data[2] // // These are the iterations this loop would perform: // pos = 11, b = data[1], mask = 16 = 0b00010000 // pos = 12, b = data[1], mask = 8 = 0b00001000 // pos = 13, b = data[1], mask = 4 = 0b00000100 // pos = 14, b = data[1], mask = 2 = 0b00000010 // pos = 15, b = data[1], mask = 0 = 0b00000001 // pos = 16, b = data[2], mask = 128 = 0b10000000 // pos = 17, b = data[2], mask = 64 = 0b01000000 // pos = 18, b = data[2], mask = 32 = 0b00100000 // pos = 19, b = data[2], mask = 16 = 0b00010000 // pos = 20, b = data[2], mask = 8 = 0b00001000 // pos = 21, b = data[2], mask = 4 = 0b00000100 while (pos < end) { // fetch the byte needed for the current position const b = data[pos / 8]; // compute the mask of the bit we need const mask = @as(usize, 1) << @truncate(u6, 7 - @mod(pos, 8)); // shift the current value by one to the left since we're adding a single bit. value <<= 1; // Append a 1 if the bit for the current position is set, 0 otherwise. value |= if (b & mask == mask) @as(u8, 1) else 0; pos += 1; } return value; } test "extract index" { var buf: [16]u8 = undefined; const entropy = try std.fmt.hexToBytes(&buf, "18ab19a9f54a9274f03e5209a2ac8a91"); const idx = extractIndex(entropy, 10); try testing.expectEqual(idx, 277); } test "check the english wordlist" { const wordlist = readWordList(data_english); try testing.expectEqual(wordlist.len, 2048); } test "mnemonic all zeroes" { var entropy: [16]u8 = undefined; std.mem.set(u8, &entropy, 0); var encoder = try Mnemonic([16]u8).init(testing.allocator, .English); defer encoder.deinit(); const result = try encoder.encode(entropy); defer testing.allocator.free(result); try testing.expectEqualSlices(u8, "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", result); } fn testMnemonic(comptime T: type, hex_entropy: []const u8, exp: []const u8) !void { var entropy: T = undefined; _ = try std.fmt.hexToBytes(&entropy, hex_entropy); var encoder = try Mnemonic(T).init(testing.allocator, .English); defer encoder.deinit(); // compute the mnemonic const result = try encoder.encode(entropy); defer testing.allocator.free(result); // check it try testing.expectEqualStrings(exp, result); } test "all test vectors" { // create the test vectors const data = @embedFile("vectors.json"); const testVector = struct { entropy: []const u8, mnemonic: []const u8, }; const options = std.json.ParseOptions{ .allocator = testing.allocator }; const vectors = try std.json.parse([]testVector, &std.json.TokenStream.init(data), options); defer std.json.parseFree([]testVector, vectors, options); for (vectors) |v| { if (v.entropy.len == 32) { try testMnemonic([16]u8, v.entropy, v.mnemonic); } else if (v.entropy.len == 40) { try testMnemonic([20]u8, v.entropy, v.mnemonic); } else if (v.entropy.len == 48) { try testMnemonic([24]u8, v.entropy, v.mnemonic); } else if (v.entropy.len == 56) { try testMnemonic([28]u8, v.entropy, v.mnemonic); } else if (v.entropy.len == 64) { try testMnemonic([32]u8, v.entropy, v.mnemonic); } else { @panic("unhandled vector size"); } } }
src/lib.zig
const std = @import("std"); const c = @import("internal/c.zig"); const internal = @import("internal/internal.zig"); const log = std.log.scoped(.git); const git = @import("git.zig"); pub const Object = opaque { /// Close an open object /// /// This method instructs the library to close an existing object; note that `git.Object`s are owned and cached by /// the repository so the object may or may not be freed after this library call, depending on how aggressive is the /// caching mechanism used by the repository. /// /// IMPORTANT: /// It *is* necessary to call this method when you stop using an object. Failure to do so will cause a memory leak. pub fn deinit(self: *Object) void { log.debug("Object.deinit called", .{}); c.git_object_free(@ptrCast(*c.git_object, self)); log.debug("object freed successfully", .{}); } /// Get the id (SHA1) of a repository object pub fn id(self: *const Object) *const git.Oid { log.debug("Object.id called", .{}); const ret = @ptrCast( *const git.Oid, c.git_object_id(@ptrCast(*const c.git_object, self)), ); // This check is to prevent formating the oid when we are not going to print anything if (@enumToInt(std.log.Level.debug) <= @enumToInt(std.log.level)) { var buf: [git.Oid.HEX_BUFFER_SIZE]u8 = undefined; if (ret.formatHex(&buf)) |slice| { log.debug("object id: {s}", .{slice}); } else |_| {} } return ret; } /// Get a short abbreviated OID string for the object /// /// This starts at the "core.abbrev" length (default 7 characters) and iteratively extends to a longer string if that length /// is ambiguous. /// The result will be unambiguous (at least until new objects are added to the repository). pub fn shortId(self: *const Object) !git.Buf { log.debug("Object.shortId called", .{}); var buf: git.Buf = .{}; try internal.wrapCall("git_object_short_id", .{ @ptrCast(*c.git_buf, &buf), @ptrCast(*const c.git_object, self), }); log.debug("object short id: {s}", .{buf.toSlice()}); return buf; } /// Get the object type of an object pub fn objectType(self: *const Object) ObjectType { log.debug("Object.objectType called", .{}); const ret = @intToEnum( ObjectType, c.git_object_type(@ptrCast(*const c.git_object, self)), ); log.debug("object type: {}", .{ret}); return ret; } /// Get the repository that owns this object pub fn objectOwner(self: *const Object) *const git.Repository { log.debug("Object.objectOwner called", .{}); const ret = @ptrCast( *const git.Repository, c.git_object_owner(@ptrCast(*const c.git_object, self)), ); log.debug("object owner: {*}", .{ret}); return ret; } /// Describe a commit /// /// Perform the describe operation on the given committish object. pub fn describe(self: *Object, options: git.DescribeOptions) !*git.DescribeResult { log.debug("Object.describe called, options={}", .{options}); var result: *git.DescribeResult = undefined; var c_options = options.makeCOptionObject(); try internal.wrapCall("git_describe_commit", .{ @ptrCast(*?*c.git_describe_result, &result), @ptrCast(*c.git_object, self), &c_options, }); log.debug("successfully described commitish object", .{}); return result; } /// Lookup an object that represents a tree entry. /// /// ## Parameters /// * `treeish` - root object that can be peeled to a tree /// * `path` - relative path from the root object to the desired object /// * `object_type` - type of object desired pub fn lookupByPath(treeish: *const Object, path: [:0]const u8, object_type: ObjectType) !*Object { log.debug("Object.lookupByPath called, path={s}, object_type={}", .{ path, object_type }); var ret: *Object = undefined; try internal.wrapCall("git_object_lookup_bypath", .{ @ptrCast(*?*c.git_object, &ret), @ptrCast(*const c.git_object, treeish), path.ptr, @enumToInt(object_type), }); log.debug("successfully found object: {*}", .{ret}); return ret; } /// Recursively peel an object until an object of the specified type is met. /// /// If the query cannot be satisfied due to the object model, `error.InvalidSpec` will be returned (e.g. trying to peel a blob /// to a tree). /// /// If you pass `ObjectType.ANY` as the target type, then the object will be peeled until the type changes. /// A tag will be peeled until the referenced object is no longer a tag, and a commit will be peeled to a tree. /// Any other object type will return `error.InvalidSpec`. /// /// If peeling a tag we discover an object which cannot be peeled to the target type due to the object model, `error.Peel` /// will be returned. /// /// You must `deinit` the returned object. /// /// ## Parameters /// * `target_type` - The type of the requested object pub fn peel(self: *const Object, target_type: ObjectType) !*git.Object { log.debug("Object.peel called, target_type={}", .{target_type}); var ret: *Object = undefined; try internal.wrapCall("git_object_peel", .{ @ptrCast(*?*c.git_object, &ret), @ptrCast(*const c.git_object, self), @enumToInt(target_type), }); log.debug("successfully found object: {*}", .{ret}); return ret; } /// Create an in-memory copy of a Git object. The copy must be explicitly `deinit`'d or it will leak. pub fn duplicate(self: *Object) *Object { log.debug("Object.duplicate called", .{}); var ret: *Object = undefined; _ = c.git_object_dup( @ptrCast(*?*c.git_object, &ret), @ptrCast(*c.git_object, self), ); log.debug("successfully duplicated object", .{}); return ret; } comptime { std.testing.refAllDecls(@This()); } }; /// Basic type (loose or packed) of any Git object. pub const ObjectType = enum(c_int) { /// Object can be any of the following ANY = -2, /// Object is invalid. INVALID = -1, /// A commit object. COMMIT = 1, /// A tree (directory listing) object. TREE = 2, /// A file revision object. BLOB = 3, /// An annotated tag object. TAG = 4, /// A delta, base is given by an offset. OFS_DELTA = 6, /// A delta, base is given by object id. REF_DELTA = 7, /// Convert an object type to its string representation. pub fn toString(self: ObjectType) [:0]const u8 { return std.mem.sliceTo( c.git_object_type2string(@enumToInt(self)), 0, ); } /// Convert a string object type representation to it's `ObjectType`. /// /// If the given string is not a valid object type `.INVALID` is returned. pub fn fromString(str: [:0]const u8) ObjectType { return @intToEnum(ObjectType, c.git_object_string2type(str.ptr)); } /// Determine if the given `ObjectType` is a valid loose object type. pub fn validLoose(self: ObjectType) bool { return c.git_object_typeisloose(@enumToInt(self)) != 0; } }; comptime { std.testing.refAllDecls(@This()); }
src/object.zig
pub const TAPI_CURRENT_VERSION = @as(u32, 131074); pub const LINE_ADDRESSSTATE = @as(i32, 0); pub const LINE_CALLINFO = @as(i32, 1); pub const LINE_CALLSTATE = @as(i32, 2); pub const LINE_CLOSE = @as(i32, 3); pub const LINE_DEVSPECIFIC = @as(i32, 4); pub const LINE_DEVSPECIFICFEATURE = @as(i32, 5); pub const LINE_GATHERDIGITS = @as(i32, 6); pub const LINE_GENERATE = @as(i32, 7); pub const LINE_LINEDEVSTATE = @as(i32, 8); pub const LINE_MONITORDIGITS = @as(i32, 9); pub const LINE_MONITORMEDIA = @as(i32, 10); pub const LINE_MONITORTONE = @as(i32, 11); pub const LINE_REPLY = @as(i32, 12); pub const LINE_REQUEST = @as(i32, 13); pub const PHONE_BUTTON = @as(i32, 14); pub const PHONE_CLOSE = @as(i32, 15); pub const PHONE_DEVSPECIFIC = @as(i32, 16); pub const PHONE_REPLY = @as(i32, 17); pub const PHONE_STATE = @as(i32, 18); pub const LINE_CREATE = @as(i32, 19); pub const PHONE_CREATE = @as(i32, 20); pub const LINE_AGENTSPECIFIC = @as(i32, 21); pub const LINE_AGENTSTATUS = @as(i32, 22); pub const LINE_APPNEWCALL = @as(i32, 23); pub const LINE_PROXYREQUEST = @as(i32, 24); pub const LINE_REMOVE = @as(i32, 25); pub const PHONE_REMOVE = @as(i32, 26); pub const LINE_AGENTSESSIONSTATUS = @as(i32, 27); pub const LINE_QUEUESTATUS = @as(i32, 28); pub const LINE_AGENTSTATUSEX = @as(i32, 29); pub const LINE_GROUPSTATUS = @as(i32, 30); pub const LINE_PROXYSTATUS = @as(i32, 31); pub const LINE_APPNEWCALLHUB = @as(i32, 32); pub const LINE_CALLHUBCLOSE = @as(i32, 33); pub const LINE_DEVSPECIFICEX = @as(i32, 34); pub const INITIALIZE_NEGOTIATION = @as(u32, 4294967295); pub const LINEADDRCAPFLAGS_FWDNUMRINGS = @as(u32, 1); pub const LINEADDRCAPFLAGS_PICKUPGROUPID = @as(u32, 2); pub const LINEADDRCAPFLAGS_SECURE = @as(u32, 4); pub const LINEADDRCAPFLAGS_BLOCKIDDEFAULT = @as(u32, 8); pub const LINEADDRCAPFLAGS_BLOCKIDOVERRIDE = @as(u32, 16); pub const LINEADDRCAPFLAGS_DIALED = @as(u32, 32); pub const LINEADDRCAPFLAGS_ORIGOFFHOOK = @as(u32, 64); pub const LINEADDRCAPFLAGS_DESTOFFHOOK = @as(u32, 128); pub const LINEADDRCAPFLAGS_FWDCONSULT = @as(u32, 256); pub const LINEADDRCAPFLAGS_SETUPCONFNULL = @as(u32, 512); pub const LINEADDRCAPFLAGS_AUTORECONNECT = @as(u32, 1024); pub const LINEADDRCAPFLAGS_COMPLETIONID = @as(u32, 2048); pub const LINEADDRCAPFLAGS_TRANSFERHELD = @as(u32, 4096); pub const LINEADDRCAPFLAGS_TRANSFERMAKE = @as(u32, 8192); pub const LINEADDRCAPFLAGS_CONFERENCEHELD = @as(u32, 16384); pub const LINEADDRCAPFLAGS_CONFERENCEMAKE = @as(u32, 32768); pub const LINEADDRCAPFLAGS_PARTIALDIAL = @as(u32, 65536); pub const LINEADDRCAPFLAGS_FWDSTATUSVALID = @as(u32, 131072); pub const LINEADDRCAPFLAGS_FWDINTEXTADDR = @as(u32, 262144); pub const LINEADDRCAPFLAGS_FWDBUSYNAADDR = @as(u32, 524288); pub const LINEADDRCAPFLAGS_ACCEPTTOALERT = @as(u32, 1048576); pub const LINEADDRCAPFLAGS_CONFDROP = @as(u32, 2097152); pub const LINEADDRCAPFLAGS_PICKUPCALLWAIT = @as(u32, 4194304); pub const LINEADDRCAPFLAGS_PREDICTIVEDIALER = @as(u32, 8388608); pub const LINEADDRCAPFLAGS_QUEUE = @as(u32, 16777216); pub const LINEADDRCAPFLAGS_ROUTEPOINT = @as(u32, 33554432); pub const LINEADDRCAPFLAGS_HOLDMAKESNEW = @as(u32, 67108864); pub const LINEADDRCAPFLAGS_NOINTERNALCALLS = @as(u32, 134217728); pub const LINEADDRCAPFLAGS_NOEXTERNALCALLS = @as(u32, 268435456); pub const LINEADDRCAPFLAGS_SETCALLINGID = @as(u32, 536870912); pub const LINEADDRCAPFLAGS_ACDGROUP = @as(u32, 1073741824); pub const LINEADDRCAPFLAGS_NOPSTNADDRESSTRANSLATION = @as(u32, 2147483648); pub const LINEADDRESSMODE_ADDRESSID = @as(u32, 1); pub const LINEADDRESSMODE_DIALABLEADDR = @as(u32, 2); pub const LINEADDRESSSHARING_PRIVATE = @as(u32, 1); pub const LINEADDRESSSHARING_BRIDGEDEXCL = @as(u32, 2); pub const LINEADDRESSSHARING_BRIDGEDNEW = @as(u32, 4); pub const LINEADDRESSSHARING_BRIDGEDSHARED = @as(u32, 8); pub const LINEADDRESSSHARING_MONITORED = @as(u32, 16); pub const LINEADDRESSSTATE_OTHER = @as(u32, 1); pub const LINEADDRESSSTATE_DEVSPECIFIC = @as(u32, 2); pub const LINEADDRESSSTATE_INUSEZERO = @as(u32, 4); pub const LINEADDRESSSTATE_INUSEONE = @as(u32, 8); pub const LINEADDRESSSTATE_INUSEMANY = @as(u32, 16); pub const LINEADDRESSSTATE_NUMCALLS = @as(u32, 32); pub const LINEADDRESSSTATE_FORWARD = @as(u32, 64); pub const LINEADDRESSSTATE_TERMINALS = @as(u32, 128); pub const LINEADDRESSSTATE_CAPSCHANGE = @as(u32, 256); pub const LINEADDRESSTYPE_PHONENUMBER = @as(u32, 1); pub const LINEADDRESSTYPE_SDP = @as(u32, 2); pub const LINEADDRESSTYPE_EMAILNAME = @as(u32, 4); pub const LINEADDRESSTYPE_DOMAINNAME = @as(u32, 8); pub const LINEADDRESSTYPE_IPADDRESS = @as(u32, 16); pub const LINEADDRFEATURE_FORWARD = @as(u32, 1); pub const LINEADDRFEATURE_MAKECALL = @as(u32, 2); pub const LINEADDRFEATURE_PICKUP = @as(u32, 4); pub const LINEADDRFEATURE_SETMEDIACONTROL = @as(u32, 8); pub const LINEADDRFEATURE_SETTERMINAL = @as(u32, 16); pub const LINEADDRFEATURE_SETUPCONF = @as(u32, 32); pub const LINEADDRFEATURE_UNCOMPLETECALL = @as(u32, 64); pub const LINEADDRFEATURE_UNPARK = @as(u32, 128); pub const LINEADDRFEATURE_PICKUPHELD = @as(u32, 256); pub const LINEADDRFEATURE_PICKUPGROUP = @as(u32, 512); pub const LINEADDRFEATURE_PICKUPDIRECT = @as(u32, 1024); pub const LINEADDRFEATURE_PICKUPWAITING = @as(u32, 2048); pub const LINEADDRFEATURE_FORWARDFWD = @as(u32, 4096); pub const LINEADDRFEATURE_FORWARDDND = @as(u32, 8192); pub const LINEAGENTFEATURE_SETAGENTGROUP = @as(u32, 1); pub const LINEAGENTFEATURE_SETAGENTSTATE = @as(u32, 2); pub const LINEAGENTFEATURE_SETAGENTACTIVITY = @as(u32, 4); pub const LINEAGENTFEATURE_AGENTSPECIFIC = @as(u32, 8); pub const LINEAGENTFEATURE_GETAGENTACTIVITYLIST = @as(u32, 16); pub const LINEAGENTFEATURE_GETAGENTGROUP = @as(u32, 32); pub const LINEAGENTSTATE_LOGGEDOFF = @as(u32, 1); pub const LINEAGENTSTATE_NOTREADY = @as(u32, 2); pub const LINEAGENTSTATE_READY = @as(u32, 4); pub const LINEAGENTSTATE_BUSYACD = @as(u32, 8); pub const LINEAGENTSTATE_BUSYINCOMING = @as(u32, 16); pub const LINEAGENTSTATE_BUSYOUTBOUND = @as(u32, 32); pub const LINEAGENTSTATE_BUSYOTHER = @as(u32, 64); pub const LINEAGENTSTATE_WORKINGAFTERCALL = @as(u32, 128); pub const LINEAGENTSTATE_UNKNOWN = @as(u32, 256); pub const LINEAGENTSTATE_UNAVAIL = @as(u32, 512); pub const LINEAGENTSTATUS_GROUP = @as(u32, 1); pub const LINEAGENTSTATUS_STATE = @as(u32, 2); pub const LINEAGENTSTATUS_NEXTSTATE = @as(u32, 4); pub const LINEAGENTSTATUS_ACTIVITY = @as(u32, 8); pub const LINEAGENTSTATUS_ACTIVITYLIST = @as(u32, 16); pub const LINEAGENTSTATUS_GROUPLIST = @as(u32, 32); pub const LINEAGENTSTATUS_CAPSCHANGE = @as(u32, 64); pub const LINEAGENTSTATUS_VALIDSTATES = @as(u32, 128); pub const LINEAGENTSTATUS_VALIDNEXTSTATES = @as(u32, 256); pub const LINEAGENTSTATEEX_NOTREADY = @as(u32, 1); pub const LINEAGENTSTATEEX_READY = @as(u32, 2); pub const LINEAGENTSTATEEX_BUSYACD = @as(u32, 4); pub const LINEAGENTSTATEEX_BUSYINCOMING = @as(u32, 8); pub const LINEAGENTSTATEEX_BUSYOUTGOING = @as(u32, 16); pub const LINEAGENTSTATEEX_UNKNOWN = @as(u32, 32); pub const LINEAGENTSTATEEX_RELEASED = @as(u32, 64); pub const LINEAGENTSTATUSEX_NEWAGENT = @as(u32, 1); pub const LINEAGENTSTATUSEX_STATE = @as(u32, 2); pub const LINEAGENTSTATUSEX_UPDATEINFO = @as(u32, 4); pub const LINEAGENTSESSIONSTATE_NOTREADY = @as(u32, 1); pub const LINEAGENTSESSIONSTATE_READY = @as(u32, 2); pub const LINEAGENTSESSIONSTATE_BUSYONCALL = @as(u32, 4); pub const LINEAGENTSESSIONSTATE_BUSYWRAPUP = @as(u32, 8); pub const LINEAGENTSESSIONSTATE_ENDED = @as(u32, 16); pub const LINEAGENTSESSIONSTATE_RELEASED = @as(u32, 32); pub const LINEAGENTSESSIONSTATUS_NEWSESSION = @as(u32, 1); pub const LINEAGENTSESSIONSTATUS_STATE = @as(u32, 2); pub const LINEAGENTSESSIONSTATUS_UPDATEINFO = @as(u32, 4); pub const LINEQUEUESTATUS_UPDATEINFO = @as(u32, 1); pub const LINEQUEUESTATUS_NEWQUEUE = @as(u32, 2); pub const LINEQUEUESTATUS_QUEUEREMOVED = @as(u32, 4); pub const LINEGROUPSTATUS_NEWGROUP = @as(u32, 1); pub const LINEGROUPSTATUS_GROUPREMOVED = @as(u32, 2); pub const LINEPROXYSTATUS_OPEN = @as(u32, 1); pub const LINEPROXYSTATUS_CLOSE = @as(u32, 2); pub const LINEPROXYSTATUS_ALLOPENFORACD = @as(u32, 4); pub const LINEANSWERMODE_NONE = @as(u32, 1); pub const LINEANSWERMODE_DROP = @as(u32, 2); pub const LINEANSWERMODE_HOLD = @as(u32, 4); pub const LINEBEARERMODE_VOICE = @as(u32, 1); pub const LINEBEARERMODE_SPEECH = @as(u32, 2); pub const LINEBEARERMODE_MULTIUSE = @as(u32, 4); pub const LINEBEARERMODE_DATA = @as(u32, 8); pub const LINEBEARERMODE_ALTSPEECHDATA = @as(u32, 16); pub const LINEBEARERMODE_NONCALLSIGNALING = @as(u32, 32); pub const LINEBEARERMODE_PASSTHROUGH = @as(u32, 64); pub const LINEBEARERMODE_RESTRICTEDDATA = @as(u32, 128); pub const LINEBUSYMODE_STATION = @as(u32, 1); pub const LINEBUSYMODE_TRUNK = @as(u32, 2); pub const LINEBUSYMODE_UNKNOWN = @as(u32, 4); pub const LINEBUSYMODE_UNAVAIL = @as(u32, 8); pub const LINECALLCOMPLCOND_BUSY = @as(u32, 1); pub const LINECALLCOMPLCOND_NOANSWER = @as(u32, 2); pub const LINECALLCOMPLMODE_CAMPON = @as(u32, 1); pub const LINECALLCOMPLMODE_CALLBACK = @as(u32, 2); pub const LINECALLCOMPLMODE_INTRUDE = @as(u32, 4); pub const LINECALLCOMPLMODE_MESSAGE = @as(u32, 8); pub const LINECALLFEATURE_ACCEPT = @as(u32, 1); pub const LINECALLFEATURE_ADDTOCONF = @as(u32, 2); pub const LINECALLFEATURE_ANSWER = @as(u32, 4); pub const LINECALLFEATURE_BLINDTRANSFER = @as(u32, 8); pub const LINECALLFEATURE_COMPLETECALL = @as(u32, 16); pub const LINECALLFEATURE_COMPLETETRANSF = @as(u32, 32); pub const LINECALLFEATURE_DIAL = @as(u32, 64); pub const LINECALLFEATURE_DROP = @as(u32, 128); pub const LINECALLFEATURE_GATHERDIGITS = @as(u32, 256); pub const LINECALLFEATURE_GENERATEDIGITS = @as(u32, 512); pub const LINECALLFEATURE_GENERATETONE = @as(u32, 1024); pub const LINECALLFEATURE_HOLD = @as(u32, 2048); pub const LINECALLFEATURE_MONITORDIGITS = @as(u32, 4096); pub const LINECALLFEATURE_MONITORMEDIA = @as(u32, 8192); pub const LINECALLFEATURE_MONITORTONES = @as(u32, 16384); pub const LINECALLFEATURE_PARK = @as(u32, 32768); pub const LINECALLFEATURE_PREPAREADDCONF = @as(u32, 65536); pub const LINECALLFEATURE_REDIRECT = @as(u32, 131072); pub const LINECALLFEATURE_REMOVEFROMCONF = @as(u32, 262144); pub const LINECALLFEATURE_SECURECALL = @as(u32, 524288); pub const LINECALLFEATURE_SENDUSERUSER = @as(u32, 1048576); pub const LINECALLFEATURE_SETCALLPARAMS = @as(u32, 2097152); pub const LINECALLFEATURE_SETMEDIACONTROL = @as(u32, 4194304); pub const LINECALLFEATURE_SETTERMINAL = @as(u32, 8388608); pub const LINECALLFEATURE_SETUPCONF = @as(u32, 16777216); pub const LINECALLFEATURE_SETUPTRANSFER = @as(u32, 33554432); pub const LINECALLFEATURE_SWAPHOLD = @as(u32, 67108864); pub const LINECALLFEATURE_UNHOLD = @as(u32, 134217728); pub const LINECALLFEATURE_RELEASEUSERUSERINFO = @as(u32, 268435456); pub const LINECALLFEATURE_SETTREATMENT = @as(u32, 536870912); pub const LINECALLFEATURE_SETQOS = @as(u32, 1073741824); pub const LINECALLFEATURE_SETCALLDATA = @as(u32, 2147483648); pub const LINECALLFEATURE2_NOHOLDCONFERENCE = @as(u32, 1); pub const LINECALLFEATURE2_ONESTEPTRANSFER = @as(u32, 2); pub const LINECALLFEATURE2_COMPLCAMPON = @as(u32, 4); pub const LINECALLFEATURE2_COMPLCALLBACK = @as(u32, 8); pub const LINECALLFEATURE2_COMPLINTRUDE = @as(u32, 16); pub const LINECALLFEATURE2_COMPLMESSAGE = @as(u32, 32); pub const LINECALLFEATURE2_TRANSFERNORM = @as(u32, 64); pub const LINECALLFEATURE2_TRANSFERCONF = @as(u32, 128); pub const LINECALLFEATURE2_PARKDIRECT = @as(u32, 256); pub const LINECALLFEATURE2_PARKNONDIRECT = @as(u32, 512); pub const LINECALLHUBTRACKING_NONE = @as(u32, 0); pub const LINECALLHUBTRACKING_PROVIDERLEVEL = @as(u32, 1); pub const LINECALLHUBTRACKING_ALLCALLS = @as(u32, 2); pub const LINECALLINFOSTATE_OTHER = @as(u32, 1); pub const LINECALLINFOSTATE_DEVSPECIFIC = @as(u32, 2); pub const LINECALLINFOSTATE_BEARERMODE = @as(u32, 4); pub const LINECALLINFOSTATE_RATE = @as(u32, 8); pub const LINECALLINFOSTATE_MEDIAMODE = @as(u32, 16); pub const LINECALLINFOSTATE_APPSPECIFIC = @as(u32, 32); pub const LINECALLINFOSTATE_CALLID = @as(u32, 64); pub const LINECALLINFOSTATE_RELATEDCALLID = @as(u32, 128); pub const LINECALLINFOSTATE_ORIGIN = @as(u32, 256); pub const LINECALLINFOSTATE_REASON = @as(u32, 512); pub const LINECALLINFOSTATE_COMPLETIONID = @as(u32, 1024); pub const LINECALLINFOSTATE_NUMOWNERINCR = @as(u32, 2048); pub const LINECALLINFOSTATE_NUMOWNERDECR = @as(u32, 4096); pub const LINECALLINFOSTATE_NUMMONITORS = @as(u32, 8192); pub const LINECALLINFOSTATE_TRUNK = @as(u32, 16384); pub const LINECALLINFOSTATE_CALLERID = @as(u32, 32768); pub const LINECALLINFOSTATE_CALLEDID = @as(u32, 65536); pub const LINECALLINFOSTATE_CONNECTEDID = @as(u32, 131072); pub const LINECALLINFOSTATE_REDIRECTIONID = @as(u32, 262144); pub const LINECALLINFOSTATE_REDIRECTINGID = @as(u32, 524288); pub const LINECALLINFOSTATE_DISPLAY = @as(u32, 1048576); pub const LINECALLINFOSTATE_USERUSERINFO = @as(u32, 2097152); pub const LINECALLINFOSTATE_HIGHLEVELCOMP = @as(u32, 4194304); pub const LINECALLINFOSTATE_LOWLEVELCOMP = @as(u32, 8388608); pub const LINECALLINFOSTATE_CHARGINGINFO = @as(u32, 16777216); pub const LINECALLINFOSTATE_TERMINAL = @as(u32, 33554432); pub const LINECALLINFOSTATE_DIALPARAMS = @as(u32, 67108864); pub const LINECALLINFOSTATE_MONITORMODES = @as(u32, 134217728); pub const LINECALLINFOSTATE_TREATMENT = @as(u32, 268435456); pub const LINECALLINFOSTATE_QOS = @as(u32, 536870912); pub const LINECALLINFOSTATE_CALLDATA = @as(u32, 1073741824); pub const LINECALLORIGIN_OUTBOUND = @as(u32, 1); pub const LINECALLORIGIN_INTERNAL = @as(u32, 2); pub const LINECALLORIGIN_EXTERNAL = @as(u32, 4); pub const LINECALLORIGIN_UNKNOWN = @as(u32, 16); pub const LINECALLORIGIN_UNAVAIL = @as(u32, 32); pub const LINECALLORIGIN_CONFERENCE = @as(u32, 64); pub const LINECALLORIGIN_INBOUND = @as(u32, 128); pub const LINECALLPARAMFLAGS_SECURE = @as(u32, 1); pub const LINECALLPARAMFLAGS_IDLE = @as(u32, 2); pub const LINECALLPARAMFLAGS_BLOCKID = @as(u32, 4); pub const LINECALLPARAMFLAGS_ORIGOFFHOOK = @as(u32, 8); pub const LINECALLPARAMFLAGS_DESTOFFHOOK = @as(u32, 16); pub const LINECALLPARAMFLAGS_NOHOLDCONFERENCE = @as(u32, 32); pub const LINECALLPARAMFLAGS_PREDICTIVEDIAL = @as(u32, 64); pub const LINECALLPARAMFLAGS_ONESTEPTRANSFER = @as(u32, 128); pub const LINECALLPARTYID_BLOCKED = @as(u32, 1); pub const LINECALLPARTYID_OUTOFAREA = @as(u32, 2); pub const LINECALLPARTYID_NAME = @as(u32, 4); pub const LINECALLPARTYID_ADDRESS = @as(u32, 8); pub const LINECALLPARTYID_PARTIAL = @as(u32, 16); pub const LINECALLPARTYID_UNKNOWN = @as(u32, 32); pub const LINECALLPARTYID_UNAVAIL = @as(u32, 64); pub const LINECALLPRIVILEGE_NONE = @as(u32, 1); pub const LINECALLPRIVILEGE_MONITOR = @as(u32, 2); pub const LINECALLPRIVILEGE_OWNER = @as(u32, 4); pub const LINECALLREASON_DIRECT = @as(u32, 1); pub const LINECALLREASON_FWDBUSY = @as(u32, 2); pub const LINECALLREASON_FWDNOANSWER = @as(u32, 4); pub const LINECALLREASON_FWDUNCOND = @as(u32, 8); pub const LINECALLREASON_PICKUP = @as(u32, 16); pub const LINECALLREASON_UNPARK = @as(u32, 32); pub const LINECALLREASON_REDIRECT = @as(u32, 64); pub const LINECALLREASON_CALLCOMPLETION = @as(u32, 128); pub const LINECALLREASON_TRANSFER = @as(u32, 256); pub const LINECALLREASON_REMINDER = @as(u32, 512); pub const LINECALLREASON_UNKNOWN = @as(u32, 1024); pub const LINECALLREASON_UNAVAIL = @as(u32, 2048); pub const LINECALLREASON_INTRUDE = @as(u32, 4096); pub const LINECALLREASON_PARKED = @as(u32, 8192); pub const LINECALLREASON_CAMPEDON = @as(u32, 16384); pub const LINECALLREASON_ROUTEREQUEST = @as(u32, 32768); pub const LINECALLSELECT_LINE = @as(u32, 1); pub const LINECALLSELECT_ADDRESS = @as(u32, 2); pub const LINECALLSELECT_CALL = @as(u32, 4); pub const LINECALLSELECT_DEVICEID = @as(u32, 8); pub const LINECALLSELECT_CALLID = @as(u32, 16); pub const LINECALLSTATE_IDLE = @as(u32, 1); pub const LINECALLSTATE_OFFERING = @as(u32, 2); pub const LINECALLSTATE_ACCEPTED = @as(u32, 4); pub const LINECALLSTATE_DIALTONE = @as(u32, 8); pub const LINECALLSTATE_DIALING = @as(u32, 16); pub const LINECALLSTATE_RINGBACK = @as(u32, 32); pub const LINECALLSTATE_BUSY = @as(u32, 64); pub const LINECALLSTATE_SPECIALINFO = @as(u32, 128); pub const LINECALLSTATE_CONNECTED = @as(u32, 256); pub const LINECALLSTATE_PROCEEDING = @as(u32, 512); pub const LINECALLSTATE_ONHOLD = @as(u32, 1024); pub const LINECALLSTATE_CONFERENCED = @as(u32, 2048); pub const LINECALLSTATE_ONHOLDPENDCONF = @as(u32, 4096); pub const LINECALLSTATE_ONHOLDPENDTRANSFER = @as(u32, 8192); pub const LINECALLSTATE_DISCONNECTED = @as(u32, 16384); pub const LINECALLSTATE_UNKNOWN = @as(u32, 32768); pub const LINECALLTREATMENT_SILENCE = @as(u32, 1); pub const LINECALLTREATMENT_RINGBACK = @as(u32, 2); pub const LINECALLTREATMENT_BUSY = @as(u32, 3); pub const LINECALLTREATMENT_MUSIC = @as(u32, 4); pub const LINECARDOPTION_PREDEFINED = @as(u32, 1); pub const LINECARDOPTION_HIDDEN = @as(u32, 2); pub const LINECONNECTEDMODE_ACTIVE = @as(u32, 1); pub const LINECONNECTEDMODE_INACTIVE = @as(u32, 2); pub const LINECONNECTEDMODE_ACTIVEHELD = @as(u32, 4); pub const LINECONNECTEDMODE_INACTIVEHELD = @as(u32, 8); pub const LINECONNECTEDMODE_CONFIRMED = @as(u32, 16); pub const LINEDEVCAPFLAGS_CROSSADDRCONF = @as(u32, 1); pub const LINEDEVCAPFLAGS_HIGHLEVCOMP = @as(u32, 2); pub const LINEDEVCAPFLAGS_LOWLEVCOMP = @as(u32, 4); pub const LINEDEVCAPFLAGS_MEDIACONTROL = @as(u32, 8); pub const LINEDEVCAPFLAGS_MULTIPLEADDR = @as(u32, 16); pub const LINEDEVCAPFLAGS_CLOSEDROP = @as(u32, 32); pub const LINEDEVCAPFLAGS_DIALBILLING = @as(u32, 64); pub const LINEDEVCAPFLAGS_DIALQUIET = @as(u32, 128); pub const LINEDEVCAPFLAGS_DIALDIALTONE = @as(u32, 256); pub const LINEDEVCAPFLAGS_MSP = @as(u32, 512); pub const LINEDEVCAPFLAGS_CALLHUB = @as(u32, 1024); pub const LINEDEVCAPFLAGS_CALLHUBTRACKING = @as(u32, 2048); pub const LINEDEVCAPFLAGS_PRIVATEOBJECTS = @as(u32, 4096); pub const LINEDEVCAPFLAGS_LOCAL = @as(u32, 8192); pub const LINEDEVSTATE_OTHER = @as(u32, 1); pub const LINEDEVSTATE_RINGING = @as(u32, 2); pub const LINEDEVSTATE_CONNECTED = @as(u32, 4); pub const LINEDEVSTATE_DISCONNECTED = @as(u32, 8); pub const LINEDEVSTATE_MSGWAITON = @as(u32, 16); pub const LINEDEVSTATE_MSGWAITOFF = @as(u32, 32); pub const LINEDEVSTATE_INSERVICE = @as(u32, 64); pub const LINEDEVSTATE_OUTOFSERVICE = @as(u32, 128); pub const LINEDEVSTATE_MAINTENANCE = @as(u32, 256); pub const LINEDEVSTATE_OPEN = @as(u32, 512); pub const LINEDEVSTATE_CLOSE = @as(u32, 1024); pub const LINEDEVSTATE_NUMCALLS = @as(u32, 2048); pub const LINEDEVSTATE_NUMCOMPLETIONS = @as(u32, 4096); pub const LINEDEVSTATE_TERMINALS = @as(u32, 8192); pub const LINEDEVSTATE_ROAMMODE = @as(u32, 16384); pub const LINEDEVSTATE_BATTERY = @as(u32, 32768); pub const LINEDEVSTATE_SIGNAL = @as(u32, 65536); pub const LINEDEVSTATE_DEVSPECIFIC = @as(u32, 131072); pub const LINEDEVSTATE_REINIT = @as(u32, 262144); pub const LINEDEVSTATE_LOCK = @as(u32, 524288); pub const LINEDEVSTATE_CAPSCHANGE = @as(u32, 1048576); pub const LINEDEVSTATE_CONFIGCHANGE = @as(u32, 2097152); pub const LINEDEVSTATE_TRANSLATECHANGE = @as(u32, 4194304); pub const LINEDEVSTATE_COMPLCANCEL = @as(u32, 8388608); pub const LINEDEVSTATE_REMOVED = @as(u32, 16777216); pub const LINEDEVSTATUSFLAGS_CONNECTED = @as(u32, 1); pub const LINEDEVSTATUSFLAGS_MSGWAIT = @as(u32, 2); pub const LINEDEVSTATUSFLAGS_INSERVICE = @as(u32, 4); pub const LINEDEVSTATUSFLAGS_LOCKED = @as(u32, 8); pub const LINEDIALTONEMODE_NORMAL = @as(u32, 1); pub const LINEDIALTONEMODE_SPECIAL = @as(u32, 2); pub const LINEDIALTONEMODE_INTERNAL = @as(u32, 4); pub const LINEDIALTONEMODE_EXTERNAL = @as(u32, 8); pub const LINEDIALTONEMODE_UNKNOWN = @as(u32, 16); pub const LINEDIALTONEMODE_UNAVAIL = @as(u32, 32); pub const LINEDIGITMODE_PULSE = @as(u32, 1); pub const LINEDIGITMODE_DTMF = @as(u32, 2); pub const LINEDIGITMODE_DTMFEND = @as(u32, 4); pub const LINEDISCONNECTMODE_NORMAL = @as(u32, 1); pub const LINEDISCONNECTMODE_UNKNOWN = @as(u32, 2); pub const LINEDISCONNECTMODE_REJECT = @as(u32, 4); pub const LINEDISCONNECTMODE_PICKUP = @as(u32, 8); pub const LINEDISCONNECTMODE_FORWARDED = @as(u32, 16); pub const LINEDISCONNECTMODE_BUSY = @as(u32, 32); pub const LINEDISCONNECTMODE_NOANSWER = @as(u32, 64); pub const LINEDISCONNECTMODE_BADADDRESS = @as(u32, 128); pub const LINEDISCONNECTMODE_UNREACHABLE = @as(u32, 256); pub const LINEDISCONNECTMODE_CONGESTION = @as(u32, 512); pub const LINEDISCONNECTMODE_INCOMPATIBLE = @as(u32, 1024); pub const LINEDISCONNECTMODE_UNAVAIL = @as(u32, 2048); pub const LINEDISCONNECTMODE_NODIALTONE = @as(u32, 4096); pub const LINEDISCONNECTMODE_NUMBERCHANGED = @as(u32, 8192); pub const LINEDISCONNECTMODE_OUTOFORDER = @as(u32, 16384); pub const LINEDISCONNECTMODE_TEMPFAILURE = @as(u32, 32768); pub const LINEDISCONNECTMODE_QOSUNAVAIL = @as(u32, 65536); pub const LINEDISCONNECTMODE_BLOCKED = @as(u32, 131072); pub const LINEDISCONNECTMODE_DONOTDISTURB = @as(u32, 262144); pub const LINEDISCONNECTMODE_CANCELLED = @as(u32, 524288); pub const LINEDISCONNECTMODE_DESTINATIONBARRED = @as(u32, 1048576); pub const LINEDISCONNECTMODE_FDNRESTRICT = @as(u32, 2097152); pub const LINEERR_ALLOCATED = @as(u32, 2147483649); pub const LINEERR_BADDEVICEID = @as(u32, 2147483650); pub const LINEERR_BEARERMODEUNAVAIL = @as(u32, 2147483651); pub const LINEERR_CALLUNAVAIL = @as(u32, 2147483653); pub const LINEERR_COMPLETIONOVERRUN = @as(u32, 2147483654); pub const LINEERR_CONFERENCEFULL = @as(u32, 2147483655); pub const LINEERR_DIALBILLING = @as(u32, 2147483656); pub const LINEERR_DIALDIALTONE = @as(u32, 2147483657); pub const LINEERR_DIALPROMPT = @as(u32, 2147483658); pub const LINEERR_DIALQUIET = @as(u32, 2147483659); pub const LINEERR_INCOMPATIBLEAPIVERSION = @as(u32, 2147483660); pub const LINEERR_INCOMPATIBLEEXTVERSION = @as(u32, 2147483661); pub const LINEERR_INIFILECORRUPT = @as(u32, 2147483662); pub const LINEERR_INUSE = @as(u32, 2147483663); pub const LINEERR_INVALADDRESS = @as(u32, 2147483664); pub const LINEERR_INVALADDRESSID = @as(u32, 2147483665); pub const LINEERR_INVALADDRESSMODE = @as(u32, 2147483666); pub const LINEERR_INVALADDRESSSTATE = @as(u32, 2147483667); pub const LINEERR_INVALAPPHANDLE = @as(u32, 2147483668); pub const LINEERR_INVALAPPNAME = @as(u32, 2147483669); pub const LINEERR_INVALBEARERMODE = @as(u32, 2147483670); pub const LINEERR_INVALCALLCOMPLMODE = @as(u32, 2147483671); pub const LINEERR_INVALCALLHANDLE = @as(u32, 2147483672); pub const LINEERR_INVALCALLPARAMS = @as(u32, 2147483673); pub const LINEERR_INVALCALLPRIVILEGE = @as(u32, 2147483674); pub const LINEERR_INVALCALLSELECT = @as(u32, 2147483675); pub const LINEERR_INVALCALLSTATE = @as(u32, 2147483676); pub const LINEERR_INVALCALLSTATELIST = @as(u32, 2147483677); pub const LINEERR_INVALCARD = @as(u32, 2147483678); pub const LINEERR_INVALCOMPLETIONID = @as(u32, 2147483679); pub const LINEERR_INVALCONFCALLHANDLE = @as(u32, 2147483680); pub const LINEERR_INVALCONSULTCALLHANDLE = @as(u32, 2147483681); pub const LINEERR_INVALCOUNTRYCODE = @as(u32, 2147483682); pub const LINEERR_INVALDEVICECLASS = @as(u32, 2147483683); pub const LINEERR_INVALDEVICEHANDLE = @as(u32, 2147483684); pub const LINEERR_INVALDIALPARAMS = @as(u32, 2147483685); pub const LINEERR_INVALDIGITLIST = @as(u32, 2147483686); pub const LINEERR_INVALDIGITMODE = @as(u32, 2147483687); pub const LINEERR_INVALDIGITS = @as(u32, 2147483688); pub const LINEERR_INVALEXTVERSION = @as(u32, 2147483689); pub const LINEERR_INVALGROUPID = @as(u32, 2147483690); pub const LINEERR_INVALLINEHANDLE = @as(u32, 2147483691); pub const LINEERR_INVALLINESTATE = @as(u32, 2147483692); pub const LINEERR_INVALLOCATION = @as(u32, 2147483693); pub const LINEERR_INVALMEDIALIST = @as(u32, 2147483694); pub const LINEERR_INVALMEDIAMODE = @as(u32, 2147483695); pub const LINEERR_INVALMESSAGEID = @as(u32, 2147483696); pub const LINEERR_INVALPARAM = @as(u32, 2147483698); pub const LINEERR_INVALPARKID = @as(u32, 2147483699); pub const LINEERR_INVALPARKMODE = @as(u32, 2147483700); pub const LINEERR_INVALPOINTER = @as(u32, 2147483701); pub const LINEERR_INVALPRIVSELECT = @as(u32, 2147483702); pub const LINEERR_INVALRATE = @as(u32, 2147483703); pub const LINEERR_INVALREQUESTMODE = @as(u32, 2147483704); pub const LINEERR_INVALTERMINALID = @as(u32, 2147483705); pub const LINEERR_INVALTERMINALMODE = @as(u32, 2147483706); pub const LINEERR_INVALTIMEOUT = @as(u32, 2147483707); pub const LINEERR_INVALTONE = @as(u32, 2147483708); pub const LINEERR_INVALTONELIST = @as(u32, 2147483709); pub const LINEERR_INVALTONEMODE = @as(u32, 2147483710); pub const LINEERR_INVALTRANSFERMODE = @as(u32, 2147483711); pub const LINEERR_LINEMAPPERFAILED = @as(u32, 2147483712); pub const LINEERR_NOCONFERENCE = @as(u32, 2147483713); pub const LINEERR_NODEVICE = @as(u32, 2147483714); pub const LINEERR_NODRIVER = @as(u32, 2147483715); pub const LINEERR_NOMEM = @as(u32, 2147483716); pub const LINEERR_NOREQUEST = @as(u32, 2147483717); pub const LINEERR_NOTOWNER = @as(u32, 2147483718); pub const LINEERR_NOTREGISTERED = @as(u32, 2147483719); pub const LINEERR_OPERATIONFAILED = @as(u32, 2147483720); pub const LINEERR_OPERATIONUNAVAIL = @as(u32, 2147483721); pub const LINEERR_RATEUNAVAIL = @as(u32, 2147483722); pub const LINEERR_RESOURCEUNAVAIL = @as(u32, 2147483723); pub const LINEERR_REQUESTOVERRUN = @as(u32, 2147483724); pub const LINEERR_STRUCTURETOOSMALL = @as(u32, 2147483725); pub const LINEERR_TARGETNOTFOUND = @as(u32, 2147483726); pub const LINEERR_TARGETSELF = @as(u32, 2147483727); pub const LINEERR_UNINITIALIZED = @as(u32, 2147483728); pub const LINEERR_USERUSERINFOTOOBIG = @as(u32, 2147483729); pub const LINEERR_REINIT = @as(u32, 2147483730); pub const LINEERR_ADDRESSBLOCKED = @as(u32, 2147483731); pub const LINEERR_BILLINGREJECTED = @as(u32, 2147483732); pub const LINEERR_INVALFEATURE = @as(u32, 2147483733); pub const LINEERR_NOMULTIPLEINSTANCE = @as(u32, 2147483734); pub const LINEERR_INVALAGENTID = @as(u32, 2147483735); pub const LINEERR_INVALAGENTGROUP = @as(u32, 2147483736); pub const LINEERR_INVALPASSWORD = @as(u32, 2147483737); pub const LINEERR_INVALAGENTSTATE = @as(u32, 2147483738); pub const LINEERR_INVALAGENTACTIVITY = @as(u32, 2147483739); pub const LINEERR_DIALVOICEDETECT = @as(u32, 2147483740); pub const LINEERR_USERCANCELLED = @as(u32, 2147483741); pub const LINEERR_INVALADDRESSTYPE = @as(u32, 2147483742); pub const LINEERR_INVALAGENTSESSIONSTATE = @as(u32, 2147483743); pub const LINEERR_DISCONNECTED = @as(u32, 2147483744); pub const LINEERR_SERVICE_NOT_RUNNING = @as(u32, 2147483745); pub const LINEFEATURE_DEVSPECIFIC = @as(u32, 1); pub const LINEFEATURE_DEVSPECIFICFEAT = @as(u32, 2); pub const LINEFEATURE_FORWARD = @as(u32, 4); pub const LINEFEATURE_MAKECALL = @as(u32, 8); pub const LINEFEATURE_SETMEDIACONTROL = @as(u32, 16); pub const LINEFEATURE_SETTERMINAL = @as(u32, 32); pub const LINEFEATURE_SETDEVSTATUS = @as(u32, 64); pub const LINEFEATURE_FORWARDFWD = @as(u32, 128); pub const LINEFEATURE_FORWARDDND = @as(u32, 256); pub const LINEFORWARDMODE_UNCOND = @as(u32, 1); pub const LINEFORWARDMODE_UNCONDINTERNAL = @as(u32, 2); pub const LINEFORWARDMODE_UNCONDEXTERNAL = @as(u32, 4); pub const LINEFORWARDMODE_UNCONDSPECIFIC = @as(u32, 8); pub const LINEFORWARDMODE_BUSY = @as(u32, 16); pub const LINEFORWARDMODE_BUSYINTERNAL = @as(u32, 32); pub const LINEFORWARDMODE_BUSYEXTERNAL = @as(u32, 64); pub const LINEFORWARDMODE_BUSYSPECIFIC = @as(u32, 128); pub const LINEFORWARDMODE_NOANSW = @as(u32, 256); pub const LINEFORWARDMODE_NOANSWINTERNAL = @as(u32, 512); pub const LINEFORWARDMODE_NOANSWEXTERNAL = @as(u32, 1024); pub const LINEFORWARDMODE_NOANSWSPECIFIC = @as(u32, 2048); pub const LINEFORWARDMODE_BUSYNA = @as(u32, 4096); pub const LINEFORWARDMODE_BUSYNAINTERNAL = @as(u32, 8192); pub const LINEFORWARDMODE_BUSYNAEXTERNAL = @as(u32, 16384); pub const LINEFORWARDMODE_BUSYNASPECIFIC = @as(u32, 32768); pub const LINEFORWARDMODE_UNKNOWN = @as(u32, 65536); pub const LINEFORWARDMODE_UNAVAIL = @as(u32, 131072); pub const LINEGATHERTERM_BUFFERFULL = @as(u32, 1); pub const LINEGATHERTERM_TERMDIGIT = @as(u32, 2); pub const LINEGATHERTERM_FIRSTTIMEOUT = @as(u32, 4); pub const LINEGATHERTERM_INTERTIMEOUT = @as(u32, 8); pub const LINEGATHERTERM_CANCEL = @as(u32, 16); pub const LINEGENERATETERM_DONE = @as(u32, 1); pub const LINEGENERATETERM_CANCEL = @as(u32, 2); pub const LINEINITIALIZEEXOPTION_USEHIDDENWINDOW = @as(u32, 1); pub const LINEINITIALIZEEXOPTION_USEEVENT = @as(u32, 2); pub const LINEINITIALIZEEXOPTION_USECOMPLETIONPORT = @as(u32, 3); pub const LINEINITIALIZEEXOPTION_CALLHUBTRACKING = @as(u32, 2147483648); pub const LINELOCATIONOPTION_PULSEDIAL = @as(u32, 1); pub const LINEMAPPER = @as(u32, 4294967295); pub const LINEMEDIACONTROL_NONE = @as(u32, 1); pub const LINEMEDIACONTROL_START = @as(u32, 2); pub const LINEMEDIACONTROL_RESET = @as(u32, 4); pub const LINEMEDIACONTROL_PAUSE = @as(u32, 8); pub const LINEMEDIACONTROL_RESUME = @as(u32, 16); pub const LINEMEDIACONTROL_RATEUP = @as(u32, 32); pub const LINEMEDIACONTROL_RATEDOWN = @as(u32, 64); pub const LINEMEDIACONTROL_RATENORMAL = @as(u32, 128); pub const LINEMEDIACONTROL_VOLUMEUP = @as(u32, 256); pub const LINEMEDIACONTROL_VOLUMEDOWN = @as(u32, 512); pub const LINEMEDIACONTROL_VOLUMENORMAL = @as(u32, 1024); pub const LINEMEDIAMODE_UNKNOWN = @as(u32, 2); pub const LINEMEDIAMODE_INTERACTIVEVOICE = @as(u32, 4); pub const LINEMEDIAMODE_AUTOMATEDVOICE = @as(u32, 8); pub const LINEMEDIAMODE_DATAMODEM = @as(u32, 16); pub const LINEMEDIAMODE_G3FAX = @as(u32, 32); pub const LINEMEDIAMODE_TDD = @as(u32, 64); pub const LINEMEDIAMODE_G4FAX = @as(u32, 128); pub const LINEMEDIAMODE_DIGITALDATA = @as(u32, 256); pub const LINEMEDIAMODE_TELETEX = @as(u32, 512); pub const LINEMEDIAMODE_VIDEOTEX = @as(u32, 1024); pub const LINEMEDIAMODE_TELEX = @as(u32, 2048); pub const LINEMEDIAMODE_MIXED = @as(u32, 4096); pub const LINEMEDIAMODE_ADSI = @as(u32, 8192); pub const LINEMEDIAMODE_VOICEVIEW = @as(u32, 16384); pub const LINEMEDIAMODE_VIDEO = @as(u32, 32768); pub const LAST_LINEMEDIAMODE = @as(u32, 32768); pub const LINEOFFERINGMODE_ACTIVE = @as(u32, 1); pub const LINEOFFERINGMODE_INACTIVE = @as(u32, 2); pub const LINEOPENOPTION_SINGLEADDRESS = @as(u32, 2147483648); pub const LINEOPENOPTION_PROXY = @as(u32, 1073741824); pub const LINEPARKMODE_DIRECTED = @as(u32, 1); pub const LINEPARKMODE_NONDIRECTED = @as(u32, 2); pub const LINEPROXYREQUEST_SETAGENTGROUP = @as(u32, 1); pub const LINEPROXYREQUEST_SETAGENTSTATE = @as(u32, 2); pub const LINEPROXYREQUEST_SETAGENTACTIVITY = @as(u32, 3); pub const LINEPROXYREQUEST_GETAGENTCAPS = @as(u32, 4); pub const LINEPROXYREQUEST_GETAGENTSTATUS = @as(u32, 5); pub const LINEPROXYREQUEST_AGENTSPECIFIC = @as(u32, 6); pub const LINEPROXYREQUEST_GETAGENTACTIVITYLIST = @as(u32, 7); pub const LINEPROXYREQUEST_GETAGENTGROUPLIST = @as(u32, 8); pub const LINEPROXYREQUEST_CREATEAGENT = @as(u32, 9); pub const LINEPROXYREQUEST_SETAGENTMEASUREMENTPERIOD = @as(u32, 10); pub const LINEPROXYREQUEST_GETAGENTINFO = @as(u32, 11); pub const LINEPROXYREQUEST_CREATEAGENTSESSION = @as(u32, 12); pub const LINEPROXYREQUEST_GETAGENTSESSIONLIST = @as(u32, 13); pub const LINEPROXYREQUEST_SETAGENTSESSIONSTATE = @as(u32, 14); pub const LINEPROXYREQUEST_GETAGENTSESSIONINFO = @as(u32, 15); pub const LINEPROXYREQUEST_GETQUEUELIST = @as(u32, 16); pub const LINEPROXYREQUEST_SETQUEUEMEASUREMENTPERIOD = @as(u32, 17); pub const LINEPROXYREQUEST_GETQUEUEINFO = @as(u32, 18); pub const LINEPROXYREQUEST_GETGROUPLIST = @as(u32, 19); pub const LINEPROXYREQUEST_SETAGENTSTATEEX = @as(u32, 20); pub const LINEREMOVEFROMCONF_NONE = @as(u32, 1); pub const LINEREMOVEFROMCONF_LAST = @as(u32, 2); pub const LINEREMOVEFROMCONF_ANY = @as(u32, 3); pub const LINEREQUESTMODE_MAKECALL = @as(u32, 1); pub const LINEREQUESTMODE_MEDIACALL = @as(u32, 2); pub const LINEREQUESTMODE_DROP = @as(u32, 4); pub const LAST_LINEREQUESTMODE = @as(u32, 2); pub const LINEROAMMODE_UNKNOWN = @as(u32, 1); pub const LINEROAMMODE_UNAVAIL = @as(u32, 2); pub const LINEROAMMODE_HOME = @as(u32, 4); pub const LINEROAMMODE_ROAMA = @as(u32, 8); pub const LINEROAMMODE_ROAMB = @as(u32, 16); pub const LINESPECIALINFO_NOCIRCUIT = @as(u32, 1); pub const LINESPECIALINFO_CUSTIRREG = @as(u32, 2); pub const LINESPECIALINFO_REORDER = @as(u32, 4); pub const LINESPECIALINFO_UNKNOWN = @as(u32, 8); pub const LINESPECIALINFO_UNAVAIL = @as(u32, 16); pub const LINETERMDEV_PHONE = @as(u32, 1); pub const LINETERMDEV_HEADSET = @as(u32, 2); pub const LINETERMDEV_SPEAKER = @as(u32, 4); pub const LINETERMMODE_BUTTONS = @as(u32, 1); pub const LINETERMMODE_LAMPS = @as(u32, 2); pub const LINETERMMODE_DISPLAY = @as(u32, 4); pub const LINETERMMODE_RINGER = @as(u32, 8); pub const LINETERMMODE_HOOKSWITCH = @as(u32, 16); pub const LINETERMMODE_MEDIATOLINE = @as(u32, 32); pub const LINETERMMODE_MEDIAFROMLINE = @as(u32, 64); pub const LINETERMMODE_MEDIABIDIRECT = @as(u32, 128); pub const LINETERMSHARING_PRIVATE = @as(u32, 1); pub const LINETERMSHARING_SHAREDEXCL = @as(u32, 2); pub const LINETERMSHARING_SHAREDCONF = @as(u32, 4); pub const LINETOLLLISTOPTION_ADD = @as(u32, 1); pub const LINETOLLLISTOPTION_REMOVE = @as(u32, 2); pub const LINETONEMODE_CUSTOM = @as(u32, 1); pub const LINETONEMODE_RINGBACK = @as(u32, 2); pub const LINETONEMODE_BUSY = @as(u32, 4); pub const LINETONEMODE_BEEP = @as(u32, 8); pub const LINETONEMODE_BILLING = @as(u32, 16); pub const LINETRANSFERMODE_TRANSFER = @as(u32, 1); pub const LINETRANSFERMODE_CONFERENCE = @as(u32, 2); pub const LINETRANSLATEOPTION_CARDOVERRIDE = @as(u32, 1); pub const LINETRANSLATEOPTION_CANCELCALLWAITING = @as(u32, 2); pub const LINETRANSLATEOPTION_FORCELOCAL = @as(u32, 4); pub const LINETRANSLATEOPTION_FORCELD = @as(u32, 8); pub const LINETRANSLATERESULT_CANONICAL = @as(u32, 1); pub const LINETRANSLATERESULT_INTERNATIONAL = @as(u32, 2); pub const LINETRANSLATERESULT_LONGDISTANCE = @as(u32, 4); pub const LINETRANSLATERESULT_LOCAL = @as(u32, 8); pub const LINETRANSLATERESULT_INTOLLLIST = @as(u32, 16); pub const LINETRANSLATERESULT_NOTINTOLLLIST = @as(u32, 32); pub const LINETRANSLATERESULT_DIALBILLING = @as(u32, 64); pub const LINETRANSLATERESULT_DIALQUIET = @as(u32, 128); pub const LINETRANSLATERESULT_DIALDIALTONE = @as(u32, 256); pub const LINETRANSLATERESULT_DIALPROMPT = @as(u32, 512); pub const LINETRANSLATERESULT_VOICEDETECT = @as(u32, 1024); pub const LINETRANSLATERESULT_NOTRANSLATION = @as(u32, 2048); pub const PHONEBUTTONFUNCTION_UNKNOWN = @as(u32, 0); pub const PHONEBUTTONFUNCTION_CONFERENCE = @as(u32, 1); pub const PHONEBUTTONFUNCTION_TRANSFER = @as(u32, 2); pub const PHONEBUTTONFUNCTION_DROP = @as(u32, 3); pub const PHONEBUTTONFUNCTION_HOLD = @as(u32, 4); pub const PHONEBUTTONFUNCTION_RECALL = @as(u32, 5); pub const PHONEBUTTONFUNCTION_DISCONNECT = @as(u32, 6); pub const PHONEBUTTONFUNCTION_CONNECT = @as(u32, 7); pub const PHONEBUTTONFUNCTION_MSGWAITON = @as(u32, 8); pub const PHONEBUTTONFUNCTION_MSGWAITOFF = @as(u32, 9); pub const PHONEBUTTONFUNCTION_SELECTRING = @as(u32, 10); pub const PHONEBUTTONFUNCTION_ABBREVDIAL = @as(u32, 11); pub const PHONEBUTTONFUNCTION_FORWARD = @as(u32, 12); pub const PHONEBUTTONFUNCTION_PICKUP = @as(u32, 13); pub const PHONEBUTTONFUNCTION_RINGAGAIN = @as(u32, 14); pub const PHONEBUTTONFUNCTION_PARK = @as(u32, 15); pub const PHONEBUTTONFUNCTION_REJECT = @as(u32, 16); pub const PHONEBUTTONFUNCTION_REDIRECT = @as(u32, 17); pub const PHONEBUTTONFUNCTION_MUTE = @as(u32, 18); pub const PHONEBUTTONFUNCTION_VOLUMEUP = @as(u32, 19); pub const PHONEBUTTONFUNCTION_VOLUMEDOWN = @as(u32, 20); pub const PHONEBUTTONFUNCTION_SPEAKERON = @as(u32, 21); pub const PHONEBUTTONFUNCTION_SPEAKEROFF = @as(u32, 22); pub const PHONEBUTTONFUNCTION_FLASH = @as(u32, 23); pub const PHONEBUTTONFUNCTION_DATAON = @as(u32, 24); pub const PHONEBUTTONFUNCTION_DATAOFF = @as(u32, 25); pub const PHONEBUTTONFUNCTION_DONOTDISTURB = @as(u32, 26); pub const PHONEBUTTONFUNCTION_INTERCOM = @as(u32, 27); pub const PHONEBUTTONFUNCTION_BRIDGEDAPP = @as(u32, 28); pub const PHONEBUTTONFUNCTION_BUSY = @as(u32, 29); pub const PHONEBUTTONFUNCTION_CALLAPP = @as(u32, 30); pub const PHONEBUTTONFUNCTION_DATETIME = @as(u32, 31); pub const PHONEBUTTONFUNCTION_DIRECTORY = @as(u32, 32); pub const PHONEBUTTONFUNCTION_COVER = @as(u32, 33); pub const PHONEBUTTONFUNCTION_CALLID = @as(u32, 34); pub const PHONEBUTTONFUNCTION_LASTNUM = @as(u32, 35); pub const PHONEBUTTONFUNCTION_NIGHTSRV = @as(u32, 36); pub const PHONEBUTTONFUNCTION_SENDCALLS = @as(u32, 37); pub const PHONEBUTTONFUNCTION_MSGINDICATOR = @as(u32, 38); pub const PHONEBUTTONFUNCTION_REPDIAL = @as(u32, 39); pub const PHONEBUTTONFUNCTION_SETREPDIAL = @as(u32, 40); pub const PHONEBUTTONFUNCTION_SYSTEMSPEED = @as(u32, 41); pub const PHONEBUTTONFUNCTION_STATIONSPEED = @as(u32, 42); pub const PHONEBUTTONFUNCTION_CAMPON = @as(u32, 43); pub const PHONEBUTTONFUNCTION_SAVEREPEAT = @as(u32, 44); pub const PHONEBUTTONFUNCTION_QUEUECALL = @as(u32, 45); pub const PHONEBUTTONFUNCTION_NONE = @as(u32, 46); pub const PHONEBUTTONFUNCTION_SEND = @as(u32, 47); pub const PHONEBUTTONMODE_DUMMY = @as(u32, 1); pub const PHONEBUTTONMODE_CALL = @as(u32, 2); pub const PHONEBUTTONMODE_FEATURE = @as(u32, 4); pub const PHONEBUTTONMODE_KEYPAD = @as(u32, 8); pub const PHONEBUTTONMODE_LOCAL = @as(u32, 16); pub const PHONEBUTTONMODE_DISPLAY = @as(u32, 32); pub const PHONEBUTTONSTATE_UP = @as(u32, 1); pub const PHONEBUTTONSTATE_DOWN = @as(u32, 2); pub const PHONEBUTTONSTATE_UNKNOWN = @as(u32, 4); pub const PHONEBUTTONSTATE_UNAVAIL = @as(u32, 8); pub const PHONEERR_ALLOCATED = @as(u32, 2415919105); pub const PHONEERR_BADDEVICEID = @as(u32, 2415919106); pub const PHONEERR_INCOMPATIBLEAPIVERSION = @as(u32, 2415919107); pub const PHONEERR_INCOMPATIBLEEXTVERSION = @as(u32, 2415919108); pub const PHONEERR_INIFILECORRUPT = @as(u32, 2415919109); pub const PHONEERR_INUSE = @as(u32, 2415919110); pub const PHONEERR_INVALAPPHANDLE = @as(u32, 2415919111); pub const PHONEERR_INVALAPPNAME = @as(u32, 2415919112); pub const PHONEERR_INVALBUTTONLAMPID = @as(u32, 2415919113); pub const PHONEERR_INVALBUTTONMODE = @as(u32, 2415919114); pub const PHONEERR_INVALBUTTONSTATE = @as(u32, 2415919115); pub const PHONEERR_INVALDATAID = @as(u32, 2415919116); pub const PHONEERR_INVALDEVICECLASS = @as(u32, 2415919117); pub const PHONEERR_INVALEXTVERSION = @as(u32, 2415919118); pub const PHONEERR_INVALHOOKSWITCHDEV = @as(u32, 2415919119); pub const PHONEERR_INVALHOOKSWITCHMODE = @as(u32, 2415919120); pub const PHONEERR_INVALLAMPMODE = @as(u32, 2415919121); pub const PHONEERR_INVALPARAM = @as(u32, 2415919122); pub const PHONEERR_INVALPHONEHANDLE = @as(u32, 2415919123); pub const PHONEERR_INVALPHONESTATE = @as(u32, 2415919124); pub const PHONEERR_INVALPOINTER = @as(u32, 2415919125); pub const PHONEERR_INVALPRIVILEGE = @as(u32, 2415919126); pub const PHONEERR_INVALRINGMODE = @as(u32, 2415919127); pub const PHONEERR_NODEVICE = @as(u32, 2415919128); pub const PHONEERR_NODRIVER = @as(u32, 2415919129); pub const PHONEERR_NOMEM = @as(u32, 2415919130); pub const PHONEERR_NOTOWNER = @as(u32, 2415919131); pub const PHONEERR_OPERATIONFAILED = @as(u32, 2415919132); pub const PHONEERR_OPERATIONUNAVAIL = @as(u32, 2415919133); pub const PHONEERR_RESOURCEUNAVAIL = @as(u32, 2415919135); pub const PHONEERR_REQUESTOVERRUN = @as(u32, 2415919136); pub const PHONEERR_STRUCTURETOOSMALL = @as(u32, 2415919137); pub const PHONEERR_UNINITIALIZED = @as(u32, 2415919138); pub const PHONEERR_REINIT = @as(u32, 2415919139); pub const PHONEERR_DISCONNECTED = @as(u32, 2415919140); pub const PHONEERR_SERVICE_NOT_RUNNING = @as(u32, 2415919141); pub const PHONEFEATURE_GETBUTTONINFO = @as(u32, 1); pub const PHONEFEATURE_GETDATA = @as(u32, 2); pub const PHONEFEATURE_GETDISPLAY = @as(u32, 4); pub const PHONEFEATURE_GETGAINHANDSET = @as(u32, 8); pub const PHONEFEATURE_GETGAINSPEAKER = @as(u32, 16); pub const PHONEFEATURE_GETGAINHEADSET = @as(u32, 32); pub const PHONEFEATURE_GETHOOKSWITCHHANDSET = @as(u32, 64); pub const PHONEFEATURE_GETHOOKSWITCHSPEAKER = @as(u32, 128); pub const PHONEFEATURE_GETHOOKSWITCHHEADSET = @as(u32, 256); pub const PHONEFEATURE_GETLAMP = @as(u32, 512); pub const PHONEFEATURE_GETRING = @as(u32, 1024); pub const PHONEFEATURE_GETVOLUMEHANDSET = @as(u32, 2048); pub const PHONEFEATURE_GETVOLUMESPEAKER = @as(u32, 4096); pub const PHONEFEATURE_GETVOLUMEHEADSET = @as(u32, 8192); pub const PHONEFEATURE_SETBUTTONINFO = @as(u32, 16384); pub const PHONEFEATURE_SETDATA = @as(u32, 32768); pub const PHONEFEATURE_SETDISPLAY = @as(u32, 65536); pub const PHONEFEATURE_SETGAINHANDSET = @as(u32, 131072); pub const PHONEFEATURE_SETGAINSPEAKER = @as(u32, 262144); pub const PHONEFEATURE_SETGAINHEADSET = @as(u32, 524288); pub const PHONEFEATURE_SETHOOKSWITCHHANDSET = @as(u32, 1048576); pub const PHONEFEATURE_SETHOOKSWITCHSPEAKER = @as(u32, 2097152); pub const PHONEFEATURE_SETHOOKSWITCHHEADSET = @as(u32, 4194304); pub const PHONEFEATURE_SETLAMP = @as(u32, 8388608); pub const PHONEFEATURE_SETRING = @as(u32, 16777216); pub const PHONEFEATURE_SETVOLUMEHANDSET = @as(u32, 33554432); pub const PHONEFEATURE_SETVOLUMESPEAKER = @as(u32, 67108864); pub const PHONEFEATURE_SETVOLUMEHEADSET = @as(u32, 134217728); pub const PHONEFEATURE_GENERICPHONE = @as(u32, 268435456); pub const PHONEHOOKSWITCHDEV_HANDSET = @as(u32, 1); pub const PHONEHOOKSWITCHDEV_SPEAKER = @as(u32, 2); pub const PHONEHOOKSWITCHDEV_HEADSET = @as(u32, 4); pub const PHONEHOOKSWITCHMODE_ONHOOK = @as(u32, 1); pub const PHONEHOOKSWITCHMODE_MIC = @as(u32, 2); pub const PHONEHOOKSWITCHMODE_SPEAKER = @as(u32, 4); pub const PHONEHOOKSWITCHMODE_MICSPEAKER = @as(u32, 8); pub const PHONEHOOKSWITCHMODE_UNKNOWN = @as(u32, 16); pub const PHONEINITIALIZEEXOPTION_USEHIDDENWINDOW = @as(u32, 1); pub const PHONEINITIALIZEEXOPTION_USEEVENT = @as(u32, 2); pub const PHONEINITIALIZEEXOPTION_USECOMPLETIONPORT = @as(u32, 3); pub const PHONELAMPMODE_DUMMY = @as(u32, 1); pub const PHONELAMPMODE_OFF = @as(u32, 2); pub const PHONELAMPMODE_STEADY = @as(u32, 4); pub const PHONELAMPMODE_WINK = @as(u32, 8); pub const PHONELAMPMODE_FLASH = @as(u32, 16); pub const PHONELAMPMODE_FLUTTER = @as(u32, 32); pub const PHONELAMPMODE_BROKENFLUTTER = @as(u32, 64); pub const PHONELAMPMODE_UNKNOWN = @as(u32, 128); pub const PHONEPRIVILEGE_MONITOR = @as(u32, 1); pub const PHONEPRIVILEGE_OWNER = @as(u32, 2); pub const PHONESTATE_OTHER = @as(u32, 1); pub const PHONESTATE_CONNECTED = @as(u32, 2); pub const PHONESTATE_DISCONNECTED = @as(u32, 4); pub const PHONESTATE_OWNER = @as(u32, 8); pub const PHONESTATE_MONITORS = @as(u32, 16); pub const PHONESTATE_DISPLAY = @as(u32, 32); pub const PHONESTATE_LAMP = @as(u32, 64); pub const PHONESTATE_RINGMODE = @as(u32, 128); pub const PHONESTATE_RINGVOLUME = @as(u32, 256); pub const PHONESTATE_HANDSETHOOKSWITCH = @as(u32, 512); pub const PHONESTATE_HANDSETVOLUME = @as(u32, 1024); pub const PHONESTATE_HANDSETGAIN = @as(u32, 2048); pub const PHONESTATE_SPEAKERHOOKSWITCH = @as(u32, 4096); pub const PHONESTATE_SPEAKERVOLUME = @as(u32, 8192); pub const PHONESTATE_SPEAKERGAIN = @as(u32, 16384); pub const PHONESTATE_HEADSETHOOKSWITCH = @as(u32, 32768); pub const PHONESTATE_HEADSETVOLUME = @as(u32, 65536); pub const PHONESTATE_HEADSETGAIN = @as(u32, 131072); pub const PHONESTATE_SUSPEND = @as(u32, 262144); pub const PHONESTATE_RESUME = @as(u32, 524288); pub const PHONESTATE_DEVSPECIFIC = @as(u32, 1048576); pub const PHONESTATE_REINIT = @as(u32, 2097152); pub const PHONESTATE_CAPSCHANGE = @as(u32, 4194304); pub const PHONESTATE_REMOVED = @as(u32, 8388608); pub const PHONESTATUSFLAGS_CONNECTED = @as(u32, 1); pub const PHONESTATUSFLAGS_SUSPENDED = @as(u32, 2); pub const STRINGFORMAT_ASCII = @as(u32, 1); pub const STRINGFORMAT_DBCS = @as(u32, 2); pub const STRINGFORMAT_UNICODE = @as(u32, 3); pub const STRINGFORMAT_BINARY = @as(u32, 4); pub const TAPI_REPLY = @as(u32, 1123); pub const TAPIERR_CONNECTED = @as(i32, 0); pub const TAPIERR_DROPPED = @as(i32, -1); pub const TAPIERR_NOREQUESTRECIPIENT = @as(i32, -2); pub const TAPIERR_REQUESTQUEUEFULL = @as(i32, -3); pub const TAPIERR_INVALDESTADDRESS = @as(i32, -4); pub const TAPIERR_INVALWINDOWHANDLE = @as(i32, -5); pub const TAPIERR_INVALDEVICECLASS = @as(i32, -6); pub const TAPIERR_INVALDEVICEID = @as(i32, -7); pub const TAPIERR_DEVICECLASSUNAVAIL = @as(i32, -8); pub const TAPIERR_DEVICEIDUNAVAIL = @as(i32, -9); pub const TAPIERR_DEVICEINUSE = @as(i32, -10); pub const TAPIERR_DESTBUSY = @as(i32, -11); pub const TAPIERR_DESTNOANSWER = @as(i32, -12); pub const TAPIERR_DESTUNAVAIL = @as(i32, -13); pub const TAPIERR_UNKNOWNWINHANDLE = @as(i32, -14); pub const TAPIERR_UNKNOWNREQUESTID = @as(i32, -15); pub const TAPIERR_REQUESTFAILED = @as(i32, -16); pub const TAPIERR_REQUESTCANCELLED = @as(i32, -17); pub const TAPIERR_INVALPOINTER = @as(i32, -18); pub const TAPIERR_NOTADMIN = @as(i32, -19); pub const TAPIERR_MMCWRITELOCKED = @as(i32, -20); pub const TAPIERR_PROVIDERALREADYINSTALLED = @as(i32, -21); pub const TAPIERR_SCP_ALREADY_EXISTS = @as(i32, -22); pub const TAPIERR_SCP_DOES_NOT_EXIST = @as(i32, -23); pub const TAPIMAXDESTADDRESSSIZE = @as(i32, 80); pub const TAPIMAXAPPNAMESIZE = @as(i32, 40); pub const TAPIMAXCALLEDPARTYSIZE = @as(i32, 40); pub const TAPIMAXCOMMENTSIZE = @as(i32, 80); pub const TAPIMAXDEVICECLASSSIZE = @as(i32, 40); pub const TAPIMAXDEVICEIDSIZE = @as(i32, 40); pub const INTERFACEMASK = @as(u32, 16711680); pub const DISPIDMASK = @as(u32, 65535); pub const IDISPTAPI = @as(u32, 65536); pub const IDISPTAPICALLCENTER = @as(u32, 131072); pub const IDISPCALLINFO = @as(u32, 65536); pub const IDISPBASICCALLCONTROL = @as(u32, 131072); pub const IDISPLEGACYCALLMEDIACONTROL = @as(u32, 196608); pub const IDISPAGGREGATEDMSPCALLOBJ = @as(u32, 262144); pub const IDISPADDRESS = @as(u32, 65536); pub const IDISPADDRESSCAPABILITIES = @as(u32, 131072); pub const IDISPMEDIASUPPORT = @as(u32, 196608); pub const IDISPADDRESSTRANSLATION = @as(u32, 262144); pub const IDISPLEGACYADDRESSMEDIACONTROL = @as(u32, 327680); pub const IDISPAGGREGATEDMSPADDRESSOBJ = @as(u32, 393216); pub const IDISPPHONE = @as(u32, 65536); pub const IDISPAPC = @as(u32, 131072); pub const IDISPMULTITRACK = @as(u32, 65536); pub const IDISPMEDIACONTROL = @as(u32, 131072); pub const IDISPMEDIARECORD = @as(u32, 196608); pub const IDISPMEDIAPLAYBACK = @as(u32, 262144); pub const IDISPFILETRACK = @as(u32, 65536); pub const TAPIMEDIATYPE_AUDIO = @as(u32, 8); pub const TAPIMEDIATYPE_VIDEO = @as(u32, 32768); pub const TAPIMEDIATYPE_DATAMODEM = @as(u32, 16); pub const TAPIMEDIATYPE_G3FAX = @as(u32, 32); pub const TAPIMEDIATYPE_MULTITRACK = @as(u32, 65536); pub const TSPI_MESSAGE_BASE = @as(u32, 500); pub const LINETSPIOPTION_NONREENTRANT = @as(u32, 1); pub const TUISPIDLL_OBJECT_LINEID = @as(i32, 1); pub const TUISPIDLL_OBJECT_PHONEID = @as(i32, 2); pub const TUISPIDLL_OBJECT_PROVIDERID = @as(i32, 3); pub const TUISPIDLL_OBJECT_DIALOGINSTANCE = @as(i32, 4); pub const PRIVATEOBJECT_NONE = @as(u32, 1); pub const PRIVATEOBJECT_CALLID = @as(u32, 2); pub const PRIVATEOBJECT_LINE = @as(u32, 3); pub const PRIVATEOBJECT_CALL = @as(u32, 4); pub const PRIVATEOBJECT_PHONE = @as(u32, 5); pub const PRIVATEOBJECT_ADDRESS = @as(u32, 6); pub const LINEQOSREQUESTTYPE_SERVICELEVEL = @as(u32, 1); pub const LINEQOSSERVICELEVEL_NEEDED = @as(u32, 1); pub const LINEQOSSERVICELEVEL_IFAVAILABLE = @as(u32, 2); pub const LINEQOSSERVICELEVEL_BESTEFFORT = @as(u32, 3); pub const LINEEQOSINFO_NOQOS = @as(u32, 1); pub const LINEEQOSINFO_ADMISSIONFAILURE = @as(u32, 2); pub const LINEEQOSINFO_POLICYFAILURE = @as(u32, 3); pub const LINEEQOSINFO_GENERICERROR = @as(u32, 4); pub const TSPI_PROC_BASE = @as(u32, 500); pub const TSPI_LINEACCEPT = @as(u32, 500); pub const TSPI_LINEADDTOCONFERENCE = @as(u32, 501); pub const TSPI_LINEANSWER = @as(u32, 502); pub const TSPI_LINEBLINDTRANSFER = @as(u32, 503); pub const TSPI_LINECLOSE = @as(u32, 504); pub const TSPI_LINECLOSECALL = @as(u32, 505); pub const TSPI_LINECOMPLETECALL = @as(u32, 506); pub const TSPI_LINECOMPLETETRANSFER = @as(u32, 507); pub const TSPI_LINECONDITIONALMEDIADETECTION = @as(u32, 508); pub const TSPI_LINECONFIGDIALOG = @as(u32, 509); pub const TSPI_LINEDEVSPECIFIC = @as(u32, 510); pub const TSPI_LINEDEVSPECIFICFEATURE = @as(u32, 511); pub const TSPI_LINEDIAL = @as(u32, 512); pub const TSPI_LINEDROP = @as(u32, 513); pub const TSPI_LINEFORWARD = @as(u32, 514); pub const TSPI_LINEGATHERDIGITS = @as(u32, 515); pub const TSPI_LINEGENERATEDIGITS = @as(u32, 516); pub const TSPI_LINEGENERATETONE = @as(u32, 517); pub const TSPI_LINEGETADDRESSCAPS = @as(u32, 518); pub const TSPI_LINEGETADDRESSID = @as(u32, 519); pub const TSPI_LINEGETADDRESSSTATUS = @as(u32, 520); pub const TSPI_LINEGETCALLADDRESSID = @as(u32, 521); pub const TSPI_LINEGETCALLINFO = @as(u32, 522); pub const TSPI_LINEGETCALLSTATUS = @as(u32, 523); pub const TSPI_LINEGETDEVCAPS = @as(u32, 524); pub const TSPI_LINEGETDEVCONFIG = @as(u32, 525); pub const TSPI_LINEGETEXTENSIONID = @as(u32, 526); pub const TSPI_LINEGETICON = @as(u32, 527); pub const TSPI_LINEGETID = @as(u32, 528); pub const TSPI_LINEGETLINEDEVSTATUS = @as(u32, 529); pub const TSPI_LINEGETNUMADDRESSIDS = @as(u32, 530); pub const TSPI_LINEHOLD = @as(u32, 531); pub const TSPI_LINEMAKECALL = @as(u32, 532); pub const TSPI_LINEMONITORDIGITS = @as(u32, 533); pub const TSPI_LINEMONITORMEDIA = @as(u32, 534); pub const TSPI_LINEMONITORTONES = @as(u32, 535); pub const TSPI_LINENEGOTIATEEXTVERSION = @as(u32, 536); pub const TSPI_LINENEGOTIATETSPIVERSION = @as(u32, 537); pub const TSPI_LINEOPEN = @as(u32, 538); pub const TSPI_LINEPARK = @as(u32, 539); pub const TSPI_LINEPICKUP = @as(u32, 540); pub const TSPI_LINEPREPAREADDTOCONFERENCE = @as(u32, 541); pub const TSPI_LINEREDIRECT = @as(u32, 542); pub const TSPI_LINEREMOVEFROMCONFERENCE = @as(u32, 543); pub const TSPI_LINESECURECALL = @as(u32, 544); pub const TSPI_LINESELECTEXTVERSION = @as(u32, 545); pub const TSPI_LINESENDUSERUSERINFO = @as(u32, 546); pub const TSPI_LINESETAPPSPECIFIC = @as(u32, 547); pub const TSPI_LINESETCALLPARAMS = @as(u32, 548); pub const TSPI_LINESETDEFAULTMEDIADETECTION = @as(u32, 549); pub const TSPI_LINESETDEVCONFIG = @as(u32, 550); pub const TSPI_LINESETMEDIACONTROL = @as(u32, 551); pub const TSPI_LINESETMEDIAMODE = @as(u32, 552); pub const TSPI_LINESETSTATUSMESSAGES = @as(u32, 553); pub const TSPI_LINESETTERMINAL = @as(u32, 554); pub const TSPI_LINESETUPCONFERENCE = @as(u32, 555); pub const TSPI_LINESETUPTRANSFER = @as(u32, 556); pub const TSPI_LINESWAPHOLD = @as(u32, 557); pub const TSPI_LINEUNCOMPLETECALL = @as(u32, 558); pub const TSPI_LINEUNHOLD = @as(u32, 559); pub const TSPI_LINEUNPARK = @as(u32, 560); pub const TSPI_PHONECLOSE = @as(u32, 561); pub const TSPI_PHONECONFIGDIALOG = @as(u32, 562); pub const TSPI_PHONEDEVSPECIFIC = @as(u32, 563); pub const TSPI_PHONEGETBUTTONINFO = @as(u32, 564); pub const TSPI_PHONEGETDATA = @as(u32, 565); pub const TSPI_PHONEGETDEVCAPS = @as(u32, 566); pub const TSPI_PHONEGETDISPLAY = @as(u32, 567); pub const TSPI_PHONEGETEXTENSIONID = @as(u32, 568); pub const TSPI_PHONEGETGAIN = @as(u32, 569); pub const TSPI_PHONEGETHOOKSWITCH = @as(u32, 570); pub const TSPI_PHONEGETICON = @as(u32, 571); pub const TSPI_PHONEGETID = @as(u32, 572); pub const TSPI_PHONEGETLAMP = @as(u32, 573); pub const TSPI_PHONEGETRING = @as(u32, 574); pub const TSPI_PHONEGETSTATUS = @as(u32, 575); pub const TSPI_PHONEGETVOLUME = @as(u32, 576); pub const TSPI_PHONENEGOTIATEEXTVERSION = @as(u32, 577); pub const TSPI_PHONENEGOTIATETSPIVERSION = @as(u32, 578); pub const TSPI_PHONEOPEN = @as(u32, 579); pub const TSPI_PHONESELECTEXTVERSION = @as(u32, 580); pub const TSPI_PHONESETBUTTONINFO = @as(u32, 581); pub const TSPI_PHONESETDATA = @as(u32, 582); pub const TSPI_PHONESETDISPLAY = @as(u32, 583); pub const TSPI_PHONESETGAIN = @as(u32, 584); pub const TSPI_PHONESETHOOKSWITCH = @as(u32, 585); pub const TSPI_PHONESETLAMP = @as(u32, 586); pub const TSPI_PHONESETRING = @as(u32, 587); pub const TSPI_PHONESETSTATUSMESSAGES = @as(u32, 588); pub const TSPI_PHONESETVOLUME = @as(u32, 589); pub const TSPI_PROVIDERCONFIG = @as(u32, 590); pub const TSPI_PROVIDERINIT = @as(u32, 591); pub const TSPI_PROVIDERINSTALL = @as(u32, 592); pub const TSPI_PROVIDERREMOVE = @as(u32, 593); pub const TSPI_PROVIDERSHUTDOWN = @as(u32, 594); pub const TSPI_PROVIDERENUMDEVICES = @as(u32, 595); pub const TSPI_LINEDROPONCLOSE = @as(u32, 596); pub const TSPI_LINEDROPNOOWNER = @as(u32, 597); pub const TSPI_PROVIDERCREATELINEDEVICE = @as(u32, 598); pub const TSPI_PROVIDERCREATEPHONEDEVICE = @as(u32, 599); pub const TSPI_LINESETCURRENTLOCATION = @as(u32, 600); pub const TSPI_LINECONFIGDIALOGEDIT = @as(u32, 601); pub const TSPI_LINERELEASEUSERUSERINFO = @as(u32, 602); pub const TSPI_LINEGETCALLID = @as(u32, 603); pub const TSPI_LINEGETCALLHUBTRACKING = @as(u32, 604); pub const TSPI_LINESETCALLHUBTRACKING = @as(u32, 605); pub const TSPI_LINERECEIVEMSPDATA = @as(u32, 606); pub const TSPI_LINEMSPIDENTIFY = @as(u32, 607); pub const TSPI_LINECREATEMSPINSTANCE = @as(u32, 608); pub const TSPI_LINECLOSEMSPINSTANCE = @as(u32, 609); pub const IDISPDIROBJECT = @as(u32, 65536); pub const IDISPDIROBJCONFERENCE = @as(u32, 131072); pub const IDISPDIROBJUSER = @as(u32, 196608); pub const IDISPDIRECTORY = @as(u32, 65536); pub const IDISPILSCONFIG = @as(u32, 131072); pub const RENDBIND_AUTHENTICATE = @as(u32, 1); pub const RENDBIND_DEFAULTDOMAINNAME = @as(u32, 2); pub const RENDBIND_DEFAULTUSERNAME = @as(u32, 4); pub const RENDBIND_DEFAULTPASSWORD = @as(u32, 8); pub const RENDBIND_DEFAULTCREDENTIALS = @as(u32, 14); pub const STRM_INITIAL = @as(u32, 0); pub const STRM_TERMINALSELECTED = @as(u32, 1); pub const STRM_CONFIGURED = @as(u32, 2); pub const STRM_RUNNING = @as(u32, 4); pub const STRM_PAUSED = @as(u32, 8); pub const STRM_STOPPED = @as(u32, 16); pub const TAPI_E_NOTENOUGHMEMORY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221503)); pub const TAPI_E_NOITEMS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221502)); pub const TAPI_E_NOTSUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221501)); pub const TAPI_E_INVALIDMEDIATYPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221500)); pub const TAPI_E_OPERATIONFAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221499)); pub const TAPI_E_ALLOCATED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221498)); pub const TAPI_E_CALLUNAVAIL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221497)); pub const TAPI_E_COMPLETIONOVERRUN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221496)); pub const TAPI_E_CONFERENCEFULL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221495)); pub const TAPI_E_DIALMODIFIERNOTSUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221494)); pub const TAPI_E_INUSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221493)); pub const TAPI_E_INVALADDRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221492)); pub const TAPI_E_INVALADDRESSSTATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221491)); pub const TAPI_E_INVALCALLPARAMS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221490)); pub const TAPI_E_INVALCALLPRIVILEGE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221489)); pub const TAPI_E_INVALCALLSTATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221488)); pub const TAPI_E_INVALCARD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221487)); pub const TAPI_E_INVALCOMPLETIONID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221486)); pub const TAPI_E_INVALCOUNTRYCODE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221485)); pub const TAPI_E_INVALDEVICECLASS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221484)); pub const TAPI_E_INVALDIALPARAMS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221483)); pub const TAPI_E_INVALDIGITS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221482)); pub const TAPI_E_INVALGROUPID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221481)); pub const TAPI_E_INVALLOCATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221480)); pub const TAPI_E_INVALMESSAGEID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221479)); pub const TAPI_E_INVALPARKID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221478)); pub const TAPI_E_INVALRATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221477)); pub const TAPI_E_INVALTIMEOUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221476)); pub const TAPI_E_INVALTONE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221475)); pub const TAPI_E_INVALLIST = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221474)); pub const TAPI_E_INVALMODE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221473)); pub const TAPI_E_NOCONFERENCE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221472)); pub const TAPI_E_NODEVICE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221471)); pub const TAPI_E_NOREQUEST = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221470)); pub const TAPI_E_NOTOWNER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221469)); pub const TAPI_E_NOTREGISTERED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221468)); pub const TAPI_E_REQUESTOVERRUN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221467)); pub const TAPI_E_TARGETNOTFOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221466)); pub const TAPI_E_TARGETSELF = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221465)); pub const TAPI_E_USERUSERINFOTOOBIG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221464)); pub const TAPI_E_REINIT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221463)); pub const TAPI_E_ADDRESSBLOCKED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221462)); pub const TAPI_E_BILLINGREJECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221461)); pub const TAPI_E_INVALFEATURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221460)); pub const TAPI_E_INVALBUTTONLAMPID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221459)); pub const TAPI_E_INVALBUTTONSTATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221458)); pub const TAPI_E_INVALDATAID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221457)); pub const TAPI_E_INVALHOOKSWITCHDEV = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221456)); pub const TAPI_E_DROPPED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221455)); pub const TAPI_E_NOREQUESTRECIPIENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221454)); pub const TAPI_E_REQUESTQUEUEFULL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221453)); pub const TAPI_E_DESTBUSY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221452)); pub const TAPI_E_DESTNOANSWER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221451)); pub const TAPI_E_DESTUNAVAIL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221450)); pub const TAPI_E_REQUESTFAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221449)); pub const TAPI_E_REQUESTCANCELLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221448)); pub const TAPI_E_INVALPRIVILEGE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221447)); pub const TAPI_E_INVALIDDIRECTION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221446)); pub const TAPI_E_INVALIDTERMINAL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221445)); pub const TAPI_E_INVALIDTERMINALCLASS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221444)); pub const TAPI_E_NODRIVER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221443)); pub const TAPI_E_MAXSTREAMS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221442)); pub const TAPI_E_NOTERMINALSELECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221441)); pub const TAPI_E_TERMINALINUSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221440)); pub const TAPI_E_NOTSTOPPED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221439)); pub const TAPI_E_MAXTERMINALS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221438)); pub const TAPI_E_INVALIDSTREAM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221437)); pub const TAPI_E_TIMEOUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221436)); pub const TAPI_E_CALLCENTER_GROUP_REMOVED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221435)); pub const TAPI_E_CALLCENTER_QUEUE_REMOVED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221434)); pub const TAPI_E_CALLCENTER_NO_AGENT_ID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221433)); pub const TAPI_E_CALLCENTER_INVALAGENTID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221432)); pub const TAPI_E_CALLCENTER_INVALAGENTGROUP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221431)); pub const TAPI_E_CALLCENTER_INVALPASSWORD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221430)); pub const TAPI_E_CALLCENTER_INVALAGENTSTATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221429)); pub const TAPI_E_CALLCENTER_INVALAGENTACTIVITY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221428)); pub const TAPI_E_REGISTRY_SETTING_CORRUPT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221427)); pub const TAPI_E_TERMINAL_PEER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221426)); pub const TAPI_E_PEER_NOT_SET = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221425)); pub const TAPI_E_NOEVENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221424)); pub const TAPI_E_INVALADDRESSTYPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221423)); pub const TAPI_E_RESOURCEUNAVAIL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221422)); pub const TAPI_E_PHONENOTOPEN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221421)); pub const TAPI_E_CALLNOTSELECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221420)); pub const TAPI_E_WRONGEVENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221419)); pub const TAPI_E_NOFORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221418)); pub const TAPI_E_INVALIDSTREAMSTATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221417)); pub const TAPI_E_WRONG_STATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221416)); pub const TAPI_E_NOT_INITIALIZED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221415)); pub const TAPI_E_SERVICE_NOT_RUNNING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147221414)); pub const atypNull = @as(i32, 0); pub const atypFile = @as(i32, 1); pub const atypOle = @as(i32, 2); pub const atypPicture = @as(i32, 3); pub const atypMax = @as(i32, 4); //-------------------------------------------------------------------------------- // Section: Types (269) //-------------------------------------------------------------------------------- pub const LINECALLBACK = fn( hDevice: u32, dwMessage: u32, dwInstance: usize, dwParam1: usize, dwParam2: usize, dwParam3: usize, ) callconv(@import("std").os.windows.WINAPI) void; pub const PHONECALLBACK = fn( hDevice: u32, dwMessage: u32, dwInstance: usize, dwParam1: usize, dwParam2: usize, dwParam3: usize, ) callconv(@import("std").os.windows.WINAPI) void; pub const LINEADDRESSCAPS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwLineDeviceID: u32, dwAddressSize: u32, dwAddressOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwAddressSharing: u32, dwAddressStates: u32, dwCallInfoStates: u32, dwCallerIDFlags: u32, dwCalledIDFlags: u32, dwConnectedIDFlags: u32, dwRedirectionIDFlags: u32, dwRedirectingIDFlags: u32, dwCallStates: u32, dwDialToneModes: u32, dwBusyModes: u32, dwSpecialInfo: u32, dwDisconnectModes: u32, dwMaxNumActiveCalls: u32, dwMaxNumOnHoldCalls: u32, dwMaxNumOnHoldPendingCalls: u32, dwMaxNumConference: u32, dwMaxNumTransConf: u32, dwAddrCapFlags: u32, dwCallFeatures: u32, dwRemoveFromConfCaps: u32, dwRemoveFromConfState: u32, dwTransferModes: u32, dwParkModes: u32, dwForwardModes: u32, dwMaxForwardEntries: u32, dwMaxSpecificEntries: u32, dwMinFwdNumRings: u32, dwMaxFwdNumRings: u32, dwMaxCallCompletions: u32, dwCallCompletionConds: u32, dwCallCompletionModes: u32, dwNumCompletionMessages: u32, dwCompletionMsgTextEntrySize: u32, dwCompletionMsgTextSize: u32, dwCompletionMsgTextOffset: u32, dwAddressFeatures: u32, dwPredictiveAutoTransferStates: u32, dwNumCallTreatments: u32, dwCallTreatmentListSize: u32, dwCallTreatmentListOffset: u32, dwDeviceClassesSize: u32, dwDeviceClassesOffset: u32, dwMaxCallDataSize: u32, dwCallFeatures2: u32, dwMaxNoAnswerTimeout: u32, dwConnectedModes: u32, dwOfferingModes: u32, dwAvailableMediaModes: u32, }; pub const LINEADDRESSSTATUS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumInUse: u32, dwNumActiveCalls: u32, dwNumOnHoldCalls: u32, dwNumOnHoldPendCalls: u32, dwAddressFeatures: u32, dwNumRingsNoAnswer: u32, dwForwardNumEntries: u32, dwForwardSize: u32, dwForwardOffset: u32, dwTerminalModesSize: u32, dwTerminalModesOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, }; pub const LINEAGENTACTIVITYENTRY = packed struct { dwID: u32, dwNameSize: u32, dwNameOffset: u32, }; pub const LINEAGENTACTIVITYLIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumEntries: u32, dwListSize: u32, dwListOffset: u32, }; pub const LINEAGENTCAPS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwAgentHandlerInfoSize: u32, dwAgentHandlerInfoOffset: u32, dwCapsVersion: u32, dwFeatures: u32, dwStates: u32, dwNextStates: u32, dwMaxNumGroupEntries: u32, dwAgentStatusMessages: u32, dwNumAgentExtensionIDs: u32, dwAgentExtensionIDListSize: u32, dwAgentExtensionIDListOffset: u32, ProxyGUID: Guid, }; pub const LINEAGENTGROUPENTRY = packed struct { GroupID: packed struct { dwGroupID1: u32, dwGroupID2: u32, dwGroupID3: u32, dwGroupID4: u32, }, dwNameSize: u32, dwNameOffset: u32, }; pub const LINEAGENTGROUPLIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumEntries: u32, dwListSize: u32, dwListOffset: u32, }; pub const LINEAGENTSTATUS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumEntries: u32, dwGroupListSize: u32, dwGroupListOffset: u32, dwState: u32, dwNextState: u32, dwActivityID: u32, dwActivitySize: u32, dwActivityOffset: u32, dwAgentFeatures: u32, dwValidStates: u32, dwValidNextStates: u32, }; pub const LINEAPPINFO = packed struct { dwMachineNameSize: u32, dwMachineNameOffset: u32, dwUserNameSize: u32, dwUserNameOffset: u32, dwModuleFilenameSize: u32, dwModuleFilenameOffset: u32, dwFriendlyNameSize: u32, dwFriendlyNameOffset: u32, dwMediaModes: u32, dwAddressID: u32, }; pub const LINEAGENTENTRY = packed struct { hAgent: u32, dwNameSize: u32, dwNameOffset: u32, dwIDSize: u32, dwIDOffset: u32, dwPINSize: u32, dwPINOffset: u32, }; pub const LINEAGENTLIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumEntries: u32, dwListSize: u32, dwListOffset: u32, }; pub const LINEAGENTINFO = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwAgentState: u32, dwNextAgentState: u32, dwMeasurementPeriod: u32, cyOverallCallRate: CY, dwNumberOfACDCalls: u32, dwNumberOfIncomingCalls: u32, dwNumberOfOutgoingCalls: u32, dwTotalACDTalkTime: u32, dwTotalACDCallTime: u32, dwTotalACDWrapUpTime: u32, }; pub const LINEAGENTSESSIONENTRY = packed struct { hAgentSession: u32, hAgent: u32, GroupID: Guid, dwWorkingAddressID: u32, }; pub const LINEAGENTSESSIONLIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumEntries: u32, dwListSize: u32, dwListOffset: u32, }; pub const LINEAGENTSESSIONINFO = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwAgentSessionState: u32, dwNextAgentSessionState: u32, dateSessionStartTime: f64, dwSessionDuration: u32, dwNumberOfCalls: u32, dwTotalTalkTime: u32, dwAverageTalkTime: u32, dwTotalCallTime: u32, dwAverageCallTime: u32, dwTotalWrapUpTime: u32, dwAverageWrapUpTime: u32, cyACDCallRate: CY, dwLongestTimeToAnswer: u32, dwAverageTimeToAnswer: u32, }; pub const LINEQUEUEENTRY = packed struct { dwQueueID: u32, dwNameSize: u32, dwNameOffset: u32, }; pub const LINEQUEUELIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumEntries: u32, dwListSize: u32, dwListOffset: u32, }; pub const LINEQUEUEINFO = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwMeasurementPeriod: u32, dwTotalCallsQueued: u32, dwCurrentCallsQueued: u32, dwTotalCallsAbandoned: u32, dwTotalCallsFlowedIn: u32, dwTotalCallsFlowedOut: u32, dwLongestEverWaitTime: u32, dwCurrentLongestWaitTime: u32, dwAverageWaitTime: u32, dwFinalDisposition: u32, }; pub const LINEPROXYREQUESTLIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumEntries: u32, dwListSize: u32, dwListOffset: u32, }; pub const LINEDIALPARAMS = packed struct { dwDialPause: u32, dwDialSpeed: u32, dwDigitDuration: u32, dwWaitForDialtone: u32, }; pub const LINECALLINFO = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, hLine: u32, dwLineDeviceID: u32, dwAddressID: u32, dwBearerMode: u32, dwRate: u32, dwMediaMode: u32, dwAppSpecific: u32, dwCallID: u32, dwRelatedCallID: u32, dwCallParamFlags: u32, dwCallStates: u32, dwMonitorDigitModes: u32, dwMonitorMediaModes: u32, DialParams: LINEDIALPARAMS, dwOrigin: u32, dwReason: u32, dwCompletionID: u32, dwNumOwners: u32, dwNumMonitors: u32, dwCountryCode: u32, dwTrunk: u32, dwCallerIDFlags: u32, dwCallerIDSize: u32, dwCallerIDOffset: u32, dwCallerIDNameSize: u32, dwCallerIDNameOffset: u32, dwCalledIDFlags: u32, dwCalledIDSize: u32, dwCalledIDOffset: u32, dwCalledIDNameSize: u32, dwCalledIDNameOffset: u32, dwConnectedIDFlags: u32, dwConnectedIDSize: u32, dwConnectedIDOffset: u32, dwConnectedIDNameSize: u32, dwConnectedIDNameOffset: u32, dwRedirectionIDFlags: u32, dwRedirectionIDSize: u32, dwRedirectionIDOffset: u32, dwRedirectionIDNameSize: u32, dwRedirectionIDNameOffset: u32, dwRedirectingIDFlags: u32, dwRedirectingIDSize: u32, dwRedirectingIDOffset: u32, dwRedirectingIDNameSize: u32, dwRedirectingIDNameOffset: u32, dwAppNameSize: u32, dwAppNameOffset: u32, dwDisplayableAddressSize: u32, dwDisplayableAddressOffset: u32, dwCalledPartySize: u32, dwCalledPartyOffset: u32, dwCommentSize: u32, dwCommentOffset: u32, dwDisplaySize: u32, dwDisplayOffset: u32, dwUserUserInfoSize: u32, dwUserUserInfoOffset: u32, dwHighLevelCompSize: u32, dwHighLevelCompOffset: u32, dwLowLevelCompSize: u32, dwLowLevelCompOffset: u32, dwChargingInfoSize: u32, dwChargingInfoOffset: u32, dwTerminalModesSize: u32, dwTerminalModesOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwCallTreatment: u32, dwCallDataSize: u32, dwCallDataOffset: u32, dwSendingFlowspecSize: u32, dwSendingFlowspecOffset: u32, dwReceivingFlowspecSize: u32, dwReceivingFlowspecOffset: u32, }; pub const LINECALLLIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwCallsNumEntries: u32, dwCallsSize: u32, dwCallsOffset: u32, }; pub const LINECALLPARAMS = packed struct { dwTotalSize: u32, dwBearerMode: u32, dwMinRate: u32, dwMaxRate: u32, dwMediaMode: u32, dwCallParamFlags: u32, dwAddressMode: u32, dwAddressID: u32, DialParams: LINEDIALPARAMS, dwOrigAddressSize: u32, dwOrigAddressOffset: u32, dwDisplayableAddressSize: u32, dwDisplayableAddressOffset: u32, dwCalledPartySize: u32, dwCalledPartyOffset: u32, dwCommentSize: u32, dwCommentOffset: u32, dwUserUserInfoSize: u32, dwUserUserInfoOffset: u32, dwHighLevelCompSize: u32, dwHighLevelCompOffset: u32, dwLowLevelCompSize: u32, dwLowLevelCompOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwPredictiveAutoTransferStates: u32, dwTargetAddressSize: u32, dwTargetAddressOffset: u32, dwSendingFlowspecSize: u32, dwSendingFlowspecOffset: u32, dwReceivingFlowspecSize: u32, dwReceivingFlowspecOffset: u32, dwDeviceClassSize: u32, dwDeviceClassOffset: u32, dwDeviceConfigSize: u32, dwDeviceConfigOffset: u32, dwCallDataSize: u32, dwCallDataOffset: u32, dwNoAnswerTimeout: u32, dwCallingPartyIDSize: u32, dwCallingPartyIDOffset: u32, }; pub const LINECALLSTATUS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwCallState: u32, dwCallStateMode: u32, dwCallPrivilege: u32, dwCallFeatures: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwCallFeatures2: u32, tStateEntryTime: SYSTEMTIME, }; pub const LINECALLTREATMENTENTRY = packed struct { dwCallTreatmentID: u32, dwCallTreatmentNameSize: u32, dwCallTreatmentNameOffset: u32, }; pub const LINECARDENTRY = packed struct { dwPermanentCardID: u32, dwCardNameSize: u32, dwCardNameOffset: u32, dwCardNumberDigits: u32, dwSameAreaRuleSize: u32, dwSameAreaRuleOffset: u32, dwLongDistanceRuleSize: u32, dwLongDistanceRuleOffset: u32, dwInternationalRuleSize: u32, dwInternationalRuleOffset: u32, dwOptions: u32, }; pub const LINECOUNTRYENTRY = packed struct { dwCountryID: u32, dwCountryCode: u32, dwNextCountryID: u32, dwCountryNameSize: u32, dwCountryNameOffset: u32, dwSameAreaRuleSize: u32, dwSameAreaRuleOffset: u32, dwLongDistanceRuleSize: u32, dwLongDistanceRuleOffset: u32, dwInternationalRuleSize: u32, dwInternationalRuleOffset: u32, }; pub const LINECOUNTRYLIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumCountries: u32, dwCountryListSize: u32, dwCountryListOffset: u32, }; pub const LINEDEVCAPS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwProviderInfoSize: u32, dwProviderInfoOffset: u32, dwSwitchInfoSize: u32, dwSwitchInfoOffset: u32, dwPermanentLineID: u32, dwLineNameSize: u32, dwLineNameOffset: u32, dwStringFormat: u32, dwAddressModes: u32, dwNumAddresses: u32, dwBearerModes: u32, dwMaxRate: u32, dwMediaModes: u32, dwGenerateToneModes: u32, dwGenerateToneMaxNumFreq: u32, dwGenerateDigitModes: u32, dwMonitorToneMaxNumFreq: u32, dwMonitorToneMaxNumEntries: u32, dwMonitorDigitModes: u32, dwGatherDigitsMinTimeout: u32, dwGatherDigitsMaxTimeout: u32, dwMedCtlDigitMaxListSize: u32, dwMedCtlMediaMaxListSize: u32, dwMedCtlToneMaxListSize: u32, dwMedCtlCallStateMaxListSize: u32, dwDevCapFlags: u32, dwMaxNumActiveCalls: u32, dwAnswerMode: u32, dwRingModes: u32, dwLineStates: u32, dwUUIAcceptSize: u32, dwUUIAnswerSize: u32, dwUUIMakeCallSize: u32, dwUUIDropSize: u32, dwUUISendUserUserInfoSize: u32, dwUUICallInfoSize: u32, MinDialParams: LINEDIALPARAMS, MaxDialParams: LINEDIALPARAMS, DefaultDialParams: LINEDIALPARAMS, dwNumTerminals: u32, dwTerminalCapsSize: u32, dwTerminalCapsOffset: u32, dwTerminalTextEntrySize: u32, dwTerminalTextSize: u32, dwTerminalTextOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwLineFeatures: u32, dwSettableDevStatus: u32, dwDeviceClassesSize: u32, dwDeviceClassesOffset: u32, PermanentLineGuid: Guid, }; pub const LINEDEVSTATUS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumOpens: u32, dwOpenMediaModes: u32, dwNumActiveCalls: u32, dwNumOnHoldCalls: u32, dwNumOnHoldPendCalls: u32, dwLineFeatures: u32, dwNumCallCompletions: u32, dwRingMode: u32, dwSignalLevel: u32, dwBatteryLevel: u32, dwRoamMode: u32, dwDevStatusFlags: u32, dwTerminalModesSize: u32, dwTerminalModesOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwAvailableMediaModes: u32, dwAppInfoSize: u32, dwAppInfoOffset: u32, }; pub const LINEEXTENSIONID = packed struct { dwExtensionID0: u32, dwExtensionID1: u32, dwExtensionID2: u32, dwExtensionID3: u32, }; pub const LINEFORWARD = packed struct { dwForwardMode: u32, dwCallerAddressSize: u32, dwCallerAddressOffset: u32, dwDestCountryCode: u32, dwDestAddressSize: u32, dwDestAddressOffset: u32, }; pub const LINEFORWARDLIST = packed struct { dwTotalSize: u32, dwNumEntries: u32, ForwardList: [1]LINEFORWARD, }; pub const LINEGENERATETONE = packed struct { dwFrequency: u32, dwCadenceOn: u32, dwCadenceOff: u32, dwVolume: u32, }; pub const LINEINITIALIZEEXPARAMS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwOptions: u32, Handles: packed union { hEvent: ?HANDLE, hCompletionPort: ?HANDLE, }, dwCompletionKey: u32, }; pub const LINELOCATIONENTRY = packed struct { dwPermanentLocationID: u32, dwLocationNameSize: u32, dwLocationNameOffset: u32, dwCountryCode: u32, dwCityCodeSize: u32, dwCityCodeOffset: u32, dwPreferredCardID: u32, dwLocalAccessCodeSize: u32, dwLocalAccessCodeOffset: u32, dwLongDistanceAccessCodeSize: u32, dwLongDistanceAccessCodeOffset: u32, dwTollPrefixListSize: u32, dwTollPrefixListOffset: u32, dwCountryID: u32, dwOptions: u32, dwCancelCallWaitingSize: u32, dwCancelCallWaitingOffset: u32, }; pub const LINEMEDIACONTROLCALLSTATE = packed struct { dwCallStates: u32, dwMediaControl: u32, }; pub const LINEMEDIACONTROLDIGIT = packed struct { dwDigit: u32, dwDigitModes: u32, dwMediaControl: u32, }; pub const LINEMEDIACONTROLMEDIA = packed struct { dwMediaModes: u32, dwDuration: u32, dwMediaControl: u32, }; pub const LINEMEDIACONTROLTONE = packed struct { dwAppSpecific: u32, dwDuration: u32, dwFrequency1: u32, dwFrequency2: u32, dwFrequency3: u32, dwMediaControl: u32, }; pub const LINEMESSAGE = packed struct { hDevice: u32, dwMessageID: u32, dwCallbackInstance: usize, dwParam1: usize, dwParam2: usize, dwParam3: usize, }; pub const LINEMONITORTONE = packed struct { dwAppSpecific: u32, dwDuration: u32, dwFrequency1: u32, dwFrequency2: u32, dwFrequency3: u32, }; pub const LINEPROVIDERENTRY = packed struct { dwPermanentProviderID: u32, dwProviderFilenameSize: u32, dwProviderFilenameOffset: u32, }; pub const LINEPROVIDERLIST = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumProviders: u32, dwProviderListSize: u32, dwProviderListOffset: u32, }; pub const LINEPROXYREQUEST = packed struct { dwSize: u32, dwClientMachineNameSize: u32, dwClientMachineNameOffset: u32, dwClientUserNameSize: u32, dwClientUserNameOffset: u32, dwClientAppAPIVersion: u32, dwRequestType: u32, Anonymous: extern union { SetAgentGroup: packed struct { dwAddressID: u32, GroupList: LINEAGENTGROUPLIST, }, SetAgentState: packed struct { dwAddressID: u32, dwAgentState: u32, dwNextAgentState: u32, }, SetAgentActivity: packed struct { dwAddressID: u32, dwActivityID: u32, }, GetAgentCaps: packed struct { dwAddressID: u32, AgentCaps: LINEAGENTCAPS, }, GetAgentStatus: packed struct { dwAddressID: u32, AgentStatus: LINEAGENTSTATUS, }, AgentSpecific: packed struct { dwAddressID: u32, dwAgentExtensionIDIndex: u32, dwSize: u32, Params: [1]u8, }, GetAgentActivityList: packed struct { dwAddressID: u32, ActivityList: LINEAGENTACTIVITYLIST, }, GetAgentGroupList: packed struct { dwAddressID: u32, GroupList: LINEAGENTGROUPLIST, }, CreateAgent: packed struct { hAgent: u32, dwAgentIDSize: u32, dwAgentIDOffset: u32, dwAgentPINSize: u32, dwAgentPINOffset: u32, }, SetAgentStateEx: packed struct { hAgent: u32, dwAgentState: u32, dwNextAgentState: u32, }, SetAgentMeasurementPeriod: packed struct { hAgent: u32, dwMeasurementPeriod: u32, }, GetAgentInfo: packed struct { hAgent: u32, AgentInfo: LINEAGENTINFO, }, CreateAgentSession: packed struct { hAgentSession: u32, dwAgentPINSize: u32, dwAgentPINOffset: u32, hAgent: u32, GroupID: Guid, dwWorkingAddressID: u32, }, GetAgentSessionList: packed struct { hAgent: u32, SessionList: LINEAGENTSESSIONLIST, }, GetAgentSessionInfo: packed struct { hAgentSession: u32, SessionInfo: LINEAGENTSESSIONINFO, }, SetAgentSessionState: packed struct { hAgentSession: u32, dwAgentSessionState: u32, dwNextAgentSessionState: u32, }, GetQueueList: packed struct { GroupID: Guid, QueueList: LINEQUEUELIST, }, SetQueueMeasurementPeriod: packed struct { dwQueueID: u32, dwMeasurementPeriod: u32, }, GetQueueInfo: packed struct { dwQueueID: u32, QueueInfo: LINEQUEUEINFO, }, GetGroupList: extern struct { GroupList: LINEAGENTGROUPLIST, }, }, }; pub const LINEREQMAKECALL = extern struct { szDestAddress: [80]CHAR, szAppName: [40]CHAR, szCalledParty: [40]CHAR, szComment: [80]CHAR, }; pub const linereqmakecallW_tag = packed struct { szDestAddress: [80]u16, szAppName: [40]u16, szCalledParty: [40]u16, szComment: [80]u16, }; pub const LINEREQMEDIACALL = packed struct { hWnd: ?HWND, wRequestID: WPARAM, szDeviceClass: [40]CHAR, ucDeviceID: [40]u8, dwSize: u32, dwSecure: u32, szDestAddress: [80]CHAR, szAppName: [40]CHAR, szCalledParty: [40]CHAR, szComment: [80]CHAR, }; pub const linereqmediacallW_tag = packed struct { hWnd: ?HWND, wRequestID: WPARAM, szDeviceClass: [40]u16, ucDeviceID: [40]u8, dwSize: u32, dwSecure: u32, szDestAddress: [80]u16, szAppName: [40]u16, szCalledParty: [40]u16, szComment: [80]u16, }; pub const LINETERMCAPS = packed struct { dwTermDev: u32, dwTermModes: u32, dwTermSharing: u32, }; pub const LINETRANSLATECAPS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwNumLocations: u32, dwLocationListSize: u32, dwLocationListOffset: u32, dwCurrentLocationID: u32, dwNumCards: u32, dwCardListSize: u32, dwCardListOffset: u32, dwCurrentPreferredCardID: u32, }; pub const LINETRANSLATEOUTPUT = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwDialableStringSize: u32, dwDialableStringOffset: u32, dwDisplayableStringSize: u32, dwDisplayableStringOffset: u32, dwCurrentCountry: u32, dwDestCountry: u32, dwTranslateResults: u32, }; pub const PHONEBUTTONINFO = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwButtonMode: u32, dwButtonFunction: u32, dwButtonTextSize: u32, dwButtonTextOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwButtonState: u32, }; pub const PHONECAPS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwProviderInfoSize: u32, dwProviderInfoOffset: u32, dwPhoneInfoSize: u32, dwPhoneInfoOffset: u32, dwPermanentPhoneID: u32, dwPhoneNameSize: u32, dwPhoneNameOffset: u32, dwStringFormat: u32, dwPhoneStates: u32, dwHookSwitchDevs: u32, dwHandsetHookSwitchModes: u32, dwSpeakerHookSwitchModes: u32, dwHeadsetHookSwitchModes: u32, dwVolumeFlags: u32, dwGainFlags: u32, dwDisplayNumRows: u32, dwDisplayNumColumns: u32, dwNumRingModes: u32, dwNumButtonLamps: u32, dwButtonModesSize: u32, dwButtonModesOffset: u32, dwButtonFunctionsSize: u32, dwButtonFunctionsOffset: u32, dwLampModesSize: u32, dwLampModesOffset: u32, dwNumSetData: u32, dwSetDataSize: u32, dwSetDataOffset: u32, dwNumGetData: u32, dwGetDataSize: u32, dwGetDataOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwDeviceClassesSize: u32, dwDeviceClassesOffset: u32, dwPhoneFeatures: u32, dwSettableHandsetHookSwitchModes: u32, dwSettableSpeakerHookSwitchModes: u32, dwSettableHeadsetHookSwitchModes: u32, dwMonitoredHandsetHookSwitchModes: u32, dwMonitoredSpeakerHookSwitchModes: u32, dwMonitoredHeadsetHookSwitchModes: u32, PermanentPhoneGuid: Guid, }; pub const PHONEEXTENSIONID = packed struct { dwExtensionID0: u32, dwExtensionID1: u32, dwExtensionID2: u32, dwExtensionID3: u32, }; pub const PHONEINITIALIZEEXPARAMS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwOptions: u32, Handles: packed union { hEvent: ?HANDLE, hCompletionPort: ?HANDLE, }, dwCompletionKey: u32, }; pub const PHONEMESSAGE = packed struct { hDevice: u32, dwMessageID: u32, dwCallbackInstance: usize, dwParam1: usize, dwParam2: usize, dwParam3: usize, }; pub const PHONESTATUS = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwStatusFlags: u32, dwNumOwners: u32, dwNumMonitors: u32, dwRingMode: u32, dwRingVolume: u32, dwHandsetHookSwitchMode: u32, dwHandsetVolume: u32, dwHandsetGain: u32, dwSpeakerHookSwitchMode: u32, dwSpeakerVolume: u32, dwSpeakerGain: u32, dwHeadsetHookSwitchMode: u32, dwHeadsetVolume: u32, dwHeadsetGain: u32, dwDisplaySize: u32, dwDisplayOffset: u32, dwLampModesSize: u32, dwLampModesOffset: u32, dwOwnerNameSize: u32, dwOwnerNameOffset: u32, dwDevSpecificSize: u32, dwDevSpecificOffset: u32, dwPhoneFeatures: u32, }; pub const VARSTRING = packed struct { dwTotalSize: u32, dwNeededSize: u32, dwUsedSize: u32, dwStringFormat: u32, dwStringSize: u32, dwStringOffset: u32, }; pub const HDRVCALL__ = extern struct { unused: i32, }; pub const HDRVLINE__ = extern struct { unused: i32, }; pub const HDRVPHONE__ = extern struct { unused: i32, }; pub const HDRVMSPLINE__ = extern struct { unused: i32, }; pub const HDRVDIALOGINSTANCE__ = extern struct { unused: i32, }; pub const HTAPICALL__ = extern struct { unused: i32, }; pub const HTAPILINE__ = extern struct { unused: i32, }; pub const HTAPIPHONE__ = extern struct { unused: i32, }; pub const HPROVIDER__ = extern struct { unused: i32, }; pub const ASYNC_COMPLETION = fn( dwRequestID: u32, lResult: i32, ) callconv(@import("std").os.windows.WINAPI) void; pub const LINEEVENT = fn( htLine: ?*HTAPILINE__, htCall: ?*HTAPICALL__, dwMsg: u32, dwParam1: usize, dwParam2: usize, dwParam3: usize, ) callconv(@import("std").os.windows.WINAPI) void; pub const PHONEEVENT = fn( htPhone: ?*HTAPIPHONE__, dwMsg: u32, dwParam1: usize, dwParam2: usize, dwParam3: usize, ) callconv(@import("std").os.windows.WINAPI) void; pub const TUISPIDLLCALLBACK = fn( dwObjectID: usize, dwObjectType: u32, lpParams: ?*anyopaque, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub const TUISPICREATEDIALOGINSTANCEPARAMS = extern struct { dwRequestID: u32, hdDlgInst: ?*HDRVDIALOGINSTANCE__, htDlgInst: u32, lpszUIDLLName: ?[*:0]const u16, lpParams: ?*anyopaque, dwSize: u32, }; const CLSID_TAPI_Value = @import("../zig.zig").Guid.initString("21d6d48e-a88b-11d0-83dd-00aa003ccabd"); pub const CLSID_TAPI = &CLSID_TAPI_Value; const CLSID_DispatchMapper_Value = @import("../zig.zig").Guid.initString("e9225296-c759-11d1-a02b-00c04fb6809f"); pub const CLSID_DispatchMapper = &CLSID_DispatchMapper_Value; const CLSID_RequestMakeCall_Value = @import("../zig.zig").Guid.initString("ac48ffe0-f8c4-11d1-a030-00c04fb6809f"); pub const CLSID_RequestMakeCall = &CLSID_RequestMakeCall_Value; pub const TAPI_TONEMODE = enum(i32) { RINGBACK = 2, BUSY = 4, BEEP = 8, BILLING = 16, }; pub const TTM_RINGBACK = TAPI_TONEMODE.RINGBACK; pub const TTM_BUSY = TAPI_TONEMODE.BUSY; pub const TTM_BEEP = TAPI_TONEMODE.BEEP; pub const TTM_BILLING = TAPI_TONEMODE.BILLING; pub const TAPI_GATHERTERM = enum(i32) { BUFFERFULL = 1, TERMDIGIT = 2, FIRSTTIMEOUT = 4, INTERTIMEOUT = 8, CANCEL = 16, }; pub const TGT_BUFFERFULL = TAPI_GATHERTERM.BUFFERFULL; pub const TGT_TERMDIGIT = TAPI_GATHERTERM.TERMDIGIT; pub const TGT_FIRSTTIMEOUT = TAPI_GATHERTERM.FIRSTTIMEOUT; pub const TGT_INTERTIMEOUT = TAPI_GATHERTERM.INTERTIMEOUT; pub const TGT_CANCEL = TAPI_GATHERTERM.CANCEL; pub const TAPI_CUSTOMTONE = extern struct { dwFrequency: u32, dwCadenceOn: u32, dwCadenceOff: u32, dwVolume: u32, }; pub const TAPI_DETECTTONE = extern struct { dwAppSpecific: u32, dwDuration: u32, dwFrequency1: u32, dwFrequency2: u32, dwFrequency3: u32, }; pub const ADDRESS_EVENT = enum(i32) { STATE = 0, CAPSCHANGE = 1, RINGING = 2, CONFIGCHANGE = 3, FORWARD = 4, NEWTERMINAL = 5, REMOVETERMINAL = 6, MSGWAITON = 7, MSGWAITOFF = 8, // LASTITEM = 8, this enum value conflicts with MSGWAITOFF }; pub const AE_STATE = ADDRESS_EVENT.STATE; pub const AE_CAPSCHANGE = ADDRESS_EVENT.CAPSCHANGE; pub const AE_RINGING = ADDRESS_EVENT.RINGING; pub const AE_CONFIGCHANGE = ADDRESS_EVENT.CONFIGCHANGE; pub const AE_FORWARD = ADDRESS_EVENT.FORWARD; pub const AE_NEWTERMINAL = ADDRESS_EVENT.NEWTERMINAL; pub const AE_REMOVETERMINAL = ADDRESS_EVENT.REMOVETERMINAL; pub const AE_MSGWAITON = ADDRESS_EVENT.MSGWAITON; pub const AE_MSGWAITOFF = ADDRESS_EVENT.MSGWAITOFF; pub const AE_LASTITEM = ADDRESS_EVENT.MSGWAITOFF; pub const ADDRESS_STATE = enum(i32) { INSERVICE = 0, OUTOFSERVICE = 1, }; pub const AS_INSERVICE = ADDRESS_STATE.INSERVICE; pub const AS_OUTOFSERVICE = ADDRESS_STATE.OUTOFSERVICE; pub const CALL_STATE = enum(i32) { IDLE = 0, INPROGRESS = 1, CONNECTED = 2, DISCONNECTED = 3, OFFERING = 4, HOLD = 5, QUEUED = 6, // LASTITEM = 6, this enum value conflicts with QUEUED }; pub const CS_IDLE = CALL_STATE.IDLE; pub const CS_INPROGRESS = CALL_STATE.INPROGRESS; pub const CS_CONNECTED = CALL_STATE.CONNECTED; pub const CS_DISCONNECTED = CALL_STATE.DISCONNECTED; pub const CS_OFFERING = CALL_STATE.OFFERING; pub const CS_HOLD = CALL_STATE.HOLD; pub const CS_QUEUED = CALL_STATE.QUEUED; pub const CS_LASTITEM = CALL_STATE.QUEUED; pub const CALL_STATE_EVENT_CAUSE = enum(i32) { NONE = 0, DISCONNECT_NORMAL = 1, DISCONNECT_BUSY = 2, DISCONNECT_BADADDRESS = 3, DISCONNECT_NOANSWER = 4, DISCONNECT_CANCELLED = 5, DISCONNECT_REJECTED = 6, DISCONNECT_FAILED = 7, DISCONNECT_BLOCKED = 8, }; pub const CEC_NONE = CALL_STATE_EVENT_CAUSE.NONE; pub const CEC_DISCONNECT_NORMAL = CALL_STATE_EVENT_CAUSE.DISCONNECT_NORMAL; pub const CEC_DISCONNECT_BUSY = CALL_STATE_EVENT_CAUSE.DISCONNECT_BUSY; pub const CEC_DISCONNECT_BADADDRESS = CALL_STATE_EVENT_CAUSE.DISCONNECT_BADADDRESS; pub const CEC_DISCONNECT_NOANSWER = CALL_STATE_EVENT_CAUSE.DISCONNECT_NOANSWER; pub const CEC_DISCONNECT_CANCELLED = CALL_STATE_EVENT_CAUSE.DISCONNECT_CANCELLED; pub const CEC_DISCONNECT_REJECTED = CALL_STATE_EVENT_CAUSE.DISCONNECT_REJECTED; pub const CEC_DISCONNECT_FAILED = CALL_STATE_EVENT_CAUSE.DISCONNECT_FAILED; pub const CEC_DISCONNECT_BLOCKED = CALL_STATE_EVENT_CAUSE.DISCONNECT_BLOCKED; pub const CALL_MEDIA_EVENT = enum(i32) { NEW_STREAM = 0, STREAM_FAIL = 1, TERMINAL_FAIL = 2, STREAM_NOT_USED = 3, STREAM_ACTIVE = 4, STREAM_INACTIVE = 5, // LASTITEM = 5, this enum value conflicts with STREAM_INACTIVE }; pub const CME_NEW_STREAM = CALL_MEDIA_EVENT.NEW_STREAM; pub const CME_STREAM_FAIL = CALL_MEDIA_EVENT.STREAM_FAIL; pub const CME_TERMINAL_FAIL = CALL_MEDIA_EVENT.TERMINAL_FAIL; pub const CME_STREAM_NOT_USED = CALL_MEDIA_EVENT.STREAM_NOT_USED; pub const CME_STREAM_ACTIVE = CALL_MEDIA_EVENT.STREAM_ACTIVE; pub const CME_STREAM_INACTIVE = CALL_MEDIA_EVENT.STREAM_INACTIVE; pub const CME_LASTITEM = CALL_MEDIA_EVENT.STREAM_INACTIVE; pub const CALL_MEDIA_EVENT_CAUSE = enum(i32) { UNKNOWN = 0, BAD_DEVICE = 1, CONNECT_FAIL = 2, LOCAL_REQUEST = 3, REMOTE_REQUEST = 4, MEDIA_TIMEOUT = 5, MEDIA_RECOVERED = 6, QUALITY_OF_SERVICE = 7, }; pub const CMC_UNKNOWN = CALL_MEDIA_EVENT_CAUSE.UNKNOWN; pub const CMC_BAD_DEVICE = CALL_MEDIA_EVENT_CAUSE.BAD_DEVICE; pub const CMC_CONNECT_FAIL = CALL_MEDIA_EVENT_CAUSE.CONNECT_FAIL; pub const CMC_LOCAL_REQUEST = CALL_MEDIA_EVENT_CAUSE.LOCAL_REQUEST; pub const CMC_REMOTE_REQUEST = CALL_MEDIA_EVENT_CAUSE.REMOTE_REQUEST; pub const CMC_MEDIA_TIMEOUT = CALL_MEDIA_EVENT_CAUSE.MEDIA_TIMEOUT; pub const CMC_MEDIA_RECOVERED = CALL_MEDIA_EVENT_CAUSE.MEDIA_RECOVERED; pub const CMC_QUALITY_OF_SERVICE = CALL_MEDIA_EVENT_CAUSE.QUALITY_OF_SERVICE; pub const DISCONNECT_CODE = enum(i32) { NORMAL = 0, NOANSWER = 1, REJECTED = 2, }; pub const DC_NORMAL = DISCONNECT_CODE.NORMAL; pub const DC_NOANSWER = DISCONNECT_CODE.NOANSWER; pub const DC_REJECTED = DISCONNECT_CODE.REJECTED; pub const TERMINAL_STATE = enum(i32) { INUSE = 0, NOTINUSE = 1, }; pub const TS_INUSE = TERMINAL_STATE.INUSE; pub const TS_NOTINUSE = TERMINAL_STATE.NOTINUSE; pub const TERMINAL_DIRECTION = enum(i32) { CAPTURE = 0, RENDER = 1, BIDIRECTIONAL = 2, MULTITRACK_MIXED = 3, NONE = 4, }; pub const TD_CAPTURE = TERMINAL_DIRECTION.CAPTURE; pub const TD_RENDER = TERMINAL_DIRECTION.RENDER; pub const TD_BIDIRECTIONAL = TERMINAL_DIRECTION.BIDIRECTIONAL; pub const TD_MULTITRACK_MIXED = TERMINAL_DIRECTION.MULTITRACK_MIXED; pub const TD_NONE = TERMINAL_DIRECTION.NONE; pub const TERMINAL_TYPE = enum(i32) { STATIC = 0, DYNAMIC = 1, }; pub const TT_STATIC = TERMINAL_TYPE.STATIC; pub const TT_DYNAMIC = TERMINAL_TYPE.DYNAMIC; pub const CALL_PRIVILEGE = enum(i32) { OWNER = 0, MONITOR = 1, }; pub const CP_OWNER = CALL_PRIVILEGE.OWNER; pub const CP_MONITOR = CALL_PRIVILEGE.MONITOR; pub const TAPI_EVENT = enum(i32) { TAPIOBJECT = 1, ADDRESS = 2, CALLNOTIFICATION = 4, CALLSTATE = 8, CALLMEDIA = 16, CALLHUB = 32, CALLINFOCHANGE = 64, PRIVATE = 128, REQUEST = 256, AGENT = 512, AGENTSESSION = 1024, QOSEVENT = 2048, AGENTHANDLER = 4096, ACDGROUP = 8192, QUEUE = 16384, DIGITEVENT = 32768, GENERATEEVENT = 65536, ASRTERMINAL = 131072, TTSTERMINAL = 262144, FILETERMINAL = 524288, TONETERMINAL = 1048576, PHONEEVENT = 2097152, TONEEVENT = 4194304, GATHERDIGITS = 8388608, ADDRESSDEVSPECIFIC = 16777216, PHONEDEVSPECIFIC = 33554432, }; pub const TE_TAPIOBJECT = TAPI_EVENT.TAPIOBJECT; pub const TE_ADDRESS = TAPI_EVENT.ADDRESS; pub const TE_CALLNOTIFICATION = TAPI_EVENT.CALLNOTIFICATION; pub const TE_CALLSTATE = TAPI_EVENT.CALLSTATE; pub const TE_CALLMEDIA = TAPI_EVENT.CALLMEDIA; pub const TE_CALLHUB = TAPI_EVENT.CALLHUB; pub const TE_CALLINFOCHANGE = TAPI_EVENT.CALLINFOCHANGE; pub const TE_PRIVATE = TAPI_EVENT.PRIVATE; pub const TE_REQUEST = TAPI_EVENT.REQUEST; pub const TE_AGENT = TAPI_EVENT.AGENT; pub const TE_AGENTSESSION = TAPI_EVENT.AGENTSESSION; pub const TE_QOSEVENT = TAPI_EVENT.QOSEVENT; pub const TE_AGENTHANDLER = TAPI_EVENT.AGENTHANDLER; pub const TE_ACDGROUP = TAPI_EVENT.ACDGROUP; pub const TE_QUEUE = TAPI_EVENT.QUEUE; pub const TE_DIGITEVENT = TAPI_EVENT.DIGITEVENT; pub const TE_GENERATEEVENT = TAPI_EVENT.GENERATEEVENT; pub const TE_ASRTERMINAL = TAPI_EVENT.ASRTERMINAL; pub const TE_TTSTERMINAL = TAPI_EVENT.TTSTERMINAL; pub const TE_FILETERMINAL = TAPI_EVENT.FILETERMINAL; pub const TE_TONETERMINAL = TAPI_EVENT.TONETERMINAL; pub const TE_PHONEEVENT = TAPI_EVENT.PHONEEVENT; pub const TE_TONEEVENT = TAPI_EVENT.TONEEVENT; pub const TE_GATHERDIGITS = TAPI_EVENT.GATHERDIGITS; pub const TE_ADDRESSDEVSPECIFIC = TAPI_EVENT.ADDRESSDEVSPECIFIC; pub const TE_PHONEDEVSPECIFIC = TAPI_EVENT.PHONEDEVSPECIFIC; pub const CALL_NOTIFICATION_EVENT = enum(i32) { OWNER = 0, MONITOR = 1, // LASTITEM = 1, this enum value conflicts with MONITOR }; pub const CNE_OWNER = CALL_NOTIFICATION_EVENT.OWNER; pub const CNE_MONITOR = CALL_NOTIFICATION_EVENT.MONITOR; pub const CNE_LASTITEM = CALL_NOTIFICATION_EVENT.MONITOR; pub const CALLHUB_EVENT = enum(i32) { CALLJOIN = 0, CALLLEAVE = 1, CALLHUBNEW = 2, CALLHUBIDLE = 3, // LASTITEM = 3, this enum value conflicts with CALLHUBIDLE }; pub const CHE_CALLJOIN = CALLHUB_EVENT.CALLJOIN; pub const CHE_CALLLEAVE = CALLHUB_EVENT.CALLLEAVE; pub const CHE_CALLHUBNEW = CALLHUB_EVENT.CALLHUBNEW; pub const CHE_CALLHUBIDLE = CALLHUB_EVENT.CALLHUBIDLE; pub const CHE_LASTITEM = CALLHUB_EVENT.CALLHUBIDLE; pub const CALLHUB_STATE = enum(i32) { ACTIVE = 0, IDLE = 1, }; pub const CHS_ACTIVE = CALLHUB_STATE.ACTIVE; pub const CHS_IDLE = CALLHUB_STATE.IDLE; pub const TAPIOBJECT_EVENT = enum(i32) { ADDRESSCREATE = 0, ADDRESSREMOVE = 1, REINIT = 2, TRANSLATECHANGE = 3, ADDRESSCLOSE = 4, PHONECREATE = 5, PHONEREMOVE = 6, }; pub const TE_ADDRESSCREATE = TAPIOBJECT_EVENT.ADDRESSCREATE; pub const TE_ADDRESSREMOVE = TAPIOBJECT_EVENT.ADDRESSREMOVE; pub const TE_REINIT = TAPIOBJECT_EVENT.REINIT; pub const TE_TRANSLATECHANGE = TAPIOBJECT_EVENT.TRANSLATECHANGE; pub const TE_ADDRESSCLOSE = TAPIOBJECT_EVENT.ADDRESSCLOSE; pub const TE_PHONECREATE = TAPIOBJECT_EVENT.PHONECREATE; pub const TE_PHONEREMOVE = TAPIOBJECT_EVENT.PHONEREMOVE; pub const TAPI_OBJECT_TYPE = enum(i32) { NONE = 0, TAPI = 1, ADDRESS = 2, TERMINAL = 3, CALL = 4, CALLHUB = 5, PHONE = 6, }; pub const TOT_NONE = TAPI_OBJECT_TYPE.NONE; pub const TOT_TAPI = TAPI_OBJECT_TYPE.TAPI; pub const TOT_ADDRESS = TAPI_OBJECT_TYPE.ADDRESS; pub const TOT_TERMINAL = TAPI_OBJECT_TYPE.TERMINAL; pub const TOT_CALL = TAPI_OBJECT_TYPE.CALL; pub const TOT_CALLHUB = TAPI_OBJECT_TYPE.CALLHUB; pub const TOT_PHONE = TAPI_OBJECT_TYPE.PHONE; pub const QOS_SERVICE_LEVEL = enum(i32) { NEEDED = 1, IF_AVAILABLE = 2, BEST_EFFORT = 3, }; pub const QSL_NEEDED = QOS_SERVICE_LEVEL.NEEDED; pub const QSL_IF_AVAILABLE = QOS_SERVICE_LEVEL.IF_AVAILABLE; pub const QSL_BEST_EFFORT = QOS_SERVICE_LEVEL.BEST_EFFORT; pub const QOS_EVENT = enum(i32) { NOQOS = 1, ADMISSIONFAILURE = 2, POLICYFAILURE = 3, GENERICERROR = 4, // LASTITEM = 4, this enum value conflicts with GENERICERROR }; pub const QE_NOQOS = QOS_EVENT.NOQOS; pub const QE_ADMISSIONFAILURE = QOS_EVENT.ADMISSIONFAILURE; pub const QE_POLICYFAILURE = QOS_EVENT.POLICYFAILURE; pub const QE_GENERICERROR = QOS_EVENT.GENERICERROR; pub const QE_LASTITEM = QOS_EVENT.GENERICERROR; pub const CALLINFOCHANGE_CAUSE = enum(i32) { OTHER = 0, DEVSPECIFIC = 1, BEARERMODE = 2, RATE = 3, APPSPECIFIC = 4, CALLID = 5, RELATEDCALLID = 6, ORIGIN = 7, REASON = 8, COMPLETIONID = 9, NUMOWNERINCR = 10, NUMOWNERDECR = 11, NUMMONITORS = 12, TRUNK = 13, CALLERID = 14, CALLEDID = 15, CONNECTEDID = 16, REDIRECTIONID = 17, REDIRECTINGID = 18, USERUSERINFO = 19, HIGHLEVELCOMP = 20, LOWLEVELCOMP = 21, CHARGINGINFO = 22, TREATMENT = 23, CALLDATA = 24, PRIVILEGE = 25, MEDIATYPE = 26, // LASTITEM = 26, this enum value conflicts with MEDIATYPE }; pub const CIC_OTHER = CALLINFOCHANGE_CAUSE.OTHER; pub const CIC_DEVSPECIFIC = CALLINFOCHANGE_CAUSE.DEVSPECIFIC; pub const CIC_BEARERMODE = CALLINFOCHANGE_CAUSE.BEARERMODE; pub const CIC_RATE = CALLINFOCHANGE_CAUSE.RATE; pub const CIC_APPSPECIFIC = CALLINFOCHANGE_CAUSE.APPSPECIFIC; pub const CIC_CALLID = CALLINFOCHANGE_CAUSE.CALLID; pub const CIC_RELATEDCALLID = CALLINFOCHANGE_CAUSE.RELATEDCALLID; pub const CIC_ORIGIN = CALLINFOCHANGE_CAUSE.ORIGIN; pub const CIC_REASON = CALLINFOCHANGE_CAUSE.REASON; pub const CIC_COMPLETIONID = CALLINFOCHANGE_CAUSE.COMPLETIONID; pub const CIC_NUMOWNERINCR = CALLINFOCHANGE_CAUSE.NUMOWNERINCR; pub const CIC_NUMOWNERDECR = CALLINFOCHANGE_CAUSE.NUMOWNERDECR; pub const CIC_NUMMONITORS = CALLINFOCHANGE_CAUSE.NUMMONITORS; pub const CIC_TRUNK = CALLINFOCHANGE_CAUSE.TRUNK; pub const CIC_CALLERID = CALLINFOCHANGE_CAUSE.CALLERID; pub const CIC_CALLEDID = CALLINFOCHANGE_CAUSE.CALLEDID; pub const CIC_CONNECTEDID = CALLINFOCHANGE_CAUSE.CONNECTEDID; pub const CIC_REDIRECTIONID = CALLINFOCHANGE_CAUSE.REDIRECTIONID; pub const CIC_REDIRECTINGID = CALLINFOCHANGE_CAUSE.REDIRECTINGID; pub const CIC_USERUSERINFO = CALLINFOCHANGE_CAUSE.USERUSERINFO; pub const CIC_HIGHLEVELCOMP = CALLINFOCHANGE_CAUSE.HIGHLEVELCOMP; pub const CIC_LOWLEVELCOMP = CALLINFOCHANGE_CAUSE.LOWLEVELCOMP; pub const CIC_CHARGINGINFO = CALLINFOCHANGE_CAUSE.CHARGINGINFO; pub const CIC_TREATMENT = CALLINFOCHANGE_CAUSE.TREATMENT; pub const CIC_CALLDATA = CALLINFOCHANGE_CAUSE.CALLDATA; pub const CIC_PRIVILEGE = CALLINFOCHANGE_CAUSE.PRIVILEGE; pub const CIC_MEDIATYPE = CALLINFOCHANGE_CAUSE.MEDIATYPE; pub const CIC_LASTITEM = CALLINFOCHANGE_CAUSE.MEDIATYPE; pub const CALLINFO_LONG = enum(i32) { MEDIATYPESAVAILABLE = 0, BEARERMODE = 1, CALLERIDADDRESSTYPE = 2, CALLEDIDADDRESSTYPE = 3, CONNECTEDIDADDRESSTYPE = 4, REDIRECTIONIDADDRESSTYPE = 5, REDIRECTINGIDADDRESSTYPE = 6, ORIGIN = 7, REASON = 8, APPSPECIFIC = 9, CALLPARAMSFLAGS = 10, CALLTREATMENT = 11, MINRATE = 12, MAXRATE = 13, COUNTRYCODE = 14, CALLID = 15, RELATEDCALLID = 16, COMPLETIONID = 17, NUMBEROFOWNERS = 18, NUMBEROFMONITORS = 19, TRUNK = 20, RATE = 21, GENERATEDIGITDURATION = 22, MONITORDIGITMODES = 23, MONITORMEDIAMODES = 24, }; pub const CIL_MEDIATYPESAVAILABLE = CALLINFO_LONG.MEDIATYPESAVAILABLE; pub const CIL_BEARERMODE = CALLINFO_LONG.BEARERMODE; pub const CIL_CALLERIDADDRESSTYPE = CALLINFO_LONG.CALLERIDADDRESSTYPE; pub const CIL_CALLEDIDADDRESSTYPE = CALLINFO_LONG.CALLEDIDADDRESSTYPE; pub const CIL_CONNECTEDIDADDRESSTYPE = CALLINFO_LONG.CONNECTEDIDADDRESSTYPE; pub const CIL_REDIRECTIONIDADDRESSTYPE = CALLINFO_LONG.REDIRECTIONIDADDRESSTYPE; pub const CIL_REDIRECTINGIDADDRESSTYPE = CALLINFO_LONG.REDIRECTINGIDADDRESSTYPE; pub const CIL_ORIGIN = CALLINFO_LONG.ORIGIN; pub const CIL_REASON = CALLINFO_LONG.REASON; pub const CIL_APPSPECIFIC = CALLINFO_LONG.APPSPECIFIC; pub const CIL_CALLPARAMSFLAGS = CALLINFO_LONG.CALLPARAMSFLAGS; pub const CIL_CALLTREATMENT = CALLINFO_LONG.CALLTREATMENT; pub const CIL_MINRATE = CALLINFO_LONG.MINRATE; pub const CIL_MAXRATE = CALLINFO_LONG.MAXRATE; pub const CIL_COUNTRYCODE = CALLINFO_LONG.COUNTRYCODE; pub const CIL_CALLID = CALLINFO_LONG.CALLID; pub const CIL_RELATEDCALLID = CALLINFO_LONG.RELATEDCALLID; pub const CIL_COMPLETIONID = CALLINFO_LONG.COMPLETIONID; pub const CIL_NUMBEROFOWNERS = CALLINFO_LONG.NUMBEROFOWNERS; pub const CIL_NUMBEROFMONITORS = CALLINFO_LONG.NUMBEROFMONITORS; pub const CIL_TRUNK = CALLINFO_LONG.TRUNK; pub const CIL_RATE = CALLINFO_LONG.RATE; pub const CIL_GENERATEDIGITDURATION = CALLINFO_LONG.GENERATEDIGITDURATION; pub const CIL_MONITORDIGITMODES = CALLINFO_LONG.MONITORDIGITMODES; pub const CIL_MONITORMEDIAMODES = CALLINFO_LONG.MONITORMEDIAMODES; pub const CALLINFO_STRING = enum(i32) { CALLERIDNAME = 0, CALLERIDNUMBER = 1, CALLEDIDNAME = 2, CALLEDIDNUMBER = 3, CONNECTEDIDNAME = 4, CONNECTEDIDNUMBER = 5, REDIRECTIONIDNAME = 6, REDIRECTIONIDNUMBER = 7, REDIRECTINGIDNAME = 8, REDIRECTINGIDNUMBER = 9, CALLEDPARTYFRIENDLYNAME = 10, COMMENT = 11, DISPLAYABLEADDRESS = 12, CALLINGPARTYID = 13, }; pub const CIS_CALLERIDNAME = CALLINFO_STRING.CALLERIDNAME; pub const CIS_CALLERIDNUMBER = CALLINFO_STRING.CALLERIDNUMBER; pub const CIS_CALLEDIDNAME = CALLINFO_STRING.CALLEDIDNAME; pub const CIS_CALLEDIDNUMBER = CALLINFO_STRING.CALLEDIDNUMBER; pub const CIS_CONNECTEDIDNAME = CALLINFO_STRING.CONNECTEDIDNAME; pub const CIS_CONNECTEDIDNUMBER = CALLINFO_STRING.CONNECTEDIDNUMBER; pub const CIS_REDIRECTIONIDNAME = CALLINFO_STRING.REDIRECTIONIDNAME; pub const CIS_REDIRECTIONIDNUMBER = CALLINFO_STRING.REDIRECTIONIDNUMBER; pub const CIS_REDIRECTINGIDNAME = CALLINFO_STRING.REDIRECTINGIDNAME; pub const CIS_REDIRECTINGIDNUMBER = CALLINFO_STRING.REDIRECTINGIDNUMBER; pub const CIS_CALLEDPARTYFRIENDLYNAME = CALLINFO_STRING.CALLEDPARTYFRIENDLYNAME; pub const CIS_COMMENT = CALLINFO_STRING.COMMENT; pub const CIS_DISPLAYABLEADDRESS = CALLINFO_STRING.DISPLAYABLEADDRESS; pub const CIS_CALLINGPARTYID = CALLINFO_STRING.CALLINGPARTYID; pub const CALLINFO_BUFFER = enum(i32) { USERUSERINFO = 0, DEVSPECIFICBUFFER = 1, CALLDATABUFFER = 2, CHARGINGINFOBUFFER = 3, HIGHLEVELCOMPATIBILITYBUFFER = 4, LOWLEVELCOMPATIBILITYBUFFER = 5, }; pub const CIB_USERUSERINFO = CALLINFO_BUFFER.USERUSERINFO; pub const CIB_DEVSPECIFICBUFFER = CALLINFO_BUFFER.DEVSPECIFICBUFFER; pub const CIB_CALLDATABUFFER = CALLINFO_BUFFER.CALLDATABUFFER; pub const CIB_CHARGINGINFOBUFFER = CALLINFO_BUFFER.CHARGINGINFOBUFFER; pub const CIB_HIGHLEVELCOMPATIBILITYBUFFER = CALLINFO_BUFFER.HIGHLEVELCOMPATIBILITYBUFFER; pub const CIB_LOWLEVELCOMPATIBILITYBUFFER = CALLINFO_BUFFER.LOWLEVELCOMPATIBILITYBUFFER; pub const ADDRESS_CAPABILITY = enum(i32) { ADDRESSTYPES = 0, BEARERMODES = 1, MAXACTIVECALLS = 2, MAXONHOLDCALLS = 3, MAXONHOLDPENDINGCALLS = 4, MAXNUMCONFERENCE = 5, MAXNUMTRANSCONF = 6, MONITORDIGITSUPPORT = 7, GENERATEDIGITSUPPORT = 8, GENERATETONEMODES = 9, GENERATETONEMAXNUMFREQ = 10, MONITORTONEMAXNUMFREQ = 11, MONITORTONEMAXNUMENTRIES = 12, DEVCAPFLAGS = 13, ANSWERMODES = 14, LINEFEATURES = 15, SETTABLEDEVSTATUS = 16, PARKSUPPORT = 17, CALLERIDSUPPORT = 18, CALLEDIDSUPPORT = 19, CONNECTEDIDSUPPORT = 20, REDIRECTIONIDSUPPORT = 21, REDIRECTINGIDSUPPORT = 22, ADDRESSCAPFLAGS = 23, CALLFEATURES1 = 24, CALLFEATURES2 = 25, REMOVEFROMCONFCAPS = 26, REMOVEFROMCONFSTATE = 27, TRANSFERMODES = 28, ADDRESSFEATURES = 29, PREDICTIVEAUTOTRANSFERSTATES = 30, MAXCALLDATASIZE = 31, LINEID = 32, ADDRESSID = 33, FORWARDMODES = 34, MAXFORWARDENTRIES = 35, MAXSPECIFICENTRIES = 36, MINFWDNUMRINGS = 37, MAXFWDNUMRINGS = 38, MAXCALLCOMPLETIONS = 39, CALLCOMPLETIONCONDITIONS = 40, CALLCOMPLETIONMODES = 41, PERMANENTDEVICEID = 42, GATHERDIGITSMINTIMEOUT = 43, GATHERDIGITSMAXTIMEOUT = 44, GENERATEDIGITMINDURATION = 45, GENERATEDIGITMAXDURATION = 46, GENERATEDIGITDEFAULTDURATION = 47, }; pub const AC_ADDRESSTYPES = ADDRESS_CAPABILITY.ADDRESSTYPES; pub const AC_BEARERMODES = ADDRESS_CAPABILITY.BEARERMODES; pub const AC_MAXACTIVECALLS = ADDRESS_CAPABILITY.MAXACTIVECALLS; pub const AC_MAXONHOLDCALLS = ADDRESS_CAPABILITY.MAXONHOLDCALLS; pub const AC_MAXONHOLDPENDINGCALLS = ADDRESS_CAPABILITY.MAXONHOLDPENDINGCALLS; pub const AC_MAXNUMCONFERENCE = ADDRESS_CAPABILITY.MAXNUMCONFERENCE; pub const AC_MAXNUMTRANSCONF = ADDRESS_CAPABILITY.MAXNUMTRANSCONF; pub const AC_MONITORDIGITSUPPORT = ADDRESS_CAPABILITY.MONITORDIGITSUPPORT; pub const AC_GENERATEDIGITSUPPORT = ADDRESS_CAPABILITY.GENERATEDIGITSUPPORT; pub const AC_GENERATETONEMODES = ADDRESS_CAPABILITY.GENERATETONEMODES; pub const AC_GENERATETONEMAXNUMFREQ = ADDRESS_CAPABILITY.GENERATETONEMAXNUMFREQ; pub const AC_MONITORTONEMAXNUMFREQ = ADDRESS_CAPABILITY.MONITORTONEMAXNUMFREQ; pub const AC_MONITORTONEMAXNUMENTRIES = ADDRESS_CAPABILITY.MONITORTONEMAXNUMENTRIES; pub const AC_DEVCAPFLAGS = ADDRESS_CAPABILITY.DEVCAPFLAGS; pub const AC_ANSWERMODES = ADDRESS_CAPABILITY.ANSWERMODES; pub const AC_LINEFEATURES = ADDRESS_CAPABILITY.LINEFEATURES; pub const AC_SETTABLEDEVSTATUS = ADDRESS_CAPABILITY.SETTABLEDEVSTATUS; pub const AC_PARKSUPPORT = ADDRESS_CAPABILITY.PARKSUPPORT; pub const AC_CALLERIDSUPPORT = ADDRESS_CAPABILITY.CALLERIDSUPPORT; pub const AC_CALLEDIDSUPPORT = ADDRESS_CAPABILITY.CALLEDIDSUPPORT; pub const AC_CONNECTEDIDSUPPORT = ADDRESS_CAPABILITY.CONNECTEDIDSUPPORT; pub const AC_REDIRECTIONIDSUPPORT = ADDRESS_CAPABILITY.REDIRECTIONIDSUPPORT; pub const AC_REDIRECTINGIDSUPPORT = ADDRESS_CAPABILITY.REDIRECTINGIDSUPPORT; pub const AC_ADDRESSCAPFLAGS = ADDRESS_CAPABILITY.ADDRESSCAPFLAGS; pub const AC_CALLFEATURES1 = ADDRESS_CAPABILITY.CALLFEATURES1; pub const AC_CALLFEATURES2 = ADDRESS_CAPABILITY.CALLFEATURES2; pub const AC_REMOVEFROMCONFCAPS = ADDRESS_CAPABILITY.REMOVEFROMCONFCAPS; pub const AC_REMOVEFROMCONFSTATE = ADDRESS_CAPABILITY.REMOVEFROMCONFSTATE; pub const AC_TRANSFERMODES = ADDRESS_CAPABILITY.TRANSFERMODES; pub const AC_ADDRESSFEATURES = ADDRESS_CAPABILITY.ADDRESSFEATURES; pub const AC_PREDICTIVEAUTOTRANSFERSTATES = ADDRESS_CAPABILITY.PREDICTIVEAUTOTRANSFERSTATES; pub const AC_MAXCALLDATASIZE = ADDRESS_CAPABILITY.MAXCALLDATASIZE; pub const AC_LINEID = ADDRESS_CAPABILITY.LINEID; pub const AC_ADDRESSID = ADDRESS_CAPABILITY.ADDRESSID; pub const AC_FORWARDMODES = ADDRESS_CAPABILITY.FORWARDMODES; pub const AC_MAXFORWARDENTRIES = ADDRESS_CAPABILITY.MAXFORWARDENTRIES; pub const AC_MAXSPECIFICENTRIES = ADDRESS_CAPABILITY.MAXSPECIFICENTRIES; pub const AC_MINFWDNUMRINGS = ADDRESS_CAPABILITY.MINFWDNUMRINGS; pub const AC_MAXFWDNUMRINGS = ADDRESS_CAPABILITY.MAXFWDNUMRINGS; pub const AC_MAXCALLCOMPLETIONS = ADDRESS_CAPABILITY.MAXCALLCOMPLETIONS; pub const AC_CALLCOMPLETIONCONDITIONS = ADDRESS_CAPABILITY.CALLCOMPLETIONCONDITIONS; pub const AC_CALLCOMPLETIONMODES = ADDRESS_CAPABILITY.CALLCOMPLETIONMODES; pub const AC_PERMANENTDEVICEID = ADDRESS_CAPABILITY.PERMANENTDEVICEID; pub const AC_GATHERDIGITSMINTIMEOUT = ADDRESS_CAPABILITY.GATHERDIGITSMINTIMEOUT; pub const AC_GATHERDIGITSMAXTIMEOUT = ADDRESS_CAPABILITY.GATHERDIGITSMAXTIMEOUT; pub const AC_GENERATEDIGITMINDURATION = ADDRESS_CAPABILITY.GENERATEDIGITMINDURATION; pub const AC_GENERATEDIGITMAXDURATION = ADDRESS_CAPABILITY.GENERATEDIGITMAXDURATION; pub const AC_GENERATEDIGITDEFAULTDURATION = ADDRESS_CAPABILITY.GENERATEDIGITDEFAULTDURATION; pub const ADDRESS_CAPABILITY_STRING = enum(i32) { PROTOCOL = 0, ADDRESSDEVICESPECIFIC = 1, LINEDEVICESPECIFIC = 2, PROVIDERSPECIFIC = 3, SWITCHSPECIFIC = 4, PERMANENTDEVICEGUID = 5, }; pub const ACS_PROTOCOL = ADDRESS_CAPABILITY_STRING.PROTOCOL; pub const ACS_ADDRESSDEVICESPECIFIC = ADDRESS_CAPABILITY_STRING.ADDRESSDEVICESPECIFIC; pub const ACS_LINEDEVICESPECIFIC = ADDRESS_CAPABILITY_STRING.LINEDEVICESPECIFIC; pub const ACS_PROVIDERSPECIFIC = ADDRESS_CAPABILITY_STRING.PROVIDERSPECIFIC; pub const ACS_SWITCHSPECIFIC = ADDRESS_CAPABILITY_STRING.SWITCHSPECIFIC; pub const ACS_PERMANENTDEVICEGUID = ADDRESS_CAPABILITY_STRING.PERMANENTDEVICEGUID; pub const FULLDUPLEX_SUPPORT = enum(i32) { SUPPORTED = 0, NOTSUPPORTED = 1, UNKNOWN = 2, }; pub const FDS_SUPPORTED = FULLDUPLEX_SUPPORT.SUPPORTED; pub const FDS_NOTSUPPORTED = FULLDUPLEX_SUPPORT.NOTSUPPORTED; pub const FDS_UNKNOWN = FULLDUPLEX_SUPPORT.UNKNOWN; pub const FINISH_MODE = enum(i32) { TRANSFER = 0, CONFERENCE = 1, }; pub const FM_ASTRANSFER = FINISH_MODE.TRANSFER; pub const FM_ASCONFERENCE = FINISH_MODE.CONFERENCE; pub const PHONE_PRIVILEGE = enum(i32) { OWNER = 0, MONITOR = 1, }; pub const PP_OWNER = PHONE_PRIVILEGE.OWNER; pub const PP_MONITOR = PHONE_PRIVILEGE.MONITOR; pub const PHONE_HOOK_SWITCH_DEVICE = enum(i32) { HANDSET = 1, SPEAKERPHONE = 2, HEADSET = 4, }; pub const PHSD_HANDSET = PHONE_HOOK_SWITCH_DEVICE.HANDSET; pub const PHSD_SPEAKERPHONE = PHONE_HOOK_SWITCH_DEVICE.SPEAKERPHONE; pub const PHSD_HEADSET = PHONE_HOOK_SWITCH_DEVICE.HEADSET; pub const PHONE_HOOK_SWITCH_STATE = enum(i32) { NHOOK = 1, FFHOOK_MIC_ONLY = 2, FFHOOK_SPEAKER_ONLY = 4, FFHOOK = 8, }; pub const PHSS_ONHOOK = PHONE_HOOK_SWITCH_STATE.NHOOK; pub const PHSS_OFFHOOK_MIC_ONLY = PHONE_HOOK_SWITCH_STATE.FFHOOK_MIC_ONLY; pub const PHSS_OFFHOOK_SPEAKER_ONLY = PHONE_HOOK_SWITCH_STATE.FFHOOK_SPEAKER_ONLY; pub const PHSS_OFFHOOK = PHONE_HOOK_SWITCH_STATE.FFHOOK; pub const PHONE_LAMP_MODE = enum(i32) { DUMMY = 1, OFF = 2, STEADY = 4, WINK = 8, FLASH = 16, FLUTTER = 32, BROKENFLUTTER = 64, UNKNOWN = 128, }; pub const LM_DUMMY = PHONE_LAMP_MODE.DUMMY; pub const LM_OFF = PHONE_LAMP_MODE.OFF; pub const LM_STEADY = PHONE_LAMP_MODE.STEADY; pub const LM_WINK = PHONE_LAMP_MODE.WINK; pub const LM_FLASH = PHONE_LAMP_MODE.FLASH; pub const LM_FLUTTER = PHONE_LAMP_MODE.FLUTTER; pub const LM_BROKENFLUTTER = PHONE_LAMP_MODE.BROKENFLUTTER; pub const LM_UNKNOWN = PHONE_LAMP_MODE.UNKNOWN; pub const PHONECAPS_LONG = enum(i32) { HOOKSWITCHES = 0, HANDSETHOOKSWITCHMODES = 1, HEADSETHOOKSWITCHMODES = 2, SPEAKERPHONEHOOKSWITCHMODES = 3, DISPLAYNUMROWS = 4, DISPLAYNUMCOLUMNS = 5, NUMRINGMODES = 6, NUMBUTTONLAMPS = 7, GENERICPHONE = 8, }; pub const PCL_HOOKSWITCHES = PHONECAPS_LONG.HOOKSWITCHES; pub const PCL_HANDSETHOOKSWITCHMODES = PHONECAPS_LONG.HANDSETHOOKSWITCHMODES; pub const PCL_HEADSETHOOKSWITCHMODES = PHONECAPS_LONG.HEADSETHOOKSWITCHMODES; pub const PCL_SPEAKERPHONEHOOKSWITCHMODES = PHONECAPS_LONG.SPEAKERPHONEHOOKSWITCHMODES; pub const PCL_DISPLAYNUMROWS = PHONECAPS_LONG.DISPLAYNUMROWS; pub const PCL_DISPLAYNUMCOLUMNS = PHONECAPS_LONG.DISPLAYNUMCOLUMNS; pub const PCL_NUMRINGMODES = PHONECAPS_LONG.NUMRINGMODES; pub const PCL_NUMBUTTONLAMPS = PHONECAPS_LONG.NUMBUTTONLAMPS; pub const PCL_GENERICPHONE = PHONECAPS_LONG.GENERICPHONE; pub const PHONECAPS_STRING = enum(i32) { HONENAME = 0, HONEINFO = 1, ROVIDERINFO = 2, }; pub const PCS_PHONENAME = PHONECAPS_STRING.HONENAME; pub const PCS_PHONEINFO = PHONECAPS_STRING.HONEINFO; pub const PCS_PROVIDERINFO = PHONECAPS_STRING.ROVIDERINFO; pub const PHONECAPS_BUFFER = enum(i32) { R = 0, }; pub const PCB_DEVSPECIFICBUFFER = PHONECAPS_BUFFER.R; pub const PHONE_BUTTON_STATE = enum(i32) { UP = 1, DOWN = 2, UNKNOWN = 4, UNAVAIL = 8, }; pub const PBS_UP = PHONE_BUTTON_STATE.UP; pub const PBS_DOWN = PHONE_BUTTON_STATE.DOWN; pub const PBS_UNKNOWN = PHONE_BUTTON_STATE.UNKNOWN; pub const PBS_UNAVAIL = PHONE_BUTTON_STATE.UNAVAIL; pub const PHONE_BUTTON_MODE = enum(i32) { DUMMY = 0, CALL = 1, FEATURE = 2, KEYPAD = 3, LOCAL = 4, DISPLAY = 5, }; pub const PBM_DUMMY = PHONE_BUTTON_MODE.DUMMY; pub const PBM_CALL = PHONE_BUTTON_MODE.CALL; pub const PBM_FEATURE = PHONE_BUTTON_MODE.FEATURE; pub const PBM_KEYPAD = PHONE_BUTTON_MODE.KEYPAD; pub const PBM_LOCAL = PHONE_BUTTON_MODE.LOCAL; pub const PBM_DISPLAY = PHONE_BUTTON_MODE.DISPLAY; pub const PHONE_BUTTON_FUNCTION = enum(i32) { UNKNOWN = 0, CONFERENCE = 1, TRANSFER = 2, DROP = 3, HOLD = 4, RECALL = 5, DISCONNECT = 6, CONNECT = 7, MSGWAITON = 8, MSGWAITOFF = 9, SELECTRING = 10, ABBREVDIAL = 11, FORWARD = 12, PICKUP = 13, RINGAGAIN = 14, PARK = 15, REJECT = 16, REDIRECT = 17, MUTE = 18, VOLUMEUP = 19, VOLUMEDOWN = 20, SPEAKERON = 21, SPEAKEROFF = 22, FLASH = 23, DATAON = 24, DATAOFF = 25, DONOTDISTURB = 26, INTERCOM = 27, BRIDGEDAPP = 28, BUSY = 29, CALLAPP = 30, DATETIME = 31, DIRECTORY = 32, COVER = 33, CALLID = 34, LASTNUM = 35, NIGHTSRV = 36, SENDCALLS = 37, MSGINDICATOR = 38, REPDIAL = 39, SETREPDIAL = 40, SYSTEMSPEED = 41, STATIONSPEED = 42, CAMPON = 43, SAVEREPEAT = 44, QUEUECALL = 45, NONE = 46, SEND = 47, }; pub const PBF_UNKNOWN = PHONE_BUTTON_FUNCTION.UNKNOWN; pub const PBF_CONFERENCE = PHONE_BUTTON_FUNCTION.CONFERENCE; pub const PBF_TRANSFER = PHONE_BUTTON_FUNCTION.TRANSFER; pub const PBF_DROP = PHONE_BUTTON_FUNCTION.DROP; pub const PBF_HOLD = PHONE_BUTTON_FUNCTION.HOLD; pub const PBF_RECALL = PHONE_BUTTON_FUNCTION.RECALL; pub const PBF_DISCONNECT = PHONE_BUTTON_FUNCTION.DISCONNECT; pub const PBF_CONNECT = PHONE_BUTTON_FUNCTION.CONNECT; pub const PBF_MSGWAITON = PHONE_BUTTON_FUNCTION.MSGWAITON; pub const PBF_MSGWAITOFF = PHONE_BUTTON_FUNCTION.MSGWAITOFF; pub const PBF_SELECTRING = PHONE_BUTTON_FUNCTION.SELECTRING; pub const PBF_ABBREVDIAL = PHONE_BUTTON_FUNCTION.ABBREVDIAL; pub const PBF_FORWARD = PHONE_BUTTON_FUNCTION.FORWARD; pub const PBF_PICKUP = PHONE_BUTTON_FUNCTION.PICKUP; pub const PBF_RINGAGAIN = PHONE_BUTTON_FUNCTION.RINGAGAIN; pub const PBF_PARK = PHONE_BUTTON_FUNCTION.PARK; pub const PBF_REJECT = PHONE_BUTTON_FUNCTION.REJECT; pub const PBF_REDIRECT = PHONE_BUTTON_FUNCTION.REDIRECT; pub const PBF_MUTE = PHONE_BUTTON_FUNCTION.MUTE; pub const PBF_VOLUMEUP = PHONE_BUTTON_FUNCTION.VOLUMEUP; pub const PBF_VOLUMEDOWN = PHONE_BUTTON_FUNCTION.VOLUMEDOWN; pub const PBF_SPEAKERON = PHONE_BUTTON_FUNCTION.SPEAKERON; pub const PBF_SPEAKEROFF = PHONE_BUTTON_FUNCTION.SPEAKEROFF; pub const PBF_FLASH = PHONE_BUTTON_FUNCTION.FLASH; pub const PBF_DATAON = PHONE_BUTTON_FUNCTION.DATAON; pub const PBF_DATAOFF = PHONE_BUTTON_FUNCTION.DATAOFF; pub const PBF_DONOTDISTURB = PHONE_BUTTON_FUNCTION.DONOTDISTURB; pub const PBF_INTERCOM = PHONE_BUTTON_FUNCTION.INTERCOM; pub const PBF_BRIDGEDAPP = PHONE_BUTTON_FUNCTION.BRIDGEDAPP; pub const PBF_BUSY = PHONE_BUTTON_FUNCTION.BUSY; pub const PBF_CALLAPP = PHONE_BUTTON_FUNCTION.CALLAPP; pub const PBF_DATETIME = PHONE_BUTTON_FUNCTION.DATETIME; pub const PBF_DIRECTORY = PHONE_BUTTON_FUNCTION.DIRECTORY; pub const PBF_COVER = PHONE_BUTTON_FUNCTION.COVER; pub const PBF_CALLID = PHONE_BUTTON_FUNCTION.CALLID; pub const PBF_LASTNUM = PHONE_BUTTON_FUNCTION.LASTNUM; pub const PBF_NIGHTSRV = PHONE_BUTTON_FUNCTION.NIGHTSRV; pub const PBF_SENDCALLS = PHONE_BUTTON_FUNCTION.SENDCALLS; pub const PBF_MSGINDICATOR = PHONE_BUTTON_FUNCTION.MSGINDICATOR; pub const PBF_REPDIAL = PHONE_BUTTON_FUNCTION.REPDIAL; pub const PBF_SETREPDIAL = PHONE_BUTTON_FUNCTION.SETREPDIAL; pub const PBF_SYSTEMSPEED = PHONE_BUTTON_FUNCTION.SYSTEMSPEED; pub const PBF_STATIONSPEED = PHONE_BUTTON_FUNCTION.STATIONSPEED; pub const PBF_CAMPON = PHONE_BUTTON_FUNCTION.CAMPON; pub const PBF_SAVEREPEAT = PHONE_BUTTON_FUNCTION.SAVEREPEAT; pub const PBF_QUEUECALL = PHONE_BUTTON_FUNCTION.QUEUECALL; pub const PBF_NONE = PHONE_BUTTON_FUNCTION.NONE; pub const PBF_SEND = PHONE_BUTTON_FUNCTION.SEND; pub const PHONE_TONE = enum(i32) { KEYPADZERO = 0, KEYPADONE = 1, KEYPADTWO = 2, KEYPADTHREE = 3, KEYPADFOUR = 4, KEYPADFIVE = 5, KEYPADSIX = 6, KEYPADSEVEN = 7, KEYPADEIGHT = 8, KEYPADNINE = 9, KEYPADSTAR = 10, KEYPADPOUND = 11, KEYPADA = 12, KEYPADB = 13, KEYPADC = 14, KEYPADD = 15, NORMALDIALTONE = 16, EXTERNALDIALTONE = 17, BUSY = 18, RINGBACK = 19, ERRORTONE = 20, SILENCE = 21, }; pub const PT_KEYPADZERO = PHONE_TONE.KEYPADZERO; pub const PT_KEYPADONE = PHONE_TONE.KEYPADONE; pub const PT_KEYPADTWO = PHONE_TONE.KEYPADTWO; pub const PT_KEYPADTHREE = PHONE_TONE.KEYPADTHREE; pub const PT_KEYPADFOUR = PHONE_TONE.KEYPADFOUR; pub const PT_KEYPADFIVE = PHONE_TONE.KEYPADFIVE; pub const PT_KEYPADSIX = PHONE_TONE.KEYPADSIX; pub const PT_KEYPADSEVEN = PHONE_TONE.KEYPADSEVEN; pub const PT_KEYPADEIGHT = PHONE_TONE.KEYPADEIGHT; pub const PT_KEYPADNINE = PHONE_TONE.KEYPADNINE; pub const PT_KEYPADSTAR = PHONE_TONE.KEYPADSTAR; pub const PT_KEYPADPOUND = PHONE_TONE.KEYPADPOUND; pub const PT_KEYPADA = PHONE_TONE.KEYPADA; pub const PT_KEYPADB = PHONE_TONE.KEYPADB; pub const PT_KEYPADC = PHONE_TONE.KEYPADC; pub const PT_KEYPADD = PHONE_TONE.KEYPADD; pub const PT_NORMALDIALTONE = PHONE_TONE.NORMALDIALTONE; pub const PT_EXTERNALDIALTONE = PHONE_TONE.EXTERNALDIALTONE; pub const PT_BUSY = PHONE_TONE.BUSY; pub const PT_RINGBACK = PHONE_TONE.RINGBACK; pub const PT_ERRORTONE = PHONE_TONE.ERRORTONE; pub const PT_SILENCE = PHONE_TONE.SILENCE; pub const PHONE_EVENT = enum(i32) { DISPLAY = 0, LAMPMODE = 1, RINGMODE = 2, RINGVOLUME = 3, HOOKSWITCH = 4, CAPSCHANGE = 5, BUTTON = 6, CLOSE = 7, NUMBERGATHERED = 8, DIALING = 9, ANSWER = 10, DISCONNECT = 11, // LASTITEM = 11, this enum value conflicts with DISCONNECT }; pub const PE_DISPLAY = PHONE_EVENT.DISPLAY; pub const PE_LAMPMODE = PHONE_EVENT.LAMPMODE; pub const PE_RINGMODE = PHONE_EVENT.RINGMODE; pub const PE_RINGVOLUME = PHONE_EVENT.RINGVOLUME; pub const PE_HOOKSWITCH = PHONE_EVENT.HOOKSWITCH; pub const PE_CAPSCHANGE = PHONE_EVENT.CAPSCHANGE; pub const PE_BUTTON = PHONE_EVENT.BUTTON; pub const PE_CLOSE = PHONE_EVENT.CLOSE; pub const PE_NUMBERGATHERED = PHONE_EVENT.NUMBERGATHERED; pub const PE_DIALING = PHONE_EVENT.DIALING; pub const PE_ANSWER = PHONE_EVENT.ANSWER; pub const PE_DISCONNECT = PHONE_EVENT.DISCONNECT; pub const PE_LASTITEM = PHONE_EVENT.DISCONNECT; const IID_ITTAPI_Value = @import("../zig.zig").Guid.initString("b1efc382-9355-11d0-835c-00aa003ccabd"); pub const IID_ITTAPI = &IID_ITTAPI_Value; pub const ITTAPI = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Initialize: fn( self: *const ITTAPI, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Shutdown: fn( self: *const ITTAPI, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Addresses: fn( self: *const ITTAPI, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateAddresses: fn( self: *const ITTAPI, ppEnumAddress: ?*?*IEnumAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RegisterCallNotifications: fn( self: *const ITTAPI, pAddress: ?*ITAddress, fMonitor: i16, fOwner: i16, lMediaTypes: i32, lCallbackInstance: i32, plRegister: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnregisterNotifications: fn( self: *const ITTAPI, lRegister: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallHubs: fn( self: *const ITTAPI, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateCallHubs: fn( self: *const ITTAPI, ppEnumCallHub: ?*?*IEnumCallHub, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetCallHubTracking: fn( self: *const ITTAPI, pAddresses: VARIANT, bTracking: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumeratePrivateTAPIObjects: fn( self: *const ITTAPI, ppEnumUnknown: ?*?*IEnumUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivateTAPIObjects: fn( self: *const ITTAPI, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RegisterRequestRecipient: fn( self: *const ITTAPI, lRegistrationInstance: i32, lRequestMode: i32, fEnable: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetAssistedTelephonyPriority: fn( self: *const ITTAPI, pAppFilename: ?BSTR, fPriority: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetApplicationPriority: fn( self: *const ITTAPI, pAppFilename: ?BSTR, lMediaType: i32, fPriority: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EventFilter: fn( self: *const ITTAPI, lFilterMask: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EventFilter: fn( self: *const ITTAPI, plFilterMask: ?*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 ITTAPI_Initialize(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).Initialize(@ptrCast(*const ITTAPI, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_Shutdown(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).Shutdown(@ptrCast(*const ITTAPI, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_get_Addresses(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).get_Addresses(@ptrCast(*const ITTAPI, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_EnumerateAddresses(self: *const T, ppEnumAddress: ?*?*IEnumAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).EnumerateAddresses(@ptrCast(*const ITTAPI, self), ppEnumAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_RegisterCallNotifications(self: *const T, pAddress: ?*ITAddress, fMonitor: i16, fOwner: i16, lMediaTypes: i32, lCallbackInstance: i32, plRegister: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).RegisterCallNotifications(@ptrCast(*const ITTAPI, self), pAddress, fMonitor, fOwner, lMediaTypes, lCallbackInstance, plRegister); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_UnregisterNotifications(self: *const T, lRegister: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).UnregisterNotifications(@ptrCast(*const ITTAPI, self), lRegister); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_get_CallHubs(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).get_CallHubs(@ptrCast(*const ITTAPI, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_EnumerateCallHubs(self: *const T, ppEnumCallHub: ?*?*IEnumCallHub) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).EnumerateCallHubs(@ptrCast(*const ITTAPI, self), ppEnumCallHub); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_SetCallHubTracking(self: *const T, pAddresses: VARIANT, bTracking: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).SetCallHubTracking(@ptrCast(*const ITTAPI, self), pAddresses, bTracking); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_EnumeratePrivateTAPIObjects(self: *const T, ppEnumUnknown: ?*?*IEnumUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).EnumeratePrivateTAPIObjects(@ptrCast(*const ITTAPI, self), ppEnumUnknown); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_get_PrivateTAPIObjects(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).get_PrivateTAPIObjects(@ptrCast(*const ITTAPI, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_RegisterRequestRecipient(self: *const T, lRegistrationInstance: i32, lRequestMode: i32, fEnable: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).RegisterRequestRecipient(@ptrCast(*const ITTAPI, self), lRegistrationInstance, lRequestMode, fEnable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_SetAssistedTelephonyPriority(self: *const T, pAppFilename: ?BSTR, fPriority: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).SetAssistedTelephonyPriority(@ptrCast(*const ITTAPI, self), pAppFilename, fPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_SetApplicationPriority(self: *const T, pAppFilename: ?BSTR, lMediaType: i32, fPriority: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).SetApplicationPriority(@ptrCast(*const ITTAPI, self), pAppFilename, lMediaType, fPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_put_EventFilter(self: *const T, lFilterMask: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).put_EventFilter(@ptrCast(*const ITTAPI, self), lFilterMask); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI_get_EventFilter(self: *const T, plFilterMask: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI.VTable, self.vtable).get_EventFilter(@ptrCast(*const ITTAPI, self), plFilterMask); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTAPI2_Value = @import("../zig.zig").Guid.initString("54fbdc8c-d90f-4dad-9695-b373097f094b"); pub const IID_ITTAPI2 = &IID_ITTAPI2_Value; pub const ITTAPI2 = extern struct { pub const VTable = extern struct { base: ITTAPI.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Phones: fn( self: *const ITTAPI2, pPhones: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumeratePhones: fn( self: *const ITTAPI2, ppEnumPhone: ?*?*IEnumPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateEmptyCollectionObject: fn( self: *const ITTAPI2, ppCollection: ?*?*ITCollection2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITTAPI.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI2_get_Phones(self: *const T, pPhones: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI2.VTable, self.vtable).get_Phones(@ptrCast(*const ITTAPI2, self), pPhones); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI2_EnumeratePhones(self: *const T, ppEnumPhone: ?*?*IEnumPhone) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI2.VTable, self.vtable).EnumeratePhones(@ptrCast(*const ITTAPI2, self), ppEnumPhone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPI2_CreateEmptyCollectionObject(self: *const T, ppCollection: ?*?*ITCollection2) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPI2.VTable, self.vtable).CreateEmptyCollectionObject(@ptrCast(*const ITTAPI2, self), ppCollection); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITMediaSupport_Value = @import("../zig.zig").Guid.initString("b1efc384-9355-11d0-835c-00aa003ccabd"); pub const IID_ITMediaSupport = &IID_ITMediaSupport_Value; pub const ITMediaSupport = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MediaTypes: fn( self: *const ITMediaSupport, plMediaTypes: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, QueryMediaType: fn( self: *const ITMediaSupport, lMediaType: i32, pfSupport: ?*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 ITMediaSupport_get_MediaTypes(self: *const T, plMediaTypes: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaSupport.VTable, self.vtable).get_MediaTypes(@ptrCast(*const ITMediaSupport, self), plMediaTypes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMediaSupport_QueryMediaType(self: *const T, lMediaType: i32, pfSupport: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaSupport.VTable, self.vtable).QueryMediaType(@ptrCast(*const ITMediaSupport, self), lMediaType, pfSupport); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITPluggableTerminalClassInfo_Value = @import("../zig.zig").Guid.initString("41757f4a-cf09-4b34-bc96-0a79d2390076"); pub const IID_ITPluggableTerminalClassInfo = &IID_ITPluggableTerminalClassInfo_Value; pub const ITPluggableTerminalClassInfo = 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 ITPluggableTerminalClassInfo, pName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Company: fn( self: *const ITPluggableTerminalClassInfo, pCompany: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Version: fn( self: *const ITPluggableTerminalClassInfo, pVersion: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TerminalClass: fn( self: *const ITPluggableTerminalClassInfo, pTerminalClass: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CLSID: fn( self: *const ITPluggableTerminalClassInfo, pCLSID: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Direction: fn( self: *const ITPluggableTerminalClassInfo, pDirection: ?*TERMINAL_DIRECTION, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MediaTypes: fn( self: *const ITPluggableTerminalClassInfo, pMediaTypes: ?*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 ITPluggableTerminalClassInfo_get_Name(self: *const T, pName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalClassInfo.VTable, self.vtable).get_Name(@ptrCast(*const ITPluggableTerminalClassInfo, self), pName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPluggableTerminalClassInfo_get_Company(self: *const T, pCompany: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalClassInfo.VTable, self.vtable).get_Company(@ptrCast(*const ITPluggableTerminalClassInfo, self), pCompany); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPluggableTerminalClassInfo_get_Version(self: *const T, pVersion: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalClassInfo.VTable, self.vtable).get_Version(@ptrCast(*const ITPluggableTerminalClassInfo, self), pVersion); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPluggableTerminalClassInfo_get_TerminalClass(self: *const T, pTerminalClass: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalClassInfo.VTable, self.vtable).get_TerminalClass(@ptrCast(*const ITPluggableTerminalClassInfo, self), pTerminalClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPluggableTerminalClassInfo_get_CLSID(self: *const T, pCLSID: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalClassInfo.VTable, self.vtable).get_CLSID(@ptrCast(*const ITPluggableTerminalClassInfo, self), pCLSID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPluggableTerminalClassInfo_get_Direction(self: *const T, pDirection: ?*TERMINAL_DIRECTION) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalClassInfo.VTable, self.vtable).get_Direction(@ptrCast(*const ITPluggableTerminalClassInfo, self), pDirection); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPluggableTerminalClassInfo_get_MediaTypes(self: *const T, pMediaTypes: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalClassInfo.VTable, self.vtable).get_MediaTypes(@ptrCast(*const ITPluggableTerminalClassInfo, self), pMediaTypes); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITPluggableTerminalSuperclassInfo_Value = @import("../zig.zig").Guid.initString("6d54e42c-4625-4359-a6f7-631999107e05"); pub const IID_ITPluggableTerminalSuperclassInfo = &IID_ITPluggableTerminalSuperclassInfo_Value; pub const ITPluggableTerminalSuperclassInfo = 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 ITPluggableTerminalSuperclassInfo, pName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CLSID: fn( self: *const ITPluggableTerminalSuperclassInfo, pCLSID: ?*?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 ITPluggableTerminalSuperclassInfo_get_Name(self: *const T, pName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalSuperclassInfo.VTable, self.vtable).get_Name(@ptrCast(*const ITPluggableTerminalSuperclassInfo, self), pName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPluggableTerminalSuperclassInfo_get_CLSID(self: *const T, pCLSID: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalSuperclassInfo.VTable, self.vtable).get_CLSID(@ptrCast(*const ITPluggableTerminalSuperclassInfo, self), pCLSID); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTerminalSupport_Value = @import("../zig.zig").Guid.initString("b1efc385-9355-11d0-835c-00aa003ccabd"); pub const IID_ITTerminalSupport = &IID_ITTerminalSupport_Value; pub const ITTerminalSupport = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_StaticTerminals: fn( self: *const ITTerminalSupport, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateStaticTerminals: fn( self: *const ITTerminalSupport, ppTerminalEnumerator: ?*?*IEnumTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DynamicTerminalClasses: fn( self: *const ITTerminalSupport, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateDynamicTerminalClasses: fn( self: *const ITTerminalSupport, ppTerminalClassEnumerator: ?*?*IEnumTerminalClass, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateTerminal: fn( self: *const ITTerminalSupport, pTerminalClass: ?BSTR, lMediaType: i32, Direction: TERMINAL_DIRECTION, ppTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultStaticTerminal: fn( self: *const ITTerminalSupport, lMediaType: i32, Direction: TERMINAL_DIRECTION, ppTerminal: ?*?*ITTerminal, ) 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 ITTerminalSupport_get_StaticTerminals(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport.VTable, self.vtable).get_StaticTerminals(@ptrCast(*const ITTerminalSupport, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport_EnumerateStaticTerminals(self: *const T, ppTerminalEnumerator: ?*?*IEnumTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport.VTable, self.vtable).EnumerateStaticTerminals(@ptrCast(*const ITTerminalSupport, self), ppTerminalEnumerator); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport_get_DynamicTerminalClasses(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport.VTable, self.vtable).get_DynamicTerminalClasses(@ptrCast(*const ITTerminalSupport, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport_EnumerateDynamicTerminalClasses(self: *const T, ppTerminalClassEnumerator: ?*?*IEnumTerminalClass) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport.VTable, self.vtable).EnumerateDynamicTerminalClasses(@ptrCast(*const ITTerminalSupport, self), ppTerminalClassEnumerator); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport_CreateTerminal(self: *const T, pTerminalClass: ?BSTR, lMediaType: i32, Direction: TERMINAL_DIRECTION, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport.VTable, self.vtable).CreateTerminal(@ptrCast(*const ITTerminalSupport, self), pTerminalClass, lMediaType, Direction, ppTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport_GetDefaultStaticTerminal(self: *const T, lMediaType: i32, Direction: TERMINAL_DIRECTION, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport.VTable, self.vtable).GetDefaultStaticTerminal(@ptrCast(*const ITTerminalSupport, self), lMediaType, Direction, ppTerminal); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTerminalSupport2_Value = @import("../zig.zig").Guid.initString("f3eb39bc-1b1f-4e99-a0c0-56305c4dd591"); pub const IID_ITTerminalSupport2 = &IID_ITTerminalSupport2_Value; pub const ITTerminalSupport2 = extern struct { pub const VTable = extern struct { base: ITTerminalSupport.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PluggableSuperclasses: fn( self: *const ITTerminalSupport2, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumeratePluggableSuperclasses: fn( self: *const ITTerminalSupport2, ppSuperclassEnumerator: ?*?*IEnumPluggableSuperclassInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PluggableTerminalClasses: fn( self: *const ITTerminalSupport2, bstrTerminalSuperclass: ?BSTR, lMediaType: i32, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumeratePluggableTerminalClasses: fn( self: *const ITTerminalSupport2, iidTerminalSuperclass: Guid, lMediaType: i32, ppClassEnumerator: ?*?*IEnumPluggableTerminalClassInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITTerminalSupport.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport2_get_PluggableSuperclasses(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport2.VTable, self.vtable).get_PluggableSuperclasses(@ptrCast(*const ITTerminalSupport2, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport2_EnumeratePluggableSuperclasses(self: *const T, ppSuperclassEnumerator: ?*?*IEnumPluggableSuperclassInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport2.VTable, self.vtable).EnumeratePluggableSuperclasses(@ptrCast(*const ITTerminalSupport2, self), ppSuperclassEnumerator); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport2_get_PluggableTerminalClasses(self: *const T, bstrTerminalSuperclass: ?BSTR, lMediaType: i32, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport2.VTable, self.vtable).get_PluggableTerminalClasses(@ptrCast(*const ITTerminalSupport2, self), bstrTerminalSuperclass, lMediaType, pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminalSupport2_EnumeratePluggableTerminalClasses(self: *const T, iidTerminalSuperclass: Guid, lMediaType: i32, ppClassEnumerator: ?*?*IEnumPluggableTerminalClassInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminalSupport2.VTable, self.vtable).EnumeratePluggableTerminalClasses(@ptrCast(*const ITTerminalSupport2, self), iidTerminalSuperclass, lMediaType, ppClassEnumerator); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAddress_Value = @import("../zig.zig").Guid.initString("b1efc386-9355-11d0-835c-00aa003ccabd"); pub const IID_ITAddress = &IID_ITAddress_Value; pub const ITAddress = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const ITAddress, pAddressState: ?*ADDRESS_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AddressName: fn( self: *const ITAddress, ppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceProviderName: fn( self: *const ITAddress, ppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TAPIObject: fn( self: *const ITAddress, ppTapiObject: ?*?*ITTAPI, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateCall: fn( self: *const ITAddress, pDestAddress: ?BSTR, lAddressType: i32, lMediaTypes: i32, ppCall: ?*?*ITBasicCallControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Calls: fn( self: *const ITAddress, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateCalls: fn( self: *const ITAddress, ppCallEnum: ?*?*IEnumCall, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DialableAddress: fn( self: *const ITAddress, pDialableAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateForwardInfoObject: fn( self: *const ITAddress, ppForwardInfo: ?*?*ITForwardInformation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Forward: fn( self: *const ITAddress, pForwardInfo: ?*ITForwardInformation, pCall: ?*ITBasicCallControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentForwardInfo: fn( self: *const ITAddress, ppForwardInfo: ?*?*ITForwardInformation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MessageWaiting: fn( self: *const ITAddress, fMessageWaiting: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MessageWaiting: fn( self: *const ITAddress, pfMessageWaiting: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DoNotDisturb: fn( self: *const ITAddress, fDoNotDisturb: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DoNotDisturb: fn( self: *const ITAddress, pfDoNotDisturb: ?*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 ITAddress_get_State(self: *const T, pAddressState: ?*ADDRESS_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_State(@ptrCast(*const ITAddress, self), pAddressState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_get_AddressName(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_AddressName(@ptrCast(*const ITAddress, self), ppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_get_ServiceProviderName(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_ServiceProviderName(@ptrCast(*const ITAddress, self), ppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_get_TAPIObject(self: *const T, ppTapiObject: ?*?*ITTAPI) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_TAPIObject(@ptrCast(*const ITAddress, self), ppTapiObject); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_CreateCall(self: *const T, pDestAddress: ?BSTR, lAddressType: i32, lMediaTypes: i32, ppCall: ?*?*ITBasicCallControl) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).CreateCall(@ptrCast(*const ITAddress, self), pDestAddress, lAddressType, lMediaTypes, ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_get_Calls(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_Calls(@ptrCast(*const ITAddress, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_EnumerateCalls(self: *const T, ppCallEnum: ?*?*IEnumCall) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).EnumerateCalls(@ptrCast(*const ITAddress, self), ppCallEnum); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_get_DialableAddress(self: *const T, pDialableAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_DialableAddress(@ptrCast(*const ITAddress, self), pDialableAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_CreateForwardInfoObject(self: *const T, ppForwardInfo: ?*?*ITForwardInformation) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).CreateForwardInfoObject(@ptrCast(*const ITAddress, self), ppForwardInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_Forward(self: *const T, pForwardInfo: ?*ITForwardInformation, pCall: ?*ITBasicCallControl) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).Forward(@ptrCast(*const ITAddress, self), pForwardInfo, pCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_get_CurrentForwardInfo(self: *const T, ppForwardInfo: ?*?*ITForwardInformation) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_CurrentForwardInfo(@ptrCast(*const ITAddress, self), ppForwardInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_put_MessageWaiting(self: *const T, fMessageWaiting: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).put_MessageWaiting(@ptrCast(*const ITAddress, self), fMessageWaiting); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_get_MessageWaiting(self: *const T, pfMessageWaiting: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_MessageWaiting(@ptrCast(*const ITAddress, self), pfMessageWaiting); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_put_DoNotDisturb(self: *const T, fDoNotDisturb: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).put_DoNotDisturb(@ptrCast(*const ITAddress, self), fDoNotDisturb); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress_get_DoNotDisturb(self: *const T, pfDoNotDisturb: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress.VTable, self.vtable).get_DoNotDisturb(@ptrCast(*const ITAddress, self), pfDoNotDisturb); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAddress2_Value = @import("../zig.zig").Guid.initString("b0ae5d9b-be51-46c9-b0f7-dfa8a22a8bc4"); pub const IID_ITAddress2 = &IID_ITAddress2_Value; pub const ITAddress2 = extern struct { pub const VTable = extern struct { base: ITAddress.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Phones: fn( self: *const ITAddress2, pPhones: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumeratePhones: fn( self: *const ITAddress2, ppEnumPhone: ?*?*IEnumPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPhoneFromTerminal: fn( self: *const ITAddress2, pTerminal: ?*ITTerminal, ppPhone: ?*?*ITPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PreferredPhones: fn( self: *const ITAddress2, pPhones: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumeratePreferredPhones: fn( self: *const ITAddress2, ppEnumPhone: ?*?*IEnumPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EventFilter: fn( self: *const ITAddress2, TapiEvent: TAPI_EVENT, lSubEvent: i32, pEnable: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EventFilter: fn( self: *const ITAddress2, TapiEvent: TAPI_EVENT, lSubEvent: i32, bEnable: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeviceSpecific: fn( self: *const ITAddress2, pCall: ?*ITCallInfo, pParams: ?*u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeviceSpecificVariant: fn( self: *const ITAddress2, pCall: ?*ITCallInfo, varDevSpecificByteArray: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, NegotiateExtVersion: fn( self: *const ITAddress2, lLowVersion: i32, lHighVersion: i32, plExtVersion: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITAddress.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_get_Phones(self: *const T, pPhones: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).get_Phones(@ptrCast(*const ITAddress2, self), pPhones); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_EnumeratePhones(self: *const T, ppEnumPhone: ?*?*IEnumPhone) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).EnumeratePhones(@ptrCast(*const ITAddress2, self), ppEnumPhone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_GetPhoneFromTerminal(self: *const T, pTerminal: ?*ITTerminal, ppPhone: ?*?*ITPhone) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).GetPhoneFromTerminal(@ptrCast(*const ITAddress2, self), pTerminal, ppPhone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_get_PreferredPhones(self: *const T, pPhones: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).get_PreferredPhones(@ptrCast(*const ITAddress2, self), pPhones); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_EnumeratePreferredPhones(self: *const T, ppEnumPhone: ?*?*IEnumPhone) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).EnumeratePreferredPhones(@ptrCast(*const ITAddress2, self), ppEnumPhone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_get_EventFilter(self: *const T, TapiEvent: TAPI_EVENT, lSubEvent: i32, pEnable: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).get_EventFilter(@ptrCast(*const ITAddress2, self), TapiEvent, lSubEvent, pEnable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_put_EventFilter(self: *const T, TapiEvent: TAPI_EVENT, lSubEvent: i32, bEnable: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).put_EventFilter(@ptrCast(*const ITAddress2, self), TapiEvent, lSubEvent, bEnable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_DeviceSpecific(self: *const T, pCall: ?*ITCallInfo, pParams: ?*u8, dwSize: u32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).DeviceSpecific(@ptrCast(*const ITAddress2, self), pCall, pParams, dwSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_DeviceSpecificVariant(self: *const T, pCall: ?*ITCallInfo, varDevSpecificByteArray: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).DeviceSpecificVariant(@ptrCast(*const ITAddress2, self), pCall, varDevSpecificByteArray); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddress2_NegotiateExtVersion(self: *const T, lLowVersion: i32, lHighVersion: i32, plExtVersion: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddress2.VTable, self.vtable).NegotiateExtVersion(@ptrCast(*const ITAddress2, self), lLowVersion, lHighVersion, plExtVersion); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAddressCapabilities_Value = @import("../zig.zig").Guid.initString("8df232f5-821b-11d1-bb5c-00c04fb6809f"); pub const IID_ITAddressCapabilities = &IID_ITAddressCapabilities_Value; pub const ITAddressCapabilities = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AddressCapability: fn( self: *const ITAddressCapabilities, AddressCap: ADDRESS_CAPABILITY, plCapability: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AddressCapabilityString: fn( self: *const ITAddressCapabilities, AddressCapString: ADDRESS_CAPABILITY_STRING, ppCapabilityString: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallTreatments: fn( self: *const ITAddressCapabilities, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateCallTreatments: fn( self: *const ITAddressCapabilities, ppEnumCallTreatment: ?*?*IEnumBstr, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CompletionMessages: fn( self: *const ITAddressCapabilities, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateCompletionMessages: fn( self: *const ITAddressCapabilities, ppEnumCompletionMessage: ?*?*IEnumBstr, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DeviceClasses: fn( self: *const ITAddressCapabilities, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateDeviceClasses: fn( self: *const ITAddressCapabilities, ppEnumDeviceClass: ?*?*IEnumBstr, ) 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 ITAddressCapabilities_get_AddressCapability(self: *const T, AddressCap: ADDRESS_CAPABILITY, plCapability: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressCapabilities.VTable, self.vtable).get_AddressCapability(@ptrCast(*const ITAddressCapabilities, self), AddressCap, plCapability); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressCapabilities_get_AddressCapabilityString(self: *const T, AddressCapString: ADDRESS_CAPABILITY_STRING, ppCapabilityString: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressCapabilities.VTable, self.vtable).get_AddressCapabilityString(@ptrCast(*const ITAddressCapabilities, self), AddressCapString, ppCapabilityString); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressCapabilities_get_CallTreatments(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressCapabilities.VTable, self.vtable).get_CallTreatments(@ptrCast(*const ITAddressCapabilities, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressCapabilities_EnumerateCallTreatments(self: *const T, ppEnumCallTreatment: ?*?*IEnumBstr) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressCapabilities.VTable, self.vtable).EnumerateCallTreatments(@ptrCast(*const ITAddressCapabilities, self), ppEnumCallTreatment); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressCapabilities_get_CompletionMessages(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressCapabilities.VTable, self.vtable).get_CompletionMessages(@ptrCast(*const ITAddressCapabilities, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressCapabilities_EnumerateCompletionMessages(self: *const T, ppEnumCompletionMessage: ?*?*IEnumBstr) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressCapabilities.VTable, self.vtable).EnumerateCompletionMessages(@ptrCast(*const ITAddressCapabilities, self), ppEnumCompletionMessage); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressCapabilities_get_DeviceClasses(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressCapabilities.VTable, self.vtable).get_DeviceClasses(@ptrCast(*const ITAddressCapabilities, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressCapabilities_EnumerateDeviceClasses(self: *const T, ppEnumDeviceClass: ?*?*IEnumBstr) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressCapabilities.VTable, self.vtable).EnumerateDeviceClasses(@ptrCast(*const ITAddressCapabilities, self), ppEnumDeviceClass); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITPhone_Value = @import("../zig.zig").Guid.initString("09d48db4-10cc-4388-9de7-a8465618975a"); pub const IID_ITPhone = &IID_ITPhone_Value; pub const ITPhone = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Open: fn( self: *const ITPhone, Privilege: PHONE_PRIVILEGE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Close: fn( self: *const ITPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Addresses: fn( self: *const ITPhone, pAddresses: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateAddresses: fn( self: *const ITPhone, ppEnumAddress: ?*?*IEnumAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PhoneCapsLong: fn( self: *const ITPhone, pclCap: PHONECAPS_LONG, plCapability: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PhoneCapsString: fn( self: *const ITPhone, pcsCap: PHONECAPS_STRING, ppCapability: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminals: fn( self: *const ITPhone, pAddress: ?*ITAddress, pTerminals: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateTerminals: fn( self: *const ITPhone, pAddress: ?*ITAddress, ppEnumTerminal: ?*?*IEnumTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ButtonMode: fn( self: *const ITPhone, lButtonID: i32, pButtonMode: ?*PHONE_BUTTON_MODE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ButtonMode: fn( self: *const ITPhone, lButtonID: i32, ButtonMode: PHONE_BUTTON_MODE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ButtonFunction: fn( self: *const ITPhone, lButtonID: i32, pButtonFunction: ?*PHONE_BUTTON_FUNCTION, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ButtonFunction: fn( self: *const ITPhone, lButtonID: i32, ButtonFunction: PHONE_BUTTON_FUNCTION, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ButtonText: fn( self: *const ITPhone, lButtonID: i32, ppButtonText: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ButtonText: fn( self: *const ITPhone, lButtonID: i32, bstrButtonText: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ButtonState: fn( self: *const ITPhone, lButtonID: i32, pButtonState: ?*PHONE_BUTTON_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HookSwitchState: fn( self: *const ITPhone, HookSwitchDevice: PHONE_HOOK_SWITCH_DEVICE, pHookSwitchState: ?*PHONE_HOOK_SWITCH_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_HookSwitchState: fn( self: *const ITPhone, HookSwitchDevice: PHONE_HOOK_SWITCH_DEVICE, HookSwitchState: PHONE_HOOK_SWITCH_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_RingMode: fn( self: *const ITPhone, lRingMode: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RingMode: fn( self: *const ITPhone, plRingMode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_RingVolume: fn( self: *const ITPhone, lRingVolume: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RingVolume: fn( self: *const ITPhone, plRingVolume: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Privilege: fn( self: *const ITPhone, pPrivilege: ?*PHONE_PRIVILEGE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPhoneCapsBuffer: fn( self: *const ITPhone, pcbCaps: PHONECAPS_BUFFER, pdwSize: ?*u32, ppPhoneCapsBuffer: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PhoneCapsBuffer: fn( self: *const ITPhone, pcbCaps: PHONECAPS_BUFFER, pVarBuffer: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LampMode: fn( self: *const ITPhone, lLampID: i32, pLampMode: ?*PHONE_LAMP_MODE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_LampMode: fn( self: *const ITPhone, lLampID: i32, LampMode: PHONE_LAMP_MODE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Display: fn( self: *const ITPhone, pbstrDisplay: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetDisplay: fn( self: *const ITPhone, lRow: i32, lColumn: i32, bstrDisplay: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PreferredAddresses: fn( self: *const ITPhone, pAddresses: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumeratePreferredAddresses: fn( self: *const ITPhone, ppEnumAddress: ?*?*IEnumAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeviceSpecific: fn( self: *const ITPhone, pParams: ?*u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeviceSpecificVariant: fn( self: *const ITPhone, varDevSpecificByteArray: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, NegotiateExtVersion: fn( self: *const ITPhone, lLowVersion: i32, lHighVersion: i32, plExtVersion: ?*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 ITPhone_Open(self: *const T, Privilege: PHONE_PRIVILEGE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).Open(@ptrCast(*const ITPhone, self), Privilege); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_Close(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).Close(@ptrCast(*const ITPhone, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_Addresses(self: *const T, pAddresses: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_Addresses(@ptrCast(*const ITPhone, self), pAddresses); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_EnumerateAddresses(self: *const T, ppEnumAddress: ?*?*IEnumAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).EnumerateAddresses(@ptrCast(*const ITPhone, self), ppEnumAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_PhoneCapsLong(self: *const T, pclCap: PHONECAPS_LONG, plCapability: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_PhoneCapsLong(@ptrCast(*const ITPhone, self), pclCap, plCapability); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_PhoneCapsString(self: *const T, pcsCap: PHONECAPS_STRING, ppCapability: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_PhoneCapsString(@ptrCast(*const ITPhone, self), pcsCap, ppCapability); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_Terminals(self: *const T, pAddress: ?*ITAddress, pTerminals: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_Terminals(@ptrCast(*const ITPhone, self), pAddress, pTerminals); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_EnumerateTerminals(self: *const T, pAddress: ?*ITAddress, ppEnumTerminal: ?*?*IEnumTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).EnumerateTerminals(@ptrCast(*const ITPhone, self), pAddress, ppEnumTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_ButtonMode(self: *const T, lButtonID: i32, pButtonMode: ?*PHONE_BUTTON_MODE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_ButtonMode(@ptrCast(*const ITPhone, self), lButtonID, pButtonMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_put_ButtonMode(self: *const T, lButtonID: i32, ButtonMode: PHONE_BUTTON_MODE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).put_ButtonMode(@ptrCast(*const ITPhone, self), lButtonID, ButtonMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_ButtonFunction(self: *const T, lButtonID: i32, pButtonFunction: ?*PHONE_BUTTON_FUNCTION) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_ButtonFunction(@ptrCast(*const ITPhone, self), lButtonID, pButtonFunction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_put_ButtonFunction(self: *const T, lButtonID: i32, ButtonFunction: PHONE_BUTTON_FUNCTION) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).put_ButtonFunction(@ptrCast(*const ITPhone, self), lButtonID, ButtonFunction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_ButtonText(self: *const T, lButtonID: i32, ppButtonText: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_ButtonText(@ptrCast(*const ITPhone, self), lButtonID, ppButtonText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_put_ButtonText(self: *const T, lButtonID: i32, bstrButtonText: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).put_ButtonText(@ptrCast(*const ITPhone, self), lButtonID, bstrButtonText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_ButtonState(self: *const T, lButtonID: i32, pButtonState: ?*PHONE_BUTTON_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_ButtonState(@ptrCast(*const ITPhone, self), lButtonID, pButtonState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_HookSwitchState(self: *const T, HookSwitchDevice: PHONE_HOOK_SWITCH_DEVICE, pHookSwitchState: ?*PHONE_HOOK_SWITCH_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_HookSwitchState(@ptrCast(*const ITPhone, self), HookSwitchDevice, pHookSwitchState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_put_HookSwitchState(self: *const T, HookSwitchDevice: PHONE_HOOK_SWITCH_DEVICE, HookSwitchState: PHONE_HOOK_SWITCH_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).put_HookSwitchState(@ptrCast(*const ITPhone, self), HookSwitchDevice, HookSwitchState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_put_RingMode(self: *const T, lRingMode: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).put_RingMode(@ptrCast(*const ITPhone, self), lRingMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_RingMode(self: *const T, plRingMode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_RingMode(@ptrCast(*const ITPhone, self), plRingMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_put_RingVolume(self: *const T, lRingVolume: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).put_RingVolume(@ptrCast(*const ITPhone, self), lRingVolume); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_RingVolume(self: *const T, plRingVolume: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_RingVolume(@ptrCast(*const ITPhone, self), plRingVolume); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_Privilege(self: *const T, pPrivilege: ?*PHONE_PRIVILEGE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_Privilege(@ptrCast(*const ITPhone, self), pPrivilege); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_GetPhoneCapsBuffer(self: *const T, pcbCaps: PHONECAPS_BUFFER, pdwSize: ?*u32, ppPhoneCapsBuffer: ?*?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).GetPhoneCapsBuffer(@ptrCast(*const ITPhone, self), pcbCaps, pdwSize, ppPhoneCapsBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_PhoneCapsBuffer(self: *const T, pcbCaps: PHONECAPS_BUFFER, pVarBuffer: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_PhoneCapsBuffer(@ptrCast(*const ITPhone, self), pcbCaps, pVarBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_LampMode(self: *const T, lLampID: i32, pLampMode: ?*PHONE_LAMP_MODE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_LampMode(@ptrCast(*const ITPhone, self), lLampID, pLampMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_put_LampMode(self: *const T, lLampID: i32, LampMode: PHONE_LAMP_MODE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).put_LampMode(@ptrCast(*const ITPhone, self), lLampID, LampMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_Display(self: *const T, pbstrDisplay: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_Display(@ptrCast(*const ITPhone, self), pbstrDisplay); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_SetDisplay(self: *const T, lRow: i32, lColumn: i32, bstrDisplay: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).SetDisplay(@ptrCast(*const ITPhone, self), lRow, lColumn, bstrDisplay); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_get_PreferredAddresses(self: *const T, pAddresses: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).get_PreferredAddresses(@ptrCast(*const ITPhone, self), pAddresses); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_EnumeratePreferredAddresses(self: *const T, ppEnumAddress: ?*?*IEnumAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).EnumeratePreferredAddresses(@ptrCast(*const ITPhone, self), ppEnumAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_DeviceSpecific(self: *const T, pParams: ?*u8, dwSize: u32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).DeviceSpecific(@ptrCast(*const ITPhone, self), pParams, dwSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_DeviceSpecificVariant(self: *const T, varDevSpecificByteArray: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).DeviceSpecificVariant(@ptrCast(*const ITPhone, self), varDevSpecificByteArray); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhone_NegotiateExtVersion(self: *const T, lLowVersion: i32, lHighVersion: i32, plExtVersion: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhone.VTable, self.vtable).NegotiateExtVersion(@ptrCast(*const ITPhone, self), lLowVersion, lHighVersion, plExtVersion); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAutomatedPhoneControl_Value = @import("../zig.zig").Guid.initString("1ee1af0e-6159-4a61-b79b-6a4ba3fc9dfc"); pub const IID_ITAutomatedPhoneControl = &IID_ITAutomatedPhoneControl_Value; pub const ITAutomatedPhoneControl = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, StartTone: fn( self: *const ITAutomatedPhoneControl, Tone: PHONE_TONE, lDuration: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, StopTone: fn( self: *const ITAutomatedPhoneControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Tone: fn( self: *const ITAutomatedPhoneControl, pTone: ?*PHONE_TONE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, StartRinger: fn( self: *const ITAutomatedPhoneControl, lRingMode: i32, lDuration: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, StopRinger: fn( self: *const ITAutomatedPhoneControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Ringer: fn( self: *const ITAutomatedPhoneControl, pfRinging: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PhoneHandlingEnabled: fn( self: *const ITAutomatedPhoneControl, fEnabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PhoneHandlingEnabled: fn( self: *const ITAutomatedPhoneControl, pfEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoEndOfNumberTimeout: fn( self: *const ITAutomatedPhoneControl, lTimeout: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoEndOfNumberTimeout: fn( self: *const ITAutomatedPhoneControl, plTimeout: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoDialtone: fn( self: *const ITAutomatedPhoneControl, fEnabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoDialtone: fn( self: *const ITAutomatedPhoneControl, pfEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoStopTonesOnOnHook: fn( self: *const ITAutomatedPhoneControl, fEnabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoStopTonesOnOnHook: fn( self: *const ITAutomatedPhoneControl, pfEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoStopRingOnOffHook: fn( self: *const ITAutomatedPhoneControl, fEnabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoStopRingOnOffHook: fn( self: *const ITAutomatedPhoneControl, pfEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoKeypadTones: fn( self: *const ITAutomatedPhoneControl, fEnabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoKeypadTones: fn( self: *const ITAutomatedPhoneControl, pfEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoKeypadTonesMinimumDuration: fn( self: *const ITAutomatedPhoneControl, lDuration: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoKeypadTonesMinimumDuration: fn( self: *const ITAutomatedPhoneControl, plDuration: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoVolumeControl: fn( self: *const ITAutomatedPhoneControl, fEnabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoVolumeControl: fn( self: *const ITAutomatedPhoneControl, fEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoVolumeControlStep: fn( self: *const ITAutomatedPhoneControl, lStepSize: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoVolumeControlStep: fn( self: *const ITAutomatedPhoneControl, plStepSize: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoVolumeControlRepeatDelay: fn( self: *const ITAutomatedPhoneControl, lDelay: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoVolumeControlRepeatDelay: fn( self: *const ITAutomatedPhoneControl, plDelay: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AutoVolumeControlRepeatPeriod: fn( self: *const ITAutomatedPhoneControl, lPeriod: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AutoVolumeControlRepeatPeriod: fn( self: *const ITAutomatedPhoneControl, plPeriod: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SelectCall: fn( self: *const ITAutomatedPhoneControl, pCall: ?*ITCallInfo, fSelectDefaultTerminals: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnselectCall: fn( self: *const ITAutomatedPhoneControl, pCall: ?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateSelectedCalls: fn( self: *const ITAutomatedPhoneControl, ppCallEnum: ?*?*IEnumCall, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SelectedCalls: fn( self: *const ITAutomatedPhoneControl, pVariant: ?*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 ITAutomatedPhoneControl_StartTone(self: *const T, Tone: PHONE_TONE, lDuration: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).StartTone(@ptrCast(*const ITAutomatedPhoneControl, self), Tone, lDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_StopTone(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).StopTone(@ptrCast(*const ITAutomatedPhoneControl, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_Tone(self: *const T, pTone: ?*PHONE_TONE) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_Tone(@ptrCast(*const ITAutomatedPhoneControl, self), pTone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_StartRinger(self: *const T, lRingMode: i32, lDuration: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).StartRinger(@ptrCast(*const ITAutomatedPhoneControl, self), lRingMode, lDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_StopRinger(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).StopRinger(@ptrCast(*const ITAutomatedPhoneControl, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_Ringer(self: *const T, pfRinging: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_Ringer(@ptrCast(*const ITAutomatedPhoneControl, self), pfRinging); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_PhoneHandlingEnabled(self: *const T, fEnabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_PhoneHandlingEnabled(@ptrCast(*const ITAutomatedPhoneControl, self), fEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_PhoneHandlingEnabled(self: *const T, pfEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_PhoneHandlingEnabled(@ptrCast(*const ITAutomatedPhoneControl, self), pfEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoEndOfNumberTimeout(self: *const T, lTimeout: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoEndOfNumberTimeout(@ptrCast(*const ITAutomatedPhoneControl, self), lTimeout); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoEndOfNumberTimeout(self: *const T, plTimeout: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoEndOfNumberTimeout(@ptrCast(*const ITAutomatedPhoneControl, self), plTimeout); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoDialtone(self: *const T, fEnabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoDialtone(@ptrCast(*const ITAutomatedPhoneControl, self), fEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoDialtone(self: *const T, pfEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoDialtone(@ptrCast(*const ITAutomatedPhoneControl, self), pfEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoStopTonesOnOnHook(self: *const T, fEnabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoStopTonesOnOnHook(@ptrCast(*const ITAutomatedPhoneControl, self), fEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoStopTonesOnOnHook(self: *const T, pfEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoStopTonesOnOnHook(@ptrCast(*const ITAutomatedPhoneControl, self), pfEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoStopRingOnOffHook(self: *const T, fEnabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoStopRingOnOffHook(@ptrCast(*const ITAutomatedPhoneControl, self), fEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoStopRingOnOffHook(self: *const T, pfEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoStopRingOnOffHook(@ptrCast(*const ITAutomatedPhoneControl, self), pfEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoKeypadTones(self: *const T, fEnabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoKeypadTones(@ptrCast(*const ITAutomatedPhoneControl, self), fEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoKeypadTones(self: *const T, pfEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoKeypadTones(@ptrCast(*const ITAutomatedPhoneControl, self), pfEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoKeypadTonesMinimumDuration(self: *const T, lDuration: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoKeypadTonesMinimumDuration(@ptrCast(*const ITAutomatedPhoneControl, self), lDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoKeypadTonesMinimumDuration(self: *const T, plDuration: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoKeypadTonesMinimumDuration(@ptrCast(*const ITAutomatedPhoneControl, self), plDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoVolumeControl(self: *const T, fEnabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoVolumeControl(@ptrCast(*const ITAutomatedPhoneControl, self), fEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoVolumeControl(self: *const T, fEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoVolumeControl(@ptrCast(*const ITAutomatedPhoneControl, self), fEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoVolumeControlStep(self: *const T, lStepSize: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoVolumeControlStep(@ptrCast(*const ITAutomatedPhoneControl, self), lStepSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoVolumeControlStep(self: *const T, plStepSize: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoVolumeControlStep(@ptrCast(*const ITAutomatedPhoneControl, self), plStepSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoVolumeControlRepeatDelay(self: *const T, lDelay: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoVolumeControlRepeatDelay(@ptrCast(*const ITAutomatedPhoneControl, self), lDelay); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoVolumeControlRepeatDelay(self: *const T, plDelay: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoVolumeControlRepeatDelay(@ptrCast(*const ITAutomatedPhoneControl, self), plDelay); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_put_AutoVolumeControlRepeatPeriod(self: *const T, lPeriod: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).put_AutoVolumeControlRepeatPeriod(@ptrCast(*const ITAutomatedPhoneControl, self), lPeriod); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_AutoVolumeControlRepeatPeriod(self: *const T, plPeriod: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_AutoVolumeControlRepeatPeriod(@ptrCast(*const ITAutomatedPhoneControl, self), plPeriod); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_SelectCall(self: *const T, pCall: ?*ITCallInfo, fSelectDefaultTerminals: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).SelectCall(@ptrCast(*const ITAutomatedPhoneControl, self), pCall, fSelectDefaultTerminals); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_UnselectCall(self: *const T, pCall: ?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).UnselectCall(@ptrCast(*const ITAutomatedPhoneControl, self), pCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_EnumerateSelectedCalls(self: *const T, ppCallEnum: ?*?*IEnumCall) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).EnumerateSelectedCalls(@ptrCast(*const ITAutomatedPhoneControl, self), ppCallEnum); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAutomatedPhoneControl_get_SelectedCalls(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAutomatedPhoneControl.VTable, self.vtable).get_SelectedCalls(@ptrCast(*const ITAutomatedPhoneControl, self), pVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITBasicCallControl_Value = @import("../zig.zig").Guid.initString("b1efc389-9355-11d0-835c-00aa003ccabd"); pub const IID_ITBasicCallControl = &IID_ITBasicCallControl_Value; pub const ITBasicCallControl = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Connect: fn( self: *const ITBasicCallControl, fSync: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Answer: fn( self: *const ITBasicCallControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Disconnect: fn( self: *const ITBasicCallControl, code: DISCONNECT_CODE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Hold: fn( self: *const ITBasicCallControl, fHold: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, HandoffDirect: fn( self: *const ITBasicCallControl, pApplicationName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, HandoffIndirect: fn( self: *const ITBasicCallControl, lMediaType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Conference: fn( self: *const ITBasicCallControl, pCall: ?*ITBasicCallControl, fSync: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Transfer: fn( self: *const ITBasicCallControl, pCall: ?*ITBasicCallControl, fSync: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, BlindTransfer: fn( self: *const ITBasicCallControl, pDestAddress: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SwapHold: fn( self: *const ITBasicCallControl, pCall: ?*ITBasicCallControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ParkDirect: fn( self: *const ITBasicCallControl, pParkAddress: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ParkIndirect: fn( self: *const ITBasicCallControl, ppNonDirAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Unpark: fn( self: *const ITBasicCallControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetQOS: fn( self: *const ITBasicCallControl, lMediaType: i32, ServiceLevel: QOS_SERVICE_LEVEL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Pickup: fn( self: *const ITBasicCallControl, pGroupID: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Dial: fn( self: *const ITBasicCallControl, pDestAddress: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Finish: fn( self: *const ITBasicCallControl, finishMode: FINISH_MODE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveFromConference: fn( self: *const ITBasicCallControl, ) 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 ITBasicCallControl_Connect(self: *const T, fSync: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Connect(@ptrCast(*const ITBasicCallControl, self), fSync); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Answer(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Answer(@ptrCast(*const ITBasicCallControl, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Disconnect(self: *const T, code: DISCONNECT_CODE) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Disconnect(@ptrCast(*const ITBasicCallControl, self), code); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Hold(self: *const T, fHold: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Hold(@ptrCast(*const ITBasicCallControl, self), fHold); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_HandoffDirect(self: *const T, pApplicationName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).HandoffDirect(@ptrCast(*const ITBasicCallControl, self), pApplicationName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_HandoffIndirect(self: *const T, lMediaType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).HandoffIndirect(@ptrCast(*const ITBasicCallControl, self), lMediaType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Conference(self: *const T, pCall: ?*ITBasicCallControl, fSync: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Conference(@ptrCast(*const ITBasicCallControl, self), pCall, fSync); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Transfer(self: *const T, pCall: ?*ITBasicCallControl, fSync: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Transfer(@ptrCast(*const ITBasicCallControl, self), pCall, fSync); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_BlindTransfer(self: *const T, pDestAddress: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).BlindTransfer(@ptrCast(*const ITBasicCallControl, self), pDestAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_SwapHold(self: *const T, pCall: ?*ITBasicCallControl) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).SwapHold(@ptrCast(*const ITBasicCallControl, self), pCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_ParkDirect(self: *const T, pParkAddress: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).ParkDirect(@ptrCast(*const ITBasicCallControl, self), pParkAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_ParkIndirect(self: *const T, ppNonDirAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).ParkIndirect(@ptrCast(*const ITBasicCallControl, self), ppNonDirAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Unpark(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Unpark(@ptrCast(*const ITBasicCallControl, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_SetQOS(self: *const T, lMediaType: i32, ServiceLevel: QOS_SERVICE_LEVEL) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).SetQOS(@ptrCast(*const ITBasicCallControl, self), lMediaType, ServiceLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Pickup(self: *const T, pGroupID: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Pickup(@ptrCast(*const ITBasicCallControl, self), pGroupID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Dial(self: *const T, pDestAddress: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Dial(@ptrCast(*const ITBasicCallControl, self), pDestAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_Finish(self: *const T, finishMode: FINISH_MODE) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).Finish(@ptrCast(*const ITBasicCallControl, self), finishMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl_RemoveFromConference(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl.VTable, self.vtable).RemoveFromConference(@ptrCast(*const ITBasicCallControl, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallInfo_Value = @import("../zig.zig").Guid.initString("350f85d1-1227-11d3-83d4-00c04fb6809f"); pub const IID_ITCallInfo = &IID_ITCallInfo_Value; pub const ITCallInfo = 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 ITCallInfo, ppAddress: ?*?*ITAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallState: fn( self: *const ITCallInfo, pCallState: ?*CALL_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Privilege: fn( self: *const ITCallInfo, pPrivilege: ?*CALL_PRIVILEGE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallHub: fn( self: *const ITCallInfo, ppCallHub: ?*?*ITCallHub, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallInfoLong: fn( self: *const ITCallInfo, CallInfoLong: CALLINFO_LONG, plCallInfoLongVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CallInfoLong: fn( self: *const ITCallInfo, CallInfoLong: CALLINFO_LONG, lCallInfoLongVal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallInfoString: fn( self: *const ITCallInfo, CallInfoString: CALLINFO_STRING, ppCallInfoString: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CallInfoString: fn( self: *const ITCallInfo, CallInfoString: CALLINFO_STRING, pCallInfoString: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallInfoBuffer: fn( self: *const ITCallInfo, CallInfoBuffer: CALLINFO_BUFFER, ppCallInfoBuffer: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CallInfoBuffer: fn( self: *const ITCallInfo, CallInfoBuffer: CALLINFO_BUFFER, pCallInfoBuffer: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetCallInfoBuffer: fn( self: *const ITCallInfo, CallInfoBuffer: CALLINFO_BUFFER, pdwSize: ?*u32, ppCallInfoBuffer: [*]?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetCallInfoBuffer: fn( self: *const ITCallInfo, CallInfoBuffer: CALLINFO_BUFFER, dwSize: u32, pCallInfoBuffer: [*:0]u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReleaseUserUserInfo: fn( self: *const ITCallInfo, ) 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 ITCallInfo_get_Address(self: *const T, ppAddress: ?*?*ITAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).get_Address(@ptrCast(*const ITCallInfo, self), ppAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_get_CallState(self: *const T, pCallState: ?*CALL_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).get_CallState(@ptrCast(*const ITCallInfo, self), pCallState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_get_Privilege(self: *const T, pPrivilege: ?*CALL_PRIVILEGE) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).get_Privilege(@ptrCast(*const ITCallInfo, self), pPrivilege); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_get_CallHub(self: *const T, ppCallHub: ?*?*ITCallHub) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).get_CallHub(@ptrCast(*const ITCallInfo, self), ppCallHub); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_get_CallInfoLong(self: *const T, CallInfoLong: CALLINFO_LONG, plCallInfoLongVal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).get_CallInfoLong(@ptrCast(*const ITCallInfo, self), CallInfoLong, plCallInfoLongVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_put_CallInfoLong(self: *const T, CallInfoLong: CALLINFO_LONG, lCallInfoLongVal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).put_CallInfoLong(@ptrCast(*const ITCallInfo, self), CallInfoLong, lCallInfoLongVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_get_CallInfoString(self: *const T, CallInfoString: CALLINFO_STRING, ppCallInfoString: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).get_CallInfoString(@ptrCast(*const ITCallInfo, self), CallInfoString, ppCallInfoString); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_put_CallInfoString(self: *const T, CallInfoString: CALLINFO_STRING, pCallInfoString: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).put_CallInfoString(@ptrCast(*const ITCallInfo, self), CallInfoString, pCallInfoString); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_get_CallInfoBuffer(self: *const T, CallInfoBuffer: CALLINFO_BUFFER, ppCallInfoBuffer: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).get_CallInfoBuffer(@ptrCast(*const ITCallInfo, self), CallInfoBuffer, ppCallInfoBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_put_CallInfoBuffer(self: *const T, CallInfoBuffer: CALLINFO_BUFFER, pCallInfoBuffer: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).put_CallInfoBuffer(@ptrCast(*const ITCallInfo, self), CallInfoBuffer, pCallInfoBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_GetCallInfoBuffer(self: *const T, CallInfoBuffer: CALLINFO_BUFFER, pdwSize: ?*u32, ppCallInfoBuffer: [*]?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).GetCallInfoBuffer(@ptrCast(*const ITCallInfo, self), CallInfoBuffer, pdwSize, ppCallInfoBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_SetCallInfoBuffer(self: *const T, CallInfoBuffer: CALLINFO_BUFFER, dwSize: u32, pCallInfoBuffer: [*:0]u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).SetCallInfoBuffer(@ptrCast(*const ITCallInfo, self), CallInfoBuffer, dwSize, pCallInfoBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo_ReleaseUserUserInfo(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo.VTable, self.vtable).ReleaseUserUserInfo(@ptrCast(*const ITCallInfo, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallInfo2_Value = @import("../zig.zig").Guid.initString("94d70ca6-7ab0-4daa-81ca-b8f8643faec1"); pub const IID_ITCallInfo2 = &IID_ITCallInfo2_Value; pub const ITCallInfo2 = extern struct { pub const VTable = extern struct { base: ITCallInfo.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EventFilter: fn( self: *const ITCallInfo2, TapiEvent: TAPI_EVENT, lSubEvent: i32, pEnable: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EventFilter: fn( self: *const ITCallInfo2, TapiEvent: TAPI_EVENT, lSubEvent: i32, bEnable: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITCallInfo.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo2_get_EventFilter(self: *const T, TapiEvent: TAPI_EVENT, lSubEvent: i32, pEnable: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo2.VTable, self.vtable).get_EventFilter(@ptrCast(*const ITCallInfo2, self), TapiEvent, lSubEvent, pEnable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfo2_put_EventFilter(self: *const T, TapiEvent: TAPI_EVENT, lSubEvent: i32, bEnable: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfo2.VTable, self.vtable).put_EventFilter(@ptrCast(*const ITCallInfo2, self), TapiEvent, lSubEvent, bEnable); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTerminal_Value = @import("../zig.zig").Guid.initString("b1efc38a-9355-11d0-835c-00aa003ccabd"); pub const IID_ITTerminal = &IID_ITTerminal_Value; pub const ITTerminal = 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 ITTerminal, ppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const ITTerminal, pTerminalState: ?*TERMINAL_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TerminalType: fn( self: *const ITTerminal, pType: ?*TERMINAL_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TerminalClass: fn( self: *const ITTerminal, ppTerminalClass: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MediaType: fn( self: *const ITTerminal, plMediaType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Direction: fn( self: *const ITTerminal, pDirection: ?*TERMINAL_DIRECTION, ) 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 ITTerminal_get_Name(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminal.VTable, self.vtable).get_Name(@ptrCast(*const ITTerminal, self), ppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminal_get_State(self: *const T, pTerminalState: ?*TERMINAL_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminal.VTable, self.vtable).get_State(@ptrCast(*const ITTerminal, self), pTerminalState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminal_get_TerminalType(self: *const T, pType: ?*TERMINAL_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminal.VTable, self.vtable).get_TerminalType(@ptrCast(*const ITTerminal, self), pType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminal_get_TerminalClass(self: *const T, ppTerminalClass: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminal.VTable, self.vtable).get_TerminalClass(@ptrCast(*const ITTerminal, self), ppTerminalClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminal_get_MediaType(self: *const T, plMediaType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminal.VTable, self.vtable).get_MediaType(@ptrCast(*const ITTerminal, self), plMediaType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTerminal_get_Direction(self: *const T, pDirection: ?*TERMINAL_DIRECTION) callconv(.Inline) HRESULT { return @ptrCast(*const ITTerminal.VTable, self.vtable).get_Direction(@ptrCast(*const ITTerminal, self), pDirection); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITMultiTrackTerminal_Value = @import("../zig.zig").Guid.initString("fe040091-ade8-4072-95c9-bf7de8c54b44"); pub const IID_ITMultiTrackTerminal = &IID_ITMultiTrackTerminal_Value; pub const ITMultiTrackTerminal = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TrackTerminals: fn( self: *const ITMultiTrackTerminal, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateTrackTerminals: fn( self: *const ITMultiTrackTerminal, ppEnumTerminal: ?*?*IEnumTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateTrackTerminal: fn( self: *const ITMultiTrackTerminal, MediaType: i32, TerminalDirection: TERMINAL_DIRECTION, ppTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MediaTypesInUse: fn( self: *const ITMultiTrackTerminal, plMediaTypesInUse: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DirectionsInUse: fn( self: *const ITMultiTrackTerminal, plDirectionsInUsed: ?*TERMINAL_DIRECTION, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveTrackTerminal: fn( self: *const ITMultiTrackTerminal, pTrackTerminalToRemove: ?*ITTerminal, ) 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 ITMultiTrackTerminal_get_TrackTerminals(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITMultiTrackTerminal.VTable, self.vtable).get_TrackTerminals(@ptrCast(*const ITMultiTrackTerminal, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMultiTrackTerminal_EnumerateTrackTerminals(self: *const T, ppEnumTerminal: ?*?*IEnumTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITMultiTrackTerminal.VTable, self.vtable).EnumerateTrackTerminals(@ptrCast(*const ITMultiTrackTerminal, self), ppEnumTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMultiTrackTerminal_CreateTrackTerminal(self: *const T, MediaType: i32, TerminalDirection: TERMINAL_DIRECTION, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITMultiTrackTerminal.VTable, self.vtable).CreateTrackTerminal(@ptrCast(*const ITMultiTrackTerminal, self), MediaType, TerminalDirection, ppTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMultiTrackTerminal_get_MediaTypesInUse(self: *const T, plMediaTypesInUse: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITMultiTrackTerminal.VTable, self.vtable).get_MediaTypesInUse(@ptrCast(*const ITMultiTrackTerminal, self), plMediaTypesInUse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMultiTrackTerminal_get_DirectionsInUse(self: *const T, plDirectionsInUsed: ?*TERMINAL_DIRECTION) callconv(.Inline) HRESULT { return @ptrCast(*const ITMultiTrackTerminal.VTable, self.vtable).get_DirectionsInUse(@ptrCast(*const ITMultiTrackTerminal, self), plDirectionsInUsed); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMultiTrackTerminal_RemoveTrackTerminal(self: *const T, pTrackTerminalToRemove: ?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITMultiTrackTerminal.VTable, self.vtable).RemoveTrackTerminal(@ptrCast(*const ITMultiTrackTerminal, self), pTrackTerminalToRemove); } };} pub usingnamespace MethodMixin(@This()); }; pub const TERMINAL_MEDIA_STATE = enum(i32) { IDLE = 0, ACTIVE = 1, PAUSED = 2, // LASTITEM = 2, this enum value conflicts with PAUSED }; pub const TMS_IDLE = TERMINAL_MEDIA_STATE.IDLE; pub const TMS_ACTIVE = TERMINAL_MEDIA_STATE.ACTIVE; pub const TMS_PAUSED = TERMINAL_MEDIA_STATE.PAUSED; pub const TMS_LASTITEM = TERMINAL_MEDIA_STATE.PAUSED; pub const FT_STATE_EVENT_CAUSE = enum(i32) { NORMAL = 0, END_OF_FILE = 1, READ_ERROR = 2, WRITE_ERROR = 3, }; pub const FTEC_NORMAL = FT_STATE_EVENT_CAUSE.NORMAL; pub const FTEC_END_OF_FILE = FT_STATE_EVENT_CAUSE.END_OF_FILE; pub const FTEC_READ_ERROR = FT_STATE_EVENT_CAUSE.READ_ERROR; pub const FTEC_WRITE_ERROR = FT_STATE_EVENT_CAUSE.WRITE_ERROR; const IID_ITFileTrack_Value = @import("../zig.zig").Guid.initString("31ca6ea9-c08a-4bea-8811-8e9c1ba3ea3a"); pub const IID_ITFileTrack = &IID_ITFileTrack_Value; pub const ITFileTrack = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Format: fn( self: *const ITFileTrack, ppmt: ?*?*AM_MEDIA_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Format: fn( self: *const ITFileTrack, pmt: ?*const AM_MEDIA_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ControllingTerminal: fn( self: *const ITFileTrack, ppControllingTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AudioFormatForScripting: fn( self: *const ITFileTrack, ppAudioFormat: ?*?*ITScriptableAudioFormat, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AudioFormatForScripting: fn( self: *const ITFileTrack, pAudioFormat: ?*ITScriptableAudioFormat, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EmptyAudioFormatForScripting: fn( self: *const ITFileTrack, ppAudioFormat: ?*?*ITScriptableAudioFormat, ) 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 ITFileTrack_get_Format(self: *const T, ppmt: ?*?*AM_MEDIA_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTrack.VTable, self.vtable).get_Format(@ptrCast(*const ITFileTrack, self), ppmt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTrack_put_Format(self: *const T, pmt: ?*const AM_MEDIA_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTrack.VTable, self.vtable).put_Format(@ptrCast(*const ITFileTrack, self), pmt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTrack_get_ControllingTerminal(self: *const T, ppControllingTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTrack.VTable, self.vtable).get_ControllingTerminal(@ptrCast(*const ITFileTrack, self), ppControllingTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTrack_get_AudioFormatForScripting(self: *const T, ppAudioFormat: ?*?*ITScriptableAudioFormat) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTrack.VTable, self.vtable).get_AudioFormatForScripting(@ptrCast(*const ITFileTrack, self), ppAudioFormat); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTrack_put_AudioFormatForScripting(self: *const T, pAudioFormat: ?*ITScriptableAudioFormat) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTrack.VTable, self.vtable).put_AudioFormatForScripting(@ptrCast(*const ITFileTrack, self), pAudioFormat); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTrack_get_EmptyAudioFormatForScripting(self: *const T, ppAudioFormat: ?*?*ITScriptableAudioFormat) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTrack.VTable, self.vtable).get_EmptyAudioFormatForScripting(@ptrCast(*const ITFileTrack, self), ppAudioFormat); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITMediaPlayback_Value = @import("../zig.zig").Guid.initString("627e8ae6-ae4c-4a69-bb63-2ad625404b77"); pub const IID_ITMediaPlayback = &IID_ITMediaPlayback_Value; pub const ITMediaPlayback = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PlayList: fn( self: *const ITMediaPlayback, PlayListVariant: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PlayList: fn( self: *const ITMediaPlayback, pPlayListVariant: ?*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 ITMediaPlayback_put_PlayList(self: *const T, PlayListVariant: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaPlayback.VTable, self.vtable).put_PlayList(@ptrCast(*const ITMediaPlayback, self), PlayListVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMediaPlayback_get_PlayList(self: *const T, pPlayListVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaPlayback.VTable, self.vtable).get_PlayList(@ptrCast(*const ITMediaPlayback, self), pPlayListVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITMediaRecord_Value = @import("../zig.zig").Guid.initString("f5dd4592-5476-4cc1-9d4d-fad3eefe7db2"); pub const IID_ITMediaRecord = &IID_ITMediaRecord_Value; pub const ITMediaRecord = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FileName: fn( self: *const ITMediaRecord, bstrFileName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FileName: fn( self: *const ITMediaRecord, pbstrFileName: ?*?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 ITMediaRecord_put_FileName(self: *const T, bstrFileName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaRecord.VTable, self.vtable).put_FileName(@ptrCast(*const ITMediaRecord, self), bstrFileName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMediaRecord_get_FileName(self: *const T, pbstrFileName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaRecord.VTable, self.vtable).get_FileName(@ptrCast(*const ITMediaRecord, self), pbstrFileName); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITMediaControl_Value = @import("../zig.zig").Guid.initString("c445dde8-5199-4bc7-9807-5ffb92e42e09"); pub const IID_ITMediaControl = &IID_ITMediaControl_Value; pub const ITMediaControl = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Start: fn( self: *const ITMediaControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Stop: fn( self: *const ITMediaControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Pause: fn( self: *const ITMediaControl, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MediaState: fn( self: *const ITMediaControl, pTerminalMediaState: ?*TERMINAL_MEDIA_STATE, ) 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 ITMediaControl_Start(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaControl.VTable, self.vtable).Start(@ptrCast(*const ITMediaControl, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMediaControl_Stop(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaControl.VTable, self.vtable).Stop(@ptrCast(*const ITMediaControl, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMediaControl_Pause(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaControl.VTable, self.vtable).Pause(@ptrCast(*const ITMediaControl, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMediaControl_get_MediaState(self: *const T, pTerminalMediaState: ?*TERMINAL_MEDIA_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITMediaControl.VTable, self.vtable).get_MediaState(@ptrCast(*const ITMediaControl, self), pTerminalMediaState); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITBasicAudioTerminal_Value = @import("../zig.zig").Guid.initString("b1efc38d-9355-11d0-835c-00aa003ccabd"); pub const IID_ITBasicAudioTerminal = &IID_ITBasicAudioTerminal_Value; pub const ITBasicAudioTerminal = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Volume: fn( self: *const ITBasicAudioTerminal, lVolume: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Volume: fn( self: *const ITBasicAudioTerminal, plVolume: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Balance: fn( self: *const ITBasicAudioTerminal, lBalance: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Balance: fn( self: *const ITBasicAudioTerminal, plBalance: ?*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 ITBasicAudioTerminal_put_Volume(self: *const T, lVolume: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicAudioTerminal.VTable, self.vtable).put_Volume(@ptrCast(*const ITBasicAudioTerminal, self), lVolume); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicAudioTerminal_get_Volume(self: *const T, plVolume: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicAudioTerminal.VTable, self.vtable).get_Volume(@ptrCast(*const ITBasicAudioTerminal, self), plVolume); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicAudioTerminal_put_Balance(self: *const T, lBalance: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicAudioTerminal.VTable, self.vtable).put_Balance(@ptrCast(*const ITBasicAudioTerminal, self), lBalance); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicAudioTerminal_get_Balance(self: *const T, plBalance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicAudioTerminal.VTable, self.vtable).get_Balance(@ptrCast(*const ITBasicAudioTerminal, self), plBalance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITStaticAudioTerminal_Value = @import("../zig.zig").Guid.initString("a86b7871-d14c-48e6-922e-a8d15f984800"); pub const IID_ITStaticAudioTerminal = &IID_ITStaticAudioTerminal_Value; pub const ITStaticAudioTerminal = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_WaveId: fn( self: *const ITStaticAudioTerminal, plWaveId: ?*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 ITStaticAudioTerminal_get_WaveId(self: *const T, plWaveId: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITStaticAudioTerminal.VTable, self.vtable).get_WaveId(@ptrCast(*const ITStaticAudioTerminal, self), plWaveId); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallHub_Value = @import("../zig.zig").Guid.initString("a3c1544e-5b92-11d1-8f4e-00c04fb6809f"); pub const IID_ITCallHub = &IID_ITCallHub_Value; pub const ITCallHub = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Clear: fn( self: *const ITCallHub, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateCalls: fn( self: *const ITCallHub, ppEnumCall: ?*?*IEnumCall, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Calls: fn( self: *const ITCallHub, pCalls: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NumCalls: fn( self: *const ITCallHub, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const ITCallHub, pState: ?*CALLHUB_STATE, ) 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 ITCallHub_Clear(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallHub.VTable, self.vtable).Clear(@ptrCast(*const ITCallHub, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallHub_EnumerateCalls(self: *const T, ppEnumCall: ?*?*IEnumCall) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallHub.VTable, self.vtable).EnumerateCalls(@ptrCast(*const ITCallHub, self), ppEnumCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallHub_get_Calls(self: *const T, pCalls: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallHub.VTable, self.vtable).get_Calls(@ptrCast(*const ITCallHub, self), pCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallHub_get_NumCalls(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallHub.VTable, self.vtable).get_NumCalls(@ptrCast(*const ITCallHub, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallHub_get_State(self: *const T, pState: ?*CALLHUB_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallHub.VTable, self.vtable).get_State(@ptrCast(*const ITCallHub, self), pState); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITLegacyAddressMediaControl_Value = @import("../zig.zig").Guid.initString("ab493640-4c0b-11d2-a046-00c04fb6809f"); pub const IID_ITLegacyAddressMediaControl = &IID_ITLegacyAddressMediaControl_Value; pub const ITLegacyAddressMediaControl = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetID: fn( self: *const ITLegacyAddressMediaControl, pDeviceClass: ?BSTR, pdwSize: ?*u32, ppDeviceID: [*]?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDevConfig: fn( self: *const ITLegacyAddressMediaControl, pDeviceClass: ?BSTR, pdwSize: ?*u32, ppDeviceConfig: [*]?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetDevConfig: fn( self: *const ITLegacyAddressMediaControl, pDeviceClass: ?BSTR, dwSize: u32, pDeviceConfig: [*:0]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 ITLegacyAddressMediaControl_GetID(self: *const T, pDeviceClass: ?BSTR, pdwSize: ?*u32, ppDeviceID: [*]?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyAddressMediaControl.VTable, self.vtable).GetID(@ptrCast(*const ITLegacyAddressMediaControl, self), pDeviceClass, pdwSize, ppDeviceID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyAddressMediaControl_GetDevConfig(self: *const T, pDeviceClass: ?BSTR, pdwSize: ?*u32, ppDeviceConfig: [*]?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyAddressMediaControl.VTable, self.vtable).GetDevConfig(@ptrCast(*const ITLegacyAddressMediaControl, self), pDeviceClass, pdwSize, ppDeviceConfig); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyAddressMediaControl_SetDevConfig(self: *const T, pDeviceClass: ?BSTR, dwSize: u32, pDeviceConfig: [*:0]u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyAddressMediaControl.VTable, self.vtable).SetDevConfig(@ptrCast(*const ITLegacyAddressMediaControl, self), pDeviceClass, dwSize, pDeviceConfig); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITPrivateEvent_Value = @import("../zig.zig").Guid.initString("0e269cd0-10d4-4121-9c22-9c85d625650d"); pub const IID_ITPrivateEvent = &IID_ITPrivateEvent_Value; pub const ITPrivateEvent = 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 ITPrivateEvent, ppAddress: ?*?*ITAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITPrivateEvent, ppCallInfo: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallHub: fn( self: *const ITPrivateEvent, ppCallHub: ?*?*ITCallHub, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EventCode: fn( self: *const ITPrivateEvent, plEventCode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EventInterface: fn( self: *const ITPrivateEvent, pEventInterface: ?*?*IDispatch, ) 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 ITPrivateEvent_get_Address(self: *const T, ppAddress: ?*?*ITAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITPrivateEvent.VTable, self.vtable).get_Address(@ptrCast(*const ITPrivateEvent, self), ppAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPrivateEvent_get_Call(self: *const T, ppCallInfo: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITPrivateEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITPrivateEvent, self), ppCallInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPrivateEvent_get_CallHub(self: *const T, ppCallHub: ?*?*ITCallHub) callconv(.Inline) HRESULT { return @ptrCast(*const ITPrivateEvent.VTable, self.vtable).get_CallHub(@ptrCast(*const ITPrivateEvent, self), ppCallHub); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPrivateEvent_get_EventCode(self: *const T, plEventCode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPrivateEvent.VTable, self.vtable).get_EventCode(@ptrCast(*const ITPrivateEvent, self), plEventCode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPrivateEvent_get_EventInterface(self: *const T, pEventInterface: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const ITPrivateEvent.VTable, self.vtable).get_EventInterface(@ptrCast(*const ITPrivateEvent, self), pEventInterface); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITLegacyAddressMediaControl2_Value = @import("../zig.zig").Guid.initString("b0ee512b-a531-409e-9dd9-4099fe86c738"); pub const IID_ITLegacyAddressMediaControl2 = &IID_ITLegacyAddressMediaControl2_Value; pub const ITLegacyAddressMediaControl2 = extern struct { pub const VTable = extern struct { base: ITLegacyAddressMediaControl.VTable, ConfigDialog: fn( self: *const ITLegacyAddressMediaControl2, hwndOwner: ?HWND, pDeviceClass: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ConfigDialogEdit: fn( self: *const ITLegacyAddressMediaControl2, hwndOwner: ?HWND, pDeviceClass: ?BSTR, dwSizeIn: u32, pDeviceConfigIn: [*:0]u8, pdwSizeOut: ?*u32, ppDeviceConfigOut: [*]?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITLegacyAddressMediaControl.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyAddressMediaControl2_ConfigDialog(self: *const T, hwndOwner: ?HWND, pDeviceClass: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyAddressMediaControl2.VTable, self.vtable).ConfigDialog(@ptrCast(*const ITLegacyAddressMediaControl2, self), hwndOwner, pDeviceClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyAddressMediaControl2_ConfigDialogEdit(self: *const T, hwndOwner: ?HWND, pDeviceClass: ?BSTR, dwSizeIn: u32, pDeviceConfigIn: [*:0]u8, pdwSizeOut: ?*u32, ppDeviceConfigOut: [*]?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyAddressMediaControl2.VTable, self.vtable).ConfigDialogEdit(@ptrCast(*const ITLegacyAddressMediaControl2, self), hwndOwner, pDeviceClass, dwSizeIn, pDeviceConfigIn, pdwSizeOut, ppDeviceConfigOut); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITLegacyCallMediaControl_Value = @import("../zig.zig").Guid.initString("d624582f-cc23-4436-b8a5-47c625c8045d"); pub const IID_ITLegacyCallMediaControl = &IID_ITLegacyCallMediaControl_Value; pub const ITLegacyCallMediaControl = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, DetectDigits: fn( self: *const ITLegacyCallMediaControl, DigitMode: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GenerateDigits: fn( self: *const ITLegacyCallMediaControl, pDigits: ?BSTR, DigitMode: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetID: fn( self: *const ITLegacyCallMediaControl, pDeviceClass: ?BSTR, pdwSize: ?*u32, ppDeviceID: [*]?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetMediaType: fn( self: *const ITLegacyCallMediaControl, lMediaType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, MonitorMedia: fn( self: *const ITLegacyCallMediaControl, lMediaType: 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 ITLegacyCallMediaControl_DetectDigits(self: *const T, DigitMode: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl.VTable, self.vtable).DetectDigits(@ptrCast(*const ITLegacyCallMediaControl, self), DigitMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl_GenerateDigits(self: *const T, pDigits: ?BSTR, DigitMode: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl.VTable, self.vtable).GenerateDigits(@ptrCast(*const ITLegacyCallMediaControl, self), pDigits, DigitMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl_GetID(self: *const T, pDeviceClass: ?BSTR, pdwSize: ?*u32, ppDeviceID: [*]?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl.VTable, self.vtable).GetID(@ptrCast(*const ITLegacyCallMediaControl, self), pDeviceClass, pdwSize, ppDeviceID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl_SetMediaType(self: *const T, lMediaType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl.VTable, self.vtable).SetMediaType(@ptrCast(*const ITLegacyCallMediaControl, self), lMediaType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl_MonitorMedia(self: *const T, lMediaType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl.VTable, self.vtable).MonitorMedia(@ptrCast(*const ITLegacyCallMediaControl, self), lMediaType); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITLegacyCallMediaControl2_Value = @import("../zig.zig").Guid.initString("57ca332d-7bc2-44f1-a60c-936fe8d7ce73"); pub const IID_ITLegacyCallMediaControl2 = &IID_ITLegacyCallMediaControl2_Value; pub const ITLegacyCallMediaControl2 = extern struct { pub const VTable = extern struct { base: ITLegacyCallMediaControl.VTable, GenerateDigits2: fn( self: *const ITLegacyCallMediaControl2, pDigits: ?BSTR, DigitMode: i32, lDuration: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GatherDigits: fn( self: *const ITLegacyCallMediaControl2, DigitMode: i32, lNumDigits: i32, pTerminationDigits: ?BSTR, lFirstDigitTimeout: i32, lInterDigitTimeout: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DetectTones: fn( self: *const ITLegacyCallMediaControl2, pToneList: ?*TAPI_DETECTTONE, lNumTones: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DetectTonesByCollection: fn( self: *const ITLegacyCallMediaControl2, pDetectToneCollection: ?*ITCollection2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GenerateTone: fn( self: *const ITLegacyCallMediaControl2, ToneMode: TAPI_TONEMODE, lDuration: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GenerateCustomTones: fn( self: *const ITLegacyCallMediaControl2, pToneList: ?*TAPI_CUSTOMTONE, lNumTones: i32, lDuration: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GenerateCustomTonesByCollection: fn( self: *const ITLegacyCallMediaControl2, pCustomToneCollection: ?*ITCollection2, lDuration: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateDetectToneObject: fn( self: *const ITLegacyCallMediaControl2, ppDetectTone: ?*?*ITDetectTone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateCustomToneObject: fn( self: *const ITLegacyCallMediaControl2, ppCustomTone: ?*?*ITCustomTone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetIDAsVariant: fn( self: *const ITLegacyCallMediaControl2, bstrDeviceClass: ?BSTR, pVarDeviceID: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITLegacyCallMediaControl.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_GenerateDigits2(self: *const T, pDigits: ?BSTR, DigitMode: i32, lDuration: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).GenerateDigits2(@ptrCast(*const ITLegacyCallMediaControl2, self), pDigits, DigitMode, lDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_GatherDigits(self: *const T, DigitMode: i32, lNumDigits: i32, pTerminationDigits: ?BSTR, lFirstDigitTimeout: i32, lInterDigitTimeout: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).GatherDigits(@ptrCast(*const ITLegacyCallMediaControl2, self), DigitMode, lNumDigits, pTerminationDigits, lFirstDigitTimeout, lInterDigitTimeout); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_DetectTones(self: *const T, pToneList: ?*TAPI_DETECTTONE, lNumTones: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).DetectTones(@ptrCast(*const ITLegacyCallMediaControl2, self), pToneList, lNumTones); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_DetectTonesByCollection(self: *const T, pDetectToneCollection: ?*ITCollection2) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).DetectTonesByCollection(@ptrCast(*const ITLegacyCallMediaControl2, self), pDetectToneCollection); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_GenerateTone(self: *const T, ToneMode: TAPI_TONEMODE, lDuration: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).GenerateTone(@ptrCast(*const ITLegacyCallMediaControl2, self), ToneMode, lDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_GenerateCustomTones(self: *const T, pToneList: ?*TAPI_CUSTOMTONE, lNumTones: i32, lDuration: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).GenerateCustomTones(@ptrCast(*const ITLegacyCallMediaControl2, self), pToneList, lNumTones, lDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_GenerateCustomTonesByCollection(self: *const T, pCustomToneCollection: ?*ITCollection2, lDuration: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).GenerateCustomTonesByCollection(@ptrCast(*const ITLegacyCallMediaControl2, self), pCustomToneCollection, lDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_CreateDetectToneObject(self: *const T, ppDetectTone: ?*?*ITDetectTone) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).CreateDetectToneObject(@ptrCast(*const ITLegacyCallMediaControl2, self), ppDetectTone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_CreateCustomToneObject(self: *const T, ppCustomTone: ?*?*ITCustomTone) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).CreateCustomToneObject(@ptrCast(*const ITLegacyCallMediaControl2, self), ppCustomTone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLegacyCallMediaControl2_GetIDAsVariant(self: *const T, bstrDeviceClass: ?BSTR, pVarDeviceID: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyCallMediaControl2.VTable, self.vtable).GetIDAsVariant(@ptrCast(*const ITLegacyCallMediaControl2, self), bstrDeviceClass, pVarDeviceID); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITDetectTone_Value = @import("../zig.zig").Guid.initString("961f79bd-3097-49df-a1d6-909b77e89ca0"); pub const IID_ITDetectTone = &IID_ITDetectTone_Value; pub const ITDetectTone = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AppSpecific: fn( self: *const ITDetectTone, plAppSpecific: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AppSpecific: fn( self: *const ITDetectTone, lAppSpecific: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Duration: fn( self: *const ITDetectTone, plDuration: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Duration: fn( self: *const ITDetectTone, lDuration: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Frequency: fn( self: *const ITDetectTone, Index: i32, plFrequency: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Frequency: fn( self: *const ITDetectTone, Index: i32, lFrequency: 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 ITDetectTone_get_AppSpecific(self: *const T, plAppSpecific: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDetectTone.VTable, self.vtable).get_AppSpecific(@ptrCast(*const ITDetectTone, self), plAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDetectTone_put_AppSpecific(self: *const T, lAppSpecific: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDetectTone.VTable, self.vtable).put_AppSpecific(@ptrCast(*const ITDetectTone, self), lAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDetectTone_get_Duration(self: *const T, plDuration: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDetectTone.VTable, self.vtable).get_Duration(@ptrCast(*const ITDetectTone, self), plDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDetectTone_put_Duration(self: *const T, lDuration: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDetectTone.VTable, self.vtable).put_Duration(@ptrCast(*const ITDetectTone, self), lDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDetectTone_get_Frequency(self: *const T, Index: i32, plFrequency: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDetectTone.VTable, self.vtable).get_Frequency(@ptrCast(*const ITDetectTone, self), Index, plFrequency); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDetectTone_put_Frequency(self: *const T, Index: i32, lFrequency: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDetectTone.VTable, self.vtable).put_Frequency(@ptrCast(*const ITDetectTone, self), Index, lFrequency); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCustomTone_Value = @import("../zig.zig").Guid.initString("357ad764-b3c6-4b2a-8fa5-0722827a9254"); pub const IID_ITCustomTone = &IID_ITCustomTone_Value; pub const ITCustomTone = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Frequency: fn( self: *const ITCustomTone, plFrequency: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Frequency: fn( self: *const ITCustomTone, lFrequency: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CadenceOn: fn( self: *const ITCustomTone, plCadenceOn: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CadenceOn: fn( self: *const ITCustomTone, CadenceOn: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CadenceOff: fn( self: *const ITCustomTone, plCadenceOff: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CadenceOff: fn( self: *const ITCustomTone, lCadenceOff: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Volume: fn( self: *const ITCustomTone, plVolume: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Volume: fn( self: *const ITCustomTone, lVolume: 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 ITCustomTone_get_Frequency(self: *const T, plFrequency: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCustomTone.VTable, self.vtable).get_Frequency(@ptrCast(*const ITCustomTone, self), plFrequency); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCustomTone_put_Frequency(self: *const T, lFrequency: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCustomTone.VTable, self.vtable).put_Frequency(@ptrCast(*const ITCustomTone, self), lFrequency); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCustomTone_get_CadenceOn(self: *const T, plCadenceOn: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCustomTone.VTable, self.vtable).get_CadenceOn(@ptrCast(*const ITCustomTone, self), plCadenceOn); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCustomTone_put_CadenceOn(self: *const T, CadenceOn: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCustomTone.VTable, self.vtable).put_CadenceOn(@ptrCast(*const ITCustomTone, self), CadenceOn); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCustomTone_get_CadenceOff(self: *const T, plCadenceOff: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCustomTone.VTable, self.vtable).get_CadenceOff(@ptrCast(*const ITCustomTone, self), plCadenceOff); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCustomTone_put_CadenceOff(self: *const T, lCadenceOff: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCustomTone.VTable, self.vtable).put_CadenceOff(@ptrCast(*const ITCustomTone, self), lCadenceOff); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCustomTone_get_Volume(self: *const T, plVolume: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCustomTone.VTable, self.vtable).get_Volume(@ptrCast(*const ITCustomTone, self), plVolume); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCustomTone_put_Volume(self: *const T, lVolume: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCustomTone.VTable, self.vtable).put_Volume(@ptrCast(*const ITCustomTone, self), lVolume); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumPhone_Value = @import("../zig.zig").Guid.initString("f15b7669-4780-4595-8c89-fb369c8cf7aa"); pub const IID_IEnumPhone = &IID_IEnumPhone_Value; pub const IEnumPhone = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumPhone, celt: u32, ppElements: [*]?*ITPhone, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumPhone, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumPhone, ppEnum: ?*?*IEnumPhone, ) 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 IEnumPhone_Next(self: *const T, celt: u32, ppElements: [*]?*ITPhone, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPhone.VTable, self.vtable).Next(@ptrCast(*const IEnumPhone, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPhone_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPhone.VTable, self.vtable).Reset(@ptrCast(*const IEnumPhone, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPhone_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPhone.VTable, self.vtable).Skip(@ptrCast(*const IEnumPhone, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPhone_Clone(self: *const T, ppEnum: ?*?*IEnumPhone) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPhone.VTable, self.vtable).Clone(@ptrCast(*const IEnumPhone, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumTerminal_Value = @import("../zig.zig").Guid.initString("ae269cf4-935e-11d0-835c-00aa003ccabd"); pub const IID_IEnumTerminal = &IID_IEnumTerminal_Value; pub const IEnumTerminal = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumTerminal, celt: u32, ppElements: ?*?*ITTerminal, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumTerminal, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumTerminal, ppEnum: ?*?*IEnumTerminal, ) 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 IEnumTerminal_Next(self: *const T, celt: u32, ppElements: ?*?*ITTerminal, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumTerminal.VTable, self.vtable).Next(@ptrCast(*const IEnumTerminal, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumTerminal_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumTerminal.VTable, self.vtable).Reset(@ptrCast(*const IEnumTerminal, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumTerminal_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumTerminal.VTable, self.vtable).Skip(@ptrCast(*const IEnumTerminal, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumTerminal_Clone(self: *const T, ppEnum: ?*?*IEnumTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumTerminal.VTable, self.vtable).Clone(@ptrCast(*const IEnumTerminal, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumTerminalClass_Value = @import("../zig.zig").Guid.initString("ae269cf5-935e-11d0-835c-00aa003ccabd"); pub const IID_IEnumTerminalClass = &IID_IEnumTerminalClass_Value; pub const IEnumTerminalClass = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumTerminalClass, celt: u32, pElements: [*]Guid, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumTerminalClass, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumTerminalClass, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumTerminalClass, ppEnum: ?*?*IEnumTerminalClass, ) 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 IEnumTerminalClass_Next(self: *const T, celt: u32, pElements: [*]Guid, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumTerminalClass.VTable, self.vtable).Next(@ptrCast(*const IEnumTerminalClass, self), celt, pElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumTerminalClass_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumTerminalClass.VTable, self.vtable).Reset(@ptrCast(*const IEnumTerminalClass, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumTerminalClass_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumTerminalClass.VTable, self.vtable).Skip(@ptrCast(*const IEnumTerminalClass, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumTerminalClass_Clone(self: *const T, ppEnum: ?*?*IEnumTerminalClass) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumTerminalClass.VTable, self.vtable).Clone(@ptrCast(*const IEnumTerminalClass, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumCall_Value = @import("../zig.zig").Guid.initString("ae269cf6-935e-11d0-835c-00aa003ccabd"); pub const IID_IEnumCall = &IID_IEnumCall_Value; pub const IEnumCall = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumCall, celt: u32, ppElements: ?*?*ITCallInfo, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumCall, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumCall, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumCall, ppEnum: ?*?*IEnumCall, ) 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 IEnumCall_Next(self: *const T, celt: u32, ppElements: ?*?*ITCallInfo, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCall.VTable, self.vtable).Next(@ptrCast(*const IEnumCall, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCall_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCall.VTable, self.vtable).Reset(@ptrCast(*const IEnumCall, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCall_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCall.VTable, self.vtable).Skip(@ptrCast(*const IEnumCall, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCall_Clone(self: *const T, ppEnum: ?*?*IEnumCall) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCall.VTable, self.vtable).Clone(@ptrCast(*const IEnumCall, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumAddress_Value = @import("../zig.zig").Guid.initString("1666fca1-9363-11d0-835c-00aa003ccabd"); pub const IID_IEnumAddress = &IID_IEnumAddress_Value; pub const IEnumAddress = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumAddress, celt: u32, ppElements: [*]?*ITAddress, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumAddress, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumAddress, ppEnum: ?*?*IEnumAddress, ) 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 IEnumAddress_Next(self: *const T, celt: u32, ppElements: [*]?*ITAddress, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAddress.VTable, self.vtable).Next(@ptrCast(*const IEnumAddress, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAddress_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAddress.VTable, self.vtable).Reset(@ptrCast(*const IEnumAddress, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAddress_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAddress.VTable, self.vtable).Skip(@ptrCast(*const IEnumAddress, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAddress_Clone(self: *const T, ppEnum: ?*?*IEnumAddress) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAddress.VTable, self.vtable).Clone(@ptrCast(*const IEnumAddress, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumCallHub_Value = @import("../zig.zig").Guid.initString("a3c15450-5b92-11d1-8f4e-00c04fb6809f"); pub const IID_IEnumCallHub = &IID_IEnumCallHub_Value; pub const IEnumCallHub = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumCallHub, celt: u32, ppElements: [*]?*ITCallHub, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumCallHub, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumCallHub, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumCallHub, ppEnum: ?*?*IEnumCallHub, ) 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 IEnumCallHub_Next(self: *const T, celt: u32, ppElements: [*]?*ITCallHub, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCallHub.VTable, self.vtable).Next(@ptrCast(*const IEnumCallHub, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCallHub_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCallHub.VTable, self.vtable).Reset(@ptrCast(*const IEnumCallHub, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCallHub_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCallHub.VTable, self.vtable).Skip(@ptrCast(*const IEnumCallHub, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCallHub_Clone(self: *const T, ppEnum: ?*?*IEnumCallHub) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCallHub.VTable, self.vtable).Clone(@ptrCast(*const IEnumCallHub, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumBstr_Value = @import("../zig.zig").Guid.initString("35372049-0bc6-11d2-a033-00c04fb6809f"); pub const IID_IEnumBstr = &IID_IEnumBstr_Value; pub const IEnumBstr = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumBstr, celt: u32, ppStrings: [*]?BSTR, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumBstr, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumBstr, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumBstr, ppEnum: ?*?*IEnumBstr, ) 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 IEnumBstr_Next(self: *const T, celt: u32, ppStrings: [*]?BSTR, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumBstr.VTable, self.vtable).Next(@ptrCast(*const IEnumBstr, self), celt, ppStrings, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumBstr_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumBstr.VTable, self.vtable).Reset(@ptrCast(*const IEnumBstr, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumBstr_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumBstr.VTable, self.vtable).Skip(@ptrCast(*const IEnumBstr, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumBstr_Clone(self: *const T, ppEnum: ?*?*IEnumBstr) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumBstr.VTable, self.vtable).Clone(@ptrCast(*const IEnumBstr, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumPluggableTerminalClassInfo_Value = @import("../zig.zig").Guid.initString("4567450c-dbee-4e3f-aaf5-37bf9ebf5e29"); pub const IID_IEnumPluggableTerminalClassInfo = &IID_IEnumPluggableTerminalClassInfo_Value; pub const IEnumPluggableTerminalClassInfo = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumPluggableTerminalClassInfo, celt: u32, ppElements: [*]?*ITPluggableTerminalClassInfo, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumPluggableTerminalClassInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumPluggableTerminalClassInfo, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumPluggableTerminalClassInfo, ppEnum: ?*?*IEnumPluggableTerminalClassInfo, ) 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 IEnumPluggableTerminalClassInfo_Next(self: *const T, celt: u32, ppElements: [*]?*ITPluggableTerminalClassInfo, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPluggableTerminalClassInfo.VTable, self.vtable).Next(@ptrCast(*const IEnumPluggableTerminalClassInfo, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPluggableTerminalClassInfo_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPluggableTerminalClassInfo.VTable, self.vtable).Reset(@ptrCast(*const IEnumPluggableTerminalClassInfo, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPluggableTerminalClassInfo_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPluggableTerminalClassInfo.VTable, self.vtable).Skip(@ptrCast(*const IEnumPluggableTerminalClassInfo, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPluggableTerminalClassInfo_Clone(self: *const T, ppEnum: ?*?*IEnumPluggableTerminalClassInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPluggableTerminalClassInfo.VTable, self.vtable).Clone(@ptrCast(*const IEnumPluggableTerminalClassInfo, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumPluggableSuperclassInfo_Value = @import("../zig.zig").Guid.initString("e9586a80-89e6-4cff-931d-478d5751f4c0"); pub const IID_IEnumPluggableSuperclassInfo = &IID_IEnumPluggableSuperclassInfo_Value; pub const IEnumPluggableSuperclassInfo = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumPluggableSuperclassInfo, celt: u32, ppElements: [*]?*ITPluggableTerminalSuperclassInfo, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumPluggableSuperclassInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumPluggableSuperclassInfo, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumPluggableSuperclassInfo, ppEnum: ?*?*IEnumPluggableSuperclassInfo, ) 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 IEnumPluggableSuperclassInfo_Next(self: *const T, celt: u32, ppElements: [*]?*ITPluggableTerminalSuperclassInfo, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPluggableSuperclassInfo.VTable, self.vtable).Next(@ptrCast(*const IEnumPluggableSuperclassInfo, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPluggableSuperclassInfo_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPluggableSuperclassInfo.VTable, self.vtable).Reset(@ptrCast(*const IEnumPluggableSuperclassInfo, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPluggableSuperclassInfo_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPluggableSuperclassInfo.VTable, self.vtable).Skip(@ptrCast(*const IEnumPluggableSuperclassInfo, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumPluggableSuperclassInfo_Clone(self: *const T, ppEnum: ?*?*IEnumPluggableSuperclassInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumPluggableSuperclassInfo.VTable, self.vtable).Clone(@ptrCast(*const IEnumPluggableSuperclassInfo, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITPhoneEvent_Value = @import("../zig.zig").Guid.initString("8f942dd8-64ed-4aaf-a77d-b23db0837ead"); pub const IID_ITPhoneEvent = &IID_ITPhoneEvent_Value; pub const ITPhoneEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Phone: fn( self: *const ITPhoneEvent, ppPhone: ?*?*ITPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITPhoneEvent, pEvent: ?*PHONE_EVENT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ButtonState: fn( self: *const ITPhoneEvent, pState: ?*PHONE_BUTTON_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HookSwitchState: fn( self: *const ITPhoneEvent, pState: ?*PHONE_HOOK_SWITCH_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HookSwitchDevice: fn( self: *const ITPhoneEvent, pDevice: ?*PHONE_HOOK_SWITCH_DEVICE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RingMode: fn( self: *const ITPhoneEvent, plRingMode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ButtonLampId: fn( self: *const ITPhoneEvent, plButtonLampId: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NumberGathered: fn( self: *const ITPhoneEvent, ppNumber: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITPhoneEvent, ppCallInfo: ?*?*ITCallInfo, ) 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 ITPhoneEvent_get_Phone(self: *const T, ppPhone: ?*?*ITPhone) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_Phone(@ptrCast(*const ITPhoneEvent, self), ppPhone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneEvent_get_Event(self: *const T, pEvent: ?*PHONE_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITPhoneEvent, self), pEvent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneEvent_get_ButtonState(self: *const T, pState: ?*PHONE_BUTTON_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_ButtonState(@ptrCast(*const ITPhoneEvent, self), pState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneEvent_get_HookSwitchState(self: *const T, pState: ?*PHONE_HOOK_SWITCH_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_HookSwitchState(@ptrCast(*const ITPhoneEvent, self), pState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneEvent_get_HookSwitchDevice(self: *const T, pDevice: ?*PHONE_HOOK_SWITCH_DEVICE) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_HookSwitchDevice(@ptrCast(*const ITPhoneEvent, self), pDevice); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneEvent_get_RingMode(self: *const T, plRingMode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_RingMode(@ptrCast(*const ITPhoneEvent, self), plRingMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneEvent_get_ButtonLampId(self: *const T, plButtonLampId: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_ButtonLampId(@ptrCast(*const ITPhoneEvent, self), plButtonLampId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneEvent_get_NumberGathered(self: *const T, ppNumber: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_NumberGathered(@ptrCast(*const ITPhoneEvent, self), ppNumber); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneEvent_get_Call(self: *const T, ppCallInfo: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITPhoneEvent, self), ppCallInfo); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallStateEvent_Value = @import("../zig.zig").Guid.initString("62f47097-95c9-11d0-835d-00aa003ccabd"); pub const IID_ITCallStateEvent = &IID_ITCallStateEvent_Value; pub const ITCallStateEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITCallStateEvent, ppCallInfo: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const ITCallStateEvent, pCallState: ?*CALL_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Cause: fn( self: *const ITCallStateEvent, pCEC: ?*CALL_STATE_EVENT_CAUSE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallbackInstance: fn( self: *const ITCallStateEvent, plCallbackInstance: ?*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 ITCallStateEvent_get_Call(self: *const T, ppCallInfo: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallStateEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITCallStateEvent, self), ppCallInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallStateEvent_get_State(self: *const T, pCallState: ?*CALL_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallStateEvent.VTable, self.vtable).get_State(@ptrCast(*const ITCallStateEvent, self), pCallState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallStateEvent_get_Cause(self: *const T, pCEC: ?*CALL_STATE_EVENT_CAUSE) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallStateEvent.VTable, self.vtable).get_Cause(@ptrCast(*const ITCallStateEvent, self), pCEC); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallStateEvent_get_CallbackInstance(self: *const T, plCallbackInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallStateEvent.VTable, self.vtable).get_CallbackInstance(@ptrCast(*const ITCallStateEvent, self), plCallbackInstance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITPhoneDeviceSpecificEvent_Value = @import("../zig.zig").Guid.initString("63ffb2a6-872b-4cd3-a501-326e8fb40af7"); pub const IID_ITPhoneDeviceSpecificEvent = &IID_ITPhoneDeviceSpecificEvent_Value; pub const ITPhoneDeviceSpecificEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Phone: fn( self: *const ITPhoneDeviceSpecificEvent, ppPhone: ?*?*ITPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_lParam1: fn( self: *const ITPhoneDeviceSpecificEvent, pParam1: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_lParam2: fn( self: *const ITPhoneDeviceSpecificEvent, pParam2: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_lParam3: fn( self: *const ITPhoneDeviceSpecificEvent, pParam3: ?*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 ITPhoneDeviceSpecificEvent_get_Phone(self: *const T, ppPhone: ?*?*ITPhone) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneDeviceSpecificEvent.VTable, self.vtable).get_Phone(@ptrCast(*const ITPhoneDeviceSpecificEvent, self), ppPhone); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneDeviceSpecificEvent_get_lParam1(self: *const T, pParam1: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneDeviceSpecificEvent.VTable, self.vtable).get_lParam1(@ptrCast(*const ITPhoneDeviceSpecificEvent, self), pParam1); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneDeviceSpecificEvent_get_lParam2(self: *const T, pParam2: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneDeviceSpecificEvent.VTable, self.vtable).get_lParam2(@ptrCast(*const ITPhoneDeviceSpecificEvent, self), pParam2); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPhoneDeviceSpecificEvent_get_lParam3(self: *const T, pParam3: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITPhoneDeviceSpecificEvent.VTable, self.vtable).get_lParam3(@ptrCast(*const ITPhoneDeviceSpecificEvent, self), pParam3); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallMediaEvent_Value = @import("../zig.zig").Guid.initString("ff36b87f-ec3a-11d0-8ee4-00c04fb6809f"); pub const IID_ITCallMediaEvent = &IID_ITCallMediaEvent_Value; pub const ITCallMediaEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITCallMediaEvent, ppCallInfo: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITCallMediaEvent, pCallMediaEvent: ?*CALL_MEDIA_EVENT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Error: fn( self: *const ITCallMediaEvent, phrError: ?*HRESULT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminal: fn( self: *const ITCallMediaEvent, ppTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Stream: fn( self: *const ITCallMediaEvent, ppStream: ?*?*ITStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Cause: fn( self: *const ITCallMediaEvent, pCause: ?*CALL_MEDIA_EVENT_CAUSE, ) 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 ITCallMediaEvent_get_Call(self: *const T, ppCallInfo: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallMediaEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITCallMediaEvent, self), ppCallInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallMediaEvent_get_Event(self: *const T, pCallMediaEvent: ?*CALL_MEDIA_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallMediaEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITCallMediaEvent, self), pCallMediaEvent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallMediaEvent_get_Error(self: *const T, phrError: ?*HRESULT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallMediaEvent.VTable, self.vtable).get_Error(@ptrCast(*const ITCallMediaEvent, self), phrError); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallMediaEvent_get_Terminal(self: *const T, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallMediaEvent.VTable, self.vtable).get_Terminal(@ptrCast(*const ITCallMediaEvent, self), ppTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallMediaEvent_get_Stream(self: *const T, ppStream: ?*?*ITStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallMediaEvent.VTable, self.vtable).get_Stream(@ptrCast(*const ITCallMediaEvent, self), ppStream); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallMediaEvent_get_Cause(self: *const T, pCause: ?*CALL_MEDIA_EVENT_CAUSE) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallMediaEvent.VTable, self.vtable).get_Cause(@ptrCast(*const ITCallMediaEvent, self), pCause); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITDigitDetectionEvent_Value = @import("../zig.zig").Guid.initString("80d3bfac-57d9-11d2-a04a-00c04fb6809f"); pub const IID_ITDigitDetectionEvent = &IID_ITDigitDetectionEvent_Value; pub const ITDigitDetectionEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITDigitDetectionEvent, ppCallInfo: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Digit: fn( self: *const ITDigitDetectionEvent, pucDigit: ?*u8, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DigitMode: fn( self: *const ITDigitDetectionEvent, pDigitMode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TickCount: fn( self: *const ITDigitDetectionEvent, plTickCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallbackInstance: fn( self: *const ITDigitDetectionEvent, plCallbackInstance: ?*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 ITDigitDetectionEvent_get_Call(self: *const T, ppCallInfo: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitDetectionEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITDigitDetectionEvent, self), ppCallInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitDetectionEvent_get_Digit(self: *const T, pucDigit: ?*u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitDetectionEvent.VTable, self.vtable).get_Digit(@ptrCast(*const ITDigitDetectionEvent, self), pucDigit); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitDetectionEvent_get_DigitMode(self: *const T, pDigitMode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitDetectionEvent.VTable, self.vtable).get_DigitMode(@ptrCast(*const ITDigitDetectionEvent, self), pDigitMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitDetectionEvent_get_TickCount(self: *const T, plTickCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitDetectionEvent.VTable, self.vtable).get_TickCount(@ptrCast(*const ITDigitDetectionEvent, self), plTickCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitDetectionEvent_get_CallbackInstance(self: *const T, plCallbackInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitDetectionEvent.VTable, self.vtable).get_CallbackInstance(@ptrCast(*const ITDigitDetectionEvent, self), plCallbackInstance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITDigitGenerationEvent_Value = @import("../zig.zig").Guid.initString("80d3bfad-57d9-11d2-a04a-00c04fb6809f"); pub const IID_ITDigitGenerationEvent = &IID_ITDigitGenerationEvent_Value; pub const ITDigitGenerationEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITDigitGenerationEvent, ppCallInfo: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_GenerationTermination: fn( self: *const ITDigitGenerationEvent, plGenerationTermination: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TickCount: fn( self: *const ITDigitGenerationEvent, plTickCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallbackInstance: fn( self: *const ITDigitGenerationEvent, plCallbackInstance: ?*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 ITDigitGenerationEvent_get_Call(self: *const T, ppCallInfo: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitGenerationEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITDigitGenerationEvent, self), ppCallInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitGenerationEvent_get_GenerationTermination(self: *const T, plGenerationTermination: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitGenerationEvent.VTable, self.vtable).get_GenerationTermination(@ptrCast(*const ITDigitGenerationEvent, self), plGenerationTermination); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitGenerationEvent_get_TickCount(self: *const T, plTickCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitGenerationEvent.VTable, self.vtable).get_TickCount(@ptrCast(*const ITDigitGenerationEvent, self), plTickCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitGenerationEvent_get_CallbackInstance(self: *const T, plCallbackInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitGenerationEvent.VTable, self.vtable).get_CallbackInstance(@ptrCast(*const ITDigitGenerationEvent, self), plCallbackInstance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITDigitsGatheredEvent_Value = @import("../zig.zig").Guid.initString("e52ec4c1-cba3-441a-9e6a-93cb909e9724"); pub const IID_ITDigitsGatheredEvent = &IID_ITDigitsGatheredEvent_Value; pub const ITDigitsGatheredEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITDigitsGatheredEvent, ppCallInfo: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Digits: fn( self: *const ITDigitsGatheredEvent, ppDigits: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_GatherTermination: fn( self: *const ITDigitsGatheredEvent, pGatherTermination: ?*TAPI_GATHERTERM, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TickCount: fn( self: *const ITDigitsGatheredEvent, plTickCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallbackInstance: fn( self: *const ITDigitsGatheredEvent, plCallbackInstance: ?*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 ITDigitsGatheredEvent_get_Call(self: *const T, ppCallInfo: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitsGatheredEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITDigitsGatheredEvent, self), ppCallInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitsGatheredEvent_get_Digits(self: *const T, ppDigits: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitsGatheredEvent.VTable, self.vtable).get_Digits(@ptrCast(*const ITDigitsGatheredEvent, self), ppDigits); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitsGatheredEvent_get_GatherTermination(self: *const T, pGatherTermination: ?*TAPI_GATHERTERM) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitsGatheredEvent.VTable, self.vtable).get_GatherTermination(@ptrCast(*const ITDigitsGatheredEvent, self), pGatherTermination); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitsGatheredEvent_get_TickCount(self: *const T, plTickCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitsGatheredEvent.VTable, self.vtable).get_TickCount(@ptrCast(*const ITDigitsGatheredEvent, self), plTickCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDigitsGatheredEvent_get_CallbackInstance(self: *const T, plCallbackInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDigitsGatheredEvent.VTable, self.vtable).get_CallbackInstance(@ptrCast(*const ITDigitsGatheredEvent, self), plCallbackInstance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITToneDetectionEvent_Value = @import("../zig.zig").Guid.initString("407e0faf-d047-4753-b0c6-8e060373fecd"); pub const IID_ITToneDetectionEvent = &IID_ITToneDetectionEvent_Value; pub const ITToneDetectionEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITToneDetectionEvent, ppCallInfo: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AppSpecific: fn( self: *const ITToneDetectionEvent, plAppSpecific: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TickCount: fn( self: *const ITToneDetectionEvent, plTickCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallbackInstance: fn( self: *const ITToneDetectionEvent, plCallbackInstance: ?*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 ITToneDetectionEvent_get_Call(self: *const T, ppCallInfo: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITToneDetectionEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITToneDetectionEvent, self), ppCallInfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITToneDetectionEvent_get_AppSpecific(self: *const T, plAppSpecific: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITToneDetectionEvent.VTable, self.vtable).get_AppSpecific(@ptrCast(*const ITToneDetectionEvent, self), plAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITToneDetectionEvent_get_TickCount(self: *const T, plTickCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITToneDetectionEvent.VTable, self.vtable).get_TickCount(@ptrCast(*const ITToneDetectionEvent, self), plTickCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITToneDetectionEvent_get_CallbackInstance(self: *const T, plCallbackInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITToneDetectionEvent.VTable, self.vtable).get_CallbackInstance(@ptrCast(*const ITToneDetectionEvent, self), plCallbackInstance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTAPIObjectEvent_Value = @import("../zig.zig").Guid.initString("f4854d48-937a-11d1-bb58-00c04fb6809f"); pub const IID_ITTAPIObjectEvent = &IID_ITTAPIObjectEvent_Value; pub const ITTAPIObjectEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TAPIObject: fn( self: *const ITTAPIObjectEvent, ppTAPIObject: ?*?*ITTAPI, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITTAPIObjectEvent, pEvent: ?*TAPIOBJECT_EVENT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Address: fn( self: *const ITTAPIObjectEvent, ppAddress: ?*?*ITAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallbackInstance: fn( self: *const ITTAPIObjectEvent, plCallbackInstance: ?*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 ITTAPIObjectEvent_get_TAPIObject(self: *const T, ppTAPIObject: ?*?*ITTAPI) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPIObjectEvent.VTable, self.vtable).get_TAPIObject(@ptrCast(*const ITTAPIObjectEvent, self), ppTAPIObject); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPIObjectEvent_get_Event(self: *const T, pEvent: ?*TAPIOBJECT_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPIObjectEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITTAPIObjectEvent, self), pEvent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPIObjectEvent_get_Address(self: *const T, ppAddress: ?*?*ITAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPIObjectEvent.VTable, self.vtable).get_Address(@ptrCast(*const ITTAPIObjectEvent, self), ppAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPIObjectEvent_get_CallbackInstance(self: *const T, plCallbackInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPIObjectEvent.VTable, self.vtable).get_CallbackInstance(@ptrCast(*const ITTAPIObjectEvent, self), plCallbackInstance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTAPIObjectEvent2_Value = @import("../zig.zig").Guid.initString("359dda6e-68ce-4383-bf0b-169133c41b46"); pub const IID_ITTAPIObjectEvent2 = &IID_ITTAPIObjectEvent2_Value; pub const ITTAPIObjectEvent2 = extern struct { pub const VTable = extern struct { base: ITTAPIObjectEvent.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Phone: fn( self: *const ITTAPIObjectEvent2, ppPhone: ?*?*ITPhone, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITTAPIObjectEvent.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPIObjectEvent2_get_Phone(self: *const T, ppPhone: ?*?*ITPhone) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPIObjectEvent2.VTable, self.vtable).get_Phone(@ptrCast(*const ITTAPIObjectEvent2, self), ppPhone); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTAPIEventNotification_Value = @import("../zig.zig").Guid.initString("eddb9426-3b91-11d1-8f30-00c04fb6809f"); pub const IID_ITTAPIEventNotification = &IID_ITTAPIEventNotification_Value; pub const ITTAPIEventNotification = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Event: fn( self: *const ITTAPIEventNotification, TapiEvent: TAPI_EVENT, pEvent: ?*IDispatch, ) 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 ITTAPIEventNotification_Event(self: *const T, TapiEvent: TAPI_EVENT, pEvent: ?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPIEventNotification.VTable, self.vtable).Event(@ptrCast(*const ITTAPIEventNotification, self), TapiEvent, pEvent); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallHubEvent_Value = @import("../zig.zig").Guid.initString("a3c15451-5b92-11d1-8f4e-00c04fb6809f"); pub const IID_ITCallHubEvent = &IID_ITCallHubEvent_Value; pub const ITCallHubEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITCallHubEvent, pEvent: ?*CALLHUB_EVENT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallHub: fn( self: *const ITCallHubEvent, ppCallHub: ?*?*ITCallHub, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITCallHubEvent, ppCall: ?*?*ITCallInfo, ) 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 ITCallHubEvent_get_Event(self: *const T, pEvent: ?*CALLHUB_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallHubEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITCallHubEvent, self), pEvent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallHubEvent_get_CallHub(self: *const T, ppCallHub: ?*?*ITCallHub) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallHubEvent.VTable, self.vtable).get_CallHub(@ptrCast(*const ITCallHubEvent, self), ppCallHub); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallHubEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallHubEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITCallHubEvent, self), ppCall); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAddressEvent_Value = @import("../zig.zig").Guid.initString("831ce2d1-83b5-11d1-bb5c-00c04fb6809f"); pub const IID_ITAddressEvent = &IID_ITAddressEvent_Value; pub const ITAddressEvent = 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 ITAddressEvent, ppAddress: ?*?*ITAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITAddressEvent, pEvent: ?*ADDRESS_EVENT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminal: fn( self: *const ITAddressEvent, ppTerminal: ?*?*ITTerminal, ) 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 ITAddressEvent_get_Address(self: *const T, ppAddress: ?*?*ITAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressEvent.VTable, self.vtable).get_Address(@ptrCast(*const ITAddressEvent, self), ppAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressEvent_get_Event(self: *const T, pEvent: ?*ADDRESS_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITAddressEvent, self), pEvent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressEvent_get_Terminal(self: *const T, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressEvent.VTable, self.vtable).get_Terminal(@ptrCast(*const ITAddressEvent, self), ppTerminal); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAddressDeviceSpecificEvent_Value = @import("../zig.zig").Guid.initString("3acb216b-40bd-487a-8672-5ce77bd7e3a3"); pub const IID_ITAddressDeviceSpecificEvent = &IID_ITAddressDeviceSpecificEvent_Value; pub const ITAddressDeviceSpecificEvent = 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 ITAddressDeviceSpecificEvent, ppAddress: ?*?*ITAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITAddressDeviceSpecificEvent, ppCall: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_lParam1: fn( self: *const ITAddressDeviceSpecificEvent, pParam1: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_lParam2: fn( self: *const ITAddressDeviceSpecificEvent, pParam2: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_lParam3: fn( self: *const ITAddressDeviceSpecificEvent, pParam3: ?*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 ITAddressDeviceSpecificEvent_get_Address(self: *const T, ppAddress: ?*?*ITAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressDeviceSpecificEvent.VTable, self.vtable).get_Address(@ptrCast(*const ITAddressDeviceSpecificEvent, self), ppAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressDeviceSpecificEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressDeviceSpecificEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITAddressDeviceSpecificEvent, self), ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressDeviceSpecificEvent_get_lParam1(self: *const T, pParam1: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressDeviceSpecificEvent.VTable, self.vtable).get_lParam1(@ptrCast(*const ITAddressDeviceSpecificEvent, self), pParam1); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressDeviceSpecificEvent_get_lParam2(self: *const T, pParam2: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressDeviceSpecificEvent.VTable, self.vtable).get_lParam2(@ptrCast(*const ITAddressDeviceSpecificEvent, self), pParam2); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressDeviceSpecificEvent_get_lParam3(self: *const T, pParam3: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressDeviceSpecificEvent.VTable, self.vtable).get_lParam3(@ptrCast(*const ITAddressDeviceSpecificEvent, self), pParam3); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITFileTerminalEvent_Value = @import("../zig.zig").Guid.initString("e4a7fbac-8c17-4427-9f55-9f589ac8af00"); pub const IID_ITFileTerminalEvent = &IID_ITFileTerminalEvent_Value; pub const ITFileTerminalEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminal: fn( self: *const ITFileTerminalEvent, ppTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Track: fn( self: *const ITFileTerminalEvent, ppTrackTerminal: ?*?*ITFileTrack, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITFileTerminalEvent, ppCall: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const ITFileTerminalEvent, pState: ?*TERMINAL_MEDIA_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Cause: fn( self: *const ITFileTerminalEvent, pCause: ?*FT_STATE_EVENT_CAUSE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Error: fn( self: *const ITFileTerminalEvent, phrErrorCode: ?*HRESULT, ) 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 ITFileTerminalEvent_get_Terminal(self: *const T, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTerminalEvent.VTable, self.vtable).get_Terminal(@ptrCast(*const ITFileTerminalEvent, self), ppTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTerminalEvent_get_Track(self: *const T, ppTrackTerminal: ?*?*ITFileTrack) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTerminalEvent.VTable, self.vtable).get_Track(@ptrCast(*const ITFileTerminalEvent, self), ppTrackTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTerminalEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTerminalEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITFileTerminalEvent, self), ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTerminalEvent_get_State(self: *const T, pState: ?*TERMINAL_MEDIA_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTerminalEvent.VTable, self.vtable).get_State(@ptrCast(*const ITFileTerminalEvent, self), pState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTerminalEvent_get_Cause(self: *const T, pCause: ?*FT_STATE_EVENT_CAUSE) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTerminalEvent.VTable, self.vtable).get_Cause(@ptrCast(*const ITFileTerminalEvent, self), pCause); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITFileTerminalEvent_get_Error(self: *const T, phrErrorCode: ?*HRESULT) callconv(.Inline) HRESULT { return @ptrCast(*const ITFileTerminalEvent.VTable, self.vtable).get_Error(@ptrCast(*const ITFileTerminalEvent, self), phrErrorCode); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTTSTerminalEvent_Value = @import("../zig.zig").Guid.initString("d964788f-95a5-461d-ab0c-b9900a6c2713"); pub const IID_ITTTSTerminalEvent = &IID_ITTTSTerminalEvent_Value; pub const ITTTSTerminalEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminal: fn( self: *const ITTTSTerminalEvent, ppTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITTTSTerminalEvent, ppCall: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Error: fn( self: *const ITTTSTerminalEvent, phrErrorCode: ?*HRESULT, ) 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 ITTTSTerminalEvent_get_Terminal(self: *const T, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITTTSTerminalEvent.VTable, self.vtable).get_Terminal(@ptrCast(*const ITTTSTerminalEvent, self), ppTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTTSTerminalEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITTTSTerminalEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITTTSTerminalEvent, self), ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTTSTerminalEvent_get_Error(self: *const T, phrErrorCode: ?*HRESULT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTTSTerminalEvent.VTable, self.vtable).get_Error(@ptrCast(*const ITTTSTerminalEvent, self), phrErrorCode); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITASRTerminalEvent_Value = @import("../zig.zig").Guid.initString("ee016a02-4fa9-467c-933f-5a15b12377d7"); pub const IID_ITASRTerminalEvent = &IID_ITASRTerminalEvent_Value; pub const ITASRTerminalEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminal: fn( self: *const ITASRTerminalEvent, ppTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITASRTerminalEvent, ppCall: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Error: fn( self: *const ITASRTerminalEvent, phrErrorCode: ?*HRESULT, ) 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 ITASRTerminalEvent_get_Terminal(self: *const T, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITASRTerminalEvent.VTable, self.vtable).get_Terminal(@ptrCast(*const ITASRTerminalEvent, self), ppTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITASRTerminalEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITASRTerminalEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITASRTerminalEvent, self), ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITASRTerminalEvent_get_Error(self: *const T, phrErrorCode: ?*HRESULT) callconv(.Inline) HRESULT { return @ptrCast(*const ITASRTerminalEvent.VTable, self.vtable).get_Error(@ptrCast(*const ITASRTerminalEvent, self), phrErrorCode); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITToneTerminalEvent_Value = @import("../zig.zig").Guid.initString("e6f56009-611f-4945-bbd2-2d0ce5612056"); pub const IID_ITToneTerminalEvent = &IID_ITToneTerminalEvent_Value; pub const ITToneTerminalEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminal: fn( self: *const ITToneTerminalEvent, ppTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITToneTerminalEvent, ppCall: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Error: fn( self: *const ITToneTerminalEvent, phrErrorCode: ?*HRESULT, ) 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 ITToneTerminalEvent_get_Terminal(self: *const T, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITToneTerminalEvent.VTable, self.vtable).get_Terminal(@ptrCast(*const ITToneTerminalEvent, self), ppTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITToneTerminalEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITToneTerminalEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITToneTerminalEvent, self), ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITToneTerminalEvent_get_Error(self: *const T, phrErrorCode: ?*HRESULT) callconv(.Inline) HRESULT { return @ptrCast(*const ITToneTerminalEvent.VTable, self.vtable).get_Error(@ptrCast(*const ITToneTerminalEvent, self), phrErrorCode); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITQOSEvent_Value = @import("../zig.zig").Guid.initString("cfa3357c-ad77-11d1-bb68-00c04fb6809f"); pub const IID_ITQOSEvent = &IID_ITQOSEvent_Value; pub const ITQOSEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITQOSEvent, ppCall: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITQOSEvent, pQosEvent: ?*QOS_EVENT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MediaType: fn( self: *const ITQOSEvent, plMediaType: ?*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 ITQOSEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITQOSEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITQOSEvent, self), ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQOSEvent_get_Event(self: *const T, pQosEvent: ?*QOS_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITQOSEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITQOSEvent, self), pQosEvent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQOSEvent_get_MediaType(self: *const T, plMediaType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQOSEvent.VTable, self.vtable).get_MediaType(@ptrCast(*const ITQOSEvent, self), plMediaType); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallInfoChangeEvent_Value = @import("../zig.zig").Guid.initString("5d4b65f9-e51c-11d1-a02f-00c04fb6809f"); pub const IID_ITCallInfoChangeEvent = &IID_ITCallInfoChangeEvent_Value; pub const ITCallInfoChangeEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITCallInfoChangeEvent, ppCall: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Cause: fn( self: *const ITCallInfoChangeEvent, pCIC: ?*CALLINFOCHANGE_CAUSE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallbackInstance: fn( self: *const ITCallInfoChangeEvent, plCallbackInstance: ?*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 ITCallInfoChangeEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfoChangeEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITCallInfoChangeEvent, self), ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfoChangeEvent_get_Cause(self: *const T, pCIC: ?*CALLINFOCHANGE_CAUSE) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfoChangeEvent.VTable, self.vtable).get_Cause(@ptrCast(*const ITCallInfoChangeEvent, self), pCIC); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallInfoChangeEvent_get_CallbackInstance(self: *const T, plCallbackInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallInfoChangeEvent.VTable, self.vtable).get_CallbackInstance(@ptrCast(*const ITCallInfoChangeEvent, self), plCallbackInstance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITRequest_Value = @import("../zig.zig").Guid.initString("ac48ffdf-f8c4-11d1-a030-00c04fb6809f"); pub const IID_ITRequest = &IID_ITRequest_Value; pub const ITRequest = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, MakeCall: fn( self: *const ITRequest, pDestAddress: ?BSTR, pAppName: ?BSTR, pCalledParty: ?BSTR, pComment: ?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 ITRequest_MakeCall(self: *const T, pDestAddress: ?BSTR, pAppName: ?BSTR, pCalledParty: ?BSTR, pComment: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITRequest.VTable, self.vtable).MakeCall(@ptrCast(*const ITRequest, self), pDestAddress, pAppName, pCalledParty, pComment); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITRequestEvent_Value = @import("../zig.zig").Guid.initString("ac48ffde-f8c4-11d1-a030-00c04fb6809f"); pub const IID_ITRequestEvent = &IID_ITRequestEvent_Value; pub const ITRequestEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RegistrationInstance: fn( self: *const ITRequestEvent, plRegistrationInstance: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RequestMode: fn( self: *const ITRequestEvent, plRequestMode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestAddress: fn( self: *const ITRequestEvent, ppDestAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AppName: fn( self: *const ITRequestEvent, ppAppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CalledParty: fn( self: *const ITRequestEvent, ppCalledParty: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Comment: fn( self: *const ITRequestEvent, ppComment: ?*?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 ITRequestEvent_get_RegistrationInstance(self: *const T, plRegistrationInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITRequestEvent.VTable, self.vtable).get_RegistrationInstance(@ptrCast(*const ITRequestEvent, self), plRegistrationInstance); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITRequestEvent_get_RequestMode(self: *const T, plRequestMode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITRequestEvent.VTable, self.vtable).get_RequestMode(@ptrCast(*const ITRequestEvent, self), plRequestMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITRequestEvent_get_DestAddress(self: *const T, ppDestAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITRequestEvent.VTable, self.vtable).get_DestAddress(@ptrCast(*const ITRequestEvent, self), ppDestAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITRequestEvent_get_AppName(self: *const T, ppAppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITRequestEvent.VTable, self.vtable).get_AppName(@ptrCast(*const ITRequestEvent, self), ppAppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITRequestEvent_get_CalledParty(self: *const T, ppCalledParty: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITRequestEvent.VTable, self.vtable).get_CalledParty(@ptrCast(*const ITRequestEvent, self), ppCalledParty); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITRequestEvent_get_Comment(self: *const T, ppComment: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITRequestEvent.VTable, self.vtable).get_Comment(@ptrCast(*const ITRequestEvent, self), ppComment); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCollection_Value = @import("../zig.zig").Guid.initString("5ec5acf2-9c02-11d0-8362-00aa003ccabd"); pub const IID_ITCollection = &IID_ITCollection_Value; pub const ITCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const ITCollection, lCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const ITCollection, Index: i32, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const ITCollection, ppNewEnum: ?*?*IUnknown, ) 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 ITCollection_get_Count(self: *const T, lCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCollection.VTable, self.vtable).get_Count(@ptrCast(*const ITCollection, self), lCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCollection_get_Item(self: *const T, Index: i32, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCollection.VTable, self.vtable).get_Item(@ptrCast(*const ITCollection, self), Index, pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCollection_get__NewEnum(self: *const T, ppNewEnum: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const ITCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const ITCollection, self), ppNewEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCollection2_Value = @import("../zig.zig").Guid.initString("e6dddda5-a6d3-48ff-8737-d32fc4d95477"); pub const IID_ITCollection2 = &IID_ITCollection2_Value; pub const ITCollection2 = extern struct { pub const VTable = extern struct { base: ITCollection.VTable, Add: fn( self: *const ITCollection2, Index: i32, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Remove: fn( self: *const ITCollection2, Index: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITCollection.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCollection2_Add(self: *const T, Index: i32, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCollection2.VTable, self.vtable).Add(@ptrCast(*const ITCollection2, self), Index, pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCollection2_Remove(self: *const T, Index: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCollection2.VTable, self.vtable).Remove(@ptrCast(*const ITCollection2, self), Index); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITForwardInformation_Value = @import("../zig.zig").Guid.initString("449f659e-88a3-11d1-bb5d-00c04fb6809f"); pub const IID_ITForwardInformation = &IID_ITForwardInformation_Value; pub const ITForwardInformation = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NumRingsNoAnswer: fn( self: *const ITForwardInformation, lNumRings: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NumRingsNoAnswer: fn( self: *const ITForwardInformation, plNumRings: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetForwardType: fn( self: *const ITForwardInformation, ForwardType: i32, pDestAddress: ?BSTR, pCallerAddress: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ForwardTypeDestination: fn( self: *const ITForwardInformation, ForwardType: i32, ppDestAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ForwardTypeCaller: fn( self: *const ITForwardInformation, Forwardtype: i32, ppCallerAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetForwardType: fn( self: *const ITForwardInformation, ForwardType: i32, ppDestinationAddress: ?*?BSTR, ppCallerAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clear: fn( self: *const ITForwardInformation, ) 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 ITForwardInformation_put_NumRingsNoAnswer(self: *const T, lNumRings: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation.VTable, self.vtable).put_NumRingsNoAnswer(@ptrCast(*const ITForwardInformation, self), lNumRings); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation_get_NumRingsNoAnswer(self: *const T, plNumRings: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation.VTable, self.vtable).get_NumRingsNoAnswer(@ptrCast(*const ITForwardInformation, self), plNumRings); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation_SetForwardType(self: *const T, ForwardType: i32, pDestAddress: ?BSTR, pCallerAddress: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation.VTable, self.vtable).SetForwardType(@ptrCast(*const ITForwardInformation, self), ForwardType, pDestAddress, pCallerAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation_get_ForwardTypeDestination(self: *const T, ForwardType: i32, ppDestAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation.VTable, self.vtable).get_ForwardTypeDestination(@ptrCast(*const ITForwardInformation, self), ForwardType, ppDestAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation_get_ForwardTypeCaller(self: *const T, Forwardtype: i32, ppCallerAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation.VTable, self.vtable).get_ForwardTypeCaller(@ptrCast(*const ITForwardInformation, self), Forwardtype, ppCallerAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation_GetForwardType(self: *const T, ForwardType: i32, ppDestinationAddress: ?*?BSTR, ppCallerAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation.VTable, self.vtable).GetForwardType(@ptrCast(*const ITForwardInformation, self), ForwardType, ppDestinationAddress, ppCallerAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation_Clear(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation.VTable, self.vtable).Clear(@ptrCast(*const ITForwardInformation, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITForwardInformation2_Value = @import("../zig.zig").Guid.initString("5229b4ed-b260-4382-8e1a-5df3a8a4ccc0"); pub const IID_ITForwardInformation2 = &IID_ITForwardInformation2_Value; pub const ITForwardInformation2 = extern struct { pub const VTable = extern struct { base: ITForwardInformation.VTable, SetForwardType2: fn( self: *const ITForwardInformation2, ForwardType: i32, pDestAddress: ?BSTR, DestAddressType: i32, pCallerAddress: ?BSTR, CallerAddressType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetForwardType2: fn( self: *const ITForwardInformation2, ForwardType: i32, ppDestinationAddress: ?*?BSTR, pDestAddressType: ?*i32, ppCallerAddress: ?*?BSTR, pCallerAddressType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ForwardTypeDestinationAddressType: fn( self: *const ITForwardInformation2, ForwardType: i32, pDestAddressType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ForwardTypeCallerAddressType: fn( self: *const ITForwardInformation2, Forwardtype: i32, pCallerAddressType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITForwardInformation.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation2_SetForwardType2(self: *const T, ForwardType: i32, pDestAddress: ?BSTR, DestAddressType: i32, pCallerAddress: ?BSTR, CallerAddressType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation2.VTable, self.vtable).SetForwardType2(@ptrCast(*const ITForwardInformation2, self), ForwardType, pDestAddress, DestAddressType, pCallerAddress, CallerAddressType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation2_GetForwardType2(self: *const T, ForwardType: i32, ppDestinationAddress: ?*?BSTR, pDestAddressType: ?*i32, ppCallerAddress: ?*?BSTR, pCallerAddressType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation2.VTable, self.vtable).GetForwardType2(@ptrCast(*const ITForwardInformation2, self), ForwardType, ppDestinationAddress, pDestAddressType, ppCallerAddress, pCallerAddressType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation2_get_ForwardTypeDestinationAddressType(self: *const T, ForwardType: i32, pDestAddressType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation2.VTable, self.vtable).get_ForwardTypeDestinationAddressType(@ptrCast(*const ITForwardInformation2, self), ForwardType, pDestAddressType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITForwardInformation2_get_ForwardTypeCallerAddressType(self: *const T, Forwardtype: i32, pCallerAddressType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITForwardInformation2.VTable, self.vtable).get_ForwardTypeCallerAddressType(@ptrCast(*const ITForwardInformation2, self), Forwardtype, pCallerAddressType); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAddressTranslation_Value = @import("../zig.zig").Guid.initString("0c4d8f03-8ddb-11d1-a09e-00805fc147d3"); pub const IID_ITAddressTranslation = &IID_ITAddressTranslation_Value; pub const ITAddressTranslation = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, TranslateAddress: fn( self: *const ITAddressTranslation, pAddressToTranslate: ?BSTR, lCard: i32, lTranslateOptions: i32, ppTranslated: ?*?*ITAddressTranslationInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, TranslateDialog: fn( self: *const ITAddressTranslation, hwndOwner: isize, pAddressIn: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateLocations: fn( self: *const ITAddressTranslation, ppEnumLocation: ?*?*IEnumLocation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Locations: fn( self: *const ITAddressTranslation, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateCallingCards: fn( self: *const ITAddressTranslation, ppEnumCallingCard: ?*?*IEnumCallingCard, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallingCards: fn( self: *const ITAddressTranslation, pVariant: ?*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 ITAddressTranslation_TranslateAddress(self: *const T, pAddressToTranslate: ?BSTR, lCard: i32, lTranslateOptions: i32, ppTranslated: ?*?*ITAddressTranslationInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslation.VTable, self.vtable).TranslateAddress(@ptrCast(*const ITAddressTranslation, self), pAddressToTranslate, lCard, lTranslateOptions, ppTranslated); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslation_TranslateDialog(self: *const T, hwndOwner: isize, pAddressIn: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslation.VTable, self.vtable).TranslateDialog(@ptrCast(*const ITAddressTranslation, self), hwndOwner, pAddressIn); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslation_EnumerateLocations(self: *const T, ppEnumLocation: ?*?*IEnumLocation) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslation.VTable, self.vtable).EnumerateLocations(@ptrCast(*const ITAddressTranslation, self), ppEnumLocation); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslation_get_Locations(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslation.VTable, self.vtable).get_Locations(@ptrCast(*const ITAddressTranslation, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslation_EnumerateCallingCards(self: *const T, ppEnumCallingCard: ?*?*IEnumCallingCard) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslation.VTable, self.vtable).EnumerateCallingCards(@ptrCast(*const ITAddressTranslation, self), ppEnumCallingCard); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslation_get_CallingCards(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslation.VTable, self.vtable).get_CallingCards(@ptrCast(*const ITAddressTranslation, self), pVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAddressTranslationInfo_Value = @import("../zig.zig").Guid.initString("afc15945-8d40-11d1-a09e-00805fc147d3"); pub const IID_ITAddressTranslationInfo = &IID_ITAddressTranslationInfo_Value; pub const ITAddressTranslationInfo = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DialableString: fn( self: *const ITAddressTranslationInfo, ppDialableString: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DisplayableString: fn( self: *const ITAddressTranslationInfo, ppDisplayableString: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentCountryCode: fn( self: *const ITAddressTranslationInfo, CountryCode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestinationCountryCode: fn( self: *const ITAddressTranslationInfo, CountryCode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TranslationResults: fn( self: *const ITAddressTranslationInfo, plResults: ?*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 ITAddressTranslationInfo_get_DialableString(self: *const T, ppDialableString: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslationInfo.VTable, self.vtable).get_DialableString(@ptrCast(*const ITAddressTranslationInfo, self), ppDialableString); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslationInfo_get_DisplayableString(self: *const T, ppDisplayableString: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslationInfo.VTable, self.vtable).get_DisplayableString(@ptrCast(*const ITAddressTranslationInfo, self), ppDisplayableString); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslationInfo_get_CurrentCountryCode(self: *const T, CountryCode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslationInfo.VTable, self.vtable).get_CurrentCountryCode(@ptrCast(*const ITAddressTranslationInfo, self), CountryCode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslationInfo_get_DestinationCountryCode(self: *const T, CountryCode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslationInfo.VTable, self.vtable).get_DestinationCountryCode(@ptrCast(*const ITAddressTranslationInfo, self), CountryCode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAddressTranslationInfo_get_TranslationResults(self: *const T, plResults: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAddressTranslationInfo.VTable, self.vtable).get_TranslationResults(@ptrCast(*const ITAddressTranslationInfo, self), plResults); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITLocationInfo_Value = @import("../zig.zig").Guid.initString("0c4d8eff-8ddb-11d1-a09e-00805fc147d3"); pub const IID_ITLocationInfo = &IID_ITLocationInfo_Value; pub const ITLocationInfo = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PermanentLocationID: fn( self: *const ITLocationInfo, plLocationID: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CountryCode: fn( self: *const ITLocationInfo, plCountryCode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CountryID: fn( self: *const ITLocationInfo, plCountryID: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Options: fn( self: *const ITLocationInfo, plOptions: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PreferredCardID: fn( self: *const ITLocationInfo, plCardID: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LocationName: fn( self: *const ITLocationInfo, ppLocationName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CityCode: fn( self: *const ITLocationInfo, ppCode: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LocalAccessCode: fn( self: *const ITLocationInfo, ppCode: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LongDistanceAccessCode: fn( self: *const ITLocationInfo, ppCode: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TollPrefixList: fn( self: *const ITLocationInfo, ppTollList: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CancelCallWaitingCode: fn( self: *const ITLocationInfo, ppCode: ?*?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 ITLocationInfo_get_PermanentLocationID(self: *const T, plLocationID: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_PermanentLocationID(@ptrCast(*const ITLocationInfo, self), plLocationID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_CountryCode(self: *const T, plCountryCode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_CountryCode(@ptrCast(*const ITLocationInfo, self), plCountryCode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_CountryID(self: *const T, plCountryID: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_CountryID(@ptrCast(*const ITLocationInfo, self), plCountryID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_Options(self: *const T, plOptions: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_Options(@ptrCast(*const ITLocationInfo, self), plOptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_PreferredCardID(self: *const T, plCardID: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_PreferredCardID(@ptrCast(*const ITLocationInfo, self), plCardID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_LocationName(self: *const T, ppLocationName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_LocationName(@ptrCast(*const ITLocationInfo, self), ppLocationName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_CityCode(self: *const T, ppCode: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_CityCode(@ptrCast(*const ITLocationInfo, self), ppCode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_LocalAccessCode(self: *const T, ppCode: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_LocalAccessCode(@ptrCast(*const ITLocationInfo, self), ppCode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_LongDistanceAccessCode(self: *const T, ppCode: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_LongDistanceAccessCode(@ptrCast(*const ITLocationInfo, self), ppCode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_TollPrefixList(self: *const T, ppTollList: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_TollPrefixList(@ptrCast(*const ITLocationInfo, self), ppTollList); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITLocationInfo_get_CancelCallWaitingCode(self: *const T, ppCode: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITLocationInfo.VTable, self.vtable).get_CancelCallWaitingCode(@ptrCast(*const ITLocationInfo, self), ppCode); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumLocation_Value = @import("../zig.zig").Guid.initString("0c4d8f01-8ddb-11d1-a09e-00805fc147d3"); pub const IID_IEnumLocation = &IID_IEnumLocation_Value; pub const IEnumLocation = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumLocation, celt: u32, ppElements: ?*?*ITLocationInfo, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumLocation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumLocation, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumLocation, ppEnum: ?*?*IEnumLocation, ) 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 IEnumLocation_Next(self: *const T, celt: u32, ppElements: ?*?*ITLocationInfo, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumLocation.VTable, self.vtable).Next(@ptrCast(*const IEnumLocation, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumLocation_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumLocation.VTable, self.vtable).Reset(@ptrCast(*const IEnumLocation, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumLocation_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumLocation.VTable, self.vtable).Skip(@ptrCast(*const IEnumLocation, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumLocation_Clone(self: *const T, ppEnum: ?*?*IEnumLocation) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumLocation.VTable, self.vtable).Clone(@ptrCast(*const IEnumLocation, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallingCard_Value = @import("../zig.zig").Guid.initString("0c4d8f00-8ddb-11d1-a09e-00805fc147d3"); pub const IID_ITCallingCard = &IID_ITCallingCard_Value; pub const ITCallingCard = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PermanentCardID: fn( self: *const ITCallingCard, plCardID: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NumberOfDigits: fn( self: *const ITCallingCard, plDigits: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Options: fn( self: *const ITCallingCard, plOptions: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CardName: fn( self: *const ITCallingCard, ppCardName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SameAreaDialingRule: fn( self: *const ITCallingCard, ppRule: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LongDistanceDialingRule: fn( self: *const ITCallingCard, ppRule: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_InternationalDialingRule: fn( self: *const ITCallingCard, ppRule: ?*?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 ITCallingCard_get_PermanentCardID(self: *const T, plCardID: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallingCard.VTable, self.vtable).get_PermanentCardID(@ptrCast(*const ITCallingCard, self), plCardID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallingCard_get_NumberOfDigits(self: *const T, plDigits: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallingCard.VTable, self.vtable).get_NumberOfDigits(@ptrCast(*const ITCallingCard, self), plDigits); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallingCard_get_Options(self: *const T, plOptions: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallingCard.VTable, self.vtable).get_Options(@ptrCast(*const ITCallingCard, self), plOptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallingCard_get_CardName(self: *const T, ppCardName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallingCard.VTable, self.vtable).get_CardName(@ptrCast(*const ITCallingCard, self), ppCardName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallingCard_get_SameAreaDialingRule(self: *const T, ppRule: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallingCard.VTable, self.vtable).get_SameAreaDialingRule(@ptrCast(*const ITCallingCard, self), ppRule); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallingCard_get_LongDistanceDialingRule(self: *const T, ppRule: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallingCard.VTable, self.vtable).get_LongDistanceDialingRule(@ptrCast(*const ITCallingCard, self), ppRule); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallingCard_get_InternationalDialingRule(self: *const T, ppRule: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallingCard.VTable, self.vtable).get_InternationalDialingRule(@ptrCast(*const ITCallingCard, self), ppRule); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumCallingCard_Value = @import("../zig.zig").Guid.initString("0c4d8f02-8ddb-11d1-a09e-00805fc147d3"); pub const IID_IEnumCallingCard = &IID_IEnumCallingCard_Value; pub const IEnumCallingCard = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumCallingCard, celt: u32, ppElements: ?*?*ITCallingCard, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumCallingCard, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumCallingCard, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumCallingCard, ppEnum: ?*?*IEnumCallingCard, ) 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 IEnumCallingCard_Next(self: *const T, celt: u32, ppElements: ?*?*ITCallingCard, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCallingCard.VTable, self.vtable).Next(@ptrCast(*const IEnumCallingCard, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCallingCard_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCallingCard.VTable, self.vtable).Reset(@ptrCast(*const IEnumCallingCard, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCallingCard_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCallingCard.VTable, self.vtable).Skip(@ptrCast(*const IEnumCallingCard, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumCallingCard_Clone(self: *const T, ppEnum: ?*?*IEnumCallingCard) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumCallingCard.VTable, self.vtable).Clone(@ptrCast(*const IEnumCallingCard, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITCallNotificationEvent_Value = @import("../zig.zig").Guid.initString("895801df-3dd6-11d1-8f30-00c04fb6809f"); pub const IID_ITCallNotificationEvent = &IID_ITCallNotificationEvent_Value; pub const ITCallNotificationEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Call: fn( self: *const ITCallNotificationEvent, ppCall: ?*?*ITCallInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITCallNotificationEvent, pCallNotificationEvent: ?*CALL_NOTIFICATION_EVENT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CallbackInstance: fn( self: *const ITCallNotificationEvent, plCallbackInstance: ?*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 ITCallNotificationEvent_get_Call(self: *const T, ppCall: ?*?*ITCallInfo) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallNotificationEvent.VTable, self.vtable).get_Call(@ptrCast(*const ITCallNotificationEvent, self), ppCall); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallNotificationEvent_get_Event(self: *const T, pCallNotificationEvent: ?*CALL_NOTIFICATION_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallNotificationEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITCallNotificationEvent, self), pCallNotificationEvent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITCallNotificationEvent_get_CallbackInstance(self: *const T, plCallbackInstance: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITCallNotificationEvent.VTable, self.vtable).get_CallbackInstance(@ptrCast(*const ITCallNotificationEvent, self), plCallbackInstance); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITDispatchMapper_Value = @import("../zig.zig").Guid.initString("e9225295-c759-11d1-a02b-00c04fb6809f"); pub const IID_ITDispatchMapper = &IID_ITDispatchMapper_Value; pub const ITDispatchMapper = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, QueryDispatchInterface: fn( self: *const ITDispatchMapper, pIID: ?BSTR, pInterfaceToMap: ?*IDispatch, ppReturnedInterface: ?*?*IDispatch, ) 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 ITDispatchMapper_QueryDispatchInterface(self: *const T, pIID: ?BSTR, pInterfaceToMap: ?*IDispatch, ppReturnedInterface: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const ITDispatchMapper.VTable, self.vtable).QueryDispatchInterface(@ptrCast(*const ITDispatchMapper, self), pIID, pInterfaceToMap, ppReturnedInterface); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITStreamControl_Value = @import("../zig.zig").Guid.initString("ee3bd604-3868-11d2-a045-00c04fb6809f"); pub const IID_ITStreamControl = &IID_ITStreamControl_Value; pub const ITStreamControl = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, CreateStream: fn( self: *const ITStreamControl, lMediaType: i32, td: TERMINAL_DIRECTION, ppStream: ?*?*ITStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveStream: fn( self: *const ITStreamControl, pStream: ?*ITStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateStreams: fn( self: *const ITStreamControl, ppEnumStream: ?*?*IEnumStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Streams: fn( self: *const ITStreamControl, pVariant: ?*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 ITStreamControl_CreateStream(self: *const T, lMediaType: i32, td: TERMINAL_DIRECTION, ppStream: ?*?*ITStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITStreamControl.VTable, self.vtable).CreateStream(@ptrCast(*const ITStreamControl, self), lMediaType, td, ppStream); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStreamControl_RemoveStream(self: *const T, pStream: ?*ITStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITStreamControl.VTable, self.vtable).RemoveStream(@ptrCast(*const ITStreamControl, self), pStream); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStreamControl_EnumerateStreams(self: *const T, ppEnumStream: ?*?*IEnumStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITStreamControl.VTable, self.vtable).EnumerateStreams(@ptrCast(*const ITStreamControl, self), ppEnumStream); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStreamControl_get_Streams(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITStreamControl.VTable, self.vtable).get_Streams(@ptrCast(*const ITStreamControl, self), pVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITStream_Value = @import("../zig.zig").Guid.initString("ee3bd605-3868-11d2-a045-00c04fb6809f"); pub const IID_ITStream = &IID_ITStream_Value; pub const ITStream = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MediaType: fn( self: *const ITStream, plMediaType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Direction: fn( self: *const ITStream, pTD: ?*TERMINAL_DIRECTION, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const ITStream, ppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, StartStream: fn( self: *const ITStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PauseStream: fn( self: *const ITStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, StopStream: fn( self: *const ITStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SelectTerminal: fn( self: *const ITStream, pTerminal: ?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnselectTerminal: fn( self: *const ITStream, pTerminal: ?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateTerminals: fn( self: *const ITStream, ppEnumTerminal: ?*?*IEnumTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminals: fn( self: *const ITStream, pTerminals: ?*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 ITStream_get_MediaType(self: *const T, plMediaType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).get_MediaType(@ptrCast(*const ITStream, self), plMediaType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_get_Direction(self: *const T, pTD: ?*TERMINAL_DIRECTION) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).get_Direction(@ptrCast(*const ITStream, self), pTD); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_get_Name(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).get_Name(@ptrCast(*const ITStream, self), ppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_StartStream(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).StartStream(@ptrCast(*const ITStream, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_PauseStream(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).PauseStream(@ptrCast(*const ITStream, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_StopStream(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).StopStream(@ptrCast(*const ITStream, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_SelectTerminal(self: *const T, pTerminal: ?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).SelectTerminal(@ptrCast(*const ITStream, self), pTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_UnselectTerminal(self: *const T, pTerminal: ?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).UnselectTerminal(@ptrCast(*const ITStream, self), pTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_EnumerateTerminals(self: *const T, ppEnumTerminal: ?*?*IEnumTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).EnumerateTerminals(@ptrCast(*const ITStream, self), ppEnumTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITStream_get_Terminals(self: *const T, pTerminals: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITStream.VTable, self.vtable).get_Terminals(@ptrCast(*const ITStream, self), pTerminals); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumStream_Value = @import("../zig.zig").Guid.initString("ee3bd606-3868-11d2-a045-00c04fb6809f"); pub const IID_IEnumStream = &IID_IEnumStream_Value; pub const IEnumStream = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumStream, celt: u32, ppElements: ?*?*ITStream, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumStream, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumStream, ppEnum: ?*?*IEnumStream, ) 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 IEnumStream_Next(self: *const T, celt: u32, ppElements: ?*?*ITStream, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumStream.VTable, self.vtable).Next(@ptrCast(*const IEnumStream, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumStream_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumStream.VTable, self.vtable).Reset(@ptrCast(*const IEnumStream, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumStream_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumStream.VTable, self.vtable).Skip(@ptrCast(*const IEnumStream, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumStream_Clone(self: *const T, ppEnum: ?*?*IEnumStream) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumStream.VTable, self.vtable).Clone(@ptrCast(*const IEnumStream, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITSubStreamControl_Value = @import("../zig.zig").Guid.initString("ee3bd607-3868-11d2-a045-00c04fb6809f"); pub const IID_ITSubStreamControl = &IID_ITSubStreamControl_Value; pub const ITSubStreamControl = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, CreateSubStream: fn( self: *const ITSubStreamControl, ppSubStream: ?*?*ITSubStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveSubStream: fn( self: *const ITSubStreamControl, pSubStream: ?*ITSubStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateSubStreams: fn( self: *const ITSubStreamControl, ppEnumSubStream: ?*?*IEnumSubStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SubStreams: fn( self: *const ITSubStreamControl, pVariant: ?*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 ITSubStreamControl_CreateSubStream(self: *const T, ppSubStream: ?*?*ITSubStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStreamControl.VTable, self.vtable).CreateSubStream(@ptrCast(*const ITSubStreamControl, self), ppSubStream); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStreamControl_RemoveSubStream(self: *const T, pSubStream: ?*ITSubStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStreamControl.VTable, self.vtable).RemoveSubStream(@ptrCast(*const ITSubStreamControl, self), pSubStream); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStreamControl_EnumerateSubStreams(self: *const T, ppEnumSubStream: ?*?*IEnumSubStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStreamControl.VTable, self.vtable).EnumerateSubStreams(@ptrCast(*const ITSubStreamControl, self), ppEnumSubStream); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStreamControl_get_SubStreams(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStreamControl.VTable, self.vtable).get_SubStreams(@ptrCast(*const ITSubStreamControl, self), pVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITSubStream_Value = @import("../zig.zig").Guid.initString("ee3bd608-3868-11d2-a045-00c04fb6809f"); pub const IID_ITSubStream = &IID_ITSubStream_Value; pub const ITSubStream = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, StartSubStream: fn( self: *const ITSubStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PauseSubStream: fn( self: *const ITSubStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, StopSubStream: fn( self: *const ITSubStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SelectTerminal: fn( self: *const ITSubStream, pTerminal: ?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnselectTerminal: fn( self: *const ITSubStream, pTerminal: ?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateTerminals: fn( self: *const ITSubStream, ppEnumTerminal: ?*?*IEnumTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Terminals: fn( self: *const ITSubStream, pTerminals: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Stream: fn( self: *const ITSubStream, ppITStream: ?*?*ITStream, ) 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 ITSubStream_StartSubStream(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStream.VTable, self.vtable).StartSubStream(@ptrCast(*const ITSubStream, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStream_PauseSubStream(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStream.VTable, self.vtable).PauseSubStream(@ptrCast(*const ITSubStream, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStream_StopSubStream(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStream.VTable, self.vtable).StopSubStream(@ptrCast(*const ITSubStream, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStream_SelectTerminal(self: *const T, pTerminal: ?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStream.VTable, self.vtable).SelectTerminal(@ptrCast(*const ITSubStream, self), pTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStream_UnselectTerminal(self: *const T, pTerminal: ?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStream.VTable, self.vtable).UnselectTerminal(@ptrCast(*const ITSubStream, self), pTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStream_EnumerateTerminals(self: *const T, ppEnumTerminal: ?*?*IEnumTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStream.VTable, self.vtable).EnumerateTerminals(@ptrCast(*const ITSubStream, self), ppEnumTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStream_get_Terminals(self: *const T, pTerminals: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStream.VTable, self.vtable).get_Terminals(@ptrCast(*const ITSubStream, self), pTerminals); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITSubStream_get_Stream(self: *const T, ppITStream: ?*?*ITStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITSubStream.VTable, self.vtable).get_Stream(@ptrCast(*const ITSubStream, self), ppITStream); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumSubStream_Value = @import("../zig.zig").Guid.initString("ee3bd609-3868-11d2-a045-00c04fb6809f"); pub const IID_IEnumSubStream = &IID_IEnumSubStream_Value; pub const IEnumSubStream = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumSubStream, celt: u32, ppElements: ?*?*ITSubStream, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumSubStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumSubStream, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumSubStream, ppEnum: ?*?*IEnumSubStream, ) 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 IEnumSubStream_Next(self: *const T, celt: u32, ppElements: ?*?*ITSubStream, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumSubStream.VTable, self.vtable).Next(@ptrCast(*const IEnumSubStream, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumSubStream_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumSubStream.VTable, self.vtable).Reset(@ptrCast(*const IEnumSubStream, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumSubStream_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumSubStream.VTable, self.vtable).Skip(@ptrCast(*const IEnumSubStream, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumSubStream_Clone(self: *const T, ppEnum: ?*?*IEnumSubStream) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumSubStream.VTable, self.vtable).Clone(@ptrCast(*const IEnumSubStream, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITLegacyWaveSupport_Value = @import("../zig.zig").Guid.initString("207823ea-e252-11d2-b77e-0080c7135381"); pub const IID_ITLegacyWaveSupport = &IID_ITLegacyWaveSupport_Value; pub const ITLegacyWaveSupport = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, IsFullDuplex: fn( self: *const ITLegacyWaveSupport, pSupport: ?*FULLDUPLEX_SUPPORT, ) 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 ITLegacyWaveSupport_IsFullDuplex(self: *const T, pSupport: ?*FULLDUPLEX_SUPPORT) callconv(.Inline) HRESULT { return @ptrCast(*const ITLegacyWaveSupport.VTable, self.vtable).IsFullDuplex(@ptrCast(*const ITLegacyWaveSupport, self), pSupport); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITBasicCallControl2_Value = @import("../zig.zig").Guid.initString("161a4a56-1e99-4b3f-a46a-168f38a5ee4c"); pub const IID_ITBasicCallControl2 = &IID_ITBasicCallControl2_Value; pub const ITBasicCallControl2 = extern struct { pub const VTable = extern struct { base: ITBasicCallControl.VTable, RequestTerminal: fn( self: *const ITBasicCallControl2, bstrTerminalClassGUID: ?BSTR, lMediaType: i32, Direction: TERMINAL_DIRECTION, ppTerminal: ?*?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SelectTerminalOnCall: fn( self: *const ITBasicCallControl2, pTerminal: ?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnselectTerminalOnCall: fn( self: *const ITBasicCallControl2, pTerminal: ?*ITTerminal, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace ITBasicCallControl.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl2_RequestTerminal(self: *const T, bstrTerminalClassGUID: ?BSTR, lMediaType: i32, Direction: TERMINAL_DIRECTION, ppTerminal: ?*?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl2.VTable, self.vtable).RequestTerminal(@ptrCast(*const ITBasicCallControl2, self), bstrTerminalClassGUID, lMediaType, Direction, ppTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl2_SelectTerminalOnCall(self: *const T, pTerminal: ?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl2.VTable, self.vtable).SelectTerminalOnCall(@ptrCast(*const ITBasicCallControl2, self), pTerminal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITBasicCallControl2_UnselectTerminalOnCall(self: *const T, pTerminal: ?*ITTerminal) callconv(.Inline) HRESULT { return @ptrCast(*const ITBasicCallControl2.VTable, self.vtable).UnselectTerminalOnCall(@ptrCast(*const ITBasicCallControl2, self), pTerminal); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITScriptableAudioFormat_Value = @import("../zig.zig").Guid.initString("b87658bd-3c59-4f64-be74-aede3e86a81e"); pub const IID_ITScriptableAudioFormat = &IID_ITScriptableAudioFormat_Value; pub const ITScriptableAudioFormat = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Channels: fn( self: *const ITScriptableAudioFormat, pVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Channels: fn( self: *const ITScriptableAudioFormat, nNewVal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SamplesPerSec: fn( self: *const ITScriptableAudioFormat, pVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SamplesPerSec: fn( self: *const ITScriptableAudioFormat, nNewVal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AvgBytesPerSec: fn( self: *const ITScriptableAudioFormat, pVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AvgBytesPerSec: fn( self: *const ITScriptableAudioFormat, nNewVal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BlockAlign: fn( self: *const ITScriptableAudioFormat, pVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BlockAlign: fn( self: *const ITScriptableAudioFormat, nNewVal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BitsPerSample: fn( self: *const ITScriptableAudioFormat, pVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BitsPerSample: fn( self: *const ITScriptableAudioFormat, nNewVal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FormatTag: fn( self: *const ITScriptableAudioFormat, pVal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FormatTag: fn( self: *const ITScriptableAudioFormat, nNewVal: 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 ITScriptableAudioFormat_get_Channels(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).get_Channels(@ptrCast(*const ITScriptableAudioFormat, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_put_Channels(self: *const T, nNewVal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).put_Channels(@ptrCast(*const ITScriptableAudioFormat, self), nNewVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_get_SamplesPerSec(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).get_SamplesPerSec(@ptrCast(*const ITScriptableAudioFormat, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_put_SamplesPerSec(self: *const T, nNewVal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).put_SamplesPerSec(@ptrCast(*const ITScriptableAudioFormat, self), nNewVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_get_AvgBytesPerSec(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).get_AvgBytesPerSec(@ptrCast(*const ITScriptableAudioFormat, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_put_AvgBytesPerSec(self: *const T, nNewVal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).put_AvgBytesPerSec(@ptrCast(*const ITScriptableAudioFormat, self), nNewVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_get_BlockAlign(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).get_BlockAlign(@ptrCast(*const ITScriptableAudioFormat, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_put_BlockAlign(self: *const T, nNewVal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).put_BlockAlign(@ptrCast(*const ITScriptableAudioFormat, self), nNewVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_get_BitsPerSample(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).get_BitsPerSample(@ptrCast(*const ITScriptableAudioFormat, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_put_BitsPerSample(self: *const T, nNewVal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).put_BitsPerSample(@ptrCast(*const ITScriptableAudioFormat, self), nNewVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_get_FormatTag(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).get_FormatTag(@ptrCast(*const ITScriptableAudioFormat, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITScriptableAudioFormat_put_FormatTag(self: *const T, nNewVal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITScriptableAudioFormat.VTable, self.vtable).put_FormatTag(@ptrCast(*const ITScriptableAudioFormat, self), nNewVal); } };} pub usingnamespace MethodMixin(@This()); }; pub const AGENT_EVENT = enum(i32) { NOT_READY = 0, READY = 1, BUSY_ACD = 2, BUSY_INCOMING = 3, BUSY_OUTGOING = 4, UNKNOWN = 5, }; pub const AE_NOT_READY = AGENT_EVENT.NOT_READY; pub const AE_READY = AGENT_EVENT.READY; pub const AE_BUSY_ACD = AGENT_EVENT.BUSY_ACD; pub const AE_BUSY_INCOMING = AGENT_EVENT.BUSY_INCOMING; pub const AE_BUSY_OUTGOING = AGENT_EVENT.BUSY_OUTGOING; pub const AE_UNKNOWN = AGENT_EVENT.UNKNOWN; pub const AGENT_STATE = enum(i32) { NOT_READY = 0, READY = 1, BUSY_ACD = 2, BUSY_INCOMING = 3, BUSY_OUTGOING = 4, UNKNOWN = 5, }; pub const AS_NOT_READY = AGENT_STATE.NOT_READY; pub const AS_READY = AGENT_STATE.READY; pub const AS_BUSY_ACD = AGENT_STATE.BUSY_ACD; pub const AS_BUSY_INCOMING = AGENT_STATE.BUSY_INCOMING; pub const AS_BUSY_OUTGOING = AGENT_STATE.BUSY_OUTGOING; pub const AS_UNKNOWN = AGENT_STATE.UNKNOWN; pub const AGENT_SESSION_EVENT = enum(i32) { NEW_SESSION = 0, NOT_READY = 1, READY = 2, BUSY = 3, WRAPUP = 4, END = 5, }; pub const ASE_NEW_SESSION = AGENT_SESSION_EVENT.NEW_SESSION; pub const ASE_NOT_READY = AGENT_SESSION_EVENT.NOT_READY; pub const ASE_READY = AGENT_SESSION_EVENT.READY; pub const ASE_BUSY = AGENT_SESSION_EVENT.BUSY; pub const ASE_WRAPUP = AGENT_SESSION_EVENT.WRAPUP; pub const ASE_END = AGENT_SESSION_EVENT.END; pub const AGENT_SESSION_STATE = enum(i32) { NOT_READY = 0, READY = 1, BUSY_ON_CALL = 2, BUSY_WRAPUP = 3, SESSION_ENDED = 4, }; pub const ASST_NOT_READY = AGENT_SESSION_STATE.NOT_READY; pub const ASST_READY = AGENT_SESSION_STATE.READY; pub const ASST_BUSY_ON_CALL = AGENT_SESSION_STATE.BUSY_ON_CALL; pub const ASST_BUSY_WRAPUP = AGENT_SESSION_STATE.BUSY_WRAPUP; pub const ASST_SESSION_ENDED = AGENT_SESSION_STATE.SESSION_ENDED; pub const AGENTHANDLER_EVENT = enum(i32) { NEW_AGENTHANDLER = 0, AGENTHANDLER_REMOVED = 1, }; pub const AHE_NEW_AGENTHANDLER = AGENTHANDLER_EVENT.NEW_AGENTHANDLER; pub const AHE_AGENTHANDLER_REMOVED = AGENTHANDLER_EVENT.AGENTHANDLER_REMOVED; pub const ACDGROUP_EVENT = enum(i32) { NEW_GROUP = 0, GROUP_REMOVED = 1, }; pub const ACDGE_NEW_GROUP = ACDGROUP_EVENT.NEW_GROUP; pub const ACDGE_GROUP_REMOVED = ACDGROUP_EVENT.GROUP_REMOVED; pub const ACDQUEUE_EVENT = enum(i32) { NEW_QUEUE = 0, QUEUE_REMOVED = 1, }; pub const ACDQE_NEW_QUEUE = ACDQUEUE_EVENT.NEW_QUEUE; pub const ACDQE_QUEUE_REMOVED = ACDQUEUE_EVENT.QUEUE_REMOVED; const IID_ITAgent_Value = @import("../zig.zig").Guid.initString("5770ece5-4b27-11d1-bf80-00805fc147d3"); pub const IID_ITAgent = &IID_ITAgent_Value; pub const ITAgent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, EnumerateAgentSessions: fn( self: *const ITAgent, ppEnumAgentSession: ?*?*IEnumAgentSession, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateSession: fn( self: *const ITAgent, pACDGroup: ?*ITACDGroup, pAddress: ?*ITAddress, ppAgentSession: ?*?*ITAgentSession, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateSessionWithPIN: fn( self: *const ITAgent, pACDGroup: ?*ITACDGroup, pAddress: ?*ITAddress, pPIN: ?BSTR, ppAgentSession: ?*?*ITAgentSession, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ID: fn( self: *const ITAgent, ppID: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_User: fn( self: *const ITAgent, ppUser: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_State: fn( self: *const ITAgent, AgentState: AGENT_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const ITAgent, pAgentState: ?*AGENT_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MeasurementPeriod: fn( self: *const ITAgent, lPeriod: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MeasurementPeriod: fn( self: *const ITAgent, plPeriod: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_OverallCallRate: fn( self: *const ITAgent, pcyCallrate: ?*CY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NumberOfACDCalls: fn( self: *const ITAgent, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NumberOfIncomingCalls: fn( self: *const ITAgent, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NumberOfOutgoingCalls: fn( self: *const ITAgent, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalACDTalkTime: fn( self: *const ITAgent, plTalkTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalACDCallTime: fn( self: *const ITAgent, plCallTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalWrapUpTime: fn( self: *const ITAgent, plWrapUpTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AgentSessions: fn( self: *const ITAgent, pVariant: ?*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 ITAgent_EnumerateAgentSessions(self: *const T, ppEnumAgentSession: ?*?*IEnumAgentSession) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).EnumerateAgentSessions(@ptrCast(*const ITAgent, self), ppEnumAgentSession); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_CreateSession(self: *const T, pACDGroup: ?*ITACDGroup, pAddress: ?*ITAddress, ppAgentSession: ?*?*ITAgentSession) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).CreateSession(@ptrCast(*const ITAgent, self), pACDGroup, pAddress, ppAgentSession); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_CreateSessionWithPIN(self: *const T, pACDGroup: ?*ITACDGroup, pAddress: ?*ITAddress, pPIN: ?BSTR, ppAgentSession: ?*?*ITAgentSession) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).CreateSessionWithPIN(@ptrCast(*const ITAgent, self), pACDGroup, pAddress, pPIN, ppAgentSession); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_ID(self: *const T, ppID: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_ID(@ptrCast(*const ITAgent, self), ppID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_User(self: *const T, ppUser: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_User(@ptrCast(*const ITAgent, self), ppUser); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_put_State(self: *const T, AgentState: AGENT_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).put_State(@ptrCast(*const ITAgent, self), AgentState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_State(self: *const T, pAgentState: ?*AGENT_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_State(@ptrCast(*const ITAgent, self), pAgentState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_put_MeasurementPeriod(self: *const T, lPeriod: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).put_MeasurementPeriod(@ptrCast(*const ITAgent, self), lPeriod); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_MeasurementPeriod(self: *const T, plPeriod: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_MeasurementPeriod(@ptrCast(*const ITAgent, self), plPeriod); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_OverallCallRate(self: *const T, pcyCallrate: ?*CY) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_OverallCallRate(@ptrCast(*const ITAgent, self), pcyCallrate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_NumberOfACDCalls(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_NumberOfACDCalls(@ptrCast(*const ITAgent, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_NumberOfIncomingCalls(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_NumberOfIncomingCalls(@ptrCast(*const ITAgent, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_NumberOfOutgoingCalls(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_NumberOfOutgoingCalls(@ptrCast(*const ITAgent, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_TotalACDTalkTime(self: *const T, plTalkTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_TotalACDTalkTime(@ptrCast(*const ITAgent, self), plTalkTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_TotalACDCallTime(self: *const T, plCallTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_TotalACDCallTime(@ptrCast(*const ITAgent, self), plCallTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_TotalWrapUpTime(self: *const T, plWrapUpTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_TotalWrapUpTime(@ptrCast(*const ITAgent, self), plWrapUpTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgent_get_AgentSessions(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgent.VTable, self.vtable).get_AgentSessions(@ptrCast(*const ITAgent, self), pVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAgentSession_Value = @import("../zig.zig").Guid.initString("5afc3147-4bcc-11d1-bf80-00805fc147d3"); pub const IID_ITAgentSession = &IID_ITAgentSession_Value; pub const ITAgentSession = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Agent: fn( self: *const ITAgentSession, ppAgent: ?*?*ITAgent, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Address: fn( self: *const ITAgentSession, ppAddress: ?*?*ITAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ACDGroup: fn( self: *const ITAgentSession, ppACDGroup: ?*?*ITACDGroup, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_State: fn( self: *const ITAgentSession, SessionState: AGENT_SESSION_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const ITAgentSession, pSessionState: ?*AGENT_SESSION_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SessionStartTime: fn( self: *const ITAgentSession, pdateSessionStart: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SessionDuration: fn( self: *const ITAgentSession, plDuration: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NumberOfCalls: fn( self: *const ITAgentSession, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalTalkTime: fn( self: *const ITAgentSession, plTalkTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AverageTalkTime: fn( self: *const ITAgentSession, plTalkTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalCallTime: fn( self: *const ITAgentSession, plCallTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AverageCallTime: fn( self: *const ITAgentSession, plCallTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalWrapUpTime: fn( self: *const ITAgentSession, plWrapUpTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AverageWrapUpTime: fn( self: *const ITAgentSession, plWrapUpTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ACDCallRate: fn( self: *const ITAgentSession, pcyCallrate: ?*CY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LongestTimeToAnswer: fn( self: *const ITAgentSession, plAnswerTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AverageTimeToAnswer: fn( self: *const ITAgentSession, plAnswerTime: ?*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 ITAgentSession_get_Agent(self: *const T, ppAgent: ?*?*ITAgent) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_Agent(@ptrCast(*const ITAgentSession, self), ppAgent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_Address(self: *const T, ppAddress: ?*?*ITAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_Address(@ptrCast(*const ITAgentSession, self), ppAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_ACDGroup(self: *const T, ppACDGroup: ?*?*ITACDGroup) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_ACDGroup(@ptrCast(*const ITAgentSession, self), ppACDGroup); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_put_State(self: *const T, SessionState: AGENT_SESSION_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).put_State(@ptrCast(*const ITAgentSession, self), SessionState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_State(self: *const T, pSessionState: ?*AGENT_SESSION_STATE) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_State(@ptrCast(*const ITAgentSession, self), pSessionState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_SessionStartTime(self: *const T, pdateSessionStart: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_SessionStartTime(@ptrCast(*const ITAgentSession, self), pdateSessionStart); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_SessionDuration(self: *const T, plDuration: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_SessionDuration(@ptrCast(*const ITAgentSession, self), plDuration); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_NumberOfCalls(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_NumberOfCalls(@ptrCast(*const ITAgentSession, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_TotalTalkTime(self: *const T, plTalkTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_TotalTalkTime(@ptrCast(*const ITAgentSession, self), plTalkTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_AverageTalkTime(self: *const T, plTalkTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_AverageTalkTime(@ptrCast(*const ITAgentSession, self), plTalkTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_TotalCallTime(self: *const T, plCallTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_TotalCallTime(@ptrCast(*const ITAgentSession, self), plCallTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_AverageCallTime(self: *const T, plCallTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_AverageCallTime(@ptrCast(*const ITAgentSession, self), plCallTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_TotalWrapUpTime(self: *const T, plWrapUpTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_TotalWrapUpTime(@ptrCast(*const ITAgentSession, self), plWrapUpTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_AverageWrapUpTime(self: *const T, plWrapUpTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_AverageWrapUpTime(@ptrCast(*const ITAgentSession, self), plWrapUpTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_ACDCallRate(self: *const T, pcyCallrate: ?*CY) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_ACDCallRate(@ptrCast(*const ITAgentSession, self), pcyCallrate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_LongestTimeToAnswer(self: *const T, plAnswerTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_LongestTimeToAnswer(@ptrCast(*const ITAgentSession, self), plAnswerTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSession_get_AverageTimeToAnswer(self: *const T, plAnswerTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSession.VTable, self.vtable).get_AverageTimeToAnswer(@ptrCast(*const ITAgentSession, self), plAnswerTime); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITACDGroup_Value = @import("../zig.zig").Guid.initString("5afc3148-4bcc-11d1-bf80-00805fc147d3"); pub const IID_ITACDGroup = &IID_ITACDGroup_Value; pub const ITACDGroup = 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 ITACDGroup, ppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateQueues: fn( self: *const ITACDGroup, ppEnumQueue: ?*?*IEnumQueue, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Queues: fn( self: *const ITACDGroup, pVariant: ?*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 ITACDGroup_get_Name(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITACDGroup.VTable, self.vtable).get_Name(@ptrCast(*const ITACDGroup, self), ppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITACDGroup_EnumerateQueues(self: *const T, ppEnumQueue: ?*?*IEnumQueue) callconv(.Inline) HRESULT { return @ptrCast(*const ITACDGroup.VTable, self.vtable).EnumerateQueues(@ptrCast(*const ITACDGroup, self), ppEnumQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITACDGroup_get_Queues(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITACDGroup.VTable, self.vtable).get_Queues(@ptrCast(*const ITACDGroup, self), pVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITQueue_Value = @import("../zig.zig").Guid.initString("5afc3149-4bcc-11d1-bf80-00805fc147d3"); pub const IID_ITQueue = &IID_ITQueue_Value; pub const ITQueue = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MeasurementPeriod: fn( self: *const ITQueue, lPeriod: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MeasurementPeriod: fn( self: *const ITQueue, plPeriod: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalCallsQueued: fn( self: *const ITQueue, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentCallsQueued: fn( self: *const ITQueue, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalCallsAbandoned: fn( self: *const ITQueue, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalCallsFlowedIn: fn( self: *const ITQueue, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TotalCallsFlowedOut: fn( self: *const ITQueue, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LongestEverWaitTime: fn( self: *const ITQueue, plWaitTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CurrentLongestWaitTime: fn( self: *const ITQueue, plWaitTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AverageWaitTime: fn( self: *const ITQueue, plWaitTime: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FinalDisposition: fn( self: *const ITQueue, plCalls: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const ITQueue, ppName: ?*?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 ITQueue_put_MeasurementPeriod(self: *const T, lPeriod: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).put_MeasurementPeriod(@ptrCast(*const ITQueue, self), lPeriod); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_MeasurementPeriod(self: *const T, plPeriod: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_MeasurementPeriod(@ptrCast(*const ITQueue, self), plPeriod); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_TotalCallsQueued(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_TotalCallsQueued(@ptrCast(*const ITQueue, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_CurrentCallsQueued(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_CurrentCallsQueued(@ptrCast(*const ITQueue, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_TotalCallsAbandoned(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_TotalCallsAbandoned(@ptrCast(*const ITQueue, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_TotalCallsFlowedIn(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_TotalCallsFlowedIn(@ptrCast(*const ITQueue, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_TotalCallsFlowedOut(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_TotalCallsFlowedOut(@ptrCast(*const ITQueue, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_LongestEverWaitTime(self: *const T, plWaitTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_LongestEverWaitTime(@ptrCast(*const ITQueue, self), plWaitTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_CurrentLongestWaitTime(self: *const T, plWaitTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_CurrentLongestWaitTime(@ptrCast(*const ITQueue, self), plWaitTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_AverageWaitTime(self: *const T, plWaitTime: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_AverageWaitTime(@ptrCast(*const ITQueue, self), plWaitTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_FinalDisposition(self: *const T, plCalls: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_FinalDisposition(@ptrCast(*const ITQueue, self), plCalls); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueue_get_Name(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueue.VTable, self.vtable).get_Name(@ptrCast(*const ITQueue, self), ppName); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAgentEvent_Value = @import("../zig.zig").Guid.initString("5afc314a-4bcc-11d1-bf80-00805fc147d3"); pub const IID_ITAgentEvent = &IID_ITAgentEvent_Value; pub const ITAgentEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Agent: fn( self: *const ITAgentEvent, ppAgent: ?*?*ITAgent, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITAgentEvent, pEvent: ?*AGENT_EVENT, ) 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 ITAgentEvent_get_Agent(self: *const T, ppAgent: ?*?*ITAgent) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentEvent.VTable, self.vtable).get_Agent(@ptrCast(*const ITAgentEvent, self), ppAgent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentEvent_get_Event(self: *const T, pEvent: ?*AGENT_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITAgentEvent, self), pEvent); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAgentSessionEvent_Value = @import("../zig.zig").Guid.initString("5afc314b-4bcc-11d1-bf80-00805fc147d3"); pub const IID_ITAgentSessionEvent = &IID_ITAgentSessionEvent_Value; pub const ITAgentSessionEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Session: fn( self: *const ITAgentSessionEvent, ppSession: ?*?*ITAgentSession, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITAgentSessionEvent, pEvent: ?*AGENT_SESSION_EVENT, ) 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 ITAgentSessionEvent_get_Session(self: *const T, ppSession: ?*?*ITAgentSession) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSessionEvent.VTable, self.vtable).get_Session(@ptrCast(*const ITAgentSessionEvent, self), ppSession); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentSessionEvent_get_Event(self: *const T, pEvent: ?*AGENT_SESSION_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentSessionEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITAgentSessionEvent, self), pEvent); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITACDGroupEvent_Value = @import("../zig.zig").Guid.initString("297f3032-bd11-11d1-a0a7-00805fc147d3"); pub const IID_ITACDGroupEvent = &IID_ITACDGroupEvent_Value; pub const ITACDGroupEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Group: fn( self: *const ITACDGroupEvent, ppGroup: ?*?*ITACDGroup, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITACDGroupEvent, pEvent: ?*ACDGROUP_EVENT, ) 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 ITACDGroupEvent_get_Group(self: *const T, ppGroup: ?*?*ITACDGroup) callconv(.Inline) HRESULT { return @ptrCast(*const ITACDGroupEvent.VTable, self.vtable).get_Group(@ptrCast(*const ITACDGroupEvent, self), ppGroup); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITACDGroupEvent_get_Event(self: *const T, pEvent: ?*ACDGROUP_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITACDGroupEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITACDGroupEvent, self), pEvent); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITQueueEvent_Value = @import("../zig.zig").Guid.initString("297f3033-bd11-11d1-a0a7-00805fc147d3"); pub const IID_ITQueueEvent = &IID_ITQueueEvent_Value; pub const ITQueueEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Queue: fn( self: *const ITQueueEvent, ppQueue: ?*?*ITQueue, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITQueueEvent, pEvent: ?*ACDQUEUE_EVENT, ) 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 ITQueueEvent_get_Queue(self: *const T, ppQueue: ?*?*ITQueue) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueueEvent.VTable, self.vtable).get_Queue(@ptrCast(*const ITQueueEvent, self), ppQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITQueueEvent_get_Event(self: *const T, pEvent: ?*ACDQUEUE_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITQueueEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITQueueEvent, self), pEvent); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAgentHandlerEvent_Value = @import("../zig.zig").Guid.initString("297f3034-bd11-11d1-a0a7-00805fc147d3"); pub const IID_ITAgentHandlerEvent = &IID_ITAgentHandlerEvent_Value; pub const ITAgentHandlerEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AgentHandler: fn( self: *const ITAgentHandlerEvent, ppAgentHandler: ?*?*ITAgentHandler, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Event: fn( self: *const ITAgentHandlerEvent, pEvent: ?*AGENTHANDLER_EVENT, ) 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 ITAgentHandlerEvent_get_AgentHandler(self: *const T, ppAgentHandler: ?*?*ITAgentHandler) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandlerEvent.VTable, self.vtable).get_AgentHandler(@ptrCast(*const ITAgentHandlerEvent, self), ppAgentHandler); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentHandlerEvent_get_Event(self: *const T, pEvent: ?*AGENTHANDLER_EVENT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandlerEvent.VTable, self.vtable).get_Event(@ptrCast(*const ITAgentHandlerEvent, self), pEvent); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTAPICallCenter_Value = @import("../zig.zig").Guid.initString("5afc3154-4bcc-11d1-bf80-00805fc147d3"); pub const IID_ITTAPICallCenter = &IID_ITTAPICallCenter_Value; pub const ITTAPICallCenter = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, EnumerateAgentHandlers: fn( self: *const ITTAPICallCenter, ppEnumHandler: ?*?*IEnumAgentHandler, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AgentHandlers: fn( self: *const ITTAPICallCenter, pVariant: ?*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 ITTAPICallCenter_EnumerateAgentHandlers(self: *const T, ppEnumHandler: ?*?*IEnumAgentHandler) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPICallCenter.VTable, self.vtable).EnumerateAgentHandlers(@ptrCast(*const ITTAPICallCenter, self), ppEnumHandler); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITTAPICallCenter_get_AgentHandlers(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITTAPICallCenter.VTable, self.vtable).get_AgentHandlers(@ptrCast(*const ITTAPICallCenter, self), pVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAgentHandler_Value = @import("../zig.zig").Guid.initString("587e8c22-9802-11d1-a0a4-00805fc147d3"); pub const IID_ITAgentHandler = &IID_ITAgentHandler_Value; pub const ITAgentHandler = 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 ITAgentHandler, ppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateAgent: fn( self: *const ITAgentHandler, ppAgent: ?*?*ITAgent, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateAgentWithID: fn( self: *const ITAgentHandler, pID: ?BSTR, pPIN: ?BSTR, ppAgent: ?*?*ITAgent, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateACDGroups: fn( self: *const ITAgentHandler, ppEnumACDGroup: ?*?*IEnumACDGroup, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateUsableAddresses: fn( self: *const ITAgentHandler, ppEnumAddress: ?*?*IEnumAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ACDGroups: fn( self: *const ITAgentHandler, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UsableAddresses: fn( self: *const ITAgentHandler, pVariant: ?*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 ITAgentHandler_get_Name(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandler.VTable, self.vtable).get_Name(@ptrCast(*const ITAgentHandler, self), ppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentHandler_CreateAgent(self: *const T, ppAgent: ?*?*ITAgent) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandler.VTable, self.vtable).CreateAgent(@ptrCast(*const ITAgentHandler, self), ppAgent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentHandler_CreateAgentWithID(self: *const T, pID: ?BSTR, pPIN: ?BSTR, ppAgent: ?*?*ITAgent) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandler.VTable, self.vtable).CreateAgentWithID(@ptrCast(*const ITAgentHandler, self), pID, pPIN, ppAgent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentHandler_EnumerateACDGroups(self: *const T, ppEnumACDGroup: ?*?*IEnumACDGroup) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandler.VTable, self.vtable).EnumerateACDGroups(@ptrCast(*const ITAgentHandler, self), ppEnumACDGroup); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentHandler_EnumerateUsableAddresses(self: *const T, ppEnumAddress: ?*?*IEnumAddress) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandler.VTable, self.vtable).EnumerateUsableAddresses(@ptrCast(*const ITAgentHandler, self), ppEnumAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentHandler_get_ACDGroups(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandler.VTable, self.vtable).get_ACDGroups(@ptrCast(*const ITAgentHandler, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAgentHandler_get_UsableAddresses(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITAgentHandler.VTable, self.vtable).get_UsableAddresses(@ptrCast(*const ITAgentHandler, self), pVariant); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumAgent_Value = @import("../zig.zig").Guid.initString("5afc314d-4bcc-11d1-bf80-00805fc147d3"); pub const IID_IEnumAgent = &IID_IEnumAgent_Value; pub const IEnumAgent = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumAgent, celt: u32, ppElements: ?*?*ITAgent, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumAgent, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumAgent, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumAgent, ppEnum: ?*?*IEnumAgent, ) 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 IEnumAgent_Next(self: *const T, celt: u32, ppElements: ?*?*ITAgent, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgent.VTable, self.vtable).Next(@ptrCast(*const IEnumAgent, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgent_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgent.VTable, self.vtable).Reset(@ptrCast(*const IEnumAgent, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgent_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgent.VTable, self.vtable).Skip(@ptrCast(*const IEnumAgent, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgent_Clone(self: *const T, ppEnum: ?*?*IEnumAgent) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgent.VTable, self.vtable).Clone(@ptrCast(*const IEnumAgent, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumAgentSession_Value = @import("../zig.zig").Guid.initString("5afc314e-4bcc-11d1-bf80-00805fc147d3"); pub const IID_IEnumAgentSession = &IID_IEnumAgentSession_Value; pub const IEnumAgentSession = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumAgentSession, celt: u32, ppElements: ?*?*ITAgentSession, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumAgentSession, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumAgentSession, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumAgentSession, ppEnum: ?*?*IEnumAgentSession, ) 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 IEnumAgentSession_Next(self: *const T, celt: u32, ppElements: ?*?*ITAgentSession, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgentSession.VTable, self.vtable).Next(@ptrCast(*const IEnumAgentSession, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgentSession_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgentSession.VTable, self.vtable).Reset(@ptrCast(*const IEnumAgentSession, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgentSession_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgentSession.VTable, self.vtable).Skip(@ptrCast(*const IEnumAgentSession, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgentSession_Clone(self: *const T, ppEnum: ?*?*IEnumAgentSession) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgentSession.VTable, self.vtable).Clone(@ptrCast(*const IEnumAgentSession, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumQueue_Value = @import("../zig.zig").Guid.initString("5afc3158-4bcc-11d1-bf80-00805fc147d3"); pub const IID_IEnumQueue = &IID_IEnumQueue_Value; pub const IEnumQueue = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumQueue, celt: u32, ppElements: ?*?*ITQueue, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumQueue, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumQueue, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumQueue, ppEnum: ?*?*IEnumQueue, ) 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 IEnumQueue_Next(self: *const T, celt: u32, ppElements: ?*?*ITQueue, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumQueue.VTable, self.vtable).Next(@ptrCast(*const IEnumQueue, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumQueue_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumQueue.VTable, self.vtable).Reset(@ptrCast(*const IEnumQueue, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumQueue_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumQueue.VTable, self.vtable).Skip(@ptrCast(*const IEnumQueue, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumQueue_Clone(self: *const T, ppEnum: ?*?*IEnumQueue) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumQueue.VTable, self.vtable).Clone(@ptrCast(*const IEnumQueue, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumACDGroup_Value = @import("../zig.zig").Guid.initString("5afc3157-4bcc-11d1-bf80-00805fc147d3"); pub const IID_IEnumACDGroup = &IID_IEnumACDGroup_Value; pub const IEnumACDGroup = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumACDGroup, celt: u32, ppElements: ?*?*ITACDGroup, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumACDGroup, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumACDGroup, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumACDGroup, ppEnum: ?*?*IEnumACDGroup, ) 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 IEnumACDGroup_Next(self: *const T, celt: u32, ppElements: ?*?*ITACDGroup, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumACDGroup.VTable, self.vtable).Next(@ptrCast(*const IEnumACDGroup, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumACDGroup_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumACDGroup.VTable, self.vtable).Reset(@ptrCast(*const IEnumACDGroup, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumACDGroup_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumACDGroup.VTable, self.vtable).Skip(@ptrCast(*const IEnumACDGroup, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumACDGroup_Clone(self: *const T, ppEnum: ?*?*IEnumACDGroup) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumACDGroup.VTable, self.vtable).Clone(@ptrCast(*const IEnumACDGroup, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumAgentHandler_Value = @import("../zig.zig").Guid.initString("587e8c28-9802-11d1-a0a4-00805fc147d3"); pub const IID_IEnumAgentHandler = &IID_IEnumAgentHandler_Value; pub const IEnumAgentHandler = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumAgentHandler, celt: u32, ppElements: ?*?*ITAgentHandler, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumAgentHandler, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumAgentHandler, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumAgentHandler, ppEnum: ?*?*IEnumAgentHandler, ) 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 IEnumAgentHandler_Next(self: *const T, celt: u32, ppElements: ?*?*ITAgentHandler, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgentHandler.VTable, self.vtable).Next(@ptrCast(*const IEnumAgentHandler, self), celt, ppElements, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgentHandler_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgentHandler.VTable, self.vtable).Reset(@ptrCast(*const IEnumAgentHandler, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgentHandler_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgentHandler.VTable, self.vtable).Skip(@ptrCast(*const IEnumAgentHandler, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumAgentHandler_Clone(self: *const T, ppEnum: ?*?*IEnumAgentHandler) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumAgentHandler.VTable, self.vtable).Clone(@ptrCast(*const IEnumAgentHandler, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAMMediaFormat_Value = @import("../zig.zig").Guid.initString("0364eb00-4a77-11d1-a671-006097c9a2e8"); pub const IID_ITAMMediaFormat = &IID_ITAMMediaFormat_Value; pub const ITAMMediaFormat = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MediaFormat: fn( self: *const ITAMMediaFormat, ppmt: ?*?*AM_MEDIA_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MediaFormat: fn( self: *const ITAMMediaFormat, pmt: ?*const AM_MEDIA_TYPE, ) 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 ITAMMediaFormat_get_MediaFormat(self: *const T, ppmt: ?*?*AM_MEDIA_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITAMMediaFormat.VTable, self.vtable).get_MediaFormat(@ptrCast(*const ITAMMediaFormat, self), ppmt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAMMediaFormat_put_MediaFormat(self: *const T, pmt: ?*const AM_MEDIA_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITAMMediaFormat.VTable, self.vtable).put_MediaFormat(@ptrCast(*const ITAMMediaFormat, self), pmt); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITAllocatorProperties_Value = @import("../zig.zig").Guid.initString("c1bc3c90-bcfe-11d1-9745-00c04fd91ac0"); pub const IID_ITAllocatorProperties = &IID_ITAllocatorProperties_Value; pub const ITAllocatorProperties = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetAllocatorProperties: fn( self: *const ITAllocatorProperties, pAllocProperties: ?*ALLOCATOR_PROPERTIES, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAllocatorProperties: fn( self: *const ITAllocatorProperties, pAllocProperties: ?*ALLOCATOR_PROPERTIES, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetAllocateBuffers: fn( self: *const ITAllocatorProperties, bAllocBuffers: BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAllocateBuffers: fn( self: *const ITAllocatorProperties, pbAllocBuffers: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetBufferSize: fn( self: *const ITAllocatorProperties, BufferSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetBufferSize: fn( self: *const ITAllocatorProperties, pBufferSize: ?*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 ITAllocatorProperties_SetAllocatorProperties(self: *const T, pAllocProperties: ?*ALLOCATOR_PROPERTIES) callconv(.Inline) HRESULT { return @ptrCast(*const ITAllocatorProperties.VTable, self.vtable).SetAllocatorProperties(@ptrCast(*const ITAllocatorProperties, self), pAllocProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAllocatorProperties_GetAllocatorProperties(self: *const T, pAllocProperties: ?*ALLOCATOR_PROPERTIES) callconv(.Inline) HRESULT { return @ptrCast(*const ITAllocatorProperties.VTable, self.vtable).GetAllocatorProperties(@ptrCast(*const ITAllocatorProperties, self), pAllocProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAllocatorProperties_SetAllocateBuffers(self: *const T, bAllocBuffers: BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const ITAllocatorProperties.VTable, self.vtable).SetAllocateBuffers(@ptrCast(*const ITAllocatorProperties, self), bAllocBuffers); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAllocatorProperties_GetAllocateBuffers(self: *const T, pbAllocBuffers: ?*BOOL) callconv(.Inline) HRESULT { return @ptrCast(*const ITAllocatorProperties.VTable, self.vtable).GetAllocateBuffers(@ptrCast(*const ITAllocatorProperties, self), pbAllocBuffers); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAllocatorProperties_SetBufferSize(self: *const T, BufferSize: u32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAllocatorProperties.VTable, self.vtable).SetBufferSize(@ptrCast(*const ITAllocatorProperties, self), BufferSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITAllocatorProperties_GetBufferSize(self: *const T, pBufferSize: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const ITAllocatorProperties.VTable, self.vtable).GetBufferSize(@ptrCast(*const ITAllocatorProperties, self), pBufferSize); } };} pub usingnamespace MethodMixin(@This()); }; pub const MSP_ADDRESS_EVENT = enum(i32) { AVAILABLE = 0, UNAVAILABLE = 1, }; pub const ADDRESS_TERMINAL_AVAILABLE = MSP_ADDRESS_EVENT.AVAILABLE; pub const ADDRESS_TERMINAL_UNAVAILABLE = MSP_ADDRESS_EVENT.UNAVAILABLE; pub const MSP_CALL_EVENT = enum(i32) { NEW_STREAM = 0, STREAM_FAIL = 1, TERMINAL_FAIL = 2, STREAM_NOT_USED = 3, STREAM_ACTIVE = 4, STREAM_INACTIVE = 5, }; pub const CALL_NEW_STREAM = MSP_CALL_EVENT.NEW_STREAM; pub const CALL_STREAM_FAIL = MSP_CALL_EVENT.STREAM_FAIL; pub const CALL_TERMINAL_FAIL = MSP_CALL_EVENT.TERMINAL_FAIL; pub const CALL_STREAM_NOT_USED = MSP_CALL_EVENT.STREAM_NOT_USED; pub const CALL_STREAM_ACTIVE = MSP_CALL_EVENT.STREAM_ACTIVE; pub const CALL_STREAM_INACTIVE = MSP_CALL_EVENT.STREAM_INACTIVE; pub const MSP_CALL_EVENT_CAUSE = enum(i32) { UNKNOWN = 0, BAD_DEVICE = 1, CONNECT_FAIL = 2, LOCAL_REQUEST = 3, REMOTE_REQUEST = 4, MEDIA_TIMEOUT = 5, MEDIA_RECOVERED = 6, QUALITY_OF_SERVICE = 7, }; pub const CALL_CAUSE_UNKNOWN = MSP_CALL_EVENT_CAUSE.UNKNOWN; pub const CALL_CAUSE_BAD_DEVICE = MSP_CALL_EVENT_CAUSE.BAD_DEVICE; pub const CALL_CAUSE_CONNECT_FAIL = MSP_CALL_EVENT_CAUSE.CONNECT_FAIL; pub const CALL_CAUSE_LOCAL_REQUEST = MSP_CALL_EVENT_CAUSE.LOCAL_REQUEST; pub const CALL_CAUSE_REMOTE_REQUEST = MSP_CALL_EVENT_CAUSE.REMOTE_REQUEST; pub const CALL_CAUSE_MEDIA_TIMEOUT = MSP_CALL_EVENT_CAUSE.MEDIA_TIMEOUT; pub const CALL_CAUSE_MEDIA_RECOVERED = MSP_CALL_EVENT_CAUSE.MEDIA_RECOVERED; pub const CALL_CAUSE_QUALITY_OF_SERVICE = MSP_CALL_EVENT_CAUSE.QUALITY_OF_SERVICE; pub const MSP_EVENT = enum(i32) { ADDRESS_EVENT = 0, CALL_EVENT = 1, TSP_DATA = 2, PRIVATE_EVENT = 3, ASR_TERMINAL_EVENT = 4, TTS_TERMINAL_EVENT = 5, FILE_TERMINAL_EVENT = 6, TONE_TERMINAL_EVENT = 7, }; pub const ME_ADDRESS_EVENT = MSP_EVENT.ADDRESS_EVENT; pub const ME_CALL_EVENT = MSP_EVENT.CALL_EVENT; pub const ME_TSP_DATA = MSP_EVENT.TSP_DATA; pub const ME_PRIVATE_EVENT = MSP_EVENT.PRIVATE_EVENT; pub const ME_ASR_TERMINAL_EVENT = MSP_EVENT.ASR_TERMINAL_EVENT; pub const ME_TTS_TERMINAL_EVENT = MSP_EVENT.TTS_TERMINAL_EVENT; pub const ME_FILE_TERMINAL_EVENT = MSP_EVENT.FILE_TERMINAL_EVENT; pub const ME_TONE_TERMINAL_EVENT = MSP_EVENT.TONE_TERMINAL_EVENT; pub const MSP_EVENT_INFO = extern struct { dwSize: u32, Event: MSP_EVENT, hCall: ?*i32, Anonymous: extern union { MSP_ADDRESS_EVENT_INFO: extern struct { Type: MSP_ADDRESS_EVENT, pTerminal: ?*ITTerminal, }, MSP_CALL_EVENT_INFO: extern struct { Type: MSP_CALL_EVENT, Cause: MSP_CALL_EVENT_CAUSE, pStream: ?*ITStream, pTerminal: ?*ITTerminal, hrError: HRESULT, }, MSP_TSP_DATA: extern struct { dwBufferSize: u32, pBuffer: [1]u8, }, MSP_PRIVATE_EVENT_INFO: extern struct { pEvent: ?*IDispatch, lEventCode: i32, }, MSP_FILE_TERMINAL_EVENT_INFO: extern struct { pParentFileTerminal: ?*ITTerminal, pFileTrack: ?*ITFileTrack, TerminalMediaState: TERMINAL_MEDIA_STATE, ftecEventCause: FT_STATE_EVENT_CAUSE, hrErrorCode: HRESULT, }, MSP_ASR_TERMINAL_EVENT_INFO: extern struct { pASRTerminal: ?*ITTerminal, hrErrorCode: HRESULT, }, MSP_TTS_TERMINAL_EVENT_INFO: extern struct { pTTSTerminal: ?*ITTerminal, hrErrorCode: HRESULT, }, MSP_TONE_TERMINAL_EVENT_INFO: extern struct { pToneTerminal: ?*ITTerminal, hrErrorCode: HRESULT, }, }, }; const IID_ITPluggableTerminalEventSink_Value = @import("../zig.zig").Guid.initString("6e0887be-ba1a-492e-bd10-4020ec5e33e0"); pub const IID_ITPluggableTerminalEventSink = &IID_ITPluggableTerminalEventSink_Value; pub const ITPluggableTerminalEventSink = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, FireEvent: fn( self: *const ITPluggableTerminalEventSink, pMspEventInfo: ?*const MSP_EVENT_INFO, ) 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 ITPluggableTerminalEventSink_FireEvent(self: *const T, pMspEventInfo: ?*const MSP_EVENT_INFO) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalEventSink.VTable, self.vtable).FireEvent(@ptrCast(*const ITPluggableTerminalEventSink, self), pMspEventInfo); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITPluggableTerminalEventSinkRegistration_Value = @import("../zig.zig").Guid.initString("f7115709-a216-4957-a759-060ab32a90d1"); pub const IID_ITPluggableTerminalEventSinkRegistration = &IID_ITPluggableTerminalEventSinkRegistration_Value; pub const ITPluggableTerminalEventSinkRegistration = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, RegisterSink: fn( self: *const ITPluggableTerminalEventSinkRegistration, pEventSink: ?*ITPluggableTerminalEventSink, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UnregisterSink: fn( self: *const ITPluggableTerminalEventSinkRegistration, ) 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 ITPluggableTerminalEventSinkRegistration_RegisterSink(self: *const T, pEventSink: ?*ITPluggableTerminalEventSink) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalEventSinkRegistration.VTable, self.vtable).RegisterSink(@ptrCast(*const ITPluggableTerminalEventSinkRegistration, self), pEventSink); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITPluggableTerminalEventSinkRegistration_UnregisterSink(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITPluggableTerminalEventSinkRegistration.VTable, self.vtable).UnregisterSink(@ptrCast(*const ITPluggableTerminalEventSinkRegistration, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITMSPAddress_Value = @import("../zig.zig").Guid.initString("ee3bd600-3868-11d2-a045-00c04fb6809f"); pub const IID_ITMSPAddress = &IID_ITMSPAddress_Value; pub const ITMSPAddress = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Initialize: fn( self: *const ITMSPAddress, hEvent: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Shutdown: fn( self: *const ITMSPAddress, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateMSPCall: fn( self: *const ITMSPAddress, hCall: ?*i32, dwReserved: u32, dwMediaType: u32, pOuterUnknown: ?*IUnknown, ppStreamControl: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ShutdownMSPCall: fn( self: *const ITMSPAddress, pStreamControl: ?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveTSPData: fn( self: *const ITMSPAddress, pMSPCall: ?*IUnknown, pBuffer: [*:0]u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetEvent: fn( self: *const ITMSPAddress, pdwSize: ?*u32, pEventBuffer: [*:0]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 ITMSPAddress_Initialize(self: *const T, hEvent: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITMSPAddress.VTable, self.vtable).Initialize(@ptrCast(*const ITMSPAddress, self), hEvent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMSPAddress_Shutdown(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const ITMSPAddress.VTable, self.vtable).Shutdown(@ptrCast(*const ITMSPAddress, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMSPAddress_CreateMSPCall(self: *const T, hCall: ?*i32, dwReserved: u32, dwMediaType: u32, pOuterUnknown: ?*IUnknown, ppStreamControl: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const ITMSPAddress.VTable, self.vtable).CreateMSPCall(@ptrCast(*const ITMSPAddress, self), hCall, dwReserved, dwMediaType, pOuterUnknown, ppStreamControl); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMSPAddress_ShutdownMSPCall(self: *const T, pStreamControl: ?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const ITMSPAddress.VTable, self.vtable).ShutdownMSPCall(@ptrCast(*const ITMSPAddress, self), pStreamControl); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMSPAddress_ReceiveTSPData(self: *const T, pMSPCall: ?*IUnknown, pBuffer: [*:0]u8, dwSize: u32) callconv(.Inline) HRESULT { return @ptrCast(*const ITMSPAddress.VTable, self.vtable).ReceiveTSPData(@ptrCast(*const ITMSPAddress, self), pMSPCall, pBuffer, dwSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITMSPAddress_GetEvent(self: *const T, pdwSize: ?*u32, pEventBuffer: [*:0]u8) callconv(.Inline) HRESULT { return @ptrCast(*const ITMSPAddress.VTable, self.vtable).GetEvent(@ptrCast(*const ITMSPAddress, self), pdwSize, pEventBuffer); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITTAPIDispatchEventNotification_Value = @import("../zig.zig").Guid.initString("9f34325b-7e62-11d2-9457-00c04f8ec888"); pub const IID_ITTAPIDispatchEventNotification = &IID_ITTAPIDispatchEventNotification_Value; pub const ITTAPIDispatchEventNotification = 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()); }; const CLSID_Rendezvous_Value = @import("../zig.zig").Guid.initString("f1029e5b-cb5b-11d0-8d59-00c04fd91ac0"); pub const CLSID_Rendezvous = &CLSID_Rendezvous_Value; pub const DIRECTORY_TYPE = enum(i32) { NTDS = 1, ILS = 2, }; pub const DT_NTDS = DIRECTORY_TYPE.NTDS; pub const DT_ILS = DIRECTORY_TYPE.ILS; pub const DIRECTORY_OBJECT_TYPE = enum(i32) { CONFERENCE = 1, USER = 2, }; pub const OT_CONFERENCE = DIRECTORY_OBJECT_TYPE.CONFERENCE; pub const OT_USER = DIRECTORY_OBJECT_TYPE.USER; pub const RND_ADVERTISING_SCOPE = enum(i32) { LOCAL = 1, SITE = 2, REGION = 3, WORLD = 4, }; pub const RAS_LOCAL = RND_ADVERTISING_SCOPE.LOCAL; pub const RAS_SITE = RND_ADVERTISING_SCOPE.SITE; pub const RAS_REGION = RND_ADVERTISING_SCOPE.REGION; pub const RAS_WORLD = RND_ADVERTISING_SCOPE.WORLD; const IID_ITDirectoryObjectConference_Value = @import("../zig.zig").Guid.initString("f1029e5d-cb5b-11d0-8d59-00c04fd91ac0"); pub const IID_ITDirectoryObjectConference = &IID_ITDirectoryObjectConference_Value; pub const ITDirectoryObjectConference = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Protocol: fn( self: *const ITDirectoryObjectConference, ppProtocol: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Originator: fn( self: *const ITDirectoryObjectConference, ppOriginator: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Originator: fn( self: *const ITDirectoryObjectConference, pOriginator: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdvertisingScope: fn( self: *const ITDirectoryObjectConference, pAdvertisingScope: ?*RND_ADVERTISING_SCOPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AdvertisingScope: fn( self: *const ITDirectoryObjectConference, AdvertisingScope: RND_ADVERTISING_SCOPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Url: fn( self: *const ITDirectoryObjectConference, ppUrl: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Url: fn( self: *const ITDirectoryObjectConference, pUrl: ?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 ITDirectoryObjectConference, ppDescription: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Description: fn( self: *const ITDirectoryObjectConference, pDescription: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsEncrypted: fn( self: *const ITDirectoryObjectConference, pfEncrypted: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_IsEncrypted: fn( self: *const ITDirectoryObjectConference, fEncrypted: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_StartTime: fn( self: *const ITDirectoryObjectConference, pDate: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_StartTime: fn( self: *const ITDirectoryObjectConference, Date: f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_StopTime: fn( self: *const ITDirectoryObjectConference, pDate: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_StopTime: fn( self: *const ITDirectoryObjectConference, Date: f64, ) 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 ITDirectoryObjectConference_get_Protocol(self: *const T, ppProtocol: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).get_Protocol(@ptrCast(*const ITDirectoryObjectConference, self), ppProtocol); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_get_Originator(self: *const T, ppOriginator: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).get_Originator(@ptrCast(*const ITDirectoryObjectConference, self), ppOriginator); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_put_Originator(self: *const T, pOriginator: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).put_Originator(@ptrCast(*const ITDirectoryObjectConference, self), pOriginator); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_get_AdvertisingScope(self: *const T, pAdvertisingScope: ?*RND_ADVERTISING_SCOPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).get_AdvertisingScope(@ptrCast(*const ITDirectoryObjectConference, self), pAdvertisingScope); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_put_AdvertisingScope(self: *const T, AdvertisingScope: RND_ADVERTISING_SCOPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).put_AdvertisingScope(@ptrCast(*const ITDirectoryObjectConference, self), AdvertisingScope); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_get_Url(self: *const T, ppUrl: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).get_Url(@ptrCast(*const ITDirectoryObjectConference, self), ppUrl); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_put_Url(self: *const T, pUrl: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).put_Url(@ptrCast(*const ITDirectoryObjectConference, self), pUrl); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_get_Description(self: *const T, ppDescription: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).get_Description(@ptrCast(*const ITDirectoryObjectConference, self), ppDescription); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_put_Description(self: *const T, pDescription: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).put_Description(@ptrCast(*const ITDirectoryObjectConference, self), pDescription); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_get_IsEncrypted(self: *const T, pfEncrypted: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).get_IsEncrypted(@ptrCast(*const ITDirectoryObjectConference, self), pfEncrypted); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_put_IsEncrypted(self: *const T, fEncrypted: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).put_IsEncrypted(@ptrCast(*const ITDirectoryObjectConference, self), fEncrypted); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_get_StartTime(self: *const T, pDate: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).get_StartTime(@ptrCast(*const ITDirectoryObjectConference, self), pDate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_put_StartTime(self: *const T, Date: f64) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).put_StartTime(@ptrCast(*const ITDirectoryObjectConference, self), Date); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_get_StopTime(self: *const T, pDate: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).get_StopTime(@ptrCast(*const ITDirectoryObjectConference, self), pDate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectConference_put_StopTime(self: *const T, Date: f64) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectConference.VTable, self.vtable).put_StopTime(@ptrCast(*const ITDirectoryObjectConference, self), Date); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITDirectoryObjectUser_Value = @import("../zig.zig").Guid.initString("34621d6f-6cff-11d1-aff7-00c04fc31fee"); pub const IID_ITDirectoryObjectUser = &IID_ITDirectoryObjectUser_Value; pub const ITDirectoryObjectUser = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IPPhonePrimary: fn( self: *const ITDirectoryObjectUser, ppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_IPPhonePrimary: fn( self: *const ITDirectoryObjectUser, pName: ?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 ITDirectoryObjectUser_get_IPPhonePrimary(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectUser.VTable, self.vtable).get_IPPhonePrimary(@ptrCast(*const ITDirectoryObjectUser, self), ppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObjectUser_put_IPPhonePrimary(self: *const T, pName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObjectUser.VTable, self.vtable).put_IPPhonePrimary(@ptrCast(*const ITDirectoryObjectUser, self), pName); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumDialableAddrs_Value = @import("../zig.zig").Guid.initString("34621d70-6cff-11d1-aff7-00c04fc31fee"); pub const IID_IEnumDialableAddrs = &IID_IEnumDialableAddrs_Value; pub const IEnumDialableAddrs = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumDialableAddrs, celt: u32, ppElements: [*]?BSTR, pcFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumDialableAddrs, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumDialableAddrs, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumDialableAddrs, ppEnum: ?*?*IEnumDialableAddrs, ) 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 IEnumDialableAddrs_Next(self: *const T, celt: u32, ppElements: [*]?BSTR, pcFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDialableAddrs.VTable, self.vtable).Next(@ptrCast(*const IEnumDialableAddrs, self), celt, ppElements, pcFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDialableAddrs_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDialableAddrs.VTable, self.vtable).Reset(@ptrCast(*const IEnumDialableAddrs, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDialableAddrs_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDialableAddrs.VTable, self.vtable).Skip(@ptrCast(*const IEnumDialableAddrs, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDialableAddrs_Clone(self: *const T, ppEnum: ?*?*IEnumDialableAddrs) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDialableAddrs.VTable, self.vtable).Clone(@ptrCast(*const IEnumDialableAddrs, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITDirectoryObject_Value = @import("../zig.zig").Guid.initString("34621d6e-6cff-11d1-aff7-00c04fc31fee"); pub const IID_ITDirectoryObject = &IID_ITDirectoryObject_Value; pub const ITDirectoryObject = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ObjectType: fn( self: *const ITDirectoryObject, pObjectType: ?*DIRECTORY_OBJECT_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const ITDirectoryObject, ppName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const ITDirectoryObject, pName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DialableAddrs: fn( self: *const ITDirectoryObject, dwAddressType: i32, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateDialableAddrs: fn( self: *const ITDirectoryObject, dwAddressType: u32, ppEnumDialableAddrs: ?*?*IEnumDialableAddrs, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SecurityDescriptor: fn( self: *const ITDirectoryObject, ppSecDes: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SecurityDescriptor: fn( self: *const ITDirectoryObject, pSecDes: ?*IDispatch, ) 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 ITDirectoryObject_get_ObjectType(self: *const T, pObjectType: ?*DIRECTORY_OBJECT_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObject.VTable, self.vtable).get_ObjectType(@ptrCast(*const ITDirectoryObject, self), pObjectType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObject_get_Name(self: *const T, ppName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObject.VTable, self.vtable).get_Name(@ptrCast(*const ITDirectoryObject, self), ppName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObject_put_Name(self: *const T, pName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObject.VTable, self.vtable).put_Name(@ptrCast(*const ITDirectoryObject, self), pName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObject_get_DialableAddrs(self: *const T, dwAddressType: i32, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObject.VTable, self.vtable).get_DialableAddrs(@ptrCast(*const ITDirectoryObject, self), dwAddressType, pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObject_EnumerateDialableAddrs(self: *const T, dwAddressType: u32, ppEnumDialableAddrs: ?*?*IEnumDialableAddrs) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObject.VTable, self.vtable).EnumerateDialableAddrs(@ptrCast(*const ITDirectoryObject, self), dwAddressType, ppEnumDialableAddrs); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObject_get_SecurityDescriptor(self: *const T, ppSecDes: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObject.VTable, self.vtable).get_SecurityDescriptor(@ptrCast(*const ITDirectoryObject, self), ppSecDes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectoryObject_put_SecurityDescriptor(self: *const T, pSecDes: ?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectoryObject.VTable, self.vtable).put_SecurityDescriptor(@ptrCast(*const ITDirectoryObject, self), pSecDes); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumDirectoryObject_Value = @import("../zig.zig").Guid.initString("06c9b64a-306d-11d1-9774-00c04fd91ac0"); pub const IID_IEnumDirectoryObject = &IID_IEnumDirectoryObject_Value; pub const IEnumDirectoryObject = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumDirectoryObject, celt: u32, pVal: [*]?*ITDirectoryObject, pcFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumDirectoryObject, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumDirectoryObject, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumDirectoryObject, ppEnum: ?*?*IEnumDirectoryObject, ) 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 IEnumDirectoryObject_Next(self: *const T, celt: u32, pVal: [*]?*ITDirectoryObject, pcFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDirectoryObject.VTable, self.vtable).Next(@ptrCast(*const IEnumDirectoryObject, self), celt, pVal, pcFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDirectoryObject_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDirectoryObject.VTable, self.vtable).Reset(@ptrCast(*const IEnumDirectoryObject, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDirectoryObject_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDirectoryObject.VTable, self.vtable).Skip(@ptrCast(*const IEnumDirectoryObject, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDirectoryObject_Clone(self: *const T, ppEnum: ?*?*IEnumDirectoryObject) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDirectoryObject.VTable, self.vtable).Clone(@ptrCast(*const IEnumDirectoryObject, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITILSConfig_Value = @import("../zig.zig").Guid.initString("34621d72-6cff-11d1-aff7-00c04fc31fee"); pub const IID_ITILSConfig = &IID_ITILSConfig_Value; pub const ITILSConfig = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Port: fn( self: *const ITILSConfig, pPort: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Port: fn( self: *const ITILSConfig, Port: 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 ITILSConfig_get_Port(self: *const T, pPort: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITILSConfig.VTable, self.vtable).get_Port(@ptrCast(*const ITILSConfig, self), pPort); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITILSConfig_put_Port(self: *const T, Port: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITILSConfig.VTable, self.vtable).put_Port(@ptrCast(*const ITILSConfig, self), Port); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITDirectory_Value = @import("../zig.zig").Guid.initString("34621d6c-6cff-11d1-aff7-00c04fc31fee"); pub const IID_ITDirectory = &IID_ITDirectory_Value; pub const ITDirectory = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DirectoryType: fn( self: *const ITDirectory, pDirectoryType: ?*DIRECTORY_TYPE, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DisplayName: fn( self: *const ITDirectory, pName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsDynamic: fn( self: *const ITDirectory, pfDynamic: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DefaultObjectTTL: fn( self: *const ITDirectory, pTTL: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DefaultObjectTTL: fn( self: *const ITDirectory, TTL: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnableAutoRefresh: fn( self: *const ITDirectory, fEnable: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Connect: fn( self: *const ITDirectory, fSecure: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Bind: fn( self: *const ITDirectory, pDomainName: ?BSTR, pUserName: ?BSTR, pPassword: ?BSTR, lFlags: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddDirectoryObject: fn( self: *const ITDirectory, pDirectoryObject: ?*ITDirectoryObject, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ModifyDirectoryObject: fn( self: *const ITDirectory, pDirectoryObject: ?*ITDirectoryObject, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RefreshDirectoryObject: fn( self: *const ITDirectory, pDirectoryObject: ?*ITDirectoryObject, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeleteDirectoryObject: fn( self: *const ITDirectory, pDirectoryObject: ?*ITDirectoryObject, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DirectoryObjects: fn( self: *const ITDirectory, DirectoryObjectType: DIRECTORY_OBJECT_TYPE, pName: ?BSTR, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateDirectoryObjects: fn( self: *const ITDirectory, DirectoryObjectType: DIRECTORY_OBJECT_TYPE, pName: ?BSTR, ppEnumObject: ?*?*IEnumDirectoryObject, ) 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 ITDirectory_get_DirectoryType(self: *const T, pDirectoryType: ?*DIRECTORY_TYPE) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).get_DirectoryType(@ptrCast(*const ITDirectory, self), pDirectoryType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_get_DisplayName(self: *const T, pName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).get_DisplayName(@ptrCast(*const ITDirectory, self), pName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_get_IsDynamic(self: *const T, pfDynamic: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).get_IsDynamic(@ptrCast(*const ITDirectory, self), pfDynamic); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_get_DefaultObjectTTL(self: *const T, pTTL: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).get_DefaultObjectTTL(@ptrCast(*const ITDirectory, self), pTTL); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_put_DefaultObjectTTL(self: *const T, TTL: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).put_DefaultObjectTTL(@ptrCast(*const ITDirectory, self), TTL); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_EnableAutoRefresh(self: *const T, fEnable: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).EnableAutoRefresh(@ptrCast(*const ITDirectory, self), fEnable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_Connect(self: *const T, fSecure: i16) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).Connect(@ptrCast(*const ITDirectory, self), fSecure); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_Bind(self: *const T, pDomainName: ?BSTR, pUserName: ?BSTR, pPassword: ?BSTR, lFlags: i32) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).Bind(@ptrCast(*const ITDirectory, self), pDomainName, pUserName, pPassword, lFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_AddDirectoryObject(self: *const T, pDirectoryObject: ?*ITDirectoryObject) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).AddDirectoryObject(@ptrCast(*const ITDirectory, self), pDirectoryObject); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_ModifyDirectoryObject(self: *const T, pDirectoryObject: ?*ITDirectoryObject) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).ModifyDirectoryObject(@ptrCast(*const ITDirectory, self), pDirectoryObject); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_RefreshDirectoryObject(self: *const T, pDirectoryObject: ?*ITDirectoryObject) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).RefreshDirectoryObject(@ptrCast(*const ITDirectory, self), pDirectoryObject); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_DeleteDirectoryObject(self: *const T, pDirectoryObject: ?*ITDirectoryObject) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).DeleteDirectoryObject(@ptrCast(*const ITDirectory, self), pDirectoryObject); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_get_DirectoryObjects(self: *const T, DirectoryObjectType: DIRECTORY_OBJECT_TYPE, pName: ?BSTR, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).get_DirectoryObjects(@ptrCast(*const ITDirectory, self), DirectoryObjectType, pName, pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITDirectory_EnumerateDirectoryObjects(self: *const T, DirectoryObjectType: DIRECTORY_OBJECT_TYPE, pName: ?BSTR, ppEnumObject: ?*?*IEnumDirectoryObject) callconv(.Inline) HRESULT { return @ptrCast(*const ITDirectory.VTable, self.vtable).EnumerateDirectoryObjects(@ptrCast(*const ITDirectory, self), DirectoryObjectType, pName, ppEnumObject); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumDirectory_Value = @import("../zig.zig").Guid.initString("34621d6d-6cff-11d1-aff7-00c04fc31fee"); pub const IID_IEnumDirectory = &IID_IEnumDirectory_Value; pub const IEnumDirectory = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumDirectory, celt: u32, ppElements: [*]?*ITDirectory, pcFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumDirectory, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumDirectory, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumDirectory, ppEnum: ?*?*IEnumDirectory, ) 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 IEnumDirectory_Next(self: *const T, celt: u32, ppElements: [*]?*ITDirectory, pcFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDirectory.VTable, self.vtable).Next(@ptrCast(*const IEnumDirectory, self), celt, ppElements, pcFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDirectory_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDirectory.VTable, self.vtable).Reset(@ptrCast(*const IEnumDirectory, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDirectory_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDirectory.VTable, self.vtable).Skip(@ptrCast(*const IEnumDirectory, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumDirectory_Clone(self: *const T, ppEnum: ?*?*IEnumDirectory) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumDirectory.VTable, self.vtable).Clone(@ptrCast(*const IEnumDirectory, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_ITRendezvous_Value = @import("../zig.zig").Guid.initString("34621d6b-6cff-11d1-aff7-00c04fc31fee"); pub const IID_ITRendezvous = &IID_ITRendezvous_Value; pub const ITRendezvous = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DefaultDirectories: fn( self: *const ITRendezvous, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateDefaultDirectories: fn( self: *const ITRendezvous, ppEnumDirectory: ?*?*IEnumDirectory, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateDirectory: fn( self: *const ITRendezvous, DirectoryType: DIRECTORY_TYPE, pName: ?BSTR, ppDir: ?*?*ITDirectory, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateDirectoryObject: fn( self: *const ITRendezvous, DirectoryObjectType: DIRECTORY_OBJECT_TYPE, pName: ?BSTR, ppDirectoryObject: ?*?*ITDirectoryObject, ) 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 ITRendezvous_get_DefaultDirectories(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const ITRendezvous.VTable, self.vtable).get_DefaultDirectories(@ptrCast(*const ITRendezvous, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITRendezvous_EnumerateDefaultDirectories(self: *const T, ppEnumDirectory: ?*?*IEnumDirectory) callconv(.Inline) HRESULT { return @ptrCast(*const ITRendezvous.VTable, self.vtable).EnumerateDefaultDirectories(@ptrCast(*const ITRendezvous, self), ppEnumDirectory); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITRendezvous_CreateDirectory(self: *const T, DirectoryType: DIRECTORY_TYPE, pName: ?BSTR, ppDir: ?*?*ITDirectory) callconv(.Inline) HRESULT { return @ptrCast(*const ITRendezvous.VTable, self.vtable).CreateDirectory(@ptrCast(*const ITRendezvous, self), DirectoryType, pName, ppDir); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITRendezvous_CreateDirectoryObject(self: *const T, DirectoryObjectType: DIRECTORY_OBJECT_TYPE, pName: ?BSTR, ppDirectoryObject: ?*?*ITDirectoryObject) callconv(.Inline) HRESULT { return @ptrCast(*const ITRendezvous.VTable, self.vtable).CreateDirectoryObject(@ptrCast(*const ITRendezvous, self), DirectoryObjectType, pName, ppDirectoryObject); } };} pub usingnamespace MethodMixin(@This()); }; const CLSID_McastAddressAllocation_Value = @import("../zig.zig").Guid.initString("df0daef2-a289-11d1-8697-006008b0e5d2"); pub const CLSID_McastAddressAllocation = &CLSID_McastAddressAllocation_Value; const IID_IMcastScope_Value = @import("../zig.zig").Guid.initString("df0daef4-a289-11d1-8697-006008b0e5d2"); pub const IID_IMcastScope = &IID_IMcastScope_Value; pub const IMcastScope = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ScopeID: fn( self: *const IMcastScope, pID: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServerID: fn( self: *const IMcastScope, pID: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_InterfaceID: fn( self: *const IMcastScope, pID: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ScopeDescription: fn( self: *const IMcastScope, ppDescription: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TTL: fn( self: *const IMcastScope, pTTL: ?*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 IMcastScope_get_ScopeID(self: *const T, pID: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastScope.VTable, self.vtable).get_ScopeID(@ptrCast(*const IMcastScope, self), pID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastScope_get_ServerID(self: *const T, pID: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastScope.VTable, self.vtable).get_ServerID(@ptrCast(*const IMcastScope, self), pID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastScope_get_InterfaceID(self: *const T, pID: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastScope.VTable, self.vtable).get_InterfaceID(@ptrCast(*const IMcastScope, self), pID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastScope_get_ScopeDescription(self: *const T, ppDescription: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastScope.VTable, self.vtable).get_ScopeDescription(@ptrCast(*const IMcastScope, self), ppDescription); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastScope_get_TTL(self: *const T, pTTL: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastScope.VTable, self.vtable).get_TTL(@ptrCast(*const IMcastScope, self), pTTL); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMcastLeaseInfo_Value = @import("../zig.zig").Guid.initString("df0daefd-a289-11d1-8697-006008b0e5d2"); pub const IID_IMcastLeaseInfo = &IID_IMcastLeaseInfo_Value; pub const IMcastLeaseInfo = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RequestID: fn( self: *const IMcastLeaseInfo, ppRequestID: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LeaseStartTime: fn( self: *const IMcastLeaseInfo, pTime: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_LeaseStartTime: fn( self: *const IMcastLeaseInfo, time: f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LeaseStopTime: fn( self: *const IMcastLeaseInfo, pTime: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_LeaseStopTime: fn( self: *const IMcastLeaseInfo, time: f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AddressCount: fn( self: *const IMcastLeaseInfo, pCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServerAddress: fn( self: *const IMcastLeaseInfo, ppAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TTL: fn( self: *const IMcastLeaseInfo, pTTL: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Addresses: fn( self: *const IMcastLeaseInfo, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateAddresses: fn( self: *const IMcastLeaseInfo, ppEnumAddresses: ?*?*IEnumBstr, ) 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 IMcastLeaseInfo_get_RequestID(self: *const T, ppRequestID: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).get_RequestID(@ptrCast(*const IMcastLeaseInfo, self), ppRequestID); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_get_LeaseStartTime(self: *const T, pTime: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).get_LeaseStartTime(@ptrCast(*const IMcastLeaseInfo, self), pTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_put_LeaseStartTime(self: *const T, time: f64) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).put_LeaseStartTime(@ptrCast(*const IMcastLeaseInfo, self), time); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_get_LeaseStopTime(self: *const T, pTime: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).get_LeaseStopTime(@ptrCast(*const IMcastLeaseInfo, self), pTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_put_LeaseStopTime(self: *const T, time: f64) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).put_LeaseStopTime(@ptrCast(*const IMcastLeaseInfo, self), time); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_get_AddressCount(self: *const T, pCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).get_AddressCount(@ptrCast(*const IMcastLeaseInfo, self), pCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_get_ServerAddress(self: *const T, ppAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).get_ServerAddress(@ptrCast(*const IMcastLeaseInfo, self), ppAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_get_TTL(self: *const T, pTTL: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).get_TTL(@ptrCast(*const IMcastLeaseInfo, self), pTTL); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_get_Addresses(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).get_Addresses(@ptrCast(*const IMcastLeaseInfo, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastLeaseInfo_EnumerateAddresses(self: *const T, ppEnumAddresses: ?*?*IEnumBstr) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastLeaseInfo.VTable, self.vtable).EnumerateAddresses(@ptrCast(*const IMcastLeaseInfo, self), ppEnumAddresses); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IEnumMcastScope_Value = @import("../zig.zig").Guid.initString("df0daf09-a289-11d1-8697-006008b0e5d2"); pub const IID_IEnumMcastScope = &IID_IEnumMcastScope_Value; pub const IEnumMcastScope = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Next: fn( self: *const IEnumMcastScope, celt: u32, ppScopes: ?*?*IMcastScope, pceltFetched: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IEnumMcastScope, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Skip: fn( self: *const IEnumMcastScope, celt: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IEnumMcastScope, ppEnum: ?*?*IEnumMcastScope, ) 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 IEnumMcastScope_Next(self: *const T, celt: u32, ppScopes: ?*?*IMcastScope, pceltFetched: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumMcastScope.VTable, self.vtable).Next(@ptrCast(*const IEnumMcastScope, self), celt, ppScopes, pceltFetched); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumMcastScope_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumMcastScope.VTable, self.vtable).Reset(@ptrCast(*const IEnumMcastScope, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumMcastScope_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumMcastScope.VTable, self.vtable).Skip(@ptrCast(*const IEnumMcastScope, self), celt); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IEnumMcastScope_Clone(self: *const T, ppEnum: ?*?*IEnumMcastScope) callconv(.Inline) HRESULT { return @ptrCast(*const IEnumMcastScope.VTable, self.vtable).Clone(@ptrCast(*const IEnumMcastScope, self), ppEnum); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMcastAddressAllocation_Value = @import("../zig.zig").Guid.initString("df0daef1-a289-11d1-8697-006008b0e5d2"); pub const IID_IMcastAddressAllocation = &IID_IMcastAddressAllocation_Value; pub const IMcastAddressAllocation = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Scopes: fn( self: *const IMcastAddressAllocation, pVariant: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumerateScopes: fn( self: *const IMcastAddressAllocation, ppEnumMcastScope: ?*?*IEnumMcastScope, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RequestAddress: fn( self: *const IMcastAddressAllocation, pScope: ?*IMcastScope, LeaseStartTime: f64, LeaseStopTime: f64, NumAddresses: i32, ppLeaseResponse: ?*?*IMcastLeaseInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RenewAddress: fn( self: *const IMcastAddressAllocation, lReserved: i32, pRenewRequest: ?*IMcastLeaseInfo, ppRenewResponse: ?*?*IMcastLeaseInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReleaseAddress: fn( self: *const IMcastAddressAllocation, pReleaseRequest: ?*IMcastLeaseInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateLeaseInfo: fn( self: *const IMcastAddressAllocation, LeaseStartTime: f64, LeaseStopTime: f64, dwNumAddresses: u32, ppAddresses: ?*?PWSTR, pRequestID: ?PWSTR, pServerAddress: ?PWSTR, ppReleaseRequest: ?*?*IMcastLeaseInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateLeaseInfoFromVariant: fn( self: *const IMcastAddressAllocation, LeaseStartTime: f64, LeaseStopTime: f64, vAddresses: VARIANT, pRequestID: ?BSTR, pServerAddress: ?BSTR, ppReleaseRequest: ?*?*IMcastLeaseInfo, ) 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 IMcastAddressAllocation_get_Scopes(self: *const T, pVariant: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastAddressAllocation.VTable, self.vtable).get_Scopes(@ptrCast(*const IMcastAddressAllocation, self), pVariant); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastAddressAllocation_EnumerateScopes(self: *const T, ppEnumMcastScope: ?*?*IEnumMcastScope) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastAddressAllocation.VTable, self.vtable).EnumerateScopes(@ptrCast(*const IMcastAddressAllocation, self), ppEnumMcastScope); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastAddressAllocation_RequestAddress(self: *const T, pScope: ?*IMcastScope, LeaseStartTime: f64, LeaseStopTime: f64, NumAddresses: i32, ppLeaseResponse: ?*?*IMcastLeaseInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastAddressAllocation.VTable, self.vtable).RequestAddress(@ptrCast(*const IMcastAddressAllocation, self), pScope, LeaseStartTime, LeaseStopTime, NumAddresses, ppLeaseResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastAddressAllocation_RenewAddress(self: *const T, lReserved: i32, pRenewRequest: ?*IMcastLeaseInfo, ppRenewResponse: ?*?*IMcastLeaseInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastAddressAllocation.VTable, self.vtable).RenewAddress(@ptrCast(*const IMcastAddressAllocation, self), lReserved, pRenewRequest, ppRenewResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastAddressAllocation_ReleaseAddress(self: *const T, pReleaseRequest: ?*IMcastLeaseInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastAddressAllocation.VTable, self.vtable).ReleaseAddress(@ptrCast(*const IMcastAddressAllocation, self), pReleaseRequest); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastAddressAllocation_CreateLeaseInfo(self: *const T, LeaseStartTime: f64, LeaseStopTime: f64, dwNumAddresses: u32, ppAddresses: ?*?PWSTR, pRequestID: ?PWSTR, pServerAddress: ?PWSTR, ppReleaseRequest: ?*?*IMcastLeaseInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastAddressAllocation.VTable, self.vtable).CreateLeaseInfo(@ptrCast(*const IMcastAddressAllocation, self), LeaseStartTime, LeaseStopTime, dwNumAddresses, ppAddresses, pRequestID, pServerAddress, ppReleaseRequest); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMcastAddressAllocation_CreateLeaseInfoFromVariant(self: *const T, LeaseStartTime: f64, LeaseStopTime: f64, vAddresses: VARIANT, pRequestID: ?BSTR, pServerAddress: ?BSTR, ppReleaseRequest: ?*?*IMcastLeaseInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMcastAddressAllocation.VTable, self.vtable).CreateLeaseInfoFromVariant(@ptrCast(*const IMcastAddressAllocation, self), LeaseStartTime, LeaseStopTime, vAddresses, pRequestID, pServerAddress, ppReleaseRequest); } };} pub usingnamespace MethodMixin(@This()); }; pub const STnefProblem = extern struct { ulComponent: u32, ulAttribute: u32, ulPropTag: u32, scode: i32, }; pub const STnefProblemArray = extern struct { cProblem: u32, aProblem: [1]STnefProblem, }; pub const ITnef = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, AddProps: fn( self: *const ITnef, ulFlags: u32, ulElemID: u32, lpvData: ?*anyopaque, lpPropList: ?*SPropTagArray, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ExtractProps: fn( self: *const ITnef, ulFlags: u32, lpPropList: ?*SPropTagArray, lpProblems: ?*?*STnefProblemArray, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Finish: fn( self: *const ITnef, ulFlags: u32, lpKey: ?*u16, lpProblems: ?*?*STnefProblemArray, ) callconv(@import("std").os.windows.WINAPI) HRESULT, OpenTaggedBody: fn( self: *const ITnef, lpMessage: ?*IMessage, ulFlags: u32, lppStream: ?*?*IStream, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetProps: fn( self: *const ITnef, ulFlags: u32, ulElemID: u32, cValues: u32, lpProps: ?*SPropValue, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EncodeRecips: fn( self: *const ITnef, ulFlags: u32, lpRecipientTable: ?*IMAPITable, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FinishComponent: fn( self: *const ITnef, ulFlags: u32, ulComponentID: u32, lpCustomPropList: ?*SPropTagArray, lpCustomProps: ?*SPropValue, lpPropList: ?*SPropTagArray, lpProblems: ?*?*STnefProblemArray, ) 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 ITnef_AddProps(self: *const T, ulFlags: u32, ulElemID: u32, lpvData: ?*anyopaque, lpPropList: ?*SPropTagArray) callconv(.Inline) HRESULT { return @ptrCast(*const ITnef.VTable, self.vtable).AddProps(@ptrCast(*const ITnef, self), ulFlags, ulElemID, lpvData, lpPropList); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITnef_ExtractProps(self: *const T, ulFlags: u32, lpPropList: ?*SPropTagArray, lpProblems: ?*?*STnefProblemArray) callconv(.Inline) HRESULT { return @ptrCast(*const ITnef.VTable, self.vtable).ExtractProps(@ptrCast(*const ITnef, self), ulFlags, lpPropList, lpProblems); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITnef_Finish(self: *const T, ulFlags: u32, lpKey: ?*u16, lpProblems: ?*?*STnefProblemArray) callconv(.Inline) HRESULT { return @ptrCast(*const ITnef.VTable, self.vtable).Finish(@ptrCast(*const ITnef, self), ulFlags, lpKey, lpProblems); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITnef_OpenTaggedBody(self: *const T, lpMessage: ?*IMessage, ulFlags: u32, lppStream: ?*?*IStream) callconv(.Inline) HRESULT { return @ptrCast(*const ITnef.VTable, self.vtable).OpenTaggedBody(@ptrCast(*const ITnef, self), lpMessage, ulFlags, lppStream); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITnef_SetProps(self: *const T, ulFlags: u32, ulElemID: u32, cValues: u32, lpProps: ?*SPropValue) callconv(.Inline) HRESULT { return @ptrCast(*const ITnef.VTable, self.vtable).SetProps(@ptrCast(*const ITnef, self), ulFlags, ulElemID, cValues, lpProps); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITnef_EncodeRecips(self: *const T, ulFlags: u32, lpRecipientTable: ?*IMAPITable) callconv(.Inline) HRESULT { return @ptrCast(*const ITnef.VTable, self.vtable).EncodeRecips(@ptrCast(*const ITnef, self), ulFlags, lpRecipientTable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn ITnef_FinishComponent(self: *const T, ulFlags: u32, ulComponentID: u32, lpCustomPropList: ?*SPropTagArray, lpCustomProps: ?*SPropValue, lpPropList: ?*SPropTagArray, lpProblems: ?*?*STnefProblemArray) callconv(.Inline) HRESULT { return @ptrCast(*const ITnef.VTable, self.vtable).FinishComponent(@ptrCast(*const ITnef, self), ulFlags, ulComponentID, lpCustomPropList, lpCustomProps, lpPropList, lpProblems); } };} pub usingnamespace MethodMixin(@This()); }; pub const LPOPENTNEFSTREAM = fn( lpvSupport: ?*anyopaque, lpStream: ?*IStream, lpszStreamName: ?*i8, ulFlags: u32, lpMessage: ?*IMessage, wKeyVal: u16, lppTNEF: ?*?*ITnef, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const LPOPENTNEFSTREAMEX = fn( lpvSupport: ?*anyopaque, lpStream: ?*IStream, lpszStreamName: ?*i8, ulFlags: u32, lpMessage: ?*IMessage, wKeyVal: u16, lpAdressBook: ?*IAddrBook, lppTNEF: ?*?*ITnef, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const LPGETTNEFSTREAMCODEPAGE = fn( lpStream: ?*IStream, lpulCodepage: ?*u32, lpulSubCodepage: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub const _renddata = packed struct { atyp: u16, ulPosition: u32, dxWidth: u16, dyHeight: u16, dwFlags: u32, }; pub const _dtr = packed struct { wYear: u16, wMonth: u16, wDay: u16, wHour: u16, wMinute: u16, wSecond: u16, wDayOfWeek: u16, }; pub const _trp = extern struct { trpid: u16, cbgrtrp: u16, cch: u16, cbRgb: u16, }; pub const _ADDR_ALIAS = extern struct { rgchName: [41]CHAR, rgchEName: [11]CHAR, rgchSrvr: [12]CHAR, dibDetail: u32, type: u16, }; pub const NSID = extern struct { dwSize: u32, uchType: [16]u8, xtype: u32, lTime: i32, address: extern union { alias: _ADDR_ALIAS, rgchInterNet: [1]CHAR, }, }; //-------------------------------------------------------------------------------- // Section: Functions (252) //-------------------------------------------------------------------------------- pub extern "TAPI32" fn lineAccept( hCall: u32, lpsUserUserInfo: ?[*:0]const u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineAddProvider( lpszProviderFilename: ?[*:0]const u8, hwndOwner: ?HWND, lpdwPermanentProviderID: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineAddProviderA( lpszProviderFilename: ?[*:0]const u8, hwndOwner: ?HWND, lpdwPermanentProviderID: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineAddProviderW( lpszProviderFilename: ?[*:0]const u16, hwndOwner: ?HWND, lpdwPermanentProviderID: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineAddToConference( hConfCall: u32, hConsultCall: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineAgentSpecific( hLine: u32, dwAddressID: u32, dwAgentExtensionIDIndex: u32, lpParams: ?*anyopaque, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineAnswer( hCall: u32, lpsUserUserInfo: ?[*:0]const u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineBlindTransfer( hCall: u32, lpszDestAddress: ?[*:0]const u8, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineBlindTransferA( hCall: u32, lpszDestAddress: ?[*:0]const u8, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineBlindTransferW( hCall: u32, lpszDestAddressW: ?[*:0]const u16, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineClose( hLine: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineCompleteCall( hCall: u32, lpdwCompletionID: ?*u32, dwCompletionMode: u32, dwMessageID: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineCompleteTransfer( hCall: u32, hConsultCall: u32, lphConfCall: ?*u32, dwTransferMode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineConfigDialog( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineConfigDialogA( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineConfigDialogW( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineConfigDialogEdit( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u8, lpDeviceConfigIn: ?*const anyopaque, dwSize: u32, lpDeviceConfigOut: ?*VARSTRING, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineConfigDialogEditA( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u8, lpDeviceConfigIn: ?*const anyopaque, dwSize: u32, lpDeviceConfigOut: ?*VARSTRING, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineConfigDialogEditW( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u16, lpDeviceConfigIn: ?*const anyopaque, dwSize: u32, lpDeviceConfigOut: ?*VARSTRING, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineConfigProvider( hwndOwner: ?HWND, dwPermanentProviderID: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineCreateAgentW( hLine: u32, lpszAgentID: ?[*:0]const u16, lpszAgentPIN: ?[*:0]const u16, lphAgent: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineCreateAgentA( hLine: u32, lpszAgentID: ?[*:0]const u8, lpszAgentPIN: ?[*:0]const u8, lphAgent: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineCreateAgentSessionW( hLine: u32, hAgent: u32, lpszAgentPIN: ?[*:0]const u16, dwWorkingAddressID: u32, lpGroupID: ?*Guid, lphAgentSession: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineCreateAgentSessionA( hLine: u32, hAgent: u32, lpszAgentPIN: ?[*:0]const u8, dwWorkingAddressID: u32, lpGroupID: ?*Guid, lphAgentSession: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineDeallocateCall( hCall: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineDevSpecific( hLine: u32, dwAddressID: u32, hCall: u32, lpParams: ?*anyopaque, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineDevSpecificFeature( hLine: u32, dwFeature: u32, lpParams: ?*anyopaque, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineDial( hCall: u32, lpszDestAddress: ?[*:0]const u8, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineDialA( hCall: u32, lpszDestAddress: ?[*:0]const u8, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineDialW( hCall: u32, lpszDestAddress: ?[*:0]const u16, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineDrop( hCall: u32, lpsUserUserInfo: ?[*:0]const u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineForward( hLine: u32, bAllAddresses: u32, dwAddressID: u32, lpForwardList: ?*const LINEFORWARDLIST, dwNumRingsNoAnswer: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineForwardA( hLine: u32, bAllAddresses: u32, dwAddressID: u32, lpForwardList: ?*const LINEFORWARDLIST, dwNumRingsNoAnswer: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineForwardW( hLine: u32, bAllAddresses: u32, dwAddressID: u32, lpForwardList: ?*const LINEFORWARDLIST, dwNumRingsNoAnswer: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGatherDigits( hCall: u32, dwDigitModes: u32, lpsDigits: ?[*:0]u8, dwNumDigits: u32, lpszTerminationDigits: ?[*:0]const u8, dwFirstDigitTimeout: u32, dwInterDigitTimeout: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGatherDigitsA( hCall: u32, dwDigitModes: u32, lpsDigits: ?[*:0]u8, dwNumDigits: u32, lpszTerminationDigits: ?[*:0]const u8, dwFirstDigitTimeout: u32, dwInterDigitTimeout: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGatherDigitsW( hCall: u32, dwDigitModes: u32, lpsDigits: ?[*:0]u16, dwNumDigits: u32, lpszTerminationDigits: ?[*:0]const u16, dwFirstDigitTimeout: u32, dwInterDigitTimeout: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGenerateDigits( hCall: u32, dwDigitMode: u32, lpszDigits: ?[*:0]const u8, dwDuration: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGenerateDigitsA( hCall: u32, dwDigitMode: u32, lpszDigits: ?[*:0]const u8, dwDuration: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGenerateDigitsW( hCall: u32, dwDigitMode: u32, lpszDigits: ?[*:0]const u16, dwDuration: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGenerateTone( hCall: u32, dwToneMode: u32, dwDuration: u32, dwNumTones: u32, lpTones: ?*const LINEGENERATETONE, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressCaps( hLineApp: u32, dwDeviceID: u32, dwAddressID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpAddressCaps: ?*LINEADDRESSCAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressCapsA( hLineApp: u32, dwDeviceID: u32, dwAddressID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpAddressCaps: ?*LINEADDRESSCAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressCapsW( hLineApp: u32, dwDeviceID: u32, dwAddressID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpAddressCaps: ?*LINEADDRESSCAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressID( hLine: u32, lpdwAddressID: ?*u32, dwAddressMode: u32, lpsAddress: ?[*:0]const u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressIDA( hLine: u32, lpdwAddressID: ?*u32, dwAddressMode: u32, lpsAddress: ?[*:0]const u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressIDW( hLine: u32, lpdwAddressID: ?*u32, dwAddressMode: u32, lpsAddress: ?[*:0]const u16, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressStatus( hLine: u32, dwAddressID: u32, lpAddressStatus: ?*LINEADDRESSSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressStatusA( hLine: u32, dwAddressID: u32, lpAddressStatus: ?*LINEADDRESSSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAddressStatusW( hLine: u32, dwAddressID: u32, lpAddressStatus: ?*LINEADDRESSSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentActivityListA( hLine: u32, dwAddressID: u32, lpAgentActivityList: ?*LINEAGENTACTIVITYLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentActivityListW( hLine: u32, dwAddressID: u32, lpAgentActivityList: ?*LINEAGENTACTIVITYLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentCapsA( hLineApp: u32, dwDeviceID: u32, dwAddressID: u32, dwAppAPIVersion: u32, lpAgentCaps: ?*LINEAGENTCAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentCapsW( hLineApp: u32, dwDeviceID: u32, dwAddressID: u32, dwAppAPIVersion: u32, lpAgentCaps: ?*LINEAGENTCAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentGroupListA( hLine: u32, dwAddressID: u32, lpAgentGroupList: ?*LINEAGENTGROUPLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentGroupListW( hLine: u32, dwAddressID: u32, lpAgentGroupList: ?*LINEAGENTGROUPLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentInfo( hLine: u32, hAgent: u32, lpAgentInfo: ?*LINEAGENTINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentSessionInfo( hLine: u32, hAgentSession: u32, lpAgentSessionInfo: ?*LINEAGENTSESSIONINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentSessionList( hLine: u32, hAgent: u32, lpAgentSessionList: ?*LINEAGENTSESSIONLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentStatusA( hLine: u32, dwAddressID: u32, lpAgentStatus: ?*LINEAGENTSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAgentStatusW( hLine: u32, dwAddressID: u32, lpAgentStatus: ?*LINEAGENTSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAppPriority( lpszAppFilename: ?[*:0]const u8, dwMediaMode: u32, lpExtensionID: ?*LINEEXTENSIONID, dwRequestMode: u32, lpExtensionName: ?*VARSTRING, lpdwPriority: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAppPriorityA( lpszAppFilename: ?[*:0]const u8, dwMediaMode: u32, lpExtensionID: ?*LINEEXTENSIONID, dwRequestMode: u32, lpExtensionName: ?*VARSTRING, lpdwPriority: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetAppPriorityW( lpszAppFilename: ?[*:0]const u16, dwMediaMode: u32, lpExtensionID: ?*LINEEXTENSIONID, dwRequestMode: u32, lpExtensionName: ?*VARSTRING, lpdwPriority: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetCallInfo( hCall: u32, lpCallInfo: ?*LINECALLINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetCallInfoA( hCall: u32, lpCallInfo: ?*LINECALLINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetCallInfoW( hCall: u32, lpCallInfo: ?*LINECALLINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetCallStatus( hCall: u32, lpCallStatus: ?*LINECALLSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetConfRelatedCalls( hCall: u32, lpCallList: ?*LINECALLLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetCountry( dwCountryID: u32, dwAPIVersion: u32, lpLineCountryList: ?*LINECOUNTRYLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetCountryA( dwCountryID: u32, dwAPIVersion: u32, lpLineCountryList: ?*LINECOUNTRYLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetCountryW( dwCountryID: u32, dwAPIVersion: u32, lpLineCountryList: ?*LINECOUNTRYLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetDevCaps( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpLineDevCaps: ?*LINEDEVCAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetDevCapsA( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpLineDevCaps: ?*LINEDEVCAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetDevCapsW( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpLineDevCaps: ?*LINEDEVCAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetDevConfig( dwDeviceID: u32, lpDeviceConfig: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetDevConfigA( dwDeviceID: u32, lpDeviceConfig: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetDevConfigW( dwDeviceID: u32, lpDeviceConfig: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetGroupListA( hLine: u32, lpGroupList: ?*LINEAGENTGROUPLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetGroupListW( hLine: u32, lpGroupList: ?*LINEAGENTGROUPLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetIcon( dwDeviceID: u32, lpszDeviceClass: ?[*:0]const u8, lphIcon: ?*isize, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetIconA( dwDeviceID: u32, lpszDeviceClass: ?[*:0]const u8, lphIcon: ?*isize, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetIconW( dwDeviceID: u32, lpszDeviceClass: ?[*:0]const u16, lphIcon: ?*isize, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetID( hLine: u32, dwAddressID: u32, hCall: u32, dwSelect: u32, lpDeviceID: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetIDA( hLine: u32, dwAddressID: u32, hCall: u32, dwSelect: u32, lpDeviceID: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetIDW( hLine: u32, dwAddressID: u32, hCall: u32, dwSelect: u32, lpDeviceID: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetLineDevStatus( hLine: u32, lpLineDevStatus: ?*LINEDEVSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetLineDevStatusA( hLine: u32, lpLineDevStatus: ?*LINEDEVSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetLineDevStatusW( hLine: u32, lpLineDevStatus: ?*LINEDEVSTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetMessage( hLineApp: u32, lpMessage: ?*LINEMESSAGE, dwTimeout: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetNewCalls( hLine: u32, dwAddressID: u32, dwSelect: u32, lpCallList: ?*LINECALLLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetNumRings( hLine: u32, dwAddressID: u32, lpdwNumRings: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetProviderList( dwAPIVersion: u32, lpProviderList: ?*LINEPROVIDERLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetProviderListA( dwAPIVersion: u32, lpProviderList: ?*LINEPROVIDERLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetProviderListW( dwAPIVersion: u32, lpProviderList: ?*LINEPROVIDERLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetProxyStatus( hLineApp: u32, dwDeviceID: u32, dwAppAPIVersion: u32, lpLineProxyReqestList: ?*LINEPROXYREQUESTLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetQueueInfo( hLine: u32, dwQueueID: u32, lpLineQueueInfo: ?*LINEQUEUEINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetQueueListA( hLine: u32, lpGroupID: ?*Guid, lpQueueList: ?*LINEQUEUELIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetQueueListW( hLine: u32, lpGroupID: ?*Guid, lpQueueList: ?*LINEQUEUELIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetRequest( hLineApp: u32, dwRequestMode: u32, lpRequestBuffer: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetRequestA( hLineApp: u32, dwRequestMode: u32, lpRequestBuffer: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetRequestW( hLineApp: u32, dwRequestMode: u32, lpRequestBuffer: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetStatusMessages( hLine: u32, lpdwLineStates: ?*u32, lpdwAddressStates: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetTranslateCaps( hLineApp: u32, dwAPIVersion: u32, lpTranslateCaps: ?*LINETRANSLATECAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetTranslateCapsA( hLineApp: u32, dwAPIVersion: u32, lpTranslateCaps: ?*LINETRANSLATECAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineGetTranslateCapsW( hLineApp: u32, dwAPIVersion: u32, lpTranslateCaps: ?*LINETRANSLATECAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineHandoff( hCall: u32, lpszFileName: ?[*:0]const u8, dwMediaMode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineHandoffA( hCall: u32, lpszFileName: ?[*:0]const u8, dwMediaMode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineHandoffW( hCall: u32, lpszFileName: ?[*:0]const u16, dwMediaMode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineHold( hCall: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineInitialize( lphLineApp: ?*u32, hInstance: ?HINSTANCE, lpfnCallback: ?LINECALLBACK, lpszAppName: ?[*:0]const u8, lpdwNumDevs: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineInitializeExA( lphLineApp: ?*u32, hInstance: ?HINSTANCE, lpfnCallback: ?LINECALLBACK, lpszFriendlyAppName: ?[*:0]const u8, lpdwNumDevs: ?*u32, lpdwAPIVersion: ?*u32, lpLineInitializeExParams: ?*LINEINITIALIZEEXPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineInitializeExW( lphLineApp: ?*u32, hInstance: ?HINSTANCE, lpfnCallback: ?LINECALLBACK, lpszFriendlyAppName: ?[*:0]const u16, lpdwNumDevs: ?*u32, lpdwAPIVersion: ?*u32, lpLineInitializeExParams: ?*LINEINITIALIZEEXPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineMakeCall( hLine: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u8, dwCountryCode: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineMakeCallA( hLine: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u8, dwCountryCode: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineMakeCallW( hLine: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u16, dwCountryCode: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineMonitorDigits( hCall: u32, dwDigitModes: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineMonitorMedia( hCall: u32, dwMediaModes: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineMonitorTones( hCall: u32, lpToneList: ?*const LINEMONITORTONE, dwNumEntries: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineNegotiateAPIVersion( hLineApp: u32, dwDeviceID: u32, dwAPILowVersion: u32, dwAPIHighVersion: u32, lpdwAPIVersion: ?*u32, lpExtensionID: ?*LINEEXTENSIONID, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineNegotiateExtVersion( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, dwExtLowVersion: u32, dwExtHighVersion: u32, lpdwExtVersion: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineOpen( hLineApp: u32, dwDeviceID: u32, lphLine: ?*u32, dwAPIVersion: u32, dwExtVersion: u32, dwCallbackInstance: usize, dwPrivileges: u32, dwMediaModes: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineOpenA( hLineApp: u32, dwDeviceID: u32, lphLine: ?*u32, dwAPIVersion: u32, dwExtVersion: u32, dwCallbackInstance: usize, dwPrivileges: u32, dwMediaModes: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineOpenW( hLineApp: u32, dwDeviceID: u32, lphLine: ?*u32, dwAPIVersion: u32, dwExtVersion: u32, dwCallbackInstance: usize, dwPrivileges: u32, dwMediaModes: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn linePark( hCall: u32, dwParkMode: u32, lpszDirAddress: ?[*:0]const u8, lpNonDirAddress: ?*VARSTRING, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineParkA( hCall: u32, dwParkMode: u32, lpszDirAddress: ?[*:0]const u8, lpNonDirAddress: ?*VARSTRING, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineParkW( hCall: u32, dwParkMode: u32, lpszDirAddress: ?[*:0]const u16, lpNonDirAddress: ?*VARSTRING, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn linePickup( hLine: u32, dwAddressID: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u8, lpszGroupID: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn linePickupA( hLine: u32, dwAddressID: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u8, lpszGroupID: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn linePickupW( hLine: u32, dwAddressID: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u16, lpszGroupID: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn linePrepareAddToConference( hConfCall: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn linePrepareAddToConferenceA( hConfCall: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn linePrepareAddToConferenceW( hConfCall: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineProxyMessage( hLine: u32, hCall: u32, dwMsg: u32, dwParam1: u32, dwParam2: u32, dwParam3: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineProxyResponse( hLine: u32, lpProxyRequest: ?*LINEPROXYREQUEST, dwResult: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineRedirect( hCall: u32, lpszDestAddress: ?[*:0]const u8, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineRedirectA( hCall: u32, lpszDestAddress: ?[*:0]const u8, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineRedirectW( hCall: u32, lpszDestAddress: ?[*:0]const u16, dwCountryCode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineRegisterRequestRecipient( hLineApp: u32, dwRegistrationInstance: u32, dwRequestMode: u32, bEnable: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineReleaseUserUserInfo( hCall: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineRemoveFromConference( hCall: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineRemoveProvider( dwPermanentProviderID: u32, hwndOwner: ?HWND, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSecureCall( hCall: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSendUserUserInfo( hCall: u32, lpsUserUserInfo: ?[*:0]const u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAgentActivity( hLine: u32, dwAddressID: u32, dwActivityID: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAgentGroup( hLine: u32, dwAddressID: u32, lpAgentGroupList: ?*LINEAGENTGROUPLIST, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAgentMeasurementPeriod( hLine: u32, hAgent: u32, dwMeasurementPeriod: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAgentSessionState( hLine: u32, hAgentSession: u32, dwAgentSessionState: u32, dwNextAgentSessionState: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAgentStateEx( hLine: u32, hAgent: u32, dwAgentState: u32, dwNextAgentState: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAgentState( hLine: u32, dwAddressID: u32, dwAgentState: u32, dwNextAgentState: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAppPriority( lpszAppFilename: ?[*:0]const u8, dwMediaMode: u32, lpExtensionID: ?*LINEEXTENSIONID, dwRequestMode: u32, lpszExtensionName: ?[*:0]const u8, dwPriority: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAppPriorityA( lpszAppFilename: ?[*:0]const u8, dwMediaMode: u32, lpExtensionID: ?*LINEEXTENSIONID, dwRequestMode: u32, lpszExtensionName: ?[*:0]const u8, dwPriority: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAppPriorityW( lpszAppFilename: ?[*:0]const u16, dwMediaMode: u32, lpExtensionID: ?*LINEEXTENSIONID, dwRequestMode: u32, lpszExtensionName: ?[*:0]const u16, dwPriority: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetAppSpecific( hCall: u32, dwAppSpecific: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetCallData( hCall: u32, lpCallData: ?*anyopaque, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetCallParams( hCall: u32, dwBearerMode: u32, dwMinRate: u32, dwMaxRate: u32, lpDialParams: ?*const LINEDIALPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetCallPrivilege( hCall: u32, dwCallPrivilege: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetCallQualityOfService( hCall: u32, lpSendingFlowspec: ?*anyopaque, dwSendingFlowspecSize: u32, lpReceivingFlowspec: ?*anyopaque, dwReceivingFlowspecSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetCallTreatment( hCall: u32, dwTreatment: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetCurrentLocation( hLineApp: u32, dwLocation: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetDevConfig( dwDeviceID: u32, lpDeviceConfig: ?*const anyopaque, dwSize: u32, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetDevConfigA( dwDeviceID: u32, lpDeviceConfig: ?*const anyopaque, dwSize: u32, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetDevConfigW( dwDeviceID: u32, lpDeviceConfig: ?*const anyopaque, dwSize: u32, lpszDeviceClass: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetLineDevStatus( hLine: u32, dwStatusToChange: u32, fStatus: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetMediaControl( hLine: u32, dwAddressID: u32, hCall: u32, dwSelect: u32, lpDigitList: ?*const LINEMEDIACONTROLDIGIT, dwDigitNumEntries: u32, lpMediaList: ?*const LINEMEDIACONTROLMEDIA, dwMediaNumEntries: u32, lpToneList: ?*const LINEMEDIACONTROLTONE, dwToneNumEntries: u32, lpCallStateList: ?*const LINEMEDIACONTROLCALLSTATE, dwCallStateNumEntries: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetMediaMode( hCall: u32, dwMediaModes: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetQueueMeasurementPeriod( hLine: u32, dwQueueID: u32, dwMeasurementPeriod: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetNumRings( hLine: u32, dwAddressID: u32, dwNumRings: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetStatusMessages( hLine: u32, dwLineStates: u32, dwAddressStates: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetTerminal( hLine: u32, dwAddressID: u32, hCall: u32, dwSelect: u32, dwTerminalModes: u32, dwTerminalID: u32, bEnable: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetTollList( hLineApp: u32, dwDeviceID: u32, lpszAddressIn: ?[*:0]const u8, dwTollListOption: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetTollListA( hLineApp: u32, dwDeviceID: u32, lpszAddressIn: ?[*:0]const u8, dwTollListOption: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetTollListW( hLineApp: u32, dwDeviceID: u32, lpszAddressInW: ?[*:0]const u16, dwTollListOption: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetupConference( hCall: u32, hLine: u32, lphConfCall: ?*u32, lphConsultCall: ?*u32, dwNumParties: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetupConferenceA( hCall: u32, hLine: u32, lphConfCall: ?*u32, lphConsultCall: ?*u32, dwNumParties: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetupConferenceW( hCall: u32, hLine: u32, lphConfCall: ?*u32, lphConsultCall: ?*u32, dwNumParties: u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetupTransfer( hCall: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetupTransferA( hCall: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSetupTransferW( hCall: u32, lphConsultCall: ?*u32, lpCallParams: ?*const LINECALLPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineShutdown( hLineApp: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineSwapHold( hActiveCall: u32, hHeldCall: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineTranslateAddress( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, lpszAddressIn: ?[*:0]const u8, dwCard: u32, dwTranslateOptions: u32, lpTranslateOutput: ?*LINETRANSLATEOUTPUT, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineTranslateAddressA( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, lpszAddressIn: ?[*:0]const u8, dwCard: u32, dwTranslateOptions: u32, lpTranslateOutput: ?*LINETRANSLATEOUTPUT, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineTranslateAddressW( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, lpszAddressIn: ?[*:0]const u16, dwCard: u32, dwTranslateOptions: u32, lpTranslateOutput: ?*LINETRANSLATEOUTPUT, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineTranslateDialog( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, hwndOwner: ?HWND, lpszAddressIn: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineTranslateDialogA( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, hwndOwner: ?HWND, lpszAddressIn: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineTranslateDialogW( hLineApp: u32, dwDeviceID: u32, dwAPIVersion: u32, hwndOwner: ?HWND, lpszAddressIn: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineUncompleteCall( hLine: u32, dwCompletionID: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineUnhold( hCall: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineUnpark( hLine: u32, dwAddressID: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineUnparkA( hLine: u32, dwAddressID: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn lineUnparkW( hLine: u32, dwAddressID: u32, lphCall: ?*u32, lpszDestAddress: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneClose( hPhone: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneConfigDialog( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneConfigDialogA( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneConfigDialogW( dwDeviceID: u32, hwndOwner: ?HWND, lpszDeviceClass: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneDevSpecific( hPhone: u32, lpParams: ?*anyopaque, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetButtonInfo( hPhone: u32, dwButtonLampID: u32, lpButtonInfo: ?*PHONEBUTTONINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetButtonInfoA( hPhone: u32, dwButtonLampID: u32, lpButtonInfo: ?*PHONEBUTTONINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetButtonInfoW( hPhone: u32, dwButtonLampID: u32, lpButtonInfo: ?*PHONEBUTTONINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetData( hPhone: u32, dwDataID: u32, lpData: ?*anyopaque, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetDevCaps( hPhoneApp: u32, dwDeviceID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpPhoneCaps: ?*PHONECAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetDevCapsA( hPhoneApp: u32, dwDeviceID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpPhoneCaps: ?*PHONECAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetDevCapsW( hPhoneApp: u32, dwDeviceID: u32, dwAPIVersion: u32, dwExtVersion: u32, lpPhoneCaps: ?*PHONECAPS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetDisplay( hPhone: u32, lpDisplay: ?*VARSTRING, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetGain( hPhone: u32, dwHookSwitchDev: u32, lpdwGain: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetHookSwitch( hPhone: u32, lpdwHookSwitchDevs: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetIcon( dwDeviceID: u32, lpszDeviceClass: ?[*:0]const u8, lphIcon: ?*isize, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetIconA( dwDeviceID: u32, lpszDeviceClass: ?[*:0]const u8, lphIcon: ?*isize, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetIconW( dwDeviceID: u32, lpszDeviceClass: ?[*:0]const u16, lphIcon: ?*isize, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetID( hPhone: u32, lpDeviceID: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetIDA( hPhone: u32, lpDeviceID: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetIDW( hPhone: u32, lpDeviceID: ?*VARSTRING, lpszDeviceClass: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetLamp( hPhone: u32, dwButtonLampID: u32, lpdwLampMode: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetMessage( hPhoneApp: u32, lpMessage: ?*PHONEMESSAGE, dwTimeout: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetRing( hPhone: u32, lpdwRingMode: ?*u32, lpdwVolume: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetStatus( hPhone: u32, lpPhoneStatus: ?*PHONESTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetStatusA( hPhone: u32, lpPhoneStatus: ?*PHONESTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetStatusW( hPhone: u32, lpPhoneStatus: ?*PHONESTATUS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetStatusMessages( hPhone: u32, lpdwPhoneStates: ?*u32, lpdwButtonModes: ?*u32, lpdwButtonStates: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneGetVolume( hPhone: u32, dwHookSwitchDev: u32, lpdwVolume: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneInitialize( lphPhoneApp: ?*u32, hInstance: ?HINSTANCE, lpfnCallback: ?PHONECALLBACK, lpszAppName: ?[*:0]const u8, lpdwNumDevs: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneInitializeExA( lphPhoneApp: ?*u32, hInstance: ?HINSTANCE, lpfnCallback: ?PHONECALLBACK, lpszFriendlyAppName: ?[*:0]const u8, lpdwNumDevs: ?*u32, lpdwAPIVersion: ?*u32, lpPhoneInitializeExParams: ?*PHONEINITIALIZEEXPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneInitializeExW( lphPhoneApp: ?*u32, hInstance: ?HINSTANCE, lpfnCallback: ?PHONECALLBACK, lpszFriendlyAppName: ?[*:0]const u16, lpdwNumDevs: ?*u32, lpdwAPIVersion: ?*u32, lpPhoneInitializeExParams: ?*PHONEINITIALIZEEXPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneNegotiateAPIVersion( hPhoneApp: u32, dwDeviceID: u32, dwAPILowVersion: u32, dwAPIHighVersion: u32, lpdwAPIVersion: ?*u32, lpExtensionID: ?*PHONEEXTENSIONID, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneNegotiateExtVersion( hPhoneApp: u32, dwDeviceID: u32, dwAPIVersion: u32, dwExtLowVersion: u32, dwExtHighVersion: u32, lpdwExtVersion: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneOpen( hPhoneApp: u32, dwDeviceID: u32, lphPhone: ?*u32, dwAPIVersion: u32, dwExtVersion: u32, dwCallbackInstance: usize, dwPrivilege: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetButtonInfo( hPhone: u32, dwButtonLampID: u32, lpButtonInfo: ?*const PHONEBUTTONINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetButtonInfoA( hPhone: u32, dwButtonLampID: u32, lpButtonInfo: ?*const PHONEBUTTONINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetButtonInfoW( hPhone: u32, dwButtonLampID: u32, lpButtonInfo: ?*const PHONEBUTTONINFO, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetData( hPhone: u32, dwDataID: u32, lpData: ?*const anyopaque, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetDisplay( hPhone: u32, dwRow: u32, dwColumn: u32, lpsDisplay: ?[*:0]const u8, dwSize: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetGain( hPhone: u32, dwHookSwitchDev: u32, dwGain: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetHookSwitch( hPhone: u32, dwHookSwitchDevs: u32, dwHookSwitchMode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetLamp( hPhone: u32, dwButtonLampID: u32, dwLampMode: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetRing( hPhone: u32, dwRingMode: u32, dwVolume: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetStatusMessages( hPhone: u32, dwPhoneStates: u32, dwButtonModes: u32, dwButtonStates: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneSetVolume( hPhone: u32, dwHookSwitchDev: u32, dwVolume: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn phoneShutdown( hPhoneApp: u32, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiGetLocationInfo( lpszCountryCode: *[8]u8, lpszCityCode: *[8]u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiGetLocationInfoA( lpszCountryCode: *[8]u8, lpszCityCode: *[8]u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiGetLocationInfoW( lpszCountryCodeW: *[8]u16, lpszCityCodeW: *[8]u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiRequestDrop( hwnd: ?HWND, wRequestID: WPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiRequestMakeCall( lpszDestAddress: ?[*:0]const u8, lpszAppName: ?[*:0]const u8, lpszCalledParty: ?[*:0]const u8, lpszComment: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiRequestMakeCallA( lpszDestAddress: ?[*:0]const u8, lpszAppName: ?[*:0]const u8, lpszCalledParty: ?[*:0]const u8, lpszComment: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiRequestMakeCallW( lpszDestAddress: ?[*:0]const u16, lpszAppName: ?[*:0]const u16, lpszCalledParty: ?[*:0]const u16, lpszComment: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiRequestMediaCall( hwnd: ?HWND, wRequestID: WPARAM, lpszDeviceClass: ?[*:0]const u8, lpDeviceID: ?[*:0]const u8, dwSize: u32, dwSecure: u32, lpszDestAddress: ?[*:0]const u8, lpszAppName: ?[*:0]const u8, lpszCalledParty: ?[*:0]const u8, lpszComment: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiRequestMediaCallA( hwnd: ?HWND, wRequestID: WPARAM, lpszDeviceClass: ?[*:0]const u8, lpDeviceID: ?[*:0]const u8, dwSize: u32, dwSecure: u32, lpszDestAddress: ?[*:0]const u8, lpszAppName: ?[*:0]const u8, lpszCalledParty: ?[*:0]const u8, lpszComment: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "TAPI32" fn tapiRequestMediaCallW( hwnd: ?HWND, wRequestID: WPARAM, lpszDeviceClass: ?[*:0]const u16, lpDeviceID: ?[*:0]const u16, dwSize: u32, dwSecure: u32, lpszDestAddress: ?[*:0]const u16, lpszAppName: ?[*:0]const u16, lpszCalledParty: ?[*:0]const u16, lpszComment: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; pub extern "MAPI32" fn OpenTnefStream( lpvSupport: ?*anyopaque, lpStream: ?*IStream, lpszStreamName: ?*i8, ulFlags: u32, lpMessage: ?*IMessage, wKeyVal: u16, lppTNEF: ?*?*ITnef, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "MAPI32" fn OpenTnefStreamEx( lpvSupport: ?*anyopaque, lpStream: ?*IStream, lpszStreamName: ?*i8, ulFlags: u32, lpMessage: ?*IMessage, wKeyVal: u16, lpAdressBook: ?*IAddrBook, lppTNEF: ?*?*ITnef, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "MAPI32" fn GetTnefStreamCodepage( lpStream: ?*IStream, lpulCodepage: ?*u32, lpulSubCodepage: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (10) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { pub const lineCreateAgent = thismodule.lineCreateAgentA; pub const lineCreateAgentSession = thismodule.lineCreateAgentSessionA; pub const lineGetAgentActivityList = thismodule.lineGetAgentActivityListA; pub const lineGetAgentCaps = thismodule.lineGetAgentCapsA; pub const lineGetAgentGroupList = thismodule.lineGetAgentGroupListA; pub const lineGetAgentStatus = thismodule.lineGetAgentStatusA; pub const lineGetGroupList = thismodule.lineGetGroupListA; pub const lineGetQueueList = thismodule.lineGetQueueListA; pub const lineInitializeEx = thismodule.lineInitializeExA; pub const phoneInitializeEx = thismodule.phoneInitializeExA; }, .wide => struct { pub const lineCreateAgent = thismodule.lineCreateAgentW; pub const lineCreateAgentSession = thismodule.lineCreateAgentSessionW; pub const lineGetAgentActivityList = thismodule.lineGetAgentActivityListW; pub const lineGetAgentCaps = thismodule.lineGetAgentCapsW; pub const lineGetAgentGroupList = thismodule.lineGetAgentGroupListW; pub const lineGetAgentStatus = thismodule.lineGetAgentStatusW; pub const lineGetGroupList = thismodule.lineGetGroupListW; pub const lineGetQueueList = thismodule.lineGetQueueListW; pub const lineInitializeEx = thismodule.lineInitializeExW; pub const phoneInitializeEx = thismodule.phoneInitializeExW; }, .unspecified => if (@import("builtin").is_test) struct { pub const lineCreateAgent = *opaque{}; pub const lineCreateAgentSession = *opaque{}; pub const lineGetAgentActivityList = *opaque{}; pub const lineGetAgentCaps = *opaque{}; pub const lineGetAgentGroupList = *opaque{}; pub const lineGetAgentStatus = *opaque{}; pub const lineGetGroupList = *opaque{}; pub const lineGetQueueList = *opaque{}; pub const lineInitializeEx = *opaque{}; pub const phoneInitializeEx = *opaque{}; } else struct { pub const lineCreateAgent = @compileError("'lineCreateAgent' requires that UNICODE be set to true or false in the root module"); pub const lineCreateAgentSession = @compileError("'lineCreateAgentSession' requires that UNICODE be set to true or false in the root module"); pub const lineGetAgentActivityList = @compileError("'lineGetAgentActivityList' requires that UNICODE be set to true or false in the root module"); pub const lineGetAgentCaps = @compileError("'lineGetAgentCaps' requires that UNICODE be set to true or false in the root module"); pub const lineGetAgentGroupList = @compileError("'lineGetAgentGroupList' requires that UNICODE be set to true or false in the root module"); pub const lineGetAgentStatus = @compileError("'lineGetAgentStatus' requires that UNICODE be set to true or false in the root module"); pub const lineGetGroupList = @compileError("'lineGetGroupList' requires that UNICODE be set to true or false in the root module"); pub const lineGetQueueList = @compileError("'lineGetQueueList' requires that UNICODE be set to true or false in the root module"); pub const lineInitializeEx = @compileError("'lineInitializeEx' requires that UNICODE be set to true or false in the root module"); pub const phoneInitializeEx = @compileError("'phoneInitializeEx' requires that UNICODE be set to true or false in the root module"); }, }; //-------------------------------------------------------------------------------- // Section: Imports (25) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const ALLOCATOR_PROPERTIES = @import("../media/direct_show.zig").ALLOCATOR_PROPERTIES; const AM_MEDIA_TYPE = @import("../media/direct_show.zig").AM_MEDIA_TYPE; const BOOL = @import("../foundation.zig").BOOL; const BSTR = @import("../foundation.zig").BSTR; const CHAR = @import("../foundation.zig").CHAR; const CY = @import("../system/com.zig").CY; const HANDLE = @import("../foundation.zig").HANDLE; const HINSTANCE = @import("../foundation.zig").HINSTANCE; const HRESULT = @import("../foundation.zig").HRESULT; const HWND = @import("../foundation.zig").HWND; const IAddrBook = @import("../system/address_book.zig").IAddrBook; const IDispatch = @import("../system/com.zig").IDispatch; const IEnumUnknown = @import("../system/com.zig").IEnumUnknown; const IMAPITable = @import("../system/address_book.zig").IMAPITable; const IMessage = @import("../system/address_book.zig").IMessage; const IStream = @import("../system/com.zig").IStream; const IUnknown = @import("../system/com.zig").IUnknown; const PSTR = @import("../foundation.zig").PSTR; const PWSTR = @import("../foundation.zig").PWSTR; const SPropTagArray = @import("../system/address_book.zig").SPropTagArray; const SPropValue = @import("../system/address_book.zig").SPropValue; const SYSTEMTIME = @import("../foundation.zig").SYSTEMTIME; const VARIANT = @import("../system/com.zig").VARIANT; const WPARAM = @import("../foundation.zig").WPARAM; test { // The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476 if (@hasDecl(@This(), "LINECALLBACK")) { _ = LINECALLBACK; } if (@hasDecl(@This(), "PHONECALLBACK")) { _ = PHONECALLBACK; } if (@hasDecl(@This(), "ASYNC_COMPLETION")) { _ = ASYNC_COMPLETION; } if (@hasDecl(@This(), "LINEEVENT")) { _ = LINEEVENT; } if (@hasDecl(@This(), "PHONEEVENT")) { _ = PHONEEVENT; } if (@hasDecl(@This(), "TUISPIDLLCALLBACK")) { _ = TUISPIDLLCALLBACK; } if (@hasDecl(@This(), "LPOPENTNEFSTREAM")) { _ = LPOPENTNEFSTREAM; } if (@hasDecl(@This(), "LPOPENTNEFSTREAMEX")) { _ = LPOPENTNEFSTREAMEX; } if (@hasDecl(@This(), "LPGETTNEFSTREAMCODEPAGE")) { _ = LPGETTNEFSTREAMCODEPAGE; } @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/devices/tapi.zig
const sf = struct { pub usingnamespace @import("../sfml.zig"); pub usingnamespace sf.system; }; pub const Event = union(Event.Type) { const Self = @This(); pub const Type = enum(c_int) { closed, resized, lostFocus, gainedFocus, textEntered, keyPressed, keyReleased, mouseWheelScrolled, mouseButtonPressed, mouseButtonReleased, mouseMoved, mouseEntered, mouseLeft, joystickButtonPressed, joystickButtonReleased, joystickMoved, joystickConnected, joystickDisconnected, touchBegan, touchMoved, touchEnded, sensorChanged, }; // Big oof /// Creates this event from a csfml one pub fn _fromCSFML(event: sf.c.sfEvent) Self { return switch (event.type) { sf.c.sfEvtClosed => .{ .closed = {} }, sf.c.sfEvtResized => .{ .resized = .{ .size = .{ .x = event.size.width, .y = event.size.height } } }, sf.c.sfEvtLostFocus => .{ .lostFocus = {} }, sf.c.sfEvtGainedFocus => .{ .gainedFocus = {} }, sf.c.sfEvtTextEntered => .{ .textEntered = .{ .unicode = event.text.unicode } }, sf.c.sfEvtKeyPressed => .{ .keyPressed = .{ .code = @intToEnum(sf.window.keyboard.KeyCode, event.key.code), .alt = (event.key.alt != 0), .control = (event.key.control != 0), .shift = (event.key.shift != 0), .system = (event.key.system != 0) } }, sf.c.sfEvtKeyReleased => .{ .keyReleased = .{ .code = @intToEnum(sf.window.keyboard.KeyCode, event.key.code), .alt = (event.key.alt != 0), .control = (event.key.control != 0), .shift = (event.key.shift != 0), .system = (event.key.system != 0) } }, sf.c.sfEvtMouseWheelScrolled => .{ .mouseWheelScrolled = .{ .wheel = @intToEnum(sf.window.mouse.Wheel, event.mouseWheelScroll.wheel), .delta = event.mouseWheelScroll.delta, .pos = .{ .x = event.mouseWheelScroll.x, .y = event.mouseWheelScroll.y } } }, sf.c.sfEvtMouseButtonPressed => .{ .mouseButtonPressed = .{ .button = @intToEnum(sf.window.mouse.Button, event.mouseButton.button), .pos = .{ .x = event.mouseButton.x, .y = event.mouseButton.y } } }, sf.c.sfEvtMouseButtonReleased => .{ .mouseButtonReleased = .{ .button = @intToEnum(sf.window.mouse.Button, event.mouseButton.button), .pos = .{ .x = event.mouseButton.x, .y = event.mouseButton.y } } }, sf.c.sfEvtMouseMoved => .{ .mouseMoved = .{ .pos = .{ .x = event.mouseMove.x, .y = event.mouseMove.y } } }, sf.c.sfEvtMouseEntered => .{ .mouseEntered = {} }, sf.c.sfEvtMouseLeft => .{ .mouseLeft = {} }, sf.c.sfEvtJoystickButtonPressed => .{ .joystickButtonPressed = .{ .joystickId = event.joystickButton.joystickId, .button = event.joystickButton.button } }, sf.c.sfEvtJoystickButtonReleased => .{ .joystickButtonReleased = .{ .joystickId = event.joystickButton.joystickId, .button = event.joystickButton.button } }, sf.c.sfEvtJoystickMoved => .{ .joystickMoved = .{ .joystickId = event.joystickMove.joystickId, .axis = event.joystickMove.axis, .position = event.joystickMove.position } }, sf.c.sfEvtJoystickConnected => .{ .joystickConnected = .{ .joystickId = event.joystickConnect.joystickId } }, sf.c.sfEvtJoystickDisconnected => .{ .joystickDisconnected = .{ .joystickId = event.joystickConnect.joystickId } }, sf.c.sfEvtTouchBegan => .{ .touchBegan = .{ .finger = event.touch.finger, .pos = .{ .x = event.touch.x, .y = event.touch.y } } }, sf.c.sfEvtTouchMoved => .{ .touchMoved = .{ .finger = event.touch.finger, .pos = .{ .x = event.touch.x, .y = event.touch.y } } }, sf.c.sfEvtTouchEnded => .{ .touchEnded = .{ .finger = event.touch.finger, .pos = .{ .x = event.touch.x, .y = event.touch.y } } }, sf.c.sfEvtSensorChanged => .{ .sensorChanged = .{ .sensorType = event.sensor.sensorType, .vector = .{ .x = event.sensor.x, .y = event.sensor.y, .z = event.sensor.z } } }, sf.c.sfEvtCount => @panic("sfEvtCount should't exist as an event!"), else => @panic("Unknown event!"), }; } /// Gets how many types of event exist pub fn getEventCount() c_uint { return @enumToInt(sf.c.sfEventType.sfEvtCount); } /// Size events parameters pub const SizeEvent = struct { size: sf.Vector2u, }; /// Keyboard event parameters pub const KeyEvent = struct { code: sf.window.keyboard.KeyCode, alt: bool, control: bool, shift: bool, system: bool, }; /// Text event parameters pub const TextEvent = struct { unicode: u32, }; /// Mouse move event parameters pub const MouseMoveEvent = struct { pos: sf.Vector2i, }; /// Mouse buttons events parameters pub const MouseButtonEvent = struct { button: sf.window.mouse.Button, pos: sf.Vector2i, }; /// Mouse wheel events parameters pub const MouseWheelScrollEvent = struct { wheel: sf.window.mouse.Wheel, delta: f32, pos: sf.Vector2i, }; /// Joystick axis move event parameters pub const JoystickMoveEvent = struct { joystickId: c_uint, axis: sf.c.sfJoystickAxis, position: f32, }; /// Joystick buttons events parameters pub const JoystickButtonEvent = struct { joystickId: c_uint, button: c_uint, }; /// Joystick connection/disconnection event parameters pub const JoystickConnectEvent = struct { joystickId: c_uint, }; /// Touch events parameters pub const TouchEvent = struct { finger: c_uint, pos: sf.Vector2i, }; /// Sensor event parameters pub const SensorEvent = struct { sensorType: sf.c.sfSensorType, vector: sf.Vector3f, }; // An event is one of those closed: void, resized: SizeEvent, lostFocus: void, gainedFocus: void, textEntered: TextEvent, keyPressed: KeyEvent, keyReleased: KeyEvent, mouseWheelScrolled: MouseWheelScrollEvent, mouseButtonPressed: MouseButtonEvent, mouseButtonReleased: MouseButtonEvent, mouseMoved: MouseMoveEvent, mouseEntered: void, mouseLeft: void, joystickButtonPressed: JoystickButtonEvent, joystickButtonReleased: JoystickButtonEvent, joystickMoved: JoystickMoveEvent, joystickConnected: JoystickConnectEvent, joystickDisconnected: JoystickConnectEvent, touchBegan: TouchEvent, touchMoved: TouchEvent, touchEnded: TouchEvent, sensorChanged: SensorEvent, };
src/sfml/window/event.zig
const std = @import("std"); const os = std.os; const c = @cImport({ // process_vm_readv @cInclude("sys/uio.h"); }); // From the man page: // The data to be transferred is identified by remote_iov and riovcnt: // remote_iov is a pointer to an array describing address ranges in the process pid, // The data is transferred to the locations specified by local_iov and liovcnt: // local_iov is a pointer to an array describing address ranges in the calling process, pub fn readv(pid: os.pid_t, buffer: []u8, remote_addr: usize) !usize { var local_iov = c.iovec{ .iov_base = @ptrCast(*c_void, buffer), .iov_len = buffer.len }; var remote_iov = c.iovec{ .iov_base = @intToPtr(*c_void, remote_addr), .iov_len = buffer.len }; var write_array = [_]c.iovec{local_iov}; var read_array = [_]c.iovec{remote_iov}; const result = os.linux.syscall6( os.SYS.process_vm_readv, @intCast(usize, pid), @ptrToInt(&write_array), write_array.len, @ptrToInt(&read_array), read_array.len, 0, ); try handleError(result); return result; } pub fn writev(pid: os.pid_t, buffer: []u8, remote_addr: usize) !usize { var local_iov = c.iovec{ .iov_base = @ptrCast(*c_void, buffer), .iov_len = buffer.len }; var remote_iov = c.iovec{ .iov_base = @intToPtr(*c_void, remote_addr), .iov_len = buffer.len }; var read_array = [_]c.iovec{local_iov}; var write_array = [_]c.iovec{remote_iov}; const result = os.linux.syscall6( os.SYS.process_vm_writev, // Syscall expects pid_t, zig fn expects usize. @intCast(usize, pid), @ptrToInt(&read_array), write_array.len, @ptrToInt(&write_array), read_array.len, 0, ); try handleError(result); return result; } fn handleError(result: usize) !void { const err = os.errno(result); return switch (err) { 0 => {}, os.EFAULT => error.InvalidMemorySpace, os.EINVAL => error.EINVAL, os.ENOMEM => error.MemoryError, os.EPERM => error.InsufficientPermission, os.ESRCH => error.NoPIDExists, else => error.UnknownPVReadvError, }; }
src/helpers/interprocess_rw.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const scanner_mod = @import("./scanner.zig"); const chunks_mod = @import("./chunks.zig"); const debug_mod = @import("./debug.zig"); const Scanner = scanner_mod.Scanner; const Token = scanner_mod.Token; const TokenType = scanner_mod.TokenType; const Chunk = chunks_mod.Chunk; const OpCode = chunks_mod.OpCode; const Value = @import("./value.zig").Value; const Obj = @import("./object.zig").Obj; const Vm = @import("vm.zig").Vm; const debug_print_code = true; const CompileError = error{ CompileError, TooManyConstants }; const Precedence = enum { precNone, precAssignment, // = precOr, // or precAnd, // and precEquality, // == != precComparison, // < > <= >= precTerm, // + - precFactor, // * / precUnary, // ! - precCall, // . () precPrimary, }; pub fn compile(source: []const u8, chunk: *Chunk, vm: *Vm) !void { var scanner = Scanner.init(source); var parser = Parser.init(&scanner, chunk, vm); try parser.advance(); while (scanner.hasNextToken()) { try parser.declaration(); } parser.endCompiler(); } const ParseFn = fn (parser: *Parser, can_assign: bool) anyerror!void; const ParseRule = struct { prefix: ?ParseFn, infix: ?ParseFn, precedence: Precedence, pub fn init(prefix: ?ParseFn, infix: ?ParseFn, precedence: Precedence) ParseRule { return .{ .prefix = prefix, .infix = infix, .precedence = precedence, }; } }; fn getRule(ty: TokenType) ParseRule { return switch (ty) { .LEFT_PAREN => ParseRule.init(Parser.grouping, null, .precNone), .RIGHT_PAREN => ParseRule.init(null, null, .precNone), .LEFT_BRACE => ParseRule.init(null, null, .precNone), .RIGHT_BRACE => ParseRule.init(null, null, .precNone), .COMMA => ParseRule.init(null, null, .precNone), .DOT => ParseRule.init(null, null, .precNone), .MINUS => ParseRule.init(Parser.unary, Parser.binary, .precTerm), .PLUS => ParseRule.init(null, Parser.binary, .precTerm), .SEMICOLON => ParseRule.init(null, null, .precNone), .SLASH => ParseRule.init(null, Parser.binary, .precFactor), .STAR => ParseRule.init(null, Parser.binary, .precFactor), .BANG => ParseRule.init(Parser.unary, null, .precNone), .BANG_EQUAL => ParseRule.init(null, Parser.binary, .precEquality), .EQUAL => ParseRule.init(null, null, .precNone), .EQUAL_EQUAL => ParseRule.init(null, Parser.binary, .precEquality), .GREATER => ParseRule.init(null, Parser.binary, .precComparison), .GREATER_EQUAL => ParseRule.init(null, Parser.binary, .precComparison), .LESS => ParseRule.init(null, Parser.binary, .precComparison), .LESS_EQUAL => ParseRule.init(null, Parser.binary, .precComparison), .IDENTIFIER => ParseRule.init(Parser.variable, null, .precNone), .STRING => ParseRule.init(Parser.string, null, .precNone), .NUMBER => ParseRule.init(Parser.number, null, .precNone), .AND => ParseRule.init(null, null, .precNone), .CLASS => ParseRule.init(null, null, .precNone), .ELSE => ParseRule.init(null, null, .precNone), .FALSE => ParseRule.init(Parser.literal, null, .precNone), .FOR => ParseRule.init(null, null, .precNone), .FUN => ParseRule.init(null, null, .precNone), .IF => ParseRule.init(null, null, .precNone), .NIL => ParseRule.init(Parser.literal, null, .precNone), .OR => ParseRule.init(null, null, .precNone), .PRINT => ParseRule.init(null, null, .precNone), .RETURN => ParseRule.init(null, null, .precNone), .SUPER => ParseRule.init(null, null, .precNone), .THIS => ParseRule.init(null, null, .precNone), .TRUE => ParseRule.init(Parser.literal, null, .precNone), .VAR => ParseRule.init(null, null, .precNone), .WHILE => ParseRule.init(null, null, .precNone), .ERROR => ParseRule.init(null, null, .precNone), .EOF => ParseRule.init(null, null, .precNone), }; } const Parser = struct { const Self = @This(); current: Token = undefined, previous: Token = undefined, panicMode: bool = false, scanner: *Scanner, compilingChunk: *Chunk, vm: *Vm, pub fn init(scanner: *Scanner, chunk: *Chunk, vm: *Vm) Parser { return .{ .scanner = scanner, .compilingChunk = chunk, .vm = vm, }; } pub fn advance(self: *Self) CompileError!void { self.previous = self.current; while (self.scanner.nextToken()) |token| { self.current = token; if (token.ty != .ERROR) break; self.errAtCurrent(self.current.lexeme); return CompileError.CompileError; } } pub fn consume(self: *Self, ty: TokenType, comptime message: []const u8) CompileError!void { if (self.current.ty == ty) { try self.advance(); return; } self.errAtCurrent(message); return CompileError.CompileError; } fn match(self: *Self, ty: TokenType) !bool { if (!self.check(ty)) return false; try self.advance(); return true; } fn check(self: *Self, ty: TokenType) bool { return self.current.ty == ty; } fn errAtCurrent(self: *Self, message: []const u8) void { self.errAt(self.current, message); } fn err(self: *Self, message: []const u8) void { self.errAt(self.previous, message); } fn errAt(self: *Self, token: Token, message: []const u8) void { if (self.panicMode) return; self.panicMode = true; const errWriter = std.io.getStdErr().writer(); errWriter.print("[line {d}] Error", .{token.line}) catch unreachable; switch (token.ty) { .EOF => errWriter.writeAll(" at end") catch unreachable, .ERROR => {}, else => errWriter.print(" at '{s}'", .{token.lexeme}) catch unreachable, } errWriter.print(": {s}\n", .{message}) catch unreachable; } // Compiler Bakckend pub fn declaration(self: *Self) !void { if (try self.match(.VAR)) { try self.varDeclaration(); } else { try self.statement(); } if (self.panicMode) try self.synchronize(); } fn statement(self: *Self) !void { if (try self.match(.PRINT)) { try self.printStatement(); } else { try self.expressionStatement(); } } fn printStatement(self: *Self) !void { try self.expression(); try self.consume(.SEMICOLON, "Expect ';' after value"); self.emitOpCode(.op_print); } fn varDeclaration(self: *Self) !void { const global = try self.parseVariable("Expect variable name."); if (try self.match(.EQUAL)) { try self.expression(); } else { self.emitOpCode(.op_nil); } try self.consume(.SEMICOLON, "Expect ';' after varaible declaration."); try self.defineVariable(global); } fn parseVariable(self: *Self, comptime error_message: []const u8) !u8 { try self.consume(.IDENTIFIER, error_message); return self.identifierConstant(self.previous); } fn identifierConstant(self: *Self, token: Token) !u8 { return try self.makeConstant(Obj.String.copy(self.vm, token.lexeme).obj.toValue()); } fn defineVariable(self: *Self, global: u8) !void { self.emitBytes(OpCode.op_define_gloabl.toU8(), global); } fn expressionStatement(self: *Self) !void { try self.expression(); try self.consume(.SEMICOLON, "Expect ; after expression"); self.emitOpCode(.op_pop); } fn synchronize(self: *Self) !void { self.panicMode = false; while (self.scanner.hasNextToken()) { if (self.previous.ty == .SEMICOLON) return; switch (self.current.ty) { .CLASS, .FUN, .VAR, .FOR, .IF, .WHILE, .PRINT, .RETURN => return, else => try self.advance(), } } } fn expression(self: *Self) !void { try self.parsePrecendece(.precAssignment); } fn number(self: *Self, can_assign: bool) !void { _ = can_assign; const x = std.fmt.parseFloat(f64, self.previous.lexeme) catch unreachable; try self.emitConstant(Value.fromNumber(x)); } fn string(self: *Self, can_assign: bool) !void { _ = can_assign; const lexeme_len = self.previous.lexeme.len; const str = Obj.String.copy(self.vm, self.previous.lexeme[1 .. lexeme_len - 1]); try self.emitConstant(str.obj.toValue()); } fn variable(self: *Self, can_assign: bool) !void { try self.namedVariable(self.previous, can_assign); } fn namedVariable(self: *Self, name: Token, can_assign: bool) !void { const arg = try self.identifierConstant(name); if (can_assign and try self.match(.EQUAL)) { try self.expression(); self.emitBytes(OpCode.op_set_global.toU8(), arg); } else { self.emitBytes(OpCode.op_get_global.toU8(), arg); } } fn grouping(self: *Self, can_assign: bool) !void { _ = can_assign; try self.expression(); try self.consume(.RIGHT_PAREN, "Expect ')' after expression."); } fn unary(self: *Self, can_assign: bool) !void { _ = can_assign; const operatorType = self.previous.ty; try self.parsePrecendece(.precUnary); switch (operatorType) { .BANG => self.emitOpCode(.op_not), .MINUS => self.emitOpCode(.op_negate), else => unreachable, } } fn binary(self: *Self, can_assign: bool) !void { _ = can_assign; const operatorType = self.previous.ty; const rule = getRule(operatorType); try self.parsePrecendece(@intToEnum(Precedence, @enumToInt(rule.precedence) + 1)); switch (operatorType) { .EQUAL_EQUAL => self.emitOpCode(.op_equal), .GREATER => self.emitOpCode(.op_greater), .LESS => self.emitOpCode(.op_less), .BANG_EQUAL => self.emitTwoOpCodes(.op_equal, .op_not), .GREATER_EQUAL => self.emitTwoOpCodes(.op_less, .op_not), .LESS_EQUAL => self.emitTwoOpCodes(.op_greater, .op_not), .PLUS => self.emitOpCode(.op_add), .MINUS => self.emitOpCode(.op_sub), .STAR => self.emitOpCode(.op_mul), .SLASH => self.emitOpCode(.op_div), else => unreachable, } } fn literal(self: *Self, can_assign: bool) !void { _ = can_assign; switch (self.previous.ty) { .FALSE => self.emitOpCode(.op_false), .NIL => self.emitOpCode(.op_nil), .TRUE => self.emitOpCode(.op_true), else => unreachable, } } fn parsePrecendece(self: *Self, precedence: Precedence) !void { try self.advance(); const prefix_rule = getRule(self.previous.ty).prefix orelse { self.err("Expect expression."); return CompileError.CompileError; }; const can_assign = @enumToInt(precedence) <= @enumToInt(Precedence.precAssignment); try prefix_rule(self, can_assign); while (@enumToInt(precedence) <= @enumToInt(getRule(self.current.ty).precedence)) { try self.advance(); const rule = getRule(self.previous.ty); const infix_rule = rule.infix orelse { self.err("Unreachable????"); return CompileError.CompileError; }; try infix_rule(self, can_assign); } if (can_assign and try self.match(.EQUAL)) { self.err("Invalid assignment target."); } } fn emitConstant(self: *Self, value: Value) !void { const const_idx = try self.makeConstant(value); self.emitBytes(OpCode.op_constant.toU8(), const_idx); } fn makeConstant(self: *Self, value: Value) !u8 { const constant = self.currentChunk().addConstant(value); if (constant > std.math.maxInt(u8)) { self.err("Too many constants in a chunk."); return CompileError.TooManyConstants; } return @intCast(u8, constant); } fn emitTwoOpCodes(self: *Self, op_code1: OpCode, op_code2: OpCode) void { self.emitBytes(op_code1.toU8(), op_code2.toU8()); } fn emitOpCode(self: *Self, opCode: OpCode) void { self.emitByte(opCode.toU8()); } fn emitByte(self: *Self, byte: u8) void { self.currentChunk().write(byte, self.previous.line); } fn emitBytes(self: *Self, byte1: u8, byte2: u8) void { self.emitByte(byte1); self.emitByte(byte2); } pub fn endCompiler(self: *Self) void { self.emitReturn(); if (comptime debug_print_code) { debug_mod.dissasembleChunk(self.currentChunk(), "code"); } } fn emitReturn(self: *Self) void { self.emitByte(OpCode.op_ret.toU8()); } fn currentChunk(self: *Self) *Chunk { return self.compilingChunk; } }; // Function used to test the scanner. fn scannerTest(source: []const u8) void { var scanner = Scanner.init(source); var line: u64 = 0; while (scanner.nextToken()) |token| { if (token.line != line) { std.debug.print("{d: >4} ", .{token.line}); line = token.line; } else { std.debug.print(" | ", .{}); } std.debug.print(".{s: <13} '{s}'\n", .{ @tagName(token.ty), token.lexeme }); } }
src/compiler.zig
pub const padding = 0x00; pub const array_type = 0x01; pub const class_type = 0x02; pub const entry_point = 0x03; pub const enumeration_type = 0x04; pub const formal_parameter = 0x05; pub const imported_declaration = 0x08; pub const label = 0x0a; pub const lexical_block = 0x0b; pub const member = 0x0d; pub const pointer_type = 0x0f; pub const reference_type = 0x10; pub const compile_unit = 0x11; pub const string_type = 0x12; pub const structure_type = 0x13; pub const subroutine = 0x14; pub const subroutine_type = 0x15; pub const typedef = 0x16; pub const union_type = 0x17; pub const unspecified_parameters = 0x18; pub const variant = 0x19; pub const common_block = 0x1a; pub const common_inclusion = 0x1b; pub const inheritance = 0x1c; pub const inlined_subroutine = 0x1d; pub const module = 0x1e; pub const ptr_to_member_type = 0x1f; pub const set_type = 0x20; pub const subrange_type = 0x21; pub const with_stmt = 0x22; pub const access_declaration = 0x23; pub const base_type = 0x24; pub const catch_block = 0x25; pub const const_type = 0x26; pub const constant = 0x27; pub const enumerator = 0x28; pub const file_type = 0x29; pub const friend = 0x2a; pub const namelist = 0x2b; pub const namelist_item = 0x2c; pub const packed_type = 0x2d; pub const subprogram = 0x2e; pub const template_type_param = 0x2f; pub const template_value_param = 0x30; pub const thrown_type = 0x31; pub const try_block = 0x32; pub const variant_part = 0x33; pub const variable = 0x34; pub const volatile_type = 0x35; // DWARF 3 pub const dwarf_procedure = 0x36; pub const restrict_type = 0x37; pub const interface_type = 0x38; pub const namespace = 0x39; pub const imported_module = 0x3a; pub const unspecified_type = 0x3b; pub const partial_unit = 0x3c; pub const imported_unit = 0x3d; pub const condition = 0x3f; pub const shared_type = 0x40; // DWARF 4 pub const type_unit = 0x41; pub const rvalue_reference_type = 0x42; pub const template_alias = 0x43; pub const lo_user = 0x4080; pub const hi_user = 0xffff; // SGI/MIPS Extensions. pub const MIPS_loop = 0x4081; // HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz . pub const HP_array_descriptor = 0x4090; pub const HP_Bliss_field = 0x4091; pub const HP_Bliss_field_set = 0x4092; // GNU extensions. pub const format_label = 0x4101; // For FORTRAN 77 and Fortran 90. pub const function_template = 0x4102; // For C++. pub const class_template = 0x4103; //For C++. pub const GNU_BINCL = 0x4104; pub const GNU_EINCL = 0x4105; // Template template parameter. // See http://gcc.gnu.org/wiki/TemplateParmsDwarf . pub const GNU_template_template_param = 0x4106; // Template parameter pack extension = specified at // http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates // The values of these two TAGS are in the DW_TAG_GNU_* space until the tags // are properly part of DWARF 5. pub const GNU_template_parameter_pack = 0x4107; pub const GNU_formal_parameter_pack = 0x4108; // The GNU call site extension = specified at // http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open . // The values of these two TAGS are in the DW_TAG_GNU_* space until the tags // are properly part of DWARF 5. pub const GNU_call_site = 0x4109; pub const GNU_call_site_parameter = 0x410a; // Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf. pub const upc_shared_type = 0x8765; pub const upc_strict_type = 0x8766; pub const upc_relaxed_type = 0x8767; // PGI (STMicroelectronics; extensions. No documentation available. pub const PGI_kanji_type = 0xA000; pub const PGI_interface_block = 0xA020;
lib/std/dwarf/TAG.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 util = @import("util.zig"); const gpa = util.gpa; const data = @embedFile("../data/day09.txt"); // const data = @embedFile("../data/day09-tst.txt"); fn sortAscFn(context: void, a: u32, b: u32) bool { return std.sort.asc(u32)(context, a, b); } fn sortDescFn(context: void, a: u32, b: u32) bool { return std.sort.desc(u32)(context, a, b); } pub fn main() !void { var grid = try Grid.init(); var j: isize = 0; var part1: u32 = 0; var part2 = List(u32).init(gpa); while (j < grid.h) : (j += 1) { var i: isize = 0; while (i < grid.w) : (i += 1) { const value = grid.value(Point{ .x = i, .y = j }); const neighbors = grid.neighbors(i, j); var ok = true; for (neighbors) |neighbor| { if (value >= grid.value(neighbor)) { ok = false; break; } } if (ok) { part1 += @intCast(u32, value + 1); try part2.append(grid.floodFill(i, j)); } } } print("{}\n", .{part1}); std.sort.sort(u32, part2.items, {}, sortDescFn); print("{}\n", .{part2.items[0] * part2.items[1] * part2.items[2]}); } const Point = struct { x: isize, y: isize, }; const Grid = struct { grid: List(u8), hist: List(bool), w: isize, h: isize, buffer: [4]Point, fn init() !Grid { var grid = Grid{ .grid = List(u8).init(gpa), .hist = List(bool).init(gpa), .w = 0, .h = 0, .buffer = [_]Point{Point{ .x = 0, .y = 0 }} ** 4, }; var it = tokenize(u8, data, "\r\n"); while (it.next()) |line| { if (grid.w == 0) { grid.w = @intCast(isize, line.len); } assert(grid.w == line.len); grid.h += 1; for (line) |c| { try grid.grid.append(c - '0'); try grid.hist.append(false); } } return grid; } fn index(self: Grid, p: Point) usize { return @intCast(usize, p.x + p.y * self.w); } fn value(self: Grid, p: Point) u8 { return self.grid.items[self.index(p)]; } fn neighbors(self: *Grid, i: isize, j: isize) []Point { const l = i - 1; const r = i + 1; const t = j - 1; const b = j + 1; var result: []Point = self.buffer[0..]; var idx: usize = 0; if (l >= 0) { result[idx] = Point{ .x = l, .y = j }; idx += 1; } if (r < self.w) { result[idx] = Point{ .x = r, .y = j }; idx += 1; } if (t >= 0) { result[idx] = Point{ .x = i, .y = t }; idx += 1; } if (b < self.h) { result[idx] = Point{ .x = i, .y = b }; idx += 1; } result.len = idx; return result; } fn visited(self: Grid, p: Point) bool { return self.hist.items[self.index(p)]; } fn visit(self: *Grid, p: Point) void { self.hist.items[self.index(p)] = true; } fn floodFill(self: *Grid, i: isize, j: isize) u32 { var result: u32 = 0; self.floodFillRecurse(Point{ .x = i, .y = j }, &result); return result; } fn floodFillRecurse(self: *Grid, p: Point, result: *u32) void { self.visit(p); result.* += 1; const neighs_tmp = self.neighbors(p.x, p.y); var neighs = [_]Point{Point{ .x = 0, .y = 0 }} ** 4; std.mem.copy(Point, neighs[0..], neighs_tmp); for (neighs) |neigh| { if (!self.visited(neigh) and self.value(neigh) != 9) { self.floodFillRecurse(neigh, result); } } } }; // Useful stdlib functions const tokenize = std.mem.tokenize; const split = std.mem.split; 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 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/day09.zig
const std = @import("std"); /// Syntactic sugar to refer to the Self/@This() type in the hasFn Signature argument pub const Self = struct{}; /// A function similar to std.meta.hasFn, but providing an extra argument which allows /// to specify the signature of the function. It will check if the given type (which must be /// a struct, union, or enum) declares a function with the given name and signature. /// # Arguments /// * `name` The name of the function which we are looking for /// * `Signature`: the function signature we are looking for /// # Returns /// A std.meta.trait.TraitFn that takes a type T and returns /// true iff T declares a function with the given name and signature. There /// is one detail that allows us to query inferred error unions. /// ## On Function Signatures and Errors /// Usually the function signature declared in the type and the given `Signature` must match /// exactly, which means that the error return types must match exactly. But there is one exception /// to this rule. If we specify `fn(...)anyerror!...` as the `Signature` argument, then if and /// only if the return type of the function is also an error union, the error type is discarded when /// matching the signatures. That means only the error payload and the function argument types have to /// match and any error is accepted. This is very handy if the declaration uses an inferred error union, /// which might be almost impossible to match, or if we don't care about the exact error return type of /// the function. That means a `Signature` of `fn(T)anyerror!U` *will* match `fn(T)E!U` for any `E` and also /// `fn(T)anyerror!U`. However, it will not match `fn(T)U`. pub fn hasFn(comptime name :[]const u8, comptime Signature : type) std.meta.trait.TraitFn { const Closure = struct { pub fn trait(comptime T:type) bool { const decls = switch (@typeInfo(T)) { .Union => |u| u, .Struct => |s| s, .Enum => |e| e, else => return false, }.decls; // this *might* help save some compile time if the decl is not present in the container at all if(!@hasDecl(T, name)) { return false; } comptime { inline for (decls) |decl| { if (std.mem.eql(u8, name, decl.name)) { switch (decl.data) { .Fn => |fndecl| { return functionMatchesSignature(fndecl.fn_type,Signature); }, else => {} } } } } return false; } }; return Closure.trait; } fn functionMatchesSignature(comptime MemberFunction:type, comptime Signature:type) bool { const function_info = @typeInfo(MemberFunction).Fn; const signature_info = @typeInfo(Signature).Fn; // compare the argument list, but make sure that the argument lists are of the same length! if (function_info.args.len != signature_info.args.len) { return false; } //I have to loop unroll here, because I cannot just compare slices with std.meta.eql inline for (function_info.args) |arg,idx| { if(!std.meta.eql(arg, signature_info.args[idx])) { return false; } } // compare the signature. Here we allow anyerror to be the same as an inferred error set.function_info // if any other error is given in the return type, then the errors must exactly match // In all cases but one we test that the return types of the signatures are exactly identical // the one case is that the return type of the signature is anyerror!T. In this case we test only that // the non-error payloads of the functions are equivalent. This to give the user a chance to test for // inferred signatures without exactly knowing the error set type. if (signature_info.return_type) |signature_return_type| { if (function_info.return_type) |function_return_type| { switch(@typeInfo(signature_return_type)) { .ErrorUnion => |signature_error_union| { if (signature_error_union.error_set == anyerror) { switch(@typeInfo(function_return_type)) { .ErrorUnion => |function_return_error_union| { return std.meta.eql(function_return_error_union.payload, signature_error_union.payload); }, else => {}, } } }, else => {} } } } return std.meta.eql(signature_info.return_type, function_info.return_type); } /// TODO document, helper function /// replace occurrences of the This type with the type T fn replaceSelfType(comptime ArgType : type, comptime ReplacementType : type) type { if (ArgType == Self) { return ReplacementType; } switch (@typeInfo(ArgType)) { .Type => return ArgType, .Void => return ArgType, .Bool => return ArgType, .NoReturn => return ArgType, .Int => return ArgType, .Float => return ArgType, .Pointer => |pointer| { return @Type(std.builtin.TypeInfo{.Pointer = structUpdate(pointer,.{.child= replaceSelfType(pointer.child,ReplacementType)})}); }, .Array => return ReplacementType, //TODO .Struct => { if (ArgType == Self) { // this is not strictly necessary if we want to keep the shortcut above return ReplacementType; } else { return ArgType; } }, .ComptimeFloat => return ArgType, .ComptimeInt => return ArgType, .Undefined => return ArgType, .Null => return ArgType, .Optional => |optional| { return @Type(std.builtin.TypeInfo{.Optional = structUpdate(optional, .{.child= replaceSelfType(optional.child,ReplacementType)})}); }, .ErrorUnion => return ReplacementType, //TODO .ErrorSet => return ArgType, .Enum => { if (ArgType == Self) { // this is not strictly necessary if we want to keep the shortcut above return ReplacementType; } else { return ArgType; } }, .Union => { if (ArgType == Self) { // this is not strictly necessary if we want to keep the shortcut above return ReplacementType; } else { return ArgType; } }, .Fn => return ReplacementType, //TODO .BoundFn => return ReplacementType, //TODO .Opaque => return ArgType, .Frame => return ArgType, .AnyFrame => return ArgType, .Vector => return ReplacementType, // TODO .EnumLiteral => return ArgType, } } test "replaceSelfType" { const Base = struct{}; //TODO also test that nothing else gets altered! //TODO finish this, maybe in it's own library try std.testing.expectEqual(replaceSelfType(Self,Base),Base); try std.testing.expectEqual(replaceSelfType(*Self,Base),*Base); try std.testing.expectEqual(replaceSelfType([]Self,Base),[]Base); try std.testing.expectEqual(replaceSelfType(?Self,Base),?Base); //try std.testing.expectEqual(replaceSelfType([4]Self,Base),[4]Base); // // and so on // // etc etc // try std.testing.expectEqual(replaceSelfType(fn()Self,Base),fn()Base); // try std.testing.expectEqual(replaceSelfType(fn(*Self)?i32,Base),fn(*Base)i32); // etc etc } /// TODO DOCUMENT, this is like a rust style struct update syntax pub fn structUpdate(instance : anytype, update : anytype) @TypeOf(instance) { const InstanceType = @TypeOf(instance); if(@typeInfo(InstanceType) != .Struct) { @compileError("This function can only be applied to struct types"); } // const update_fields = switch(@typeInfo(@TypeOf(update))) { // .Struct => |info| info, // else => @compileError("The update argument must be a tuple or struct containing the fields to be updated"), // }.fields; const instance_fields = switch(@typeInfo(@TypeOf(instance))) { .Struct => |info| info, else => @compileError("The update argument must be a tuple or struct containing the fields to be updated"), }.fields; // var updated_instance = instance; // inline for (update_fields) |field| { // if(@hasField(InstanceType, field.name)) { // @field(updated_instance, field.name) = @field(update, field.name); // } else { // @compileError("Type " ++ @typeName(InstanceType) ++ " has no field named '" ++ field.name ++ "'"); // } // } var updated_instance : InstanceType = undefined; inline for (instance_fields) |field| { if (@hasField(@TypeOf(update), field.name)) { @field(updated_instance,field.name) = @field(update,field.name); } else { @field(updated_instance,field.name) = @field(instance,field.name); } } return updated_instance; } test "structUpdate" { const S = struct { a : i32, b : i32, c : f32, }; const s = S{.a=1,.b=2,.c=3.14}; const s_noupdate = structUpdate(s, .{}); try std.testing.expect(std.meta.eql(s_noupdate, s)); const s_new = structUpdate(s, .{.a = 20}); try std.testing.expect(std.meta.eql(s_new, .{.a=20,.b=2,.c=3.14})); } test "concepts.hasFn always returns false when not given a container" { try std.testing.expect(!hasFn("func",fn(i32)i32)(i32)); try std.testing.expect(!hasFn("f32", fn(f32)f32)(i32)); } test "concepts.hasFn correctly matches function name and signatures for container types" { const MyError = error{Something}; const S = struct { value : i32, fn default() @This() { return .{.value=0}; } fn new(val : i32) @This() { return .{.value=val}; } fn increment(self : *@This()) !void { if (self.value < 0) { self.value += 1; } else { return MyError.Something; } } fn withMyError(_ : i32) MyError!i32 { return MyError.Something; } fn withAnyError() anyerror!i32 { return MyError.Something; } }; // hasFn should find everything that is there try std.testing.expect(hasFn("default",fn()S)(S)); try std.testing.expect(hasFn("new",fn(i32)S)(S)); try std.testing.expect(hasFn("increment",fn(*S)anyerror!void)(S)); try std.testing.expect(hasFn("withMyError",fn(i32)MyError!i32)(S)); // // hasFn must return false for wrong names or wrong signatures try std.testing.expect(!hasFn("DeFAuLt",fn()S)(S)); try std.testing.expect(!hasFn("NEW",fn(i32,i32)S)(S)); try std.testing.expect(!hasFn("increment",fn(*S,i32)anyerror!void)(S)); try std.testing.expect(!hasFn("withMyError",fn(i64)MyError!i32)(S)); try std.testing.expect(!hasFn("withMyError",fn(i16)MyError!i32)(S)); const DifferentError = error{SomethingElse}; // // hasFn compares error unions strictly unless signature we ask for is anyerror try std.testing.expect(hasFn("withMyError",fn(i32)anyerror!i32)(S)); try std.testing.expect(hasFn("withAnyError",fn()anyerror!i32)(S)); try std.testing.expect(!hasFn("default",fn()anyerror!S)(S)); try std.testing.expect(!hasFn("withAnyError",fn()MyError!i32)(S)); try std.testing.expect(!hasFn("withAnyError",fn()DifferentError!i32)(S)); try std.testing.expect(!hasFn("withMyError",fn(i32)DifferentError!i32)(S)); // // this works because the inferred error union is exactly only MyError try std.testing.expect(!hasFn("increment",fn(*S,i32)MyError!void)(S)); } /// An extension of std.meta.hasField, which takes an additional parameter specifying the /// type of the field. /// # Arguments /// * `T` the type we want to inspect /// * `name` the name of the field we are looking for /// * `FieldType` the type of the field we are looking for /// # Returns /// True iff T has a field with name `name` and type `FieldType`. pub fn hasField(comptime name :[]const u8, comptime FieldType : type) std.meta.trait.TraitFn { const Closure = struct { pub fn trait (comptime T: type) bool{ const fields = switch (@typeInfo(T)) { .Union => |u| u, .Struct => |s| s, .Enum => |e| e, else => return false, }.fields; // this *might* help save some compile time if the decl is not present in the container at all if(!@hasField(T, name)) { return false; } inline for (fields) |field| { if (std.mem.eql(u8, field.name, name) and field.field_type == FieldType) { return true; } } return false; } }; return Closure.trait; } test "concepts.hasField" { const S = struct { foo : i32, bar : f32, }; try std.testing.expect(hasField("foo", i32)(S)); try std.testing.expect(hasField("bar", f32)(S)); try std.testing.expect(!hasField("foo", u32)(S)); try std.testing.expect(!hasField("bar", f64)(S)); try std.testing.expect(!hasField("fooo", i32)(S)); try std.testing.expect(!hasField("az", f32)(S)); try std.testing.expect(!hasField("ba", f32)(S)); try std.testing.expect(!hasField("baz", f32)(S)); try std.testing.expect(!hasField("baz", i32)(i32)); }
src/concepts.zig
pub const common = @import("common.zig"); pub const gen2 = @import("gen2.zig"); pub const gen3 = @import("gen3.zig"); pub const gen4 = @import("gen4.zig"); pub const gen5 = @import("gen5.zig"); const std = @import("std"); // TODO: We can't have packages in tests const fun = @import("../../lib/fun-with-zig/src/index.zig"); const nds = @import("../nds/index.zig"); const utils = @import("../utils/index.zig"); const bits = @import("../bits.zig"); const generic = fun.generic; const slice = generic.slice; const math = std.math; const debug = std.debug; const os = std.os; const io = std.io; const mem = std.mem; const Namespace = @typeOf(std); const lu16 = fun.platform.lu16; const lu64 = fun.platform.lu64; const lu128 = fun.platform.lu128; test "pokemon" { _ = @import("common.zig"); _ = @import("gen2-constants.zig"); _ = @import("gen2.zig"); _ = @import("gen3-constants.zig"); _ = @import("gen3.zig"); _ = @import("gen4-constants.zig"); _ = @import("gen4.zig"); _ = @import("gen5-constants.zig"); _ = @import("gen5.zig"); } pub const Version = extern enum { Red, Blue, Yellow, Gold, Silver, Crystal, Ruby, Sapphire, Emerald, FireRed, LeafGreen, Diamond, Pearl, Platinum, HeartGold, SoulSilver, Black, White, Black2, White2, X, Y, OmegaRuby, AlphaSapphire, Sun, Moon, UltraSun, UltraMoon, pub fn gen(version: Version) u8 { const V = Version; // TODO: Fix format return switch (version) { V.Red, V.Blue, V.Yellow => u8(1), V.Gold, V.Silver, V.Crystal => u8(2), V.Ruby, V.Sapphire, V.Emerald, V.FireRed, V.LeafGreen => u8(3), V.Diamond, V.Pearl, V.Platinum, V.HeartGold, V.SoulSilver => u8(4), V.Black, V.White, V.Black2, V.White2 => u8(5), V.X, V.Y, V.OmegaRuby, V.AlphaSapphire => u8(6), V.Sun, V.Moon, V.UltraSun, V.UltraMoon => u8(7), }; } /// Dispatches a generic function with signature fn(comptime Namespace, @typeOf(context)) Result /// based on the result of ::version.gen(). The first parameter passed to ::func is a comptime /// known ::Namespace containing the declarations for the generation that ::version.value() /// corrispons too. This allows us to write ::func once, but have it use different types /// depending on the generation of Pokémon games we are working on. pub fn dispatch( version: Version, comptime Result: type, context: var, comptime func: var, ) Result { return switch (version.gen()) { 1 => @panic("TODO: Gen1"), 2 => @panic("TODO: Gen1"), 3 => func(gen3, context), 4 => func(gen4, context), 5 => func(gen5, context), 6 => @panic("TODO: Gen1"), 7 => @panic("TODO: Gen1"), else => unreachable, }; } pub fn hasPhysicalSpecialSplit(gen: Gen) bool { return @TagType(Gen)(gen) > 3; } // TODO: Can we find all legendaries in a game without having these hardcoded tables? // I mean, all legendaries have over 600 total stats, and all appear as static pokemons // somewhere. Most of them also have custom music. There are lots of stuff to look for // and I think we can make it work. pub fn legendaries(version: Version) []const u16 { return version.dispatch([]const u16, void{}, legendariesHelper); } pub fn legendariesHelper(comptime g: Namespace, c: void) []const u16 { return switch (g) { gen3 => []u16{ 0x090, 0x091, 0x092, // Articuno, Zapdos, Moltres 0x096, 0x097, 0x0F3, // Mewtwo, Mew, Raikou 0x0F4, 0x0F5, 0x0F9, // Entei, Suicune, Lugia 0x0FA, 0x0FB, 0x191, // Ho-Oh, Celebi, Regirock 0x192, 0x193, 0x194, // Regice, Registeel, Kyogre 0x195, 0x196, 0x197, // Groudon, Rayquaza, Latias 0x198, 0x199, 0x19A, // Latios, Jirachi, Deoxys }, gen4 => common.legendaries[0..32], gen5 => common.legendaries, else => unreachable, }; } }; pub const Type = extern enum { Invalid, Normal, Fighting, Flying, Poison, Ground, Rock, Bug, Ghost, Steel, Fire, Water, Grass, Electric, Psychic, Ice, Dragon, Dark, Fairy, pub fn fromGame(version: Version, id: u8) Type { return version.dispatch(Type, id, fromGameHelper); } fn fromGameHelper(comptime gen: Namespace, id: u8) Type { return toOther(Type, @bitCast(gen.Type, @TagType(gen.Type)(id))) orelse Type.Invalid; } pub fn toGame(version: Version, t: Type) u8 { // TODO: What do we do when the type does not exist in the game we are hacking. // For now, we just output 0xAA which is highly likely to not be a type in the game, // so the game will probably crash. // Should we assert here instead? Throw an error? What if the game have hacked in // types? Maybe these functions are only for convinience when hacking mainline games // and are useless on hacked games. return version.dispatch(u8, t, toGameHelper); } fn toGameHelper(comptime gen: Namespace, t: Type) u8 { const res = toOther(gen.Type, t) orelse return 0xAA; return u8(res); } fn toOther(comptime Out: type, in: var) ?Out { const In = @typeOf(in); const in_tags = @typeInfo(@typeOf(in)).Enum.fields; const out_tags = @typeInfo(Out).Enum.fields; inline for (in_tags) |in_tag| { inline for (out_tags) |out_tag| { if (!mem.eql(u8, in_tag.name, out_tag.name)) continue; const out_value = @TagType(Out)(out_tag.value); return Out(out_value); } } return null; } }; pub const LevelUpMove = extern struct { version: Version, data: *u8, pub fn level(move: LevelUpMove) u8 { return move.version.dispatch(u8, move, levelHelper); } fn levelHelper(comptime gen: Namespace, lvl_up_move: LevelUpMove) u8 { const lvl = @ptrCast(*gen.LevelUpMove, lvl_up_move.data).level; return if (gen == gen5) @intCast(u8, lvl.value()) else lvl; } pub fn setLevel(move: LevelUpMove, lvl: u8) void { move.version.dispatch(void, SetLvlC{ .move = move, .lvl = lvl, }, setLevelHelper); } const SetLvlC = struct { move: LevelUpMove, lvl: u8, }; fn setLevelHelper(comptime gen: Namespace, c: var) void { const lvl = if (gen == gen5) lu16.init(c.lvl) else u7(c.lvl); @ptrCast(*gen.LevelUpMove, c.move.data).level = lvl; } pub fn moveId(move: LevelUpMove) u16 { return move.version.dispatch(u16, move, moveIdHelper); } fn moveIdHelper(comptime gen: Namespace, move: var) u16 { const move_id = @ptrCast(*gen.LevelUpMove, move.data).move_id; return if (gen == gen5) move_id.value() else move_id; } pub fn setMoveId(move: LevelUpMove, id: u16) void { move.version.dispatch(u16, SetMoveIdC{ .move = move, .id = id, }, setLevelHelper); } const SetMoveIdC = struct { move: LevelUpMove, id: u8, }; fn setMoveIdHelper(comptime gen: Namespace, c: var) void { const id = if (gen == gen5) lu16.init(c.id) else u9(c.id); @ptrCast(*gen.LevelUpMove, c.move.data).move_id = id; } }; pub const LevelUpMoves = extern struct { version: Version, data_len: usize, data: [*]u8, pub fn at(moves: LevelUpMoves, index: usize) LevelUpMove { return moves.version.dispatch(LevelUpMove, atC{ .moves = moves, .index = index, }, atHelper); } const atC = struct { moves: LevelUpMoves, index: usize, }; fn atHelper(comptime gen: Namespace, c: var) LevelUpMove { const moves = @ptrCast([*]gen.LevelUpMove, c.moves.data)[0..c.moves.data_len]; return LevelUpMove{ .version = c.moves.version, .data = @ptrCast(*u8, &moves[c.index]), }; } pub fn len(moves: LevelUpMoves) usize { return moves.data_len; } pub fn iterator(moves: LevelUpMoves) Iter { return Iter.init(moves); } const Iter = Iterator(LevelUpMoves, LevelUpMove); }; const MachineKind = enum { Hidden, Technical, }; pub const TmLearnset = Learnset(MachineKind.Technical); pub const HmLearnset = Learnset(MachineKind.Hidden); pub fn Learnset(comptime kind: MachineKind) type { return extern struct { const Self = @This(); game: *const BaseGame, data: *u8, pub fn at(learnset: Self, index: usize) bool { return learnset.game.version.dispatch(bool, atC{ .learnset = learnset, .index = index, }, atHelper); } const atC = struct { learnset: Self, index: usize, }; fn atHelper(comptime gen: Namespace, c: var) bool { const i = c.learnset.indexInLearnset(gen, c.index); const T = if (gen == gen3) lu64 else lu128; const learnset = @ptrCast(*T, c.learnset.data); const Int = @typeOf(learnset.value()); return bits.get(Int, learnset.value(), @intCast(math.Log2Int(Int), i)); } pub fn atSet(learnset: Self, index: usize, value: bool) void { learnset.game.version.dispatch(bool, atSetC{ .learnset = learnset, .index = index, .value = value, }, atSetHelper); } const atSetC = struct { learnset: Self, index: usize, value: bool, }; fn atSetHelper(comptime gen: Namespace, c: var) void { const i = c.learnset.indexInLearnset(gen, index); const T = if (gen == gen3) lu64 else lu128; const learnset = @ptrCast(*T, learnset.data); const Int = @typeOf(learnset.value()); learnset.* = T.init(bits.set(Int, learnset.value(), math.Log2Int(Int)(i), c.value)); } fn indexInLearnset(learnset: Self, comptime gen: Namespace, index: usize) usize { const game = @fieldParentPtr(gen.Game, "base", learnset.game); const i = switch (gen) { gen3, gen4 => { if (kind == MachineKind.Hidden) { debug.assert(index < game.hms.len); return index + game.tms.len; } debug.assert(index < game.tms.len); return index; }, gen5 => { if (kind == MachineKind.Hidden) { debug.assert(index < game.hms.len); return index + game.tms1.len; } debug.assert(index < game.tms1.len + game.tms2.len); return if (index < game.tms1.len) index else index + game.hms.len; }, else => @compileError("Gen not supported!"), }; } pub fn len(learnset: Self) usize { return learnset.game.version.dispatch(usize, learnset, lenHelper); } fn lenHelper(comptime gen: Namespace, learnset: var) usize { const game = @fieldParentPtr(gen.Game, "base", learnset.game); if (kind == MachineKind.Hidden) return game.hms.len; return switch (gen) { gen3, gen4 => game.tms.len, gen5 => game.tms1.len + game.tms2.len, else => @compileError("Gen not supported!"), }; } pub fn iterator(learnset: Self) Iter { return Iter.init(learnset); } const Iter = Iterator(Self, bool); }; } pub const Pokemon = extern struct { game: *const BaseGame, base: *u8, learnset: *u8, level_up_moves_len: usize, level_up_moves: [*]u8, pub fn hp(pokemon: Pokemon) *u8 { return pokemon.game.version.dispatch(*u8, pokemon, hpHelper); } fn hpHelper(comptime gen: Namespace, pokemon: var) *u8 { return &@ptrCast(*gen.BasePokemon, pokemon.base).stats.hp; } pub fn attack(pokemon: Pokemon) *u8 { return pokemon.game.version.dispatch(*u8, pokemon, attackHelper); } fn attackHelper(comptime gen: Namespace, pokemon: var) *u8 { return &@ptrCast(*gen.BasePokemon, pokemon.base).stats.attack; } pub fn defense(pokemon: Pokemon) *u8 { return pokemon.game.version.dispatch(*u8, pokemon, defenseHelper); } fn defenseHelper(comptime gen: Namespace, pokemon: var) *u8 { return &@ptrCast(*gen.BasePokemon, pokemon.base).stats.defense; } pub fn speed(pokemon: Pokemon) *u8 { return pokemon.game.version.dispatch(*u8, pokemon, speedHelper); } fn speedHelper(comptime gen: Namespace, pokemon: var) *u8 { return &@ptrCast(*gen.BasePokemon, pokemon.base).stats.speed; } pub fn spAttack(pokemon: Pokemon) *u8 { return pokemon.game.version.dispatch(*u8, pokemon, spAttackHelper); } fn spAttackHelper(comptime gen: Namespace, pokemon: var) *u8 { return &@ptrCast(*gen.BasePokemon, pokemon.base).stats.sp_attack; } pub fn spDefense(pokemon: Pokemon) *u8 { return pokemon.game.version.dispatch(*u8, pokemon, spDefenseHelper); } fn spDefenseHelper(comptime gen: Namespace, pokemon: var) *u8 { return &@ptrCast(*gen.BasePokemon, pokemon.base).stats.sp_defense; } pub fn levelUpMoves(pokemon: Pokemon) LevelUpMoves { return LevelUpMoves{ .version = pokemon.game.version, .data_len = pokemon.level_up_moves_len, .data = pokemon.level_up_moves, }; } pub fn totalStats(pokemon: Pokemon) u16 { const gen = pokemon.game.version.gen(); var total: u16 = pokemon.hp().*; total += pokemon.attack().*; total += pokemon.defense().*; total += pokemon.speed().*; total += pokemon.spAttack().*; if (gen != 1) total += pokemon.spDefense().*; return total; } pub fn types(pokemon: Pokemon) *[2]u8 { return pokemon.game.version.dispatch(*[2]u8, pokemon, typesHelper); } fn typesHelper(comptime gen: Namespace, pokemon: Pokemon) *[2]u8 { const ts = &@ptrCast(*gen.BasePokemon, pokemon.base).types; return @ptrCast(*[2]u8, ts); } pub fn tmLearnset(pokemon: Pokemon) TmLearnset { return TmLearnset{ .game = pokemon.game, .data = pokemon.learnset, }; } pub fn hmLearnset(pokemon: Pokemon) HmLearnset { return HmLearnset{ .game = pokemon.game, .data = pokemon.learnset, }; } }; pub const Pokemons = extern struct { game: *const BaseGame, pub fn at(pokemons: Pokemons, index: usize) AtErrs!Pokemon { return pokemons.game.version.dispatch(AtErrs!Pokemon, atC{ .pokemons = pokemons, .index = index, }, atHelper); } const AtErrs = error{ FileToSmall, NotFile, InvalidPointer, NodeIsFolder, }; const atC = struct { pokemons: Pokemons, index: usize, }; fn atHelper(comptime gen: Namespace, c: var) AtErrs!Pokemon { const index = c.index; const pokemons = c.pokemons; const game = @fieldParentPtr(gen.Game, "base", pokemons.game); var base_pokemon: *gen.BasePokemon = undefined; var learnset: *u8 = undefined; switch (gen) { gen3 => { base_pokemon = &game.base_stats[index]; learnset = @ptrCast(*u8, &game.machine_learnsets[index]); }, gen4, gen5 => { base_pokemon = try getFileAsType(gen.BasePokemon, game.base_stats, index); learnset = @ptrCast(*u8, &base_pokemon.machine_learnset); }, else => @compileError("Gen not supported!"), } const level_up_moves = blk: { var start: usize = undefined; var data: []u8 = undefined; switch (gen) { gen3 => { start = try game.level_up_learnset_pointers[index].toInt(); data = game.data; }, gen4, gen5 => { start = 0; data = (try getFile(game.level_up_moves, index)).data; }, else => @compileError("Gen not supported!"), } // gen3,4,5 all have 0xFF ** @sizeOf(gen.LevelUpMove) terminated level up moves, // even though gen4,5 stores level up moves in files with a length. const terminator = []u8{0xFF} ** @sizeOf(gen.LevelUpMove); const res = slice.bytesToSliceTrim(gen.LevelUpMove, data[start..]); for (res) |level_up_move, i| { const bytes = mem.toBytes(level_up_move); if (std.mem.eql(u8, bytes, terminator)) break :blk res[0..i]; } break :blk res; }; return Pokemon{ .game = pokemons.game, .base = @ptrCast(*u8, base_pokemon), .learnset = learnset, .level_up_moves_len = level_up_moves.len, .level_up_moves = @ptrCast([*]u8, level_up_moves.ptr), }; } pub fn len(pokemons: Pokemons) usize { return pokemons.game.version.dispatch(usize, pokemons, lenHelper); } fn lenHelper(comptime gen: Namespace, pokemons: Pokemons) usize { const game = @fieldParentPtr(gen.Game, "base", pokemons.game); switch (gen) { gen3 => { var min = game.base_stats.len; min = math.min(min, game.machine_learnsets.len); min = math.min(min, game.evolutions.len); return math.min(min, game.level_up_learnset_pointers.len); }, gen4, gen5 => { var min = game.base_stats.nodes.len; return math.min(min, game.level_up_moves.nodes.len); }, else => @compileError("Gen not supported!"), } } pub fn iterator(pokemons: Pokemons) Iter { return Iter.init(pokemons); } const Iter = ErrIterator(Pokemons, Pokemon); }; const PartyMemberMoves = extern struct { game: *const BaseGame, data: [*]u8, pub fn at(moves: PartyMemberMoves, index: usize) u16 { return moves.game.version.dispatch(u16, AtC{ .moves = moves, .index = index, }, atHelper); } const AtC = struct { moves: PartyMemberMoves, index: usize, }; fn atHelper(comptime gen: Namespace, c: AtC) u16 { const moves = @ptrCast(*[4]lu16, c.moves.data); return moves[c.index].value(); } pub fn atSet(moves: PartyMemberMoves, index: usize, value: u16) void { moves.game.version.dispatch(void, AtSetC{ .moves = moves, .index = index, .value = value, }, atSetHelper); } const AtSetC = struct { moves: PartyMemberMoves, index: usize, value: u16, }; fn atSetHelper(comptime gen: Namespace, c: AtSetC) void { const moves = @ptrCast(*[4]lu16, c.moves.data); moves[c.index] = lu16.init(c.value); } pub fn len(moves: PartyMemberMoves) usize { return 4; } pub fn iterator(moves: PartyMemberMoves) Iter { return Iter.init(pokemons); } const Iter = Iterator(PartyMemberMoves, u16); }; pub const PartyMember = extern struct { game: *const BaseGame, base: *u8, item_ptr: ?*u8, moves_ptr: ?[*]u8, pub fn species(member: PartyMember) u16 { return member.game.version.dispatch(u16, member, speciesHelper); } fn speciesHelper(comptime gen: Namespace, member: PartyMember) u16 { const s = @ptrCast(*gen.PartyMember, member.base).species; return if (gen != gen4) s.value() else s; } pub fn setSpecies(member: PartyMember, v: u16) void { member.game.version.dispatch(void, SetSpeciesC{ .member = member, .value = v, }, setSpeciesHelper); } const SetSpeciesC = struct { member: PartyMember, value: u16, }; fn setSpeciesHelper(comptime gen: Namespace, c: SetSpeciesC) void { const s = if (gen != gen4) lu16.init(c.value) else @intCast(u10, c.value); @ptrCast(*gen.PartyMember, c.member.base).species = s; } pub fn level(member: PartyMember) u8 { return member.game.version.dispatch(u8, member, levelHelper); } fn levelHelper(comptime gen: Namespace, member: var) u8 { const lvl = @ptrCast(*gen.PartyMember, member.base).level; return if (gen != gen5) @intCast(u8, lvl.value()) else lvl; } pub fn setLevel(member: PartyMember, lvl: u8) void { return member.game.version.dispatch(void, SetLvlC{ .member = member, .value = lvl, }, setLevelHelper); } const SetLvlC = struct { member: PartyMember, value: u8, }; fn setLevelHelper(comptime gen: Namespace, c: SetLvlC) void { const lvl = if (gen != gen5) lu16.init(c.value) else c.value; @ptrCast(*gen.PartyMember, c.member.base).level = lvl; } pub fn item(member: PartyMember) ?u16 { return member.game.version.dispatch(?u16, member, itemHelper); } fn itemHelper(comptime gen: Namespace, member: var) ?u16 { const item_ptr = @ptrCast(?*lu16, member.item_ptr) orelse return null; return item_ptr.value(); } pub fn setItem(member: PartyMember, v: u16) SetItemErr!void { return member.game.version.dispatch(SetItemErr!void, SetItemC{ .member = member, .value = v, }, setItemHelper); } const SetItemErr = error{HasNoItem}; const SetItemC = struct { member: PartyMember, value: u16, }; fn setItemHelper(comptime gen: Namespace, c: SetItemC) SetItemErr!void { const item_ptr = @ptrCast(?*lu16, c.member.item_ptr) orelse return SetItemErr.HasNoItem; item_ptr.* = lu16.init(c.value); } pub fn moves(member: PartyMember) ?PartyMemberMoves { return PartyMemberMoves{ .game = member.game, .data = member.moves_ptr orelse return null, }; } }; pub const Party = extern struct { trainer: Trainer, pub fn at(party: Party, index: usize) PartyMember { return party.trainer.game.version.dispatch(PartyMember, AtC{ .party = party, .index = index, }, atHelper); } const AtC = struct { party: Party, index: usize, }; fn atHelper(comptime gen: Namespace, c: AtC) PartyMember { const index = c.index; const trainer = @ptrCast(*gen.Trainer, c.party.trainer.base); const member_size = c.party.memberSize(); const party_size = if (gen == gen3) trainer.party.len() else trainer.party_size; const party_data = c.party.trainer.party_ptr[0 .. party_size * member_size]; const member_data = party_data[index * member_size ..][0..member_size]; var off: usize = 0; const base = &member_data[off]; off += @sizeOf(gen.PartyMember); const item = blk: { const has_item = trainer.party_type & gen.Trainer.has_item != 0; if (has_item) { const end = off + @sizeOf(u16); defer off = end; break :blk @ptrCast(*u8, &member_data[off..end][0]); } break :blk null; }; const moves = blk: { const has_item = trainer.party_type & gen.Trainer.has_moves != 0; if (has_item) { const end = off + @sizeOf([4]u16); defer off = end; break :blk member_data[off..end].ptr; } break :blk null; }; if (gen == gen3) { if (item == null) off += @sizeOf(u16); } off += switch (c.party.trainer.game.version) { Version.HeartGold, Version.SoulSilver, Version.Platinum => usize(@sizeOf(u16)), else => usize(0), }; // It's a bug, if we haven't read all member_data debug.assert(member_data.len == off); return PartyMember{ .game = c.party.trainer.game, .base = base, .item_ptr = item, .moves_ptr = moves, }; } pub fn len(party: Party) usize { return party.trainer.game.version.dispatch(usize, party, lenHelper); } fn lenHelper(comptime gen: Namespace, party: var) usize { const trainer = @ptrCast(*gen.Trainer, party.trainer.base); return switch (gen) { gen3 => trainer.party.len(), gen4, gen5 => trainer.party_size, else => @compileError("Gen not supported!"), }; } fn memberSize(party: Party) usize { return party.trainer.game.version.dispatch(usize, party, memberSizeHelper); } fn memberSizeHelper(comptime gen: Namespace, party: Party) usize { const trainer = @ptrCast(*gen.Trainer, party.trainer.base); var res: usize = @sizeOf(gen.PartyMember); if (gen == gen3) { res += @sizeOf(u16); } else if (trainer.party_type & gen.Trainer.has_item != 0) { res += @sizeOf(u16); } if (trainer.party_type & gen.Trainer.has_moves != 0) res += @sizeOf([4]u16); // In HG/SS/Plat party members are padded with two extra bytes. res += switch (party.trainer.game.version) { Version.HeartGold, Version.SoulSilver, Version.Platinum => usize(2), else => usize(0), }; return res; } pub fn iterator(party: Party) Iter { return Iter.init(party); } const Iter = Iterator(Party, PartyMember); }; pub const Trainer = extern struct { game: *const BaseGame, base: *u8, party_ptr: [*]u8, pub fn party(trainer: Trainer) Party { return Party{ .trainer = trainer }; } }; pub const Trainers = extern struct { game: *const BaseGame, pub fn at(trainers: Trainers, index: usize) AtErr!Trainer { return trainers.game.version.dispatch(AtErr!Trainer, AtC{ .trainers = trainers, .index = index, }, atHelper); } const AtErr = error{ FileToSmall, NotFile, InvalidPartySize, InvalidPointer, }; const AtC = struct { trainers: Trainers, index: usize, }; fn atHelper(comptime gen: Namespace, c: AtC) AtErr!Trainer { const trainers = c.trainers; const index = c.index; const game = @fieldParentPtr(gen.Game, "base", trainers.game); const trainer = if (gen == gen3) &game.trainers[index] else try getFileAsType(gen.Trainer, game.trainers, index); var res = Trainer{ .game = &game.base, .base = @ptrCast(*u8, trainer), .party_ptr = undefined, }; res.party_ptr = switch (gen) { gen3 => blk: { const party = try trainer.party.toSlice(game.data); break :blk party.ptr; }, gen4, gen5 => blk: { const party = try getFile(game.parties, index); const min_size = trainer.party_size * res.party().memberSize(); if (party.data.len < min_size) { @breakpoint(); return error.InvalidPartySize; } break :blk party.data.ptr; }, else => @compileError("Gen not supported!"), }; return res; } pub fn len(trainers: Trainers) usize { return trainers.game.version.dispatch(usize, trainers, lenHelper); } fn lenHelper(comptime gen: Namespace, trainers: var) usize { const game = @fieldParentPtr(gen.Game, "base", trainers.game); switch (gen) { gen3 => return game.trainers.len, gen4, gen5 => { return math.min(game.trainers.nodes.len, game.parties.nodes.len); }, else => @compileError("Gen not supported!"), } } pub fn iterator(trainers: Trainers) Iter { return Iter.init(trainers); } const Iter = ErrIterator(Trainers, Trainer); }; pub const Tms = Machines(MachineKind.Technical); pub const Hms = Machines(MachineKind.Hidden); pub fn Machines(comptime kind: MachineKind) type { return extern struct { const Self = @This(); game: *const BaseGame, pub fn at(machines: Self, index: usize) u16 { return machines.game.version.dispatch(u16, AtC{ .machines = machines, .index = index, }, atHelper); } const AtC = struct { machines: Self, index: usize, }; fn atHelper(comptime gen: Namespace, c: AtC) u16 { var index = c.index; const machines = getMachines(gen, c.machines, &index); return machines[index].value(); } pub fn atSet(machines: Self, index: usize, value: u16) void { return machines.game.version.dispatch(void, AtSetC{ .machines = machines, .index = index, .value = value, }, atSetHelper); } const AtSetC = struct { machines: *const Self, index: usize, value: u16, }; fn atSetHelper(comptime gen: Namespace, c: AtSetC) void { var index = c.index; const machines = getMachines(gen, c.machines, &index); machines[index].set(c.value); } fn getMachines(comptime gen: Namespace, machines: Self, index: *usize) []lu16 { const game = @fieldParentPtr(gen.Game, "base", machines.game); switch (gen) { gen3, gen4 => return if (kind == MachineKind.Hidden) game.hms else game.tms, gen5 => { if (kind == MachineKind.Hidden) return game.hms; if (index.* < game.tms1.len) return game.tms1; index.* -= game.tms1.len; return game.tms2; }, else => @compileError("Gen not supported!"), } } pub fn len(machines: Self) usize { return machines.game.version.dispatch(usize, machines, lenHelper); } fn lenHelper(comptime gen: Namespace, machines: Self) usize { const game = @fieldParentPtr(gen.Game, "base", machines.game); if (kind == MachineKind.Hidden) return game.hms.len; return switch (gen) { gen3, gen4 => game.tms.len, gen5 => game.tms1.len + game.tms2.len, else => @compileError("Gen not supported!"), }; } pub fn iterator(machines: Self) Iter { return Iter.init(machines); } const Iter = Iterator(Self, u16); }; } pub const Move = extern struct { game: *const BaseGame, data: *u8, pub fn types(move: Move) *[1]u8 { return move.game.version.dispatch(*[1]u8, move, typesHelper); } fn typesHelper(comptime gen: Namespace, move: var) *[1]u8 { const t = &@ptrCast(*gen.Move, move.data).@"type"; return @ptrCast(*[1]u8, t); } pub fn power(move: Move) *u8 { return move.game.version.dispatch(*u8, move, powerHelper); } fn powerHelper(comptime gen: Namespace, move: Move) *u8 { return &@ptrCast(*gen.Move, move.data).power; } pub fn pp(move: Move) *u8 { return move.game.version.dispatch(*u8, move, ppHelper); } fn ppHelper(comptime gen: Namespace, move: Move) *u8 { return &@ptrCast(*gen.Move, move.data).pp; } }; pub const Moves = extern struct { game: *const BaseGame, pub fn at(moves: Moves, index: usize) AtErr!Move { return moves.game.version.dispatch(AtErr!Move, AtC{ .moves = moves, .index = index, }, atHelper); } const AtC = struct { moves: Moves, index: usize, }; const AtErr = error{ NotFile, FileToSmall, }; fn atHelper(comptime gen: Namespace, c: AtC) AtErr!Move { const index = c.index; const moves = c.moves; const game = @fieldParentPtr(gen.Game, "base", moves.game); const move = switch (gen) { gen3 => &game.moves[index], gen4, gen5 => try getFileAsType(gen.Move, game.moves, index), else => @compileError("Gen not supported!"), }; return Move{ .game = moves.game, .data = @ptrCast(*u8, move), }; } pub fn len(moves: Moves) usize { return moves.game.version.dispatch(usize, moves, lenHelper); } fn lenHelper(comptime gen: Namespace, moves: var) usize { const game = @fieldParentPtr(gen.Game, "base", moves.game); return switch (gen) { gen3 => game.moves.len, gen4, gen5 => game.moves.nodes.len, else => @compileError("Gen not supported!"), }; } pub fn iterator(moves: Moves) Iter { return Iter.init(moves); } const Iter = ErrIterator(Moves, Move); }; pub const WildPokemon = extern struct { //vtable: *const VTable, species: *lu16, min_level: *u8, max_level: *u8, pub fn getSpecies(wild_mon: WildPokemon) u16 { return wild_mon.species.value(); } pub fn setSpecies(wild_mon: WildPokemon, species: u16) void { wild_mon.species.* = lu16.init(species); } pub fn getMinLevel(wild_mon: WildPokemon) u8 { return wild_mon.min_level.*; } pub fn setMinLevel(wild_mon: WildPokemon, lvl: u8) void { wild_mon.min_level.* = lvl; } pub fn getMaxLevel(wild_mon: WildPokemon) u8 { return wild_mon.max_level.*; } pub fn setMaxLevel(wild_mon: WildPokemon, lvl: u8) void { wild_mon.max_level.* = lvl; } const VTable = struct { fn init(comptime gen: Namespace) VTable { return VTable{}; } }; }; pub const WildPokemons = extern struct { vtable: *const VTable, game: *const BaseGame, data: *u8, pub fn at(wild_mons: WildPokemons, index: usize) !WildPokemon { return try wild_mons.vtable.at(wild_mons, index); } pub fn len(wild_mons: WildPokemons) usize { return wild_mons.vtable.len(wild_mons); } pub fn iterator(wild_mons: WildPokemons) Iter { return Iter.init(wild_mons); } const Iter = ErrIterator(WildPokemons, WildPokemon); const VTable = struct { const AtErr = error{InvalidPointer}; // TODO: convert to pass by value at: fn (wild_mons: WildPokemons, index: usize) AtErr!WildPokemon, len: fn (wild_mons: WildPokemons) usize, fn init(comptime gen: Namespace) VTable { const Funcs = struct { fn at(wild_mons: WildPokemons, index: usize) AtErr!WildPokemon { var i = index; switch (gen) { gen3 => { const game = @fieldParentPtr(gen.Game, "base", wild_mons.game); const data = @ptrCast(*gen.WildPokemonHeader, wild_mons.data); inline for ([][]const u8{ "land_pokemons", "surf_pokemons", "rock_smash_pokemons", "fishing_pokemons", }) |field| { // TODO: Compiler crash. Cause: Different types per inline loop iterations const ref = @field(data, field); if (!ref.isNull()) { const info = try ref.toSingle(game.data); const arr = try info.wild_pokemons.toSingle(game.data); if (i < arr.len) { return WildPokemon{ //.vtable = WildPokemon.VTable.init(gen), .species = &arr[i].species, .min_level = &arr[i].min_level, .max_level = &arr[i].max_level, }; } i -= arr.len; } } unreachable; }, gen4 => switch (wild_mons.game.version) { Version.Diamond, Version.Pearl, Version.Platinum => { const data = @ptrCast(*gen.DpptWildPokemons, wild_mons.data); if (i < data.grass.len) { return WildPokemon{ //.vtable = WildPokemon.VTable.init(gen), .species = &data.grass[i].species, .min_level = &data.grass[i].level, .max_level = &data.grass[i].level, }; } i -= data.grass.len; const ReplacementField = struct { name: []const u8, replace_with: []const usize, }; inline for ([]ReplacementField{ ReplacementField{ .name = "swarm_replacements", .replace_with = []const usize{ 0, 1 }, }, ReplacementField{ .name = "day_replacements", .replace_with = []const usize{ 2, 3 }, }, ReplacementField{ .name = "night_replacements", .replace_with = []const usize{ 2, 3 }, }, ReplacementField{ .name = "radar_replacements", .replace_with = []const usize{ 4, 5, 10, 11 }, }, ReplacementField{ .name = "unknown_replacements", .replace_with = []const usize{0} ** 6, }, ReplacementField{ .name = "gba_replacements", .replace_with = []const usize{ 8, 9 } ** 5, }, }) |field| { const arr = &@field(data, field.name); if (i < arr.len) { const replacement = &data.grass[field.replace_with[i]]; return WildPokemon{ //.vtable = WildPokemon.VTable.init(gen), .species = &arr[i].species, .min_level = &replacement.level, .max_level = &replacement.level, }; } i -= arr.len; } inline for ([][]const u8{ "surf", "sea_unknown", "old_rod", "good_rod", "super_rod", }) |field| { const arr = &@field(data, field); if (i < arr.len) { return WildPokemon{ //.vtable = WildPokemon.VTable.init(gen), .species = &arr[i].species, .min_level = &arr[i].level_min, .max_level = &arr[i].level_max, }; } i -= arr.len; } unreachable; }, Version.HeartGold, Version.SoulSilver => { const data = @ptrCast(*gen.HgssWildPokemons, wild_mons.data); inline for ([][]const u8{ "grass_morning", "grass_day", "grass_night", }) |field| { const arr = &@field(data, field); if (i < arr.len) { return WildPokemon{ //.vtable = WildPokemon.VTable.init(gen), .species = &arr[i], .min_level = &data.grass_levels[i], .max_level = &data.grass_levels[i], }; } i -= arr.len; } inline for ([][]const u8{ "surf", "sea_unknown", "old_rod", "good_rod", "super_rod", }) |field| { const arr = &@field(data, field); if (i < arr.len) { return WildPokemon{ //.vtable = WildPokemon.VTable.init(gen), .species = &arr[i].species, .min_level = &arr[i].level_min, .max_level = &arr[i].level_max, }; } i -= arr.len; } // TODO: Swarm and radio unreachable; }, else => unreachable, }, gen5 => { const data = @ptrCast(*gen.WildPokemons, wild_mons.data); inline for ([][]const u8{ "grass", "dark_grass", "rustling_grass", "surf", "ripple_surf", "fishing", "ripple_fishing", }) |field| { const arr = &@field(data, field); if (i < arr.len) { return WildPokemon{ //.vtable = WildPokemon.VTable.init(gen), .species = &arr[i].species, .min_level = &arr[i].level_min, .max_level = &arr[i].level_max, }; } i -= arr.len; } unreachable; }, else => comptime unreachable, } } fn len(wild_mons: WildPokemons) usize { switch (gen) { gen3 => { const data = @ptrCast(*gen.WildPokemonHeader, wild_mons.data); return usize(12) * @boolToInt(!data.land_pokemons.isNull()) + usize(5) * @boolToInt(!data.surf_pokemons.isNull()) + usize(5) * @boolToInt(!data.rock_smash_pokemons.isNull()) + usize(10) * @boolToInt(!data.fishing_pokemons.isNull()); }, gen4 => switch (wild_mons.game.version) { Version.Diamond, Version.Pearl, Version.Platinum => { const data = @ptrCast(*gen.DpptWildPokemons, wild_mons.data); return data.grass.len + data.swarm_replacements.len + data.day_replacements.len + data.night_replacements.len + data.radar_replacements.len + data.unknown_replacements.len + data.gba_replacements.len + data.surf.len + data.sea_unknown.len + data.old_rod.len + data.good_rod.len + data.super_rod.len; }, Version.HeartGold, Version.SoulSilver => { const data = @ptrCast(*gen.HgssWildPokemons, wild_mons.data); return data.grass_morning.len + data.grass_day.len + data.grass_night.len + //data.radio.len + data.surf.len + data.sea_unknown.len + data.old_rod.len + data.good_rod.len + data.super_rod.len; // + //data.swarm.len; }, else => unreachable, }, gen5 => { const data = @ptrCast(*gen.WildPokemons, wild_mons.data); return data.grass.len + data.dark_grass.len + data.rustling_grass.len + data.surf.len + data.ripple_surf.len + data.fishing.len + data.ripple_fishing.len; }, else => comptime unreachable, } } }; return VTable{ .at = Funcs.at, .len = Funcs.len, }; } }; }; pub const Zone = extern struct { vtable: *const VTable, game: *const BaseGame, wild_pokemons: *u8, pub fn getWildPokemons(zone: Zone) WildPokemons { return zone.vtable.getWildPokemons(zone); } const VTable = struct { // TODO: convert to pass by value getWildPokemons: fn (zone: Zone) WildPokemons, fn init(comptime gen: Namespace) VTable { const Funcs = struct { fn getWildPokemons(zone: Zone) WildPokemons { return WildPokemons{ .vtable = &comptime WildPokemons.VTable.init(gen), .game = zone.game, .data = zone.wild_pokemons, }; } }; return VTable{ .getWildPokemons = Funcs.getWildPokemons }; } }; }; pub const Zones = extern struct { vtable: *const VTable, game: *const BaseGame, pub fn at(zones: Zones, index: usize) !Zone { return try zones.vtable.at(zones, index); } pub fn len(zones: Zones) usize { return zones.vtable.len(zones); } pub fn iterator(zones: Zones) Iter { return Iter.init(zones); } const Iter = ErrIterator(Zones, Zone); const VTable = struct { const AtErr = error{ FileToSmall, NotFile, }; // TODO: pass by value at: fn (zones: Zones, index: usize) AtErr!Zone, len: fn (zones: Zones) usize, fn init(comptime gen: Namespace) VTable { const Funcs = struct { fn at(zones: Zones, index: usize) AtErr!Zone { const game = @fieldParentPtr(gen.Game, "base", zones.game); return Zone{ .vtable = &comptime Zone.VTable.init(gen), .game = zones.game, .wild_pokemons = switch (gen) { gen3 => @ptrCast(*u8, &game.wild_pokemon_headers[index]), gen4 => switch (zones.game.version) { Version.Diamond, Version.Pearl, Version.Platinum => blk: { break :blk @ptrCast(*u8, try getFileAsType(gen.DpptWildPokemons, game.wild_pokemons, index)); }, Version.HeartGold, Version.SoulSilver => blk: { break :blk @ptrCast(*u8, try getFileAsType(gen.HgssWildPokemons, game.wild_pokemons, index)); }, else => unreachable, }, gen5 => @ptrCast(*u8, try getFileAsType(gen.WildPokemon, game.wild_pokemons, index)), else => comptime unreachable, }, }; } fn len(zones: Zones) usize { const game = @fieldParentPtr(gen.Game, "base", zones.game); return switch (gen) { gen3 => game.wild_pokemon_headers.len, gen4, gen5 => game.wild_pokemons.nodes.len, else => comptime unreachable, }; } }; return VTable{ .at = Funcs.at, .len = Funcs.len, }; } }; }; pub const BaseGame = extern struct { version: Version, }; pub const Game = extern struct { base: *BaseGame, allocator: *mem.Allocator, nds_rom: ?*nds.Rom, pub fn load(file: os.File, allocator: *mem.Allocator) !Game { const start = try file.getPos(); try file.seekTo(start); return loadGbaGame(file, allocator) catch { try file.seekTo(start); return loadNdsGame(file, allocator) catch return error.InvalidGame; }; } pub fn loadGbaGame(file: os.File, allocator: *mem.Allocator) !Game { var game = try gen3.Game.fromFile(file, allocator); errdefer game.deinit(); const alloced_game = try allocator.create(game); errdefer allocator.destroy(alloced_game); return Game{ .base = &alloced_game.base, .allocator = allocator, .nds_rom = null, }; } pub fn loadNdsGame(file: os.File, allocator: *mem.Allocator) !Game { var rom = try nds.Rom.fromFile(file, allocator); errdefer rom.deinit(); const nds_rom = try allocator.create(rom); errdefer allocator.destroy(nds_rom); if (gen4.Game.fromRom(nds_rom.*)) |game| { const alloced_game = try allocator.create(game); return Game{ .base = &alloced_game.base, .allocator = allocator, .nds_rom = nds_rom, }; } else |e1| if (gen5.Game.fromRom(nds_rom.*)) |game| { const alloced_game = try allocator.create(game); return Game{ .base = &alloced_game.base, .allocator = allocator, .nds_rom = nds_rom, }; } else |e2| { return error.InvalidGame; } } pub fn save(game: Game, file: os.File) !void { const gen = game.base.version.gen(); if (gen == 3) { const g = @fieldParentPtr(gen3.Game, "base", game.base); var file_stream = file.outStream(); try g.writeToStream(&file_stream.stream); } if (game.nds_rom) |nds_rom| try nds_rom.writeToFile(file, game.allocator); } pub fn deinit(game: *Game) void { game.base.version.dispatch(void, game, deinitHelper); } fn deinitHelper(comptime gen: Namespace, game: *Game) void { const allocator = @ptrCast(*mem.Allocator, game.allocator); const g = @fieldParentPtr(gen.Game, "base", game.base); if (gen == gen3) g.deinit(); if (game.nds_rom) |nds_rom| { nds_rom.deinit(); allocator.destroy(nds_rom); } allocator.destroy(g); game.* = undefined; } pub fn pokemons(game: Game) Pokemons { return Pokemons{ .game = game.base }; } pub fn trainers(game: Game) Trainers { return Trainers{ .game = game.base }; } pub fn tms(game: Game) Tms { return Tms{ .game = game.base }; } pub fn hms(game: Game) Hms { return Hms{ .game = game.base }; } pub fn moves(game: Game) Moves { return Moves{ .game = game.base }; } pub fn zones(game: Game) Zones { return Zones{ .vtable = switch (game.base.version.gen()) { 3 => &comptime Zones.VTable.init(gen3), 4 => &comptime Zones.VTable.init(gen4), 5 => &comptime Zones.VTable.init(gen5), else => unreachable, }, .game = game.base, }; } }; fn Iterator(comptime Items: type, comptime Result: type) type { return struct { const Self = @This(); items: Items, curr: usize, pub const Pair = struct { index: usize, value: Result, }; pub fn init(items: Items) Self { return Self{ .items = items, .curr = 0, }; } pub fn next(iter: *Self) ?Pair { if (iter.curr >= iter.items.len()) return null; defer iter.curr += 1; return Pair{ .index = iter.curr, .value = iter.items.at(iter.curr), }; } }; } fn ErrIterator(comptime Items: type, comptime Result: type) type { return struct { const Self = @This(); items: Items, curr: usize, pub const Pair = struct { index: usize, value: Result, }; pub fn init(items: Items) Self { return Self{ .items = items, .curr = 0, }; } pub fn next(iter: *Self) !?Pair { if (iter.curr >= iter.items.len()) return null; defer iter.curr += 1; return Pair{ .index = iter.curr, .value = try iter.items.at(iter.curr), }; } pub fn nextValid(iter: *Self) ?Pair { while (true) { const n = iter.next() catch continue; return n; } } }; } fn getFile(narc: *const nds.fs.Narc, index: usize) !*nds.fs.Narc.File { switch (narc.nodes.toSliceConst()[index].kind) { nds.fs.Narc.Node.Kind.File => |file| return file, nds.fs.Narc.Node.Kind.Folder => return error.NotFile, } } fn getFileAsType(comptime T: type, narc: *const nds.fs.Narc, index: usize) !*T { const file = try getFile(narc, index); const data = slice.bytesToSliceTrim(T, file.data); return slice.at(data, 0) catch error.FileToSmall; }
src/pokemon/index.zig
const std = @import("std"); const builtin = std.builtin; const expect = std.testing.expect; const mem = std.mem; ///References: https://en.wikipedia.org/wiki/Quicksort pub fn sort(A: []i32, lo: usize, hi: usize) void { if (lo < hi) { var p = partition(A, lo, hi); sort(A, lo, std.math.min(p, p -% 1)); sort(A, p + 1, hi); } } pub fn partition(A: []i32, lo: usize, hi: usize) usize { //Pivot can be chosen otherwise, for example try picking the first or random //and check in which way that affects the performance of the sorting var pivot = A[hi]; var i = lo; var j = lo; while (j < hi) : (j += 1) { if (A[j] < pivot) { mem.swap(i32, &A[i], &A[j]); i = i + 1; } } mem.swap(i32, &A[i], &A[hi]); return i; } pub fn main() !void {} test "empty array" { var array: []i32 = &.{}; sort(array, 0, 0); const a = array.len; try expect(a == 0); } test "array with one element" { var array: [1]i32 = .{5}; sort(&array, 0, array.len - 1); const a = array.len; try expect(a == 1); try expect(array[0] == 5); } test "sorted array" { var array: [10]i32 = .{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; sort(&array, 0, array.len - 1); for (array) |value, i| { try expect(value == (i + 1)); } } test "reverse order" { var array: [10]i32 = .{ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; sort(&array, 0, array.len - 1); for (array) |value, i| { try expect(value == (i + 1)); } } test "unsorted array" { var array: [5]i32 = .{ 5, 3, 4, 1, 2 }; sort(&array, 0, array.len - 1); for (array) |value, i| { try expect(value == (i + 1)); } } test "two last unordered" { var array: [10]i32 = .{ 1, 2, 3, 4, 5, 6, 7, 8, 10, 9 }; sort(&array, 0, array.len - 1); for (array) |value, i| { try expect(value == (i + 1)); } } test "two first unordered" { var array: [10]i32 = .{ 2, 1, 3, 4, 5, 6, 7, 8, 9, 10 }; sort(&array, 0, array.len - 1); for (array) |value, i| { try expect(value == (i + 1)); } }
sorting/quicksort.zig