code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const js = @import("../quickjs.zig"); const GlobalContext = @import("../context.zig"); const E = js.JsCFunctionListEntry; fn cTagName(comptime tag: anytype) [*:0]const u8 { return std.meta.tagName(tag) ++ ""; } const target = std.Target.current; var length_atom: js.JsAtom = .invalid; threadlocal var currentContext: *js.JsContext = undefined; fn safeIntCast(comptime T: type, val: anytype) ?T { if (val >= std.math.minInt(T) and val <= std.math.maxInt(T)) return @intCast(T, val); return null; } const FunctionProxy = struct { const name = @typeName(@This()); var class: js.JsClassID = .initial; functions: std.ArrayListUnmanaged(Compiler.FunctionInfo) = .{}, backref: js.JsValue, fn delete(rt: *js.JsRuntime, val: js.JsValue) callconv(.C) void { if (val.getOpaqueT(@This(), class)) |self| { val.setOpaque(null); const allocator = rt.getOpaqueT(GlobalContext).?.allocator; for (self.functions.items) |item| { item.deinit(allocator); } self.functions.deinit(allocator); self.backref.deinitRT(rt); allocator.destroy(self); } } fn fnCall(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue, magic: c_int) callconv(.C) js.JsValue { if (this.getOpaqueT(@This(), class)) |self| { const func: Compiler.FunctionInfo = self.functions.items[@intCast(usize, magic)]; const allocator = ctx.getRuntime().getOpaqueT(GlobalContext).?.allocator; return func.invoke(allocator, ctx, argv[0..@intCast(usize, argc)]); } else { return ctx.throw(.{ .Reference = "invalid function" }); } } fn mark(rt: *js.JsRuntime, this: js.JsValue, markfn: js.JS_MarkFunc) callconv(.C) void { if (this.getOpaqueT(@This(), class)) |self| { self.backref.mark(rt, markfn); } } pub fn init(ctx: *js.JsContext, mod: *js.JsModuleDef) !void { class.init(); class.define(ctx.getRuntime(), &js.JsClassDef{ .name = name, .finalizer = delete, .gcMark = mark, }); } pub fn create(self: *@This(), ctx: *js.JsContext) js.JsValue { var ret = js.JsValue.init(ctx, .{ .Object = .{ .class = class } }); ret.setOpaque(self); for (self.functions.items) |item, i| { _ = ret.defineProperty(ctx, item.atom, .{ .configurable = false, .writable = false, .enumerable = true, .data = .{ .value = switch (item.value) { .Function => |func| js.JsValue.init(ctx, .{ .Function = .{ .name = item.name, .length = @intCast(c_int, func.arguments.len), .func = .{ .generic_magic = fnCall }, .magic = @intCast(u16, i), }, }), .Address => |addr| js.JsValue.fromBig(ctx, addr), }, }, }) catch {}; } return ret; } }; const Compiler = opaque { const name = @typeName(@This()); const cc = @import("../tcc.zig"); const TinyCC = cc.TinyCC; var class: js.JsClassID = .initial; var constructor: js.JsValue = js.JsValue.fromRaw(.Undefined); var proto: js.JsValue = js.JsValue.fromRaw(.Undefined); const template = [_]E{ E.genGetSet("valid", .{ .get = getIsValid }), E.genFunction("compile", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 0 }), E.genFunction("add", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 1 }), E.genFunction("link", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 2 }), E.genFunction("linkDir", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 3 }), E.genFunction("include", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 4 }), E.genFunction("sysinclude", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 5 }), E.genFunction("output", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 6 }), E.genFunction("option", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 7 }), E.genFunction("define", .{ .length = 1, .func = .{ .generic_magic = fnInput }, .magic = 8 }), E.genFunction("run", .{ .length = 0, .func = .{ .generic = fnRun } }), E.genFunction("bind", .{ .length = 0, .func = .{ .generic = fnBind } }), E.genFunction("relocate", .{ .length = 1, .func = .{ .generic = fnRelocate } }), }; fn getIsValid(ctx: *js.JsContext, this: js.JsValue) callconv(.C) js.JsValue { const ret = this.getOpaqueT(TinyCC, class) != null; return js.JsValue.init(ctx, .{ .Boolean = ret }); } fn fnInput(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue, magic: c_int) callconv(.C) js.JsValue { if (this.getOpaqueT(TinyCC, class)) |tcc| { if (argc != 1) return ctx.throw(.{ .Type = "require 1 args" }); const content: js.JsString = argv[0].as(js.JsString, ctx) catch |e| return ctx.throw(.{ .Type = @errorName(e) }); defer content.deinit(ctx); const re = switch (magic) { 0 => tcc.apply(.{ .input = .{ .content = content.data } }), 1 => tcc.apply(.{ .input = .{ .path = content.data } }), 2 => tcc.apply(.{ .library = content.data }), 3 => tcc.apply(.{ .library_dir = content.data }), 4 => tcc.apply(.{ .include = content.data }), 5 => tcc.apply(.{ .system_include = content.data }), 6 => tcc.writeFile(content.data), 7 => tcc.apply(.{ .opt = content.data }), 8 => tcc.apply(.{ .define = .{ .name = content.data } }), else => @panic("unsupported magic"), }; re catch |e| return ctx.throw(.{ .Internal = @errorName(e) }); return js.JsValue.fromRaw(.Undefined); } else { return ctx.throw(.{ .Type = "invalid compiler" }); } } const ArgsBlock = struct { data: []const [*:0]const u8, strbuf: []js.JsString, fn deinit(self: @This(), ctx: *js.JsContext, allocator: *std.mem.Allocator) void { allocator.free(self.data); for (self.strbuf) |str| { str.deinit(ctx); } allocator.free(self.strbuf); } }; fn convertArgs(allocator: *std.mem.Allocator, ctx: *js.JsContext, args: []js.JsValue) !ArgsBlock { var data = try allocator.alloc([*:0]const u8, args.len); errdefer allocator.free(data); var buffer = try std.ArrayListUnmanaged(js.JsString).initCapacity(allocator, args.len); errdefer { for (buffer.items) |item| item.deinit(ctx); buffer.deinit(allocator); } for (args) |arg, i| { const str = try arg.as(js.JsString, ctx); buffer.appendAssumeCapacity(str); data[i] = str.data; } return ArgsBlock{ .data = data, .strbuf = buffer.toOwnedSlice(allocator), }; } fn fnRun(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { const tcc = this.getOpaqueT(TinyCC, class) orelse return ctx.throw(.{ .Type = "invalid compiler" }); var ret: c_int = undefined; if (argc == 0) { ret = tcc.run(&[_][*:0]const u8{}); } else { const allocator = ctx.getRuntime().getOpaqueT(GlobalContext).?.allocator; const args = convertArgs(allocator, ctx, argv[0..@intCast(usize, argc)]) catch |e| return ctx.throw(.{ .Internal = @errorName(e) }); defer args.deinit(ctx, allocator); ret = tcc.run(args.data); } return js.JsValue.from(ret); } fn fnBind(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { const tcc = this.getOpaqueT(TinyCC, class) orelse return ctx.throw(.{ .Type = "invalid compiler" }); if (argc != 2) return ctx.throw(.{ .Type = "need two arguments" }); const str: js.JsString = argv[0].as(js.JsString, ctx) catch return ctx.throw(.{ .Type = "invalid name" }); defer str.deinit(ctx); const addr: i64 = argv[1].as(i64, ctx) catch return ctx.throw(.{ .Type = "invalid addr" }); tcc.apply(.{ .bind = .{ .name = str.data, .value = @intToPtr(?*c_void, @intCast(usize, addr)), }, }) catch |e| return ctx.throw(.{ .Internal = @errorName(e) }); return js.JsValue.fromRaw(.Undefined); } fn fnRelocate(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { const tcc = this.getOpaqueT(TinyCC, class) orelse return ctx.throw(.{ .Type = "invalid compiler" }); if (argc != 1) return ctx.throw(.{ .Type = "require 1 args" }); const allocator = ctx.getRuntime().getOpaqueT(GlobalContext).?.allocator; const obj: js.JsValue = argv[0]; const names = obj.getOwnPropertyNames(ctx, .{}) catch |e| return ctx.throw(.{ .Internal = @errorName(e) }); var funcs = std.ArrayListUnmanaged(FunctionInfo).initCapacity(allocator, names.len) catch |e| return ctx.throw(.{ .Internal = @errorName(e) }); var haserr = false; defer if (haserr) { for (funcs.items) |item| item.deinit(allocator); funcs.deinit(allocator); }; var cbuffer: std.fifo.LinearFifo(u8, .Dynamic) = std.fifo.LinearFifo(u8, .Dynamic).init(allocator); const out = cbuffer.writer(); out.writeAll("#include <tjs.h>\n\n") catch { haserr = true; return ctx.throw(.OutOfMemory); }; for (names) |item| { const value = obj.getProperty(ctx, item.atom) orelse continue; const str = item.atom.toCString(ctx).?.dupe(ctx, allocator) catch { haserr = true; return ctx.throw(.OutOfMemory); }; const f = fixFunction(allocator, ctx, tcc, item.atom, str, value) catch |e| { haserr = true; return ctx.throw(.{ .Type = @errorName(e) }); }; defer if (haserr) { f.deinit(allocator); }; funcs.appendAssumeCapacity(f); f.gencode(out) catch |e| { haserr = true; return ctx.throw(.{ .Internal = @errorName(e) }); }; } out.writeByte(0) catch { haserr = true; return ctx.throw(.OutOfMemory); }; const slice = cbuffer.readableSlice(0); tcc.apply(.{ .input = .{ .content = @ptrCast([*:0]const u8, slice.ptr) } }) catch |e| { haserr = true; return ctx.throw(.{ .Internal = @errorName(e) }); }; tcc.relocate() catch |e| { haserr = true; return ctx.throw(.{ .Internal = @errorName(e) }); }; for (funcs.items) |*item| if (item.loadsym(tcc, ctx)) |ret| { haserr = true; return ret; }; const proxy = allocator.create(FunctionProxy) catch { haserr = true; return ctx.throw(.OutOfMemory); }; proxy.backref = this.clone(); proxy.functions = funcs; return proxy.create(ctx); } const FunctionInfo = struct { const Type = enum { integer, double, string, wstring, vector, bigint, pointer, callback, fn allowAsResult(self: @This()) bool { return switch (self) { .string => false, .wstring => false, .vector => false, .callback => false, else => true, }; } fn gen(self: @This()) [:0]const u8 { return switch (self) { .integer => "int", .double => "double", .string => "char const *", .wstring => "wchar_t const *", .vector => "tjsvec_buf", .bigint => "int64_t", .pointer => "void *", .callback => "tjscallback", }; } fn size(self: @This()) usize { const raw: usize = switch (self) { .integer => @sizeOf(i32), .double => @sizeOf(f64), .string => @sizeOf(usize), .wstring => @sizeOf(usize), .vector => @sizeOf(usize) * 2, .bigint => @sizeOf(u64), .pointer => @sizeOf(usize), .callback => @sizeOf(usize) * 3, }; return (@divTrunc(raw - 1, @sizeOf(usize)) + 1) * @sizeOf(usize); } fn read(self: @This(), buf: [*]u8, ctx: *js.JsContext) js.JsValue { switch (self) { .integer => { const val = std.mem.bytesToValue(i32, buf[0..4]); return js.JsValue.from(val); }, .double => { const val = std.mem.bytesToValue(f64, buf[0..8]); return js.JsValue.from(val); }, .bigint, .pointer => { const val = std.mem.bytesToValue(isize, buf[0..@sizeOf(usize)]); return js.JsValue.fromBig(ctx, val); }, .string, .wstring, .vector, .callback => @panic("invalid type"), } } }; const Data = union(Type) { integer: i32, double: f64, string: [:0]const u8, wstring: [:0]const u16, vector: []u8, bigint: i64, pointer: usize, callback: js.JsValue, fn fill(comptime input: usize, writer: anytype) !void { const size = @mod(input, @sizeOf(usize)); if (size == 0) return; const z = [1]u8{0} ** size; try writer.writeAll(&z); } fn dump(self: @This(), writer: anytype) !void { switch (self) { .integer => |val| { const bytes = std.mem.toBytes(val); try writer.writeAll(&bytes); try fill(bytes.len, writer); }, .double => |val| { const bytes = std.mem.toBytes(val); try writer.writeAll(&bytes); try fill(bytes.len, writer); }, .string => |val| { const bytes = std.mem.toBytes(@ptrToInt(val.ptr)); try writer.writeAll(&bytes); }, .wstring => |val| { const bytes = std.mem.toBytes(@ptrToInt(val.ptr)); try writer.writeAll(&bytes); }, .vector => |val| { var bytes = std.mem.toBytes(@ptrToInt(val.ptr)); try writer.writeAll(&bytes); bytes = std.mem.toBytes(val.len); try writer.writeAll(&bytes); }, .bigint => |val| { const bytes = std.mem.toBytes(val); try writer.writeAll(&bytes); }, .pointer => |val| { const bytes = std.mem.toBytes(val); try writer.writeAll(&bytes); }, .callback => |val| { const bytes = std.mem.toBytes(val); try writer.writeAll(&bytes); }, } } fn from(t: Type, src: js.JsValue, ctx: *js.JsContext, allocator: *std.mem.Allocator) !@This() { return switch (t) { .integer => .{ .integer = try src.as(i32, ctx) }, .double => .{ .double = try src.as(f64, ctx) }, .string => .{ .string = try (try src.as(js.JsString, ctx)).dupe(ctx, allocator) }, .wstring => blk: { const rstr = try src.as(js.JsString, ctx); defer rstr.deinit(ctx); const r = try std.unicode.utf8ToUtf16LeWithNull(allocator, rstr.data); break :blk .{ .wstring = r }; }, .vector => .{ .vector = try src.as([]u8, ctx) }, .bigint => .{ .bigint = try src.as(i64, ctx) }, .pointer => .{ .pointer = @bitCast(usize, safeIntCast(isize, try src.as(i64, ctx)) orelse return error.InvalidPointer) }, .callback => .{ .callback = src.clone() }, }; } fn deinit(self: @This(), ctx: *js.JsContext, allocator: *std.mem.Allocator) void { switch (self) { .string => |str| allocator.free(str), .wstring => |str| allocator.free(str), .callback => |cb| cb.deinit(ctx), else => {}, } } }; atom: js.JsAtom, name: [:0]const u8, value: SymInfo, const SymInfo = union(enum) { Function: struct { arguments: []Type = undefined, result: ?Type = null, funcptr: ?fn (ptr: [*]u8) callconv(.C) void = null, }, Address: usize, }; fn gencode(self: @This(), writer: anytype) !void { switch (self.value) { .Function => |fun| { try writer.print("extern {0s} {1s}(", .{ if (fun.result) |res| res.gen() else "void", self.name }); for (fun.arguments) |arg, i| { if (i != 0) try writer.writeAll(", "); try writer.writeAll(arg.gen()); } try writer.writeAll(");\n"); try writer.print("struct pack${s} {{\n", .{self.name}); if (fun.result) |result| { if (!result.allowAsResult()) return error.ResultTypeNotAllowed; try writer.print("\t{s} result __ALIGN__;\n", .{result.gen()}); } for (fun.arguments) |arg, i| { try writer.print("\t{s} arg${} __ALIGN__;\n", .{ arg.gen(), i }); } try writer.writeAll("};\n"); try writer.print("void ${0s} (struct pack${0s} *ptr) {{\n", .{self.name}); try writer.writeAll(if (fun.result != null) "\tptr->result = " else "\t"); try writer.print("{0s}(", .{self.name}); for (fun.arguments) |arg, i| { if (i != 0) try writer.writeAll(", "); try writer.print("ptr->arg${}", .{i}); } try writer.writeAll(");\n"); try writer.writeAll("};\n\n"); }, .Address => {}, } } fn loadsym(self: *@This(), tcc: *TinyCC, ctx: *js.JsContext) ?js.JsValue { var tempbuffer: [1024]u8 = undefined; switch (self.value) { .Function => |*fun| { var fixed = std.heap.FixedBufferAllocator.init(&tempbuffer); const deco = std.fmt.allocPrint0(&fixed.allocator, "${s}", .{self.name}) catch return ctx.throw(.OutOfMemory); const symbol = tcc.get(deco) orelse return ctx.throw(.{ .Reference = std.fmt.bufPrint(&tempbuffer, "{s} not exported", .{self.name}) catch return ctx.throw(.OutOfMemory) }); fun.funcptr = @ptrCast(fn (ptr: [*]u8) callconv(.C) void, symbol); }, .Address => |*addr| { const symbol = tcc.get(self.name) orelse return ctx.throw(.{ .Reference = std.fmt.bufPrint(&tempbuffer, "{s} not exported", .{self.name}) catch return ctx.throw(.OutOfMemory) }); addr.* = @ptrToInt(symbol); }, } return null; } fn calcSize(self: @This()) usize { var ret: usize = 0; switch (self.value) { .Function => |fun| { if (fun.result) |result| ret += result.size(); for (fun.arguments) |arg| ret += arg.size(); }, .Address => {}, } return ret; } fn invoke(self: @This(), allocator: *std.mem.Allocator, ctx: *js.JsContext, args: []js.JsValue) js.JsValue { const fun = self.value.Function; if (args.len != fun.arguments.len) { var errbuf: [128]u8 = undefined; return ctx.throw(.{ .Type = std.fmt.bufPrint(&errbuf, "invalid arguments number, require {}, found {}", .{ fun.arguments.len, args.len }) catch "invalid arguments number" }); } var buf = allocator.alloc(u8, self.calcSize()) catch return ctx.throw(.OutOfMemory); errdefer allocator.free(buf); var fifo = std.fifo.LinearFifo(u8, .Slice).init(buf); const writer = fifo.writer(); var argsdata = std.ArrayListUnmanaged(Data).initCapacity(allocator, args.len) catch return ctx.throw(.OutOfMemory); defer { for (argsdata.items) |item| item.deinit(ctx, allocator); argsdata.deinit(allocator); } if (fun.result) |res| fifo.update(res.size()); for (fun.arguments) |arg, i| { const data = Data.from(arg, args[i], ctx, allocator) catch |e| return ctx.throw(.{ .Type = @errorName(e) }); data.dump(writer) catch |e| { data.deinit(ctx, allocator); return ctx.throw(.{ .Internal = @errorName(e) }); }; argsdata.appendAssumeCapacity(data); } fun.funcptr.?(buf.ptr); return if (fun.result) |res| res.read(buf.ptr, ctx) else js.JsValue.fromRaw(.Undefined); } fn deinit(self: @This(), allocator: *std.mem.Allocator) void { allocator.free(self.name); switch (self.value) { .Function => |fun| { allocator.free(fun.arguments); }, .Address => {}, } } }; fn fixFunction(allocator: *std.mem.Allocator, ctx: *js.JsContext, tcc: *TinyCC, atom: js.JsAtom, parameterName: [:0]const u8, value: js.JsValue) !FunctionInfo { var ret: FunctionInfo = .{ .atom = atom, .name = parameterName, .value = undefined }; if (value.getTag() == .Null) { ret.value = .{ .Address = undefined }; return ret; } else if (value.getTag() != .String) return error.RequireString; ret.value = .{ .Function = .{} }; const str = try value.as(js.JsString, ctx); defer str.deinit(ctx); var tempargs = std.ArrayListUnmanaged(FunctionInfo.Type){}; defer tempargs.deinit(allocator); const State = enum { arguments, callback, result, }; var s: State = .arguments; for (str.data) |ch| { switch (s) { .arguments => { const t: FunctionInfo.Type = switch (ch) { 'i' => .integer, 'd' => .double, 's' => .string, 'w' => .wstring, 'v' => .vector, 'b' => .bigint, 'p' => .pointer, '[' => .callback, '!' => { s = .result; continue; }, else => return error.InvalidParameter, }; try tempargs.append(allocator, t); if (t == .callback) s = .callback; }, .callback => { if (ch == ']') { s = .arguments; continue; } }, .result => { ret.value.Function.result = switch (ch) { 'i' => .integer, 'd' => .double, 'b' => .bigint, 'p' => .pointer, '_' => null, else => return error.InvalidResult, }; }, } } ret.value.Function.arguments = tempargs.toOwnedSlice(allocator); return ret; } fn notifyCallback(val: js.JsValue) callconv(.C) c_int { const ret = val.call(currentContext, js.JsValue.fromRaw(.Undefined), &[_]js.JsValue{}); if (ret.getNormTag() != .Exception) return ret.as(i32, currentContext) catch 0; currentContext.dumpError(); return -1; } const NotifyData = extern struct { const Tag = extern enum(usize) { unset = 0, integer = 1, double = 2, string = 3, wstring = 4, vector = 5, bigint = 6, pointer = 7, _, }; const Value = extern union { unset: void, integer: c_int, double: f64, string: [*:0]const u8, wstring: [*:0]const u16, vector: struct { ptr: [*]u8, len: usize, fn toSlice(self: @This()) []u8 { return self.ptr[0..self.len]; } }, bigint: i64, pointer: usize, }; tag: Tag, value: Value, fn toJs(self: @This(), ctx: *js.JsContext) js.JsValue { return switch (self.tag) { .unset => js.JsValue.fromRaw(.Undefined), .integer => js.JsValue.from(self.value.integer), .double => js.JsValue.from(self.value.double), .string => js.JsValue.init(ctx, .{ .String = std.mem.span(self.value.string) }), .wstring => blk: { const allocator = ctx.getRuntime().getOpaqueT(GlobalContext).?.allocator; const ret = std.unicode.utf16leToUtf8Alloc(allocator, std.mem.span(self.value.wstring)) catch @panic("decode utf16 failed"); defer allocator.free(ret); break :blk js.JsValue.init(ctx, .{ .String = ret }); }, .vector => js.JsValue.init(ctx, .{ .ArrayBuffer = self.value.vector.toSlice() }), .bigint => js.JsValue.fromBig(ctx, self.value.bigint), .pointer => js.JsValue.fromBig(ctx, self.value.pointer), else => @panic("invalid type"), }; } }; fn notifyCallbackData(val: js.JsValue, num: usize, args: [*]NotifyData) callconv(.C) i32 { const allocator = currentContext.getRuntime().getOpaqueT(GlobalContext).?.allocator; const arr = allocator.alloc(js.JsValue, num) catch return -2; defer allocator.free(arr); for (arr) |*item| item.* = js.JsValue.fromRaw(.Undefined); defer for (arr) |item| item.deinit(currentContext); for (arr) |*item, i| item.* = args[i].toJs(currentContext); const ret = val.call(currentContext, js.JsValue.fromRaw(.Undefined), arr); if (ret.getNormTag() != .Exception) return ret.as(i32, currentContext) catch 0; currentContext.dumpError(); return -1; } fn cloneCallback(val: js.JsValue) callconv(.C) js.JsValue { return val.clone(); } fn freeCallback(val: js.JsValue) callconv(.C) void { val.deinit(currentContext); } fn newInternal(ot: cc.OutputType) !*TinyCC { var curdirbuf: [std.fs.MAX_PATH_BYTES]u8 = undefined; const curdir = try std.process.getCwd(curdirbuf[0..]); curdirbuf[curdir.len] = 0; const curdirz = curdir[0..:0]; const tcc = try TinyCC.init(); errdefer tcc.deinit(); try tcc.setup(); try tcc.apply(.{ .output = ot }); try tcc.apply(.{ .define = .{ .name = "__TJS_DIRNAME__", .value = curdirz, }, }); if (ot == .memory) { try tcc.apply(.{ .define = .{ .name = "__TJS_MEMORY__" } }); try tcc.apply(.{ .bind = .{ .name = "tjs_notify", .value = notifyCallback, }, }); try tcc.apply(.{ .bind = .{ .name = "tjs_notify_data", .value = notifyCallbackData, }, }); try tcc.apply(.{ .bind = .{ .name = "tjs_duplicate_callback", .value = cloneCallback, }, }); try tcc.apply(.{ .bind = .{ .name = "tjs_free_callback", .value = freeCallback, }, }); } return tcc; } fn new(ctx: *js.JsContext, new_target: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { if (argc != 1) return ctx.throw(.{ .Type = "require 1 args" }); const output: js.JsString = argv[0].as(js.JsString, ctx) catch |e| return ctx.throw(.{ .Type = @errorName(e) }); defer output.deinit(ctx); const outputType = std.meta.stringToEnum(cc.OutputType, output.data) orelse return ctx.throw(.{ .Type = "invalid output type" }); const tcc = newInternal(outputType) catch |e| return ctx.throw(.{ .Internal = @errorName(e) }); const ret = js.JsValue.init(ctx, .{ .Object = .{ .proto = proto, .class = class, }, }); ret.setOpaque(tcc); return ret; } fn delete(rt: *js.JsRuntime, val: js.JsValue) callconv(.C) void { if (val.getOpaqueT(TinyCC, class)) |tcc| { tcc.deinit(); } } pub fn init(ctx: *js.JsContext, mod: *js.JsModuleDef) !void { class.init(); class.define(ctx.getRuntime(), &js.JsClassDef{ .name = name, .finalizer = delete, }); } pub fn load(ctx: *js.JsContext, mod: *js.JsModuleDef) void { constructor = js.JsValue.init(ctx, .{ .Function = .{ .name = name, .length = 1, .func = .{ .constructor = new }, }, }); ctx.setConstructorBit(constructor, true) catch {}; proto = js.JsValue.init(ctx, .{ .Object = .{ .class = class, .temp = &template }, }); class.setProto(ctx, proto); ctx.setConstructor(constructor, proto); mod.setModuleExport(ctx, name, constructor); } }; pub fn init(ctx: *js.JsContext, mod: *js.JsModuleDef) !void { length_atom = js.JsAtom.initAtom(ctx, "length"); currentContext = ctx; try Compiler.init(ctx, mod); try FunctionProxy.init(ctx, mod); } pub fn load(ctx: *js.JsContext, mod: *js.JsModuleDef) void { Compiler.load(ctx, mod); } extern "Kernel32" fn AddDllDirectory(NewDirectory: [*:0]const u16) callconv(if (target.cpu.arch == .i386) .Stdcall else .C) ?*c_void; pub fn appendLibSearchPath(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { if (comptime std.Target.current.os.tag != .windows) { return ctx.throw(.{ .Type = "Unsupported OS" }); } else { if (argc != 1) return ctx.throw(.{ .Type = "require 1 args" }); const str: js.JsString = argv[0].as(js.JsString, ctx) catch return ctx.throw(.{ .Type = "not a string" }); defer str.deinit(ctx); const allocator = ctx.getRuntime().getOpaqueT(GlobalContext).?.allocator; const u16str = std.unicode.utf8ToUtf16LeWithNull(allocator, str.data) catch return ctx.throw(.OutOfMemory); defer allocator.free(u16str); return js.JsValue.from(AddDllDirectory(u16str.ptr) != null); } } pub const storage = [_]E{ E.genProp("os", .{ .str = cTagName(target.os.tag) }, .{}), E.genProp("arch", .{ .str = cTagName(target.cpu.arch) }, .{}), E.genProp("abi", .{ .str = cTagName(target.abi) }, .{}), E.genFunction("appendLibSearchPath", .{ .length = 1, .func = .{ .generic = appendLibSearchPath } }), }; pub const extra = &[_][*:0]const u8{"Compiler"};
src/mods/c.zig
const std = @import("std"); const fmt = std.fmt; const math = std.math; const mem = std.mem; const testing = std.testing; const Metric = @import("metric.zig").Metric; const HistogramResult = @import("metric.zig").HistogramResult; const e10_min = -9; const e10_max = 18; const buckets_per_decimal = 18; const decimal_buckets_count = e10_max - e10_min; const buckets_count = decimal_buckets_count * buckets_per_decimal; const lower_bucket_range = blk: { var buf: [64]u8 = undefined; break :blk fmt.bufPrint(&buf, "0...{e:.3}", .{math.pow(f64, 10, e10_min)}) catch unreachable; }; const upper_bucket_range = blk: { var buf: [64]u8 = undefined; break :blk fmt.bufPrint(&buf, "{e:.3}...+Inf", .{math.pow(f64, 10, e10_max)}) catch unreachable; }; const bucket_ranges: [buckets_count][]const u8 = blk: { const bucket_multiplier = math.pow(f64, 10.0, 1.0 / @as(f64, buckets_per_decimal)); var v = math.pow(f64, 10, e10_min); var start = blk2: { var buf: [64]u8 = undefined; break :blk2 fmt.bufPrint(&buf, "{e:.3}", .{v}) catch unreachable; }; var result: [buckets_count][]const u8 = undefined; for (result) |*range| { v *= bucket_multiplier; const end = blk3: { var buf: [64]u8 = undefined; break :blk3 fmt.bufPrint(&buf, "{e:.3}", .{v}) catch unreachable; }; range.* = start ++ "..." ++ end; start = end; } break :blk result; }; test "bucket ranges" { try testing.expectEqualStrings("0...1.000e-09", lower_bucket_range); try testing.expectEqualStrings("1.000e+18...+Inf", upper_bucket_range); try testing.expectEqualStrings("1.000e-09...1.136e-09", bucket_ranges[0]); try testing.expectEqualStrings("1.136e-09...1.292e-09", bucket_ranges[1]); try testing.expectEqualStrings("8.799e-09...1.000e-08", bucket_ranges[buckets_per_decimal - 1]); try testing.expectEqualStrings("1.000e-08...1.136e-08", bucket_ranges[buckets_per_decimal]); try testing.expectEqualStrings("8.799e-01...1.000e+00", bucket_ranges[buckets_per_decimal * (-e10_min) - 1]); try testing.expectEqualStrings("1.000e+00...1.136e+00", bucket_ranges[buckets_per_decimal * (-e10_min)]); try testing.expectEqualStrings("8.799e+17...1.000e+18", bucket_ranges[buckets_per_decimal * (e10_max - e10_min) - 1]); } /// Histogram based on https://github.com/VictoriaMetrics/metrics/blob/master/histogram.go. pub const Histogram = struct { const Self = @This(); metric: Metric = .{ .getResultFn = getResult, }, mutex: std.Thread.Mutex = .{}, decimal_buckets: [decimal_buckets_count][buckets_per_decimal]u64 = undefined, lower: u64 = 0, upper: u64 = 0, sum: f64 = 0.0, pub fn init(allocator: mem.Allocator) !*Self { const self = try allocator.create(Self); self.* = .{}; for (self.decimal_buckets) |*bucket| { mem.set(u64, &bucket.*, 0); } return self; } pub fn update(self: *Self, value: f64) void { if (math.isNan(value) or value < 0) { return; } const bucket_idx: f64 = (math.log10(value) - e10_min) * buckets_per_decimal; // Keep a lock while updating the histogram. self.mutex.lock(); defer self.mutex.unlock(); self.sum += value; if (bucket_idx < 0) { self.lower += 1; } else if (bucket_idx >= buckets_count) { self.upper += 1; } else { const idx: usize = blk: { const tmp = @floatToInt(usize, bucket_idx); if (bucket_idx == @intToFloat(f64, tmp) and tmp > 0) { // Edge case for 10^n values, which must go to the lower bucket // according to Prometheus logic for `le`-based histograms. break :blk tmp - 1; } else { break :blk tmp; } }; const decimal_bucket_idx = idx / buckets_per_decimal; const offset = idx % buckets_per_decimal; var bucket: []u64 = &self.decimal_buckets[decimal_bucket_idx]; bucket[offset] += 1; } } pub fn get(self: *const Self) u64 { _ = self; return 0; } fn isBucketAllZero(bucket: []const u64) bool { for (bucket) |v| { if (v != 0) return false; } return true; } fn getResult(metric: *Metric, allocator: mem.Allocator) Metric.Error!Metric.Result { const self = @fieldParentPtr(Histogram, "metric", metric); // Arbitrary maximum capacity var buckets = try std.ArrayList(HistogramResult.Bucket).initCapacity(allocator, 16); var count_total: u64 = 0; // Keep a lock while querying the histogram. self.mutex.lock(); defer self.mutex.unlock(); if (self.lower > 0) { try buckets.append(.{ .vmrange = lower_bucket_range, .count = self.lower, }); count_total += self.lower; } for (self.decimal_buckets) |bucket, decimal_bucket_idx| { if (isBucketAllZero(&bucket)) continue; for (bucket) |count, offset| { if (count <= 0) continue; const bucket_idx = (decimal_bucket_idx * buckets_per_decimal) + offset; const vmrange = bucket_ranges[bucket_idx]; try buckets.append(.{ .vmrange = vmrange, .count = count, }); count_total += count; } } if (self.upper > 0) { try buckets.append(.{ .vmrange = upper_bucket_range, .count = self.upper, }); count_total += self.upper; } return Metric.Result{ .histogram = .{ .buckets = buckets.toOwnedSlice(), .sum = .{ .value = self.sum }, .count = count_total, }, }; } }; test "write empty" { var histogram = try Histogram.init(testing.allocator); defer testing.allocator.destroy(histogram); var buffer = std.ArrayList(u8).init(testing.allocator); defer buffer.deinit(); var metric = &histogram.metric; try metric.write(testing.allocator, buffer.writer(), "myhistogram"); try testing.expectEqual(@as(usize, 0), buffer.items.len); } test "update then write" { var histogram = try Histogram.init(testing.allocator); defer testing.allocator.destroy(histogram); var i: usize = 98; while (i < 218) : (i += 1) { histogram.update(@intToFloat(f64, i)); } var buffer = std.ArrayList(u8).init(testing.allocator); defer buffer.deinit(); var metric = &histogram.metric; try metric.write(testing.allocator, buffer.writer(), "myhistogram"); const exp = \\myhistogram_bucket{vmrange="8.799e+01...1.000e+02"} 3 \\myhistogram_bucket{vmrange="1.000e+02...1.136e+02"} 13 \\myhistogram_bucket{vmrange="1.136e+02...1.292e+02"} 16 \\myhistogram_bucket{vmrange="1.292e+02...1.468e+02"} 17 \\myhistogram_bucket{vmrange="1.468e+02...1.668e+02"} 20 \\myhistogram_bucket{vmrange="1.668e+02...1.896e+02"} 23 \\myhistogram_bucket{vmrange="1.896e+02...2.154e+02"} 26 \\myhistogram_bucket{vmrange="2.154e+02...2.448e+02"} 2 \\myhistogram_sum 18900 \\myhistogram_count 120 \\ ; try testing.expectEqualStrings(exp, buffer.items); } test "update then write with labels" { var histogram = try Histogram.init(testing.allocator); defer testing.allocator.destroy(histogram); var i: usize = 98; while (i < 218) : (i += 1) { histogram.update(@intToFloat(f64, i)); } var buffer = std.ArrayList(u8).init(testing.allocator); defer buffer.deinit(); var metric = &histogram.metric; try metric.write(testing.allocator, buffer.writer(), "myhistogram{route=\"/api/v2/users\"}"); const exp = \\myhistogram_bucket{route="/api/v2/users",vmrange="8.799e+01...1.000e+02"} 3 \\myhistogram_bucket{route="/api/v2/users",vmrange="1.000e+02...1.136e+02"} 13 \\myhistogram_bucket{route="/api/v2/users",vmrange="1.136e+02...1.292e+02"} 16 \\myhistogram_bucket{route="/api/v2/users",vmrange="1.292e+02...1.468e+02"} 17 \\myhistogram_bucket{route="/api/v2/users",vmrange="1.468e+02...1.668e+02"} 20 \\myhistogram_bucket{route="/api/v2/users",vmrange="1.668e+02...1.896e+02"} 23 \\myhistogram_bucket{route="/api/v2/users",vmrange="1.896e+02...2.154e+02"} 26 \\myhistogram_bucket{route="/api/v2/users",vmrange="2.154e+02...2.448e+02"} 2 \\myhistogram_sum{route="/api/v2/users"} 18900 \\myhistogram_count{route="/api/v2/users"} 120 \\ ; try testing.expectEqualStrings(exp, buffer.items); }
src/Histogram.zig
const main = @import("main.zig"); const vectors = @import("vectors.zig"); const uart = @import("serial/uart.zig"); pub export fn _start() callconv(.Naked) noreturn { // At startup the stack pointer is at the end of RAM // so, no need to set it manually! // Reference this such that the file is analyzed and the vectors // are added. _ = vectors; copyDataToRAM(); clearBSS(); main.main(); while (true) {} } fn copyDataToRAM() void { asm volatile ( \\ ; load Z register with the address of the data in flash \\ LDI R30, lo8(__data_load_start) \\ LDI R31, hi8(__data_load_start) \\ ; load X register with address of the data in ram \\ LDI R26, lo8(__data_start) \\ LDI R27, hi8(__data_start) \\ ; load address of end of the data in ram \\ LDI R24, lo8(__data_end) \\ LDI R25, hi8(__data_end) \\ RJMP .L2 \\ \\.L1: lpm R18, Z+ ; copy from Z into r18 and increment Z \\ ST X+, R18 ; store r18 at location X and increment X \\ \\.L2: CP R26, R24 \\ CPC R27, R25 ; check and branch if we are at the end of data \\ BRNE .L1 ); // Probably a good idea to add clobbers here, but compiler doesn't seem to care } fn clearBSS() void { asm volatile ( \\ ; load X register with the beginning of bss section \\ LDI R26, lo8(__bss_start) \\ LDI R27, hi8(__bss_start) \\ ; load end of the bss in registers \\ LDI R24, lo8(__bss_end) \\ LDI R25, hi8(__bss_end) \\ LDI R18, 0x00 \\ RJMP .L4 \\ \\.L3: ST X+, R18 \\ \\.L4: CP R26, R24 \\ CPC R27, R25 ; check and branch if we are at the end of bss \\ BRNE .L3 ); // Probably a good idea to add clobbers here, but compiler doesn't seem to care } pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn { // Currently assumes that the uart is initialized in main(). uart.sendString("PANIC: "); uart.sendString(msg); // TODO: print stack trace (addresses), which can than be turned into actual source line // numbers on the connected machine. _ = error_return_trace; while (true) {} }
src/start.zig
const std = @import("std"); const mem = std.mem; pub const StatusCode = enum(u16) { // informational Continue = 100, SwitchingProtocols = 101, Processing = 102, EarlyHints = 103, // success Ok = 200, Created = 201, Accepted = 202, NonAuthoritativeInformation = 203, NoContent = 204, ResetContent = 205, PartialContent = 206, MultiStatus = 207, AlreadyReported = 208, ImUsed = 226, // redirection MultipleChoices = 300, MovedPermanently = 301, Found = 302, SeeOther = 303, NotModified = 304, UseProxy = 305, SwitchProxy = 306, TemporaryRedirect = 307, PermanentRedirect = 308, // client error BadRequest = 400, Unauthorized = 401, PaymentRequired = 402, Forbidden = 403, NotFound = 404, MethodNotAllowed = 405, NotAcceptable = 406, ProxyAuthenticationRequired = 407, RequestTimeout = 408, Conflict = 409, Gone = 410, LengthRequired = 411, PreconditionFailed = 412, PayloadTooLarge = 413, UriTooLong = 414, UnsupportedMediaType = 415, RangeNotSatisfiable = 416, ExpectationFailed = 417, ImATeapot = 418, MisdirectedRequest = 421, UnprocessableEntity = 422, Locked = 423, FailedDependency = 424, TooEarly = 425, UpgradeRequired = 426, PreconditionRequired = 428, TooManyRequests = 429, RequestHeaderFieldsTooLarge = 431, UnavailableForLegalReasons = 451, // server error InternalServerError = 500, NotImplemented = 501, BadGateway = 502, ServiceUnavailable = 503, GatewayTimeout = 504, HttpVersionNotSupported = 505, VariantAlsoNegotiates = 506, InsufficientStorage = 507, LoopDetected = 508, NotExtended = 510, NetworkAuthenticationRequired = 511, pub fn toString(self: StatusCode) []const u8 { return switch (self) { .Continue => "Continue", .SwitchingProtocols => "Switching Protocols", .Processing => "Processing", .EarlyHints => "Early Hints", .Ok => "OK", .Created => "Created", .Accepted => "Accepted", .NonAuthoritativeInformation => "Non-Authoritative Information", .NoContent => "No Content", .ResetContent => "Reset Content", .PartialContent => "Partial Content", .MultiStatus => "Multi Status", .AlreadyReported => "Already Reported", .ImUsed => "IM Used", .MultipleChoices => "Multiple Choices", .MovedPermanently => "Moved Permanently", .Found => "Found", .SeeOther => "See Other", .NotModified => "Not Modified", .UseProxy => "Use Proxy", .SwitchProxy => "Switch Proxy", .TemporaryRedirect => "Temporary Redirect", .PermanentRedirect => "Permanent Redirect", .BadRequest => "Bad Request", .Unauthorized => "Unauthorized", .PaymentRequired => "Payment Required", .Forbidden => "Forbidden", .NotFound => "Not Found", .MethodNotAllowed => "Method Not Allowed", .NotAcceptable => "Not Acceptable", .ProxyAuthenticationRequired => "Proxy Authentication Required", .RequestTimeout => "Request Timeout", .Conflict => "Conflict", .Gone => "Gone", .LengthRequired => "Length Required", .PreconditionFailed => "Precondition Failed", .PayloadTooLarge => "Payload Too Large", .UriTooLong => "URI Too Long", .UnsupportedMediaType => "Unsupported Media Type", .RangeNotSatisfiable => "Range Not Satisfiable", .ExpectationFailed => "Expectation Failed", .ImATeapot => "I'm a teapot", .MisdirectedRequest => "Misdirected Request", .UnprocessableEntity => "Unprocessable Entity", .Locked => "Locked", .FailedDependency => "Failed Dependency", .TooEarly => "Too Early", .UpgradeRequired => "Upgrade Required", .PreconditionRequired => "Precondition Required", .TooManyRequests => "Too Many Requests", .RequestHeaderFieldsTooLarge => "Request Header Fields Too Large", .UnavailableForLegalReasons => "Unavailable For Legal Reasons", .InternalServerError => "Internal Server Error", .NotImplemented => "Not Implemented", .BadGateway => "Bad Gateway", .ServiceUnavailable => "Service Unavailable", .GatewayTimeout => "Gateway Timeout", .HttpVersionNotSupported => "HTTP Version Not Supported", .VariantAlsoNegotiates => "Variant Also Negotiates", .InsufficientStorage => "Insufficient Storage", .LoopDetected => "Loop Detected", .NotExtended => "Not Extended", .NetworkAuthenticationRequired => "Network Authentication Required", }; } }; pub const Method = struct { pub const Get = "GET"; pub const Head = "HEAD"; pub const Post = "POST"; pub const Put = "PUT"; pub const Delete = "DELETE"; pub const Connect = "CONNECT"; pub const Options = "OPTIONS"; pub const Trace = "TRACE"; pub const Patch = "PATCH"; }; pub const Version = enum { Http09, Http10, Http11, Http20, Http30, const vers = [_][]const u8{ "HTTP/0.9", "HTTP/1.0", "HTTP/1.1", "HTTP/2.0", "HTTP/3.0", }; pub fn toString(self: Version) []const u8 { return vers[@enumToInt(self)]; } pub fn fromString(str: []const u8) !Version { for (vers) |v, i| { if (mem.eql(u8, v, str)) { return @intToEnum(Version, @truncate(u3, i)); } } return error.Unsupported; } };
src/routez/http/common.zig
const std = @import("std"); const lexer = @import("lexer.zig"); const data_types = @import("data_types.zig"); const UsedNumberType = data_types.UsedNumberType; pub const Token = struct { id: lexer.Token.Id, start: u32, data: union { text: []const u8, number: UsedNumberType, single_token: u0, } }; pub fn parseTokens( alloc: std.mem.Allocator, tokens: []const lexer.Token, raw_data: []const u8, ) ![]const Token { var new_token_list = try std.ArrayList(Token).initCapacity(alloc, raw_data.len / 8); defer new_token_list.deinit(); var last_token: lexer.Token = undefined; for (tokens) |tok| { switch (tok.id) { .Comment, .Eof => {}, .PreProcUse => {}, .String => { if (last_token.id != .PreProcUse) { try new_token_list.append(Token{ .id = tok.id, .start = tok.start, .data = .{ .text = raw_data[tok.start + 1 .. tok.end - 1] }, }); } }, .Atom => { if (last_token.id != .PreProcUse) { try new_token_list.append(Token{ .id = tok.id, .start = tok.start, .data = .{ .text = raw_data[tok.start + 1 .. tok.end] }, }); } }, .Number => { try new_token_list.append(Token{ .id = tok.id, .start = tok.start, .data = .{ .number = std.fmt.parseFloat(UsedNumberType, raw_data[tok.start..tok.end]) catch unreachable }, }); }, .Function => { try new_token_list.append(Token{ .id = tok.id, .start = tok.start, .data = .{ .text = raw_data[tok.start..tok.end] }, }); }, else => { try new_token_list.append(Token{ .id = tok.id, .start = tok.start, .data = .{ .single_token = 0 }, }); }, } last_token = tok; } return new_token_list.toOwnedSlice(); }
src/parser.zig
const std = @import("std"); const gen1 = @import("../../gen1/data.zig"); const assert = std.debug.assert; const Type = gen1.Type; pub const Move = enum(u8) { None, Pound, KarateChop, DoubleSlap, CometPunch, MegaPunch, PayDay, FirePunch, IcePunch, ThunderPunch, Scratch, ViseGrip, Guillotine, RazorWind, SwordsDance, Cut, Gust, WingAttack, Whirlwind, Fly, Bind, Slam, VineWhip, Stomp, DoubleKick, MegaKick, JumpKick, RollingKick, SandAttack, Headbutt, HornAttack, FuryAttack, HornDrill, Tackle, BodySlam, Wrap, TakeDown, Thrash, DoubleEdge, TailWhip, PoisonSting, Twineedle, PinMissile, Leer, Bite, Growl, Roar, Sing, Supersonic, SonicBoom, Disable, Acid, Ember, Flamethrower, Mist, WaterGun, HydroPump, Surf, IceBeam, Blizzard, Psybeam, BubbleBeam, AuroraBeam, HyperBeam, Peck, DrillPeck, Submission, LowKick, Counter, SeismicToss, Strength, Absorb, MegaDrain, LeechSeed, Growth, RazorLeaf, SolarBeam, PoisonPowder, StunSpore, SleepPowder, PetalDance, StringShot, DragonRage, FireSpin, ThunderShock, Thunderbolt, ThunderWave, Thunder, RockThrow, Earthquake, Fissure, Dig, Toxic, Confusion, Psychic, Hypnosis, Meditate, Agility, QuickAttack, Rage, Teleport, NightShade, Mimic, Screech, DoubleTeam, Recover, Harden, Minimize, Smokescreen, ConfuseRay, Withdraw, DefenseCurl, Barrier, LightScreen, Haze, Reflect, FocusEnergy, Bide, Metronome, MirrorMove, SelfDestruct, EggBomb, Lick, Smog, Sludge, BoneClub, FireBlast, Waterfall, Clamp, Swift, SkullBash, SpikeCannon, Constrict, Amnesia, Kinesis, SoftBoiled, HighJumpKick, Glare, DreamEater, PoisonGas, Barrage, LeechLife, LovelyKiss, SkyAttack, Transform, Bubble, DizzyPunch, Spore, Flash, Psywave, Splash, AcidArmor, Crabhammer, Explosion, FurySwipes, Bonemerang, Rest, RockSlide, HyperFang, Sharpen, Conversion, TriAttack, SuperFang, Slash, Substitute, Struggle, // Sentinel used when Pokémon's turn should be skipped (eg. trapped) SKIP_TURN = 0xFF, pub const Data = packed struct { effect: Effect, bp: u8, accuracy: u8, type: Type, target: Target, comptime { assert(@sizeOf(Data) == 4); } }; const DATA = [_]Data{ // Pound .{ .effect = .None, .bp = 40, .type = .Normal, .accuracy = 100, .target = .Other, }, // KarateChop .{ .effect = .HighCritical, .bp = 50, .type = .Normal, .accuracy = 100, .target = .Other, }, // DoubleSlap .{ .effect = .MultiHit, .bp = 15, .type = .Normal, .accuracy = 85, .target = .Other, }, // CometPunch .{ .effect = .MultiHit, .bp = 18, .type = .Normal, .accuracy = 85, .target = .Other, }, // MegaPunch .{ .effect = .None, .bp = 80, .type = .Normal, .accuracy = 85, .target = .Other, }, // PayDay .{ .effect = .PayDay, .bp = 40, .type = .Normal, .accuracy = 100, .target = .Other, }, // FirePunch .{ .effect = .BurnChance1, .bp = 75, .type = .Fire, .accuracy = 100, .target = .Other, }, // IcePunch .{ .effect = .FreezeChance, .bp = 75, .type = .Ice, .accuracy = 100, .target = .Other, }, // ThunderPunch .{ .effect = .ParalyzeChance1, .bp = 75, .type = .Electric, .accuracy = 100, .target = .Other, }, // Scratch .{ .effect = .None, .bp = 40, .type = .Normal, .accuracy = 100, .target = .Other, }, // ViseGrip .{ .effect = .None, .bp = 55, .type = .Normal, .accuracy = 100, .target = .Other, }, // Guillotine .{ .effect = .OHKO, .bp = 0, .type = .Normal, .accuracy = 30, .target = .Other, }, // RazorWind .{ .effect = .Charge, .bp = 80, .type = .Normal, .accuracy = 75, .target = .Other, }, // SwordsDance .{ .effect = .AttackUp2, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Cut .{ .effect = .None, .bp = 50, .type = .Normal, .accuracy = 95, .target = .Other, }, // Gust .{ .effect = .None, .bp = 40, .type = .Normal, .accuracy = 100, .target = .Other, }, // WingAttack .{ .effect = .None, .bp = 35, .type = .Flying, .accuracy = 100, .target = .Other, }, // Whirlwind .{ .effect = .SwitchAndTeleport, .bp = 0, .type = .Normal, .accuracy = 85, .target = .Other, }, // Fly .{ .effect = .Charge, .bp = 70, .type = .Flying, .accuracy = 95, .target = .Other, }, // Bind .{ .effect = .Trapping, .bp = 15, .type = .Normal, .accuracy = 75, .target = .Other, }, // Slam .{ .effect = .None, .bp = 80, .type = .Normal, .accuracy = 75, .target = .Other, }, // VineWhip .{ .effect = .None, .bp = 35, .type = .Grass, .accuracy = 100, .target = .Other, }, // Stomp .{ .effect = .FlinchChance2, .bp = 65, .type = .Normal, .accuracy = 100, .target = .Other, }, // DoubleKick .{ .effect = .DoubleHit, .bp = 30, .type = .Fighting, .accuracy = 100, .target = .Other, }, // MegaKick .{ .effect = .None, .bp = 120, .type = .Normal, .accuracy = 75, .target = .Other, }, // JumpKick .{ .effect = .JumpKick, .bp = 70, .type = .Fighting, .accuracy = 95, .target = .Other, }, // RollingKick .{ .effect = .FlinchChance2, .bp = 60, .type = .Fighting, .accuracy = 85, .target = .Other, }, // SandAttack .{ .effect = .AccuracyDown1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Other, }, // Headbutt .{ .effect = .FlinchChance2, .bp = 70, .type = .Normal, .accuracy = 100, .target = .Other, }, // HornAttack .{ .effect = .None, .bp = 65, .type = .Normal, .accuracy = 100, .target = .Other, }, // FuryAttack .{ .effect = .MultiHit, .bp = 15, .type = .Normal, .accuracy = 85, .target = .Other, }, // HornDrill .{ .effect = .OHKO, .bp = 0, .type = .Normal, .accuracy = 30, .target = .Other, }, // Tackle .{ .effect = .None, .bp = 35, .type = .Normal, .accuracy = 95, .target = .Other, }, // BodySlam .{ .effect = .ParalyzeChance2, .bp = 85, .type = .Normal, .accuracy = 100, .target = .Other, }, // Wrap .{ .effect = .Trapping, .bp = 15, .type = .Normal, .accuracy = 85, .target = .Other, }, // TakeDown .{ .effect = .Recoil, .bp = 90, .type = .Normal, .accuracy = 85, .target = .Other, }, // Thrash .{ .effect = .Thrashing, .bp = 90, .type = .Normal, .accuracy = 100, .target = .RandomFoe, }, // DoubleEdge .{ .effect = .Recoil, .bp = 100, .type = .Normal, .accuracy = 100, .target = .Other, }, // TailWhip .{ .effect = .DefenseDown1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Foes, }, // PoisonSting .{ .effect = .PoisonChance1, .bp = 15, .type = .Poison, .accuracy = 100, .target = .Other, }, // Twineedle .{ .effect = .Twineedle, .bp = 25, .type = .Bug, .accuracy = 100, .target = .Other, }, // PinMissile .{ .effect = .MultiHit, .bp = 14, .type = .Bug, .accuracy = 85, .target = .Other, }, // Leer .{ .effect = .DefenseDown1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Foes, }, // Bite .{ .effect = .FlinchChance1, .bp = 60, .type = .Normal, .accuracy = 100, .target = .Other, }, // Growl .{ .effect = .AttackDown1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Foes, }, // Roar .{ .effect = .SwitchAndTeleport, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Other, }, // Sing .{ .effect = .Sleep, .bp = 0, .type = .Normal, .accuracy = 55, .target = .Other, }, // Supersonic .{ .effect = .Confusion, .bp = 0, .type = .Normal, .accuracy = 55, .target = .Other, }, // SonicBoom .{ .effect = .SpecialDamage, .bp = 0, .type = .Normal, .accuracy = 90, .target = .Other, }, // Disable .{ .effect = .Disable, .bp = 0, .type = .Normal, .accuracy = 55, .target = .Other, }, // Acid .{ .effect = .DefenseDownChance, .bp = 40, .type = .Poison, .accuracy = 100, .target = .Other, }, // Ember .{ .effect = .BurnChance1, .bp = 40, .type = .Fire, .accuracy = 100, .target = .Other, }, // Flamethrower .{ .effect = .BurnChance1, .bp = 95, .type = .Fire, .accuracy = 100, .target = .Other, }, // Mist .{ .effect = .Mist, .bp = 0, .type = .Ice, .accuracy = 100, .target = .Self, }, // WaterGun .{ .effect = .None, .bp = 40, .type = .Water, .accuracy = 100, .target = .Other, }, // HydroPump .{ .effect = .None, .bp = 120, .type = .Water, .accuracy = 80, .target = .Other, }, // Surf .{ .effect = .None, .bp = 95, .type = .Water, .accuracy = 100, .target = .Foes, }, // IceBeam .{ .effect = .FreezeChance, .bp = 95, .type = .Ice, .accuracy = 100, .target = .Other, }, // Blizzard .{ .effect = .FreezeChance, .bp = 120, .type = .Ice, .accuracy = 90, .target = .Other, }, // Psybeam .{ .effect = .ConfusionChance, .bp = 65, .type = .Psychic, .accuracy = 100, .target = .Other, }, // BubbleBeam .{ .effect = .SpeedDownChance, .bp = 65, .type = .Water, .accuracy = 100, .target = .Other, }, // AuroraBeam .{ .effect = .AttackDownChance, .bp = 65, .type = .Ice, .accuracy = 100, .target = .Other, }, // HyperBeam .{ .effect = .HyperBeam, .bp = 150, .type = .Normal, .accuracy = 90, .target = .Other, }, // Peck .{ .effect = .None, .bp = 35, .type = .Flying, .accuracy = 100, .target = .Other, }, // DrillPeck .{ .effect = .None, .bp = 80, .type = .Flying, .accuracy = 100, .target = .Other, }, // Submission .{ .effect = .Recoil, .bp = 80, .type = .Fighting, .accuracy = 80, .target = .Other, }, // LowKick .{ .effect = .FlinchChance2, .bp = 50, .type = .Fighting, .accuracy = 90, .target = .Other, }, // Counter .{ .effect = .None, .bp = 1, .type = .Fighting, .accuracy = 100, .target = .Depends, }, // SeismicToss .{ .effect = .SpecialDamage, .bp = 1, .type = .Fighting, .accuracy = 100, .target = .Other, }, // Strength .{ .effect = .None, .bp = 80, .type = .Normal, .accuracy = 100, .target = .Other, }, // Absorb .{ .effect = .DrainHP, .bp = 20, .type = .Grass, .accuracy = 100, .target = .Other, }, // MegaDrain .{ .effect = .DrainHP, .bp = 40, .type = .Grass, .accuracy = 100, .target = .Other, }, // LeechSeed .{ .effect = .LeechSeed, .bp = 0, .type = .Grass, .accuracy = 90, .target = .Other, }, // Growth .{ .effect = .SpecialUp1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // RazorLeaf .{ .effect = .HighCritical, .bp = 55, .type = .Grass, .accuracy = 95, .target = .Other, }, // SolarBeam .{ .effect = .Charge, .bp = 120, .type = .Grass, .accuracy = 100, .target = .Other, }, // PoisonPowder .{ .effect = .Poison, .bp = 0, .type = .Poison, .accuracy = 75, .target = .Other, }, // StunSpore .{ .effect = .Paralyze, .bp = 0, .type = .Grass, .accuracy = 75, .target = .Other, }, // SleepPowder .{ .effect = .Sleep, .bp = 0, .type = .Grass, .accuracy = 75, .target = .Other, }, // PetalDance .{ .effect = .Thrashing, .bp = 70, .type = .Grass, .accuracy = 100, .target = .RandomFoe, }, // StringShot .{ .effect = .SpeedDown1, .bp = 0, .type = .Bug, .accuracy = 95, .target = .Foes, }, // DragonRage .{ .effect = .SpecialDamage, .bp = 1, .type = .Dragon, .accuracy = 100, .target = .Other, }, // FireSpin .{ .effect = .Trapping, .bp = 15, .type = .Fire, .accuracy = 70, .target = .Other, }, // ThunderShock .{ .effect = .ParalyzeChance1, .bp = 40, .type = .Electric, .accuracy = 100, .target = .Other, }, // Thunderbolt .{ .effect = .ParalyzeChance1, .bp = 95, .type = .Electric, .accuracy = 100, .target = .Other, }, // ThunderWave .{ .effect = .Paralyze, .bp = 0, .type = .Electric, .accuracy = 100, .target = .Other, }, // Thunder .{ .effect = .ParalyzeChance1, .bp = 120, .type = .Electric, .accuracy = 70, .target = .Other, }, // RockThrow .{ .effect = .None, .bp = 50, .type = .Rock, .accuracy = 65, .target = .Other, }, // Earthquake .{ .effect = .None, .bp = 100, .type = .Ground, .accuracy = 100, .target = .AllOthers, }, // Fissure .{ .effect = .OHKO, .bp = 0, .type = .Ground, .accuracy = 30, .target = .Other, }, // Dig .{ .effect = .Charge, .bp = 100, .type = .Ground, .accuracy = 100, .target = .Other, }, // Toxic .{ .effect = .Poison, .bp = 0, .type = .Poison, .accuracy = 85, .target = .Other, }, // Confusion .{ .effect = .ConfusionChance, .bp = 50, .type = .Psychic, .accuracy = 100, .target = .Other, }, // Psychic .{ .effect = .SpecialDownChance, .bp = 90, .type = .Psychic, .accuracy = 100, .target = .Other, }, // Hypnosis .{ .effect = .Sleep, .bp = 0, .type = .Psychic, .accuracy = 60, .target = .Other, }, // Meditate .{ .effect = .AttackUp1, .bp = 0, .type = .Psychic, .accuracy = 100, .target = .Self, }, // Agility .{ .effect = .SpeedUp2, .bp = 0, .type = .Psychic, .accuracy = 100, .target = .Self, }, // QuickAttack .{ .effect = .None, .bp = 40, .type = .Normal, .accuracy = 100, .target = .Other, }, // Rage .{ .effect = .Rage, .bp = 20, .type = .Normal, .accuracy = 100, .target = .Other, }, // Teleport .{ .effect = .SwitchAndTeleport, .bp = 0, .type = .Psychic, .accuracy = 100, .target = .Self, }, // NightShade .{ .effect = .SpecialDamage, .bp = 1, .type = .Ghost, .accuracy = 100, .target = .Other, }, // Mimic .{ .effect = .Mimic, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Other, }, // Screech .{ .effect = .DefenseDown2, .bp = 0, .type = .Normal, .accuracy = 85, .target = .Other, }, // DoubleTeam .{ .effect = .EvasionUp1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Recover .{ .effect = .Heal, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Harden .{ .effect = .DefenseUp1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Minimize .{ .effect = .EvasionUp1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Smokescreen .{ .effect = .AccuracyDown1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Other, }, // ConfuseRay .{ .effect = .Confusion, .bp = 0, .type = .Ghost, .accuracy = 100, .target = .Other, }, // Withdraw .{ .effect = .DefenseUp1, .bp = 0, .type = .Water, .accuracy = 100, .target = .Self, }, // DefenseCurl .{ .effect = .DefenseUp1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Barrier .{ .effect = .DefenseUp2, .bp = 0, .type = .Psychic, .accuracy = 100, .target = .Self, }, // LightScreen .{ .effect = .LightScreen, .bp = 0, .type = .Psychic, .accuracy = 100, .target = .Self, }, // Haze .{ .effect = .Haze, .bp = 0, .type = .Ice, .accuracy = 100, .target = .Self, }, // Reflect .{ .effect = .Reflect, .bp = 0, .type = .Psychic, .accuracy = 100, .target = .Self, }, // FocusEnergy .{ .effect = .FocusEnergy, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Bide .{ .effect = .Bide, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Metronome .{ .effect = .Metronome, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // MirrorMove .{ .effect = .MirrorMove, .bp = 0, .type = .Flying, .accuracy = 100, .target = .Self, }, // SelfDestruct .{ .effect = .Explode, .bp = 130, .type = .Normal, .accuracy = 100, .target = .Other, }, // EggBomb .{ .effect = .None, .bp = 100, .type = .Normal, .accuracy = 75, .target = .Other, }, // Lick .{ .effect = .ParalyzeChance2, .bp = 20, .type = .Ghost, .accuracy = 100, .target = .Other, }, // Smog .{ .effect = .PoisonChance2, .bp = 20, .type = .Poison, .accuracy = 70, .target = .Other, }, // Sludge .{ .effect = .PoisonChance2, .bp = 65, .type = .Poison, .accuracy = 100, .target = .Other, }, // BoneClub .{ .effect = .FlinchChance1, .bp = 65, .type = .Ground, .accuracy = 85, .target = .Other, }, // FireBlast .{ .effect = .BurnChance2, .bp = 120, .type = .Fire, .accuracy = 85, .target = .Other, }, // Waterfall .{ .effect = .None, .bp = 80, .type = .Water, .accuracy = 100, .target = .Other, }, // Clamp .{ .effect = .Trapping, .bp = 35, .type = .Water, .accuracy = 75, .target = .Other, }, // Swift .{ .effect = .Swift, .bp = 60, .type = .Normal, .accuracy = 100, .target = .Foes, }, // SkullBash .{ .effect = .Charge, .bp = 100, .type = .Normal, .accuracy = 100, .target = .Other, }, // SpikeCannon .{ .effect = .MultiHit, .bp = 20, .type = .Normal, .accuracy = 100, .target = .Other, }, // Constrict .{ .effect = .SpeedDownChance, .bp = 10, .type = .Normal, .accuracy = 100, .target = .Other, }, // Amnesia .{ .effect = .SpecialUp2, .bp = 0, .type = .Psychic, .accuracy = 100, .target = .Self, }, // Kinesis .{ .effect = .AccuracyDown1, .bp = 0, .type = .Psychic, .accuracy = 80, .target = .Other, }, // SoftBoiled .{ .effect = .Heal, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // HighJumpKick .{ .effect = .JumpKick, .bp = 85, .type = .Fighting, .accuracy = 90, .target = .Other, }, // Glare .{ .effect = .Paralyze, .bp = 0, .type = .Normal, .accuracy = 75, .target = .Other, }, // DreamEater .{ .effect = .DreamEater, .bp = 100, .type = .Psychic, .accuracy = 100, .target = .Other, }, // PoisonGas .{ .effect = .Poison, .bp = 0, .type = .Poison, .accuracy = 55, .target = .Other, }, // Barrage .{ .effect = .MultiHit, .bp = 15, .type = .Normal, .accuracy = 85, .target = .Other, }, // LeechLife .{ .effect = .DrainHP, .bp = 20, .type = .Bug, .accuracy = 100, .target = .Other, }, // LovelyKiss .{ .effect = .Sleep, .bp = 0, .type = .Normal, .accuracy = 75, .target = .Other, }, // SkyAttack .{ .effect = .Charge, .bp = 140, .type = .Flying, .accuracy = 90, .target = .Other, }, // Transform .{ .effect = .Transform, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Other, }, // Bubble .{ .effect = .SpeedDownChance, .bp = 20, .type = .Water, .accuracy = 100, .target = .Other, }, // DizzyPunch .{ .effect = .None, .bp = 70, .type = .Normal, .accuracy = 100, .target = .Other, }, // Spore .{ .effect = .Sleep, .bp = 0, .type = .Grass, .accuracy = 100, .target = .Other, }, // Flash .{ .effect = .AccuracyDown1, .bp = 0, .type = .Normal, .accuracy = 70, .target = .Other, }, // Psywave .{ .effect = .SpecialDamage, .bp = 1, .type = .Psychic, .accuracy = 80, .target = .Other, }, // Splash .{ .effect = .Splash, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // AcidArmor .{ .effect = .DefenseUp2, .bp = 0, .type = .Poison, .accuracy = 100, .target = .Self, }, // Crabhammer .{ .effect = .HighCritical, .bp = 90, .type = .Water, .accuracy = 85, .target = .Other, }, // Explosion .{ .effect = .Explode, .bp = 170, .type = .Normal, .accuracy = 100, .target = .Other, }, // FurySwipes .{ .effect = .MultiHit, .bp = 18, .type = .Normal, .accuracy = 80, .target = .Other, }, // Bonemerang .{ .effect = .DoubleHit, .bp = 50, .type = .Ground, .accuracy = 90, .target = .Other, }, // Rest .{ .effect = .Heal, .bp = 0, .type = .Psychic, .accuracy = 100, .target = .Self, }, // RockSlide .{ .effect = .None, .bp = 75, .type = .Rock, .accuracy = 90, .target = .Other, }, // HyperFang .{ .effect = .FlinchChance1, .bp = 80, .type = .Normal, .accuracy = 90, .target = .Other, }, // Sharpen .{ .effect = .AttackUp1, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Conversion .{ .effect = .Conversion, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Other, }, // TriAttack .{ .effect = .None, .bp = 80, .type = .Normal, .accuracy = 100, .target = .Other, }, // SuperFang .{ .effect = .SuperFang, .bp = 1, .type = .Normal, .accuracy = 90, .target = .Other, }, // Slash .{ .effect = .HighCritical, .bp = 70, .type = .Normal, .accuracy = 100, .target = .Other, }, // Substitute .{ .effect = .Substitute, .bp = 0, .type = .Normal, .accuracy = 100, .target = .Self, }, // Struggle .{ .effect = .Recoil, .bp = 50, .type = .Normal, .accuracy = 100, .target = .RandomFoe, }, }; pub const Effect = enum(u8) { None, // onBeginMove Confusion, Conversion, FocusEnergy, Haze, Heal, LeechSeed, LightScreen, Mimic, Mist, Paralyze, Poison, Reflect, Splash, Substitute, SwitchAndTeleport, Transform, // onEnd AccuracyDown1, AttackDown1, DefenseDown1, DefenseDown2, SpeedDown1, AttackUp1, AttackUp2, Bide, DefenseUp1, DefenseUp2, EvasionUp1, Sleep, SpecialUp1, SpecialUp2, SpeedUp2, // isSpecial DrainHP, DreamEater, Explode, JumpKick, PayDay, Rage, Recoil, Charge, SpecialDamage, SuperFang, Swift, Thrashing, Trapping, // isMulti DoubleHit, MultiHit, Twineedle, // other AttackDownChance, DefenseDownChance, SpeedDownChance, SpecialDownChance, BurnChance1, BurnChance2, ConfusionChance, Disable, FlinchChance1, FlinchChance2, FreezeChance, HighCritical, HyperBeam, Metronome, MirrorMove, OHKO, ParalyzeChance1, ParalyzeChance2, PoisonChance1, PoisonChance2, comptime { assert(@sizeOf(Effect) == 1); } pub inline fn onBegin(effect: Effect) bool { return @enumToInt(effect) > 0 and @enumToInt(effect) <= 16; } pub inline fn isStatDown(effect: Effect) bool { return @enumToInt(effect) > 16 and @enumToInt(effect) <= 21; } pub inline fn onEnd(effect: Effect) bool { return @enumToInt(effect) > 16 and @enumToInt(effect) <= 31; } pub inline fn alwaysHappens(effect: Effect) bool { return @enumToInt(effect) > 31 and @enumToInt(effect) <= 38; } pub inline fn isSpecial(effect: Effect) bool { // NB: isSpecial includes isMulti up to Twineedle return @enumToInt(effect) > 31 and @enumToInt(effect) <= 46; } pub inline fn isMulti(effect: Effect) bool { return @enumToInt(effect) > 44 and @enumToInt(effect) <= 47; } pub inline fn isStatDownChance(effect: Effect) bool { return @enumToInt(effect) > 47 and @enumToInt(effect) <= 51; } }; const Target = enum(u4) { // none All, AllySide, Field, Self, // resolve AllOthers, Depends, Other, // TODO: resolve or resolve + run? Allies, Ally, AllyOrSelf, Foe, // resolve + run Foes, FoeSide, RandomFoe, pub inline fn resolves(target: Target) bool { return @enumToInt(target) >= @enumToInt(Target.AllOthers); } pub inline fn runs(target: Target) bool { return @enumToInt(target) >= @enumToInt(Target.Foes); } }; // @test-only const PP = [_]u8{ 35, // Pound 25, // KarateChop 10, // DoubleSlap 15, // CometPunch 20, // MegaPunch 20, // PayDay 15, // FirePunch 15, // IcePunch 15, // ThunderPunch 35, // Scratch 30, // ViseGrip 5, // Guillotine 10, // RazorWind 30, // SwordsDance 30, // Cut 35, // Gust 35, // WingAttack 20, // Whirlwind 15, // Fly 20, // Bind 20, // Slam 10, // VineWhip 20, // Stomp 30, // DoubleKick 5, // MegaKick 25, // JumpKick 15, // RollingKick 15, // SandAttack 15, // Headbutt 25, // HornAttack 20, // FuryAttack 5, // HornDrill 35, // Tackle 15, // BodySlam 20, // Wrap 20, // TakeDown 20, // Thrash 15, // DoubleEdge 30, // TailWhip 35, // PoisonSting 20, // Twineedle 20, // PinMissile 30, // Leer 25, // Bite 40, // Growl 20, // Roar 15, // Sing 20, // Supersonic 20, // SonicBoom 20, // Disable 30, // Acid 25, // Ember 15, // Flamethrower 30, // Mist 25, // WaterGun 5, // HydroPump 15, // Surf 10, // IceBeam 5, // Blizzard 20, // Psybeam 20, // BubbleBeam 20, // AuroraBeam 5, // HyperBeam 35, // Peck 20, // DrillPeck 25, // Submission 20, // LowKick 20, // Counter 20, // SeismicToss 15, // Strength 20, // Absorb 10, // MegaDrain 10, // LeechSeed 40, // Growth 25, // RazorLeaf 10, // SolarBeam 35, // PoisonPowder 30, // StunSpore 15, // SleepPowder 20, // PetalDance 40, // StringShot 10, // DragonRage 15, // FireSpin 30, // ThunderShock 15, // Thunderbolt 20, // ThunderWave 10, // Thunder 15, // RockThrow 10, // Earthquake 5, // Fissure 10, // Dig 10, // Toxic 25, // Confusion 10, // Psychic 20, // Hypnosis 40, // Meditate 30, // Agility 30, // QuickAttack 20, // Rage 20, // Teleport 15, // NightShade 10, // Mimic 40, // Screech 15, // DoubleTeam 20, // Recover 30, // Harden 20, // Minimize 20, // Smokescreen 10, // ConfuseRay 40, // Withdraw 40, // DefenseCurl 30, // Barrier 30, // LightScreen 30, // Haze 20, // Reflect 30, // FocusEnergy 10, // Bide 10, // Metronome 20, // MirrorMove 5, // SelfDestruct 10, // EggBomb 30, // Lick 20, // Smog 20, // Sludge 20, // BoneClub 5, // FireBlast 15, // Waterfall 10, // Clamp 20, // Swift 15, // SkullBash 15, // SpikeCannon 35, // Constrict 20, // Amnesia 15, // Kinesis 10, // SoftBoiled 20, // HighJumpKick 30, // Glare 15, // DreamEater 40, // PoisonGas 20, // Barrage 15, // LeechLife 10, // LovelyKiss 5, // SkyAttack 10, // Transform 30, // Bubble 10, // DizzyPunch 15, // Spore 20, // Flash 15, // Psywave 40, // Splash 40, // AcidArmor 10, // Crabhammer 5, // Explosion 15, // FurySwipes 10, // Bonemerang 10, // Rest 10, // RockSlide 15, // HyperFang 30, // Sharpen 30, // Conversion 10, // TriAttack 10, // SuperFang 20, // Slash 10, // Substitute 10, // Struggle, }; comptime { assert(@sizeOf(Move) == 1); assert(@sizeOf(@TypeOf(DATA)) == 660); } pub inline fn get(id: Move) Data { assert(id != .None); return DATA[@enumToInt(id) - 1]; } const Event = enum { resolve, run }; pub inline fn frames(id: Move, event: Event) u8 { if (id == .Counter and event == .resolve) return 2; return @as(u8, @boolToInt(switch (event) { .resolve => get(id).target.resolves(), .run => get(id).target.runs(), })); } // @test-only pub fn pp(id: Move) u8 { assert(id != .None); return PP[@enumToInt(id) - 1]; } };
src/lib/gen1/data/moves.zig
const Archive = @This(); const builtin = @import("builtin"); const std = @import("std"); const trace = @import("../tracy.zig").trace; const traceNamed = @import("../tracy.zig").traceNamed; const fmt = std.fmt; const fs = std.fs; const mem = std.mem; const logger = std.log.scoped(.archive); const elf = std.elf; const Elf = @import("../link/Elf/Object.zig"); const MachO = @import("../link/MachO/Object.zig"); const macho = std.macho; const Coff = @import("../link/Coff/Object.zig"); const Bitcode = @import("../link/Bitcode/Object.zig"); const coff = std.coff; const tracking_buffered_writer = @import("../tracking_buffered_writer.zig"); const Allocator = std.mem.Allocator; dir: fs.Dir, file: fs.File, name: []const u8, created: bool, // We need to differentiate between inferred and output archive type, as other ar // programs "just handle" any valid archive for parsing, regarldess of what a // user has specified - the user specification should only matter for writing // archives. inferred_archive_type: ArchiveType, output_archive_type: ArchiveType, files: std.ArrayListUnmanaged(ArchivedFile), symbols: std.ArrayListUnmanaged(Symbol), // Use it so we can easily lookup files indices when inserting! // TODO: A trie is probably a lot better here file_name_to_index: std.StringArrayHashMapUnmanaged(u64), modifiers: Modifiers, stat: fs.File.Stat, pub const ArchiveType = enum { ambiguous, gnu, gnuthin, gnu64, bsd, darwin, // *mostly* like BSD, with some differences in limited contexts when writing for determinism reasons darwin64, coff, // (windows) pub fn getAlignment(self: ArchiveType) u32 { // See: https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/lib/Object/ArchiveWriter.cpp#L311 return switch (self) { .ambiguous => unreachable, else => if (self.isBsdLike()) @as(u32, 8) else @as(u32, 2), }; } pub fn getFileAlignment(self: ArchiveType) u32 { // In this context, bsd like archives get 2 byte alignment but darwin // stick to 8 byte alignment return switch (self) { .ambiguous => unreachable, else => if (self.isDarwin()) @as(u32, 8) else @as(u32, 2), }; } pub fn isBsdLike(self: ArchiveType) bool { return switch (self) { .bsd, .darwin, .darwin64 => true, else => false, }; } pub fn isDarwin(self: ArchiveType) bool { return switch (self) { .darwin, .darwin64 => true, else => false, }; } }; pub const Operation = enum { insert, delete, move, print_contents, quick_append, ranlib, print_names, extract, print_symbols, }; // We seperate errors into two classes, "handled" and "unhandled". // The reason for this is that "handled" errors log appropriate error // messages at the point they are created, whereas unhandled errors do // not so the caller will need to print appropriate error messages // themselves (if needed at all). pub const UnhandledError = ParseError || CriticalError; pub const HandledError = IoError; pub const ParseError = error{ NotArchive, MalformedArchive, Overflow, InvalidCharacter, }; pub const CriticalError = error{ OutOfMemory, TODO, }; pub const IoError = error{ AccessDenied, BrokenPipe, ConnectionResetByPeer, ConnectionTimedOut, InputOutput, IsDir, NotOpenForReading, InvalidHandle, OperationAborted, SystemResources, Unexpected, Unseekable, WouldBlock, EndOfStream, BadPathName, DeviceBusy, FileBusy, FileLocksNotSupported, FileNotFound, FileTooBig, InvalidUtf8, NameTooLong, NoDevice, NoSpaceLeft, NotDir, PathAlreadyExists, PipeBusy, ProcessFdQuotaExceeded, SharingViolation, SymLinkLoop, SystemFdQuotaExceeded, }; // All archive files start with this magic string pub const magic_string = "!<arch>\n"; pub const magic_thin = "!<thin>\n"; // GNU constants pub const gnu_first_line_buffer_length = 60; pub const gnu_string_table_seek_pos = magic_string.len + gnu_first_line_buffer_length; // BSD constants pub const bsd_name_length_signifier = "#1/"; pub const bsd_symdef_magic = "__.SYMDEF"; pub const bsd_symdef_64_magic = "__.SYMDEF_64"; pub const bsd_symdef_sorted_magic = "__.SYMDEF SORTED"; pub const bsd_symdef_longest_magic = std.math.max(std.math.max(bsd_symdef_magic.len, bsd_symdef_64_magic.len), bsd_symdef_sorted_magic.len); pub const invalid_file_index = std.math.maxInt(u64); // The format (unparsed) of the archive per-file header // NOTE: The reality is more complex than this as different mechanisms // have been devised for storing the names of files which exceed 16 byte! pub const Header = extern struct { ar_name: [16]u8, ar_date: [12]u8, ar_uid: [6]u8, ar_gid: [6]u8, ar_mode: [8]u8, ar_size: [10]u8, ar_fmag: [2]u8, pub const format_string = "{s: <16}{: <12}{: <6}{: <6}{: <8}{: <10}`\n"; }; pub const ExplicitBooleanSetting = enum { ambiguous, set_true, set_false }; pub const MoveSetting = enum { end, before, after }; pub const Modifiers = struct { // Supress warning for file creation create: bool = false, // Only insert files with more recent timestamps than archive update_only: bool = false, use_real_timestamps_and_ids: bool = false, build_symbol_table: bool = true, sort_symbol_table: ExplicitBooleanSetting = .ambiguous, verbose: bool = false, move_setting: MoveSetting = .end, }; pub const Contents = struct { bytes: []u8, length: u64, mode: u64, timestamp: u128, // file modified time uid: u32, gid: u32, // TODO: dellocation pub fn write(self: *const Contents, out_stream: anytype, stderr: anytype) !void { try out_stream.writeAll(self.bytes); _ = stderr; } }; // An internal represantion of files being archived pub const ArchivedFile = struct { name: []const u8, contents: Contents, const Self = @This(); }; pub const Symbol = struct { name: []const u8, file_index: u64, }; // TODO: BSD symbol table interpretation is architecture dependent, // is there a way we can interpret this? (will be needed for // cross-compilation etc. could possibly take it as a spec?) // Using harcoding this information here is a bit of a hacky // workaround in the short term - even though it is part of // the spec. const IntType = i32; // TODO: This name is confusing because ranlib is also the name of the ranlib // program - but also what this struct is traditionally called within archives. // :/ // type of ranlib used depends on the archive storage format fn Ranlib(comptime storage: type) type { return extern struct { ran_strx: storage, // offset of symbol name in symbol table ran_off: storage, // offset of file header in archive }; } const ErrorContext = enum { accessing, creating, opening, reading, seeking, }; pub fn printFileIoError(comptime context: ErrorContext, file_name: []const u8, err: IoError) void { const context_str = @tagName(context); switch (err) { error.AccessDenied => logger.err("Error " ++ context_str ++ " {s}, access denied.", .{file_name}), else => logger.err("Error " ++ context_str ++ " {s}.", .{file_name}), } return; } pub fn handleFileIoError(comptime context: ErrorContext, file_name: []const u8, err_result: anytype) @TypeOf(err_result) { // TODO: at some point switch on the errors to show more info! _ = err_result catch |err| printFileIoError(context, file_name, err); return err_result; } // These are the defaults llvm ar uses (excepting windows) // https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-ar/llvm-ar.cpp pub fn getDefaultArchiveTypeFromHost() ArchiveType { // LLVM ar seems to default to gnu-style archives if nothing has been // inferred up to this point. // TODO: Figure out why this is needed to pass tests on macOS as this seems // to contradict docs/code? return .gnu; // if (builtin.os.tag.isDarwin()) return .darwin; // switch (builtin.os.tag) { // .windows => return .coff, // else => return .gnu, // } } pub fn create( dir: fs.Dir, file: fs.File, name: []const u8, output_archive_type: ArchiveType, modifiers: Modifiers, created: bool, ) !Archive { return Archive{ .dir = dir, .file = file, .name = name, .inferred_archive_type = .ambiguous, .output_archive_type = output_archive_type, .files = .{}, .symbols = .{}, .file_name_to_index = .{}, .modifiers = modifiers, .stat = try file.stat(), .created = created, }; } const SymbolStringTableAndOffsets = struct { unpadded_symbol_table_length: i32, symbol_table: []u8, symbol_offsets: []i32, pub fn deinit(self: *const SymbolStringTableAndOffsets, allocator: Allocator) void { allocator.free(self.symbol_offsets); allocator.free(self.symbol_table); } }; pub fn buildSymbolTable( self: *Archive, allocator: Allocator, ) !SymbolStringTableAndOffsets { const tracy = trace(@src()); defer tracy.end(); var symbol_table_size: usize = 0; const symbol_offsets = try allocator.alloc(i32, self.symbols.items.len); errdefer allocator.free(symbol_offsets); for (self.symbols.items) |symbol, idx| { symbol_offsets[idx] = @intCast(i32, symbol_table_size); symbol_table_size += symbol.name.len + 1; } const unpadded_symbol_table_length = symbol_table_size; while (symbol_table_size % self.output_archive_type.getAlignment() != 0) { symbol_table_size += 1; } const symbol_table = try allocator.alloc(u8, symbol_table_size); symbol_table_size = 0; for (self.symbols.items) |symbol| { mem.copy(u8, symbol_table[symbol_table_size..(symbol.name.len + symbol_table_size)], symbol.name); symbol_table[symbol_table_size + symbol.name.len] = 0; symbol_table_size += symbol.name.len + 1; } while (symbol_table_size % self.output_archive_type.getAlignment() != 0) { symbol_table[symbol_table_size] = 0; symbol_table_size += 1; } const result: SymbolStringTableAndOffsets = .{ .unpadded_symbol_table_length = @intCast(i32, unpadded_symbol_table_length), .symbol_table = symbol_table, .symbol_offsets = symbol_offsets, }; return result; } fn calculatePadding(self: *Archive, file_pos: usize) usize { var padding = file_pos % self.output_archive_type.getAlignment(); padding = (self.output_archive_type.getAlignment() - padding) % self.output_archive_type.getAlignment(); return padding; } const TrackingBufferedWriter = tracking_buffered_writer.TrackingBufferedWriter(std.io.BufferedWriter(4096, std.fs.File.Writer)); // TODO: This needs to be integrated into the workflow // used for parsing. (use same error handling workflow etc.) /// Use same naming scheme for objects (as found elsewhere in the file). pub fn finalize(self: *Archive, allocator: Allocator) !void { const tracy = trace(@src()); defer tracy.end(); if (self.output_archive_type == .ambiguous) { // if output archive type is still ambiguous (none was inferred, and // none was set) then we need to infer it from the host platform! self.output_archive_type = getDefaultArchiveTypeFromHost(); } // Overwrite all contents try self.file.seekTo(0); // We wrap the buffered writer so that can we can track file position more easily var buffered_writer = TrackingBufferedWriter{ .buffered_writer = std.io.bufferedWriter(self.file.writer()) }; const writer = buffered_writer.writer(); try writer.writeAll(if (self.output_archive_type == .gnuthin) magic_thin else magic_string); const header_names = try allocator.alloc([16]u8, self.files.items.len); const SortContext = struct { files: std.ArrayListUnmanaged(ArchivedFile), }; const SortFn = struct { fn sorter(context: *const SortContext, x: Symbol, y: Symbol) bool { const x_file_name = context.files.items[x.file_index].name; const y_file_name = context.files.items[y.file_index].name; // we only sort symbol names internally within file, but maintain // the order within which they are added. if (x.file_index < y.file_index) { return true; } else if (x.file_index > y.file_index) { return false; } const order = std.mem.order(u8, x_file_name, y_file_name); if (order == .eq) { return std.mem.lessThan(u8, x.name, y.name); } return order == .lt; } }; // Sort the symbols const sort_symbol_table = switch (self.modifiers.sort_symbol_table) { .ambiguous => self.output_archive_type.isDarwin(), .set_true => true, .set_false => false, }; const sort_context: SortContext = .{ .files = self.files }; if (sort_symbol_table) { const tracy_scope = traceNamed(@src(), "Sort Symbol Table"); defer tracy_scope.end(); std.sort.sort(Symbol, self.symbols.items, &sort_context, SortFn.sorter); } // Calculate the offset of file independent of string table and symbol table itself. // It is basically magic size + file size from position 0 const relative_file_offsets = try allocator.alloc(i32, self.files.items.len); defer allocator.free(relative_file_offsets); { var offset: u32 = 0; for (self.files.items) |file, idx| { relative_file_offsets[idx] = @intCast(i32, offset); offset += @intCast(u32, @sizeOf(Header) + file.contents.bytes.len); // BSD also keeps the name in its data section if (self.output_archive_type.isBsdLike()) { offset += @intCast(u32, file.name.len); // Add padding while (offset % self.output_archive_type.getAlignment() != 0) { offset += 1; } } } } // Set the mtime of symbol table to now seconds in non-deterministic mode const symtab_time: u64 = (if (self.modifiers.use_real_timestamps_and_ids) @intCast(u64, std.time.milliTimestamp()) else 0) / 1000; switch (self.output_archive_type) { .gnu, .gnuthin, .gnu64 => { // GNU format: Create string table var string_table = std.ArrayList(u8).init(allocator); defer string_table.deinit(); // Generate the complete string table for (self.files.items) |file, index| { const is_the_name_allowed = (file.name.len < 16) and (self.output_archive_type != .gnuthin); // If the file is small enough to fit in header, then just write it there // Otherwise, add it to string table and add a reference to its location const name = if (is_the_name_allowed) try mem.concat(allocator, u8, &.{ file.name, "/" }) else try std.fmt.allocPrint(allocator, "/{}", .{blk: { // Get the position of the file in string table const pos = string_table.items.len; // Now add the file name to string table try string_table.appendSlice(file.name); try string_table.appendSlice("/\n"); break :blk pos; }}); defer allocator.free(name); // Edit the header _ = try std.fmt.bufPrint(&(header_names[index]), "{s: <16}", .{name}); } // Write the symbol table itself if (self.modifiers.build_symbol_table and self.symbols.items.len != 0) { const tracy_scope = traceNamed(@src(), "Write Symbol Table"); defer tracy_scope.end(); const symbol_string_table_and_offsets = try self.buildSymbolTable(allocator); defer symbol_string_table_and_offsets.deinit(allocator); const symbol_table = symbol_string_table_and_offsets.symbol_table; const format = self.output_archive_type; const int_size: usize = if (format == .gnu64) @sizeOf(u64) else @sizeOf(u32); const symbol_table_size = symbol_table.len + // The string of symbols (self.symbols.items.len * int_size) + // Size of all symbol offsets int_size; // Value denoting the length of symbol table const magic: []const u8 = if (format == .gnu64) "/SYM64/" else "/"; try writer.print(Header.format_string, .{ magic, symtab_time, 0, 0, 0, symbol_table_size }); { const tracy_scope_inner = traceNamed(@src(), "Write Symbol Count"); defer tracy_scope_inner.end(); if (format == .gnu64) { try writer.writeIntBig(u64, @intCast(u64, self.symbols.items.len)); } else { try writer.writeIntBig(u32, @intCast(u32, self.symbols.items.len)); } } // magic_string.len == magic_thin.len, so its not a problem var offset_to_files = magic_string.len; // Size of symbol table itself offset_to_files += @sizeOf(Header) + symbol_table_size; // Add padding while (offset_to_files % self.output_archive_type.getAlignment() != 0) { offset_to_files += 1; } // Size of string table if (string_table.items.len != 0) { offset_to_files += @sizeOf(Header) + string_table.items.len; } // Add further padding while (offset_to_files % self.output_archive_type.getAlignment() != 0) { offset_to_files += 1; } { const tracy_scope_inner = traceNamed(@src(), "Write Symbol File Offsets"); defer tracy_scope_inner.end(); for (self.symbols.items) |symbol| { if (format == .gnu64) { try writer.writeIntBig(i64, relative_file_offsets[symbol.file_index] + @intCast(i64, offset_to_files)); } else { try writer.writeIntBig(i32, relative_file_offsets[symbol.file_index] + @intCast(i32, offset_to_files)); } } } try writer.writeAll(symbol_table); } // Write the string table itself { const tracy_scope = traceNamed(@src(), "Write String Table"); defer tracy_scope.end(); if (string_table.items.len != 0) { while (string_table.items.len % self.output_archive_type.getAlignment() != 0) try string_table.append('\n'); try writer.print("//{s}{: <10}`\n{s}", .{ " " ** 46, string_table.items.len, string_table.items }); } } }, .bsd, .darwin, .darwin64 => { // BSD format: Write the symbol table // In darwin if symbol table writing is enabled the expected behaviour // is that we write an empty symbol table! const write_symbol_table = self.modifiers.build_symbol_table and (self.symbols.items.len != 0 or self.output_archive_type != .bsd); if (write_symbol_table) { const tracy_scope = traceNamed(@src(), "Write Symbol Table"); defer tracy_scope.end(); const symbol_string_table_and_offsets = try self.buildSymbolTable(allocator); defer symbol_string_table_and_offsets.deinit(allocator); const symbol_table = symbol_string_table_and_offsets.symbol_table; const format = self.output_archive_type; const int_size: usize = if (format == .darwin64) @sizeOf(u64) else @sizeOf(u32); const num_ranlib_bytes = self.symbols.items.len * @sizeOf(Ranlib(IntType)); const symbol_table_size = bsd_symdef_64_magic.len + // Length of name int_size + // Int describing the size of ranlib num_ranlib_bytes + // Size of ranlib structs int_size + // Int describing size of symbol table's strings symbol_table.len; // The lengths of strings themselves try writer.print(Header.format_string, .{ "#1/12", symtab_time, 0, 0, 0, symbol_table_size }); const endian = builtin.cpu.arch.endian(); if (format == .darwin64) { try writer.writeAll(bsd_symdef_64_magic); try writer.writeInt(u64, @intCast(u64, num_ranlib_bytes), endian); } else { try writer.writeAll(bsd_symdef_magic ++ "\x00\x00\x00"); try writer.writeInt(u32, @intCast(u32, num_ranlib_bytes), endian); } const ranlibs = try allocator.alloc(Ranlib(IntType), self.symbols.items.len); defer allocator.free(ranlibs); var offset_to_files: usize = magic_string.len + @sizeOf(Header) + symbol_table_size; // Add padding while (offset_to_files % self.output_archive_type.getAlignment() != 0) { offset_to_files += 1; } for (self.symbols.items) |symbol, idx| { ranlibs[idx].ran_strx = symbol_string_table_and_offsets.symbol_offsets[idx]; ranlibs[idx].ran_off = relative_file_offsets[symbol.file_index] + @intCast(i32, offset_to_files); } try writer.writeAll(mem.sliceAsBytes(ranlibs)); if (format == .darwin64) { try writer.writeInt(u64, @intCast(u64, symbol_string_table_and_offsets.unpadded_symbol_table_length), endian); } else { try writer.writeInt(u32, @intCast(u32, symbol_string_table_and_offsets.unpadded_symbol_table_length), endian); } try writer.writeAll(symbol_table); } }, // This needs to be able to tell whatsupp. else => unreachable, } // Write the files const tracy_scope = traceNamed(@src(), "Write Files To Archive"); defer tracy_scope.end(); for (self.files.items) |file, index| { var header_buffer: [@sizeOf(Header)]u8 = undefined; const file_length = file_length_calculation: { if (!self.output_archive_type.isBsdLike()) { break :file_length_calculation file.contents.length; } else { const padding = self.calculatePadding(buffered_writer.file_pos + header_buffer.len + file.name.len); // BSD format: Just write the length of the name in header _ = try std.fmt.bufPrint(&(header_names[index]), "#1/{: <13}", .{file.name.len + padding}); if (self.output_archive_type.isDarwin()) { var file_padding = file.contents.length % self.output_archive_type.getFileAlignment(); file_padding = (self.output_archive_type.getFileAlignment() - file_padding) % self.output_archive_type.getFileAlignment(); break :file_length_calculation file.contents.length + file.name.len + padding + file_padding; } else { break :file_length_calculation file.contents.length + file.name.len + padding; } } }; _ = try std.fmt.bufPrint( &header_buffer, Header.format_string, .{ &header_names[index], file.contents.timestamp, file.contents.uid, file.contents.gid, file.contents.mode, file_length }, ); // TODO: handle errors _ = try writer.write(&header_buffer); // Write the name of the file in the data section if (self.output_archive_type.isBsdLike()) { try writer.writeAll(file.name); try writer.writeByteNTimes(0, self.calculatePadding(buffered_writer.file_pos)); } if (self.output_archive_type != .gnuthin) { try file.contents.write(writer, null); try writer.writeByteNTimes('\n', self.calculatePadding(buffered_writer.file_pos)); } } try buffered_writer.flush(); // Truncate the file size try self.file.setEndPos(buffered_writer.file_pos); } pub fn deleteFiles(self: *Archive, file_names: []const []const u8) !void { const tracy = trace(@src()); defer tracy.end(); // For the list of given file names, find the entry in self.files // and remove it from self.files. for (file_names) |file_name| { for (self.files.items) |file, index| { if (std.mem.eql(u8, file.name, file_name)) { // Remove all the symbols associated with the file // when file is deleted var idx: usize = 0; while (idx < self.symbols.items.len) { const sym = self.symbols.items[idx]; if (sym.file_index == index) { _ = self.symbols.orderedRemove(idx); continue; } idx += 1; } // Reset the index for all future symbols for (self.symbols.items) |*sym| { if (sym.file_index > index) { sym.file_index -= 1; } } _ = self.files.orderedRemove(index); break; } } } } pub fn moveFiles(self: *Archive, file_names: []const []const u8) !void { switch (self.modifiers.move_setting) { .end => { // TODO: find files, move them, deal with all boundary cases! _ = file_names; }, .before, .after => { // TODO: bounds check! // const relpos = file_names[0]; // const other_files = file_names[1..file_names.len]; }, } logger.err("Move operation still needs to be implemented!\n", .{}); return error.TODO; } pub fn extract(self: *Archive, file_names: []const []const u8) !void { if (self.inferred_archive_type == .gnuthin) { // TODO: better error return error.ExtractingFromThin; } for (self.files.items) |archived_file| { for (file_names) |file_name| { if (std.mem.eql(u8, archived_file.name, file_name)) { const file = try self.dir.createFile(archived_file.name, .{}); defer file.close(); try file.writeAll(archived_file.contents.bytes); break; } } } } pub fn addToSymbolTable(self: *Archive, allocator: Allocator, file_name: []const u8, file_index: usize, file: fs.File, file_offset: u32) !void { // TODO: make this read directly from the file contents buffer! // Get the file magic try file.seekTo(file_offset); var magic: [4]u8 = undefined; _ = try file.reader().read(&magic); try file.seekTo(file_offset); blk: { // TODO: Load object from memory (upstream zld) // TODO(TRC):Now this should assert that the magic number is what we expect it to be // based on the parsed archive type! Not inferring what we should do based on it. // switch(self.output_archive_type) // { // } if (mem.eql(u8, magic[0..elf.MAGIC.len], elf.MAGIC)) { if (self.output_archive_type == .ambiguous) { // TODO: double check that this is the correct inference self.output_archive_type = .gnu; } var elf_file = Elf{ .file = file, .name = file_name, .file_offset = file_offset }; defer elf_file.deinit(allocator); // TODO: Do not use builtin.target like this, be more flexible! elf_file.parse(allocator, builtin.target) catch |err| switch (err) { error.NotObject => break :blk, else => |e| return e, }; for (elf_file.symtab.items) |sym| { switch (sym.st_info >> 4) { elf.STB_WEAK, elf.STB_GLOBAL => { if (!(elf.SHN_LORESERVE <= sym.st_shndx and sym.st_shndx < elf.SHN_HIRESERVE and sym.st_shndx == elf.SHN_UNDEF)) { const symbol = Symbol{ .name = try allocator.dupe(u8, elf_file.getString(sym.st_name)), .file_index = file_index, }; try self.symbols.append(allocator, symbol); } }, else => {}, } } } else if (mem.eql(u8, magic[0..Bitcode.magic.len], Bitcode.magic)) { logger.warn("Zig ar does not currently support bitcode files, so no symbol table will be constructed for {s}.", .{file_name}); break :blk; // var bitcode_file = Bitcode{ .file = file, .name = file_name }; // defer bitcode_file.deinit(allocator); // // TODO: Do not use builtin.target like this, be more flexible! // bitcode_file.parse(allocator, builtin.target) catch |err| switch (err) { // error.NotObject => break :blk, // else => |e| return e, //}; } else { // TODO(TRC):Now this should assert that the magic number is what we expect it to be // based on the parsed archive type! Not inferring what we should do based on it. const magic_num = mem.readInt(u32, magic[0..], builtin.cpu.arch.endian()); if (magic_num == macho.MH_MAGIC or magic_num == macho.MH_MAGIC_64) { if (self.output_archive_type == .ambiguous) { self.output_archive_type = .darwin; } var macho_file = MachO{ .file = file, .name = file_name, .file_offset = file_offset }; defer macho_file.deinit(allocator); macho_file.parse(allocator, builtin.target) catch |err| switch (err) { error.NotObject => break :blk, else => |e| return e, }; for (macho_file.symtab.items) |sym| { if (sym.ext() and sym.sect()) { const symbol = Symbol{ .name = try allocator.dupe(u8, macho_file.getString(sym.n_strx)), .file_index = file_index, }; try self.symbols.append(allocator, symbol); } } } else if (false) { // TODO: Figure out the condition under which a file is a coff // file. This was originally just an else clause - but a file // might not contain any symbols! var coff_file = Coff{ .file = file, .name = file_name }; defer coff_file.deinit(allocator); coff_file.parse(allocator, builtin.target) catch |err| return err; for (coff_file.symtab.items) |sym| { if (sym.storage_class == Coff.IMAGE_SYM_CLASS_EXTERNAL) { const symbol = Symbol{ .name = try allocator.dupe(u8, sym.getName(&coff_file)), .file_index = file_index, }; try self.symbols.append(allocator, symbol); } } } } } } pub fn insertFiles(self: *Archive, allocator: Allocator, file_names: []const []const u8) !void { const tracy = trace(@src()); defer tracy.end(); // TODO: distribute this across n jobs in different chunks? for (file_names) |file_name| { // Open the file and read all of its contents const file = try handleFileIoError(.opening, file_name, self.dir.openFile(file_name, .{ .mode = .read_only })); defer file.close(); // We only need to do this because file stats don't include // guid and uid - maybe the right solution is to integrate that into // the std so we can call file.stat() on all platforms. var gid: u32 = 0; var uid: u32 = 0; var mtime: i128 = 0; var size: u64 = undefined; var mode: u64 = undefined; // FIXME: Currently windows doesnt support the Stat struct if (builtin.os.tag == .windows) { const file_stats = try file.stat(); // Convert timestamp from ns to s mtime = file_stats.mtime; size = file_stats.size; mode = file_stats.mode; } else { const file_stats = try std.os.fstat(file.handle); gid = file_stats.gid; uid = file_stats.uid; const mtime_full = file_stats.mtime(); mtime = mtime_full.tv_sec * std.time.ns_per_s + mtime_full.tv_nsec; size = @intCast(u64, file_stats.size); mode = file_stats.mode; } if (self.modifiers.update_only) { // TODO: Write a test that checks for this functionality still working! // TODO: Is this even correct? Shouldn't it be comparing to mtime in archive already? if (self.stat.mtime >= mtime and !self.created) { continue; } } if (!self.modifiers.use_real_timestamps_and_ids) { gid = 0; uid = 0; mtime = 0; // Even though it's not documented - in deterministic mode permissions are always set to: // https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/include/llvm/Object/ArchiveWriter.h#L27 // https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/lib/Object/ArchiveWriter.cpp#L105 mode = 644; } const timestamp = @intCast(u128, @divFloor(mtime, std.time.ns_per_s)); var archived_file = ArchivedFile{ .name = try allocator.dupe(u8, fs.path.basename(file_name)), .contents = Contents{ .bytes = try file.readToEndAlloc(allocator, std.math.maxInt(usize)), .length = size, .mode = mode, .timestamp = timestamp, .gid = gid, .uid = uid, }, }; const file_index = if (self.file_name_to_index.get(file_name)) |file_id| file_id else self.files.items.len; // Read symbols if (self.modifiers.build_symbol_table) { try self.addToSymbolTable(allocator, file_name, file_index, file, 0); } // A trie-based datastructure would be better for this! const getOrPutResult = try self.file_name_to_index.getOrPut(allocator, archived_file.name); if (getOrPutResult.found_existing) { const existing_index = getOrPutResult.value_ptr.*; self.files.items[existing_index] = archived_file; } else { getOrPutResult.value_ptr.* = self.files.items.len; try self.files.append(allocator, archived_file); } } } pub fn parse(self: *Archive, allocator: Allocator) (ParseError || IoError || CriticalError)!void { const tracy = trace(@src()); defer tracy.end(); const reader = self.file.reader(); { // Is the magic header found at the start of the archive? var magic: [magic_string.len]u8 = undefined; const bytes_read = try handleFileIoError(.reading, self.name, reader.read(&magic)); if (bytes_read == 0) { // Archive is empty and that is ok! return; } if (bytes_read < magic_string.len) { return ParseError.NotArchive; } const is_thin_archive = mem.eql(u8, &magic, magic_thin); if (is_thin_archive) self.inferred_archive_type = .gnuthin; if (!(mem.eql(u8, &magic, magic_string) or is_thin_archive)) { return ParseError.NotArchive; } } var gnu_symbol_table_contents: []u8 = undefined; var string_table_contents: []u8 = undefined; var has_gnu_symbol_table = false; { // https://www.freebsd.org/cgi/man.cgi?query=ar&sektion=5 // Process string/symbol tables and/or try to infer archive type! var starting_seek_pos = magic_string.len; while (true) { var first_line_buffer: [gnu_first_line_buffer_length]u8 = undefined; const has_line_to_process = result: { const chars_read = try handleFileIoError(.reading, self.name, reader.read(&first_line_buffer)); if (chars_read < first_line_buffer.len) { break :result false; } break :result true; }; if (!has_line_to_process) { try handleFileIoError(.seeking, self.name, reader.context.seekTo(starting_seek_pos)); break; } if (mem.eql(u8, first_line_buffer[0..2], "//"[0..2])) { switch (self.inferred_archive_type) { .ambiguous => self.inferred_archive_type = .gnu, .gnu, .gnuthin, .gnu64 => {}, else => { return ParseError.MalformedArchive; }, } const string_table_num_bytes_string = first_line_buffer[48..58]; const string_table_num_bytes = try fmt.parseInt(u32, mem.trim(u8, string_table_num_bytes_string, " "), 10); string_table_contents = try allocator.alloc(u8, string_table_num_bytes); try handleFileIoError(.reading, self.name, reader.readNoEof(string_table_contents)); break; } else if (!has_gnu_symbol_table and first_line_buffer[0] == '/') { has_gnu_symbol_table = true; switch (self.inferred_archive_type) { .ambiguous => self.inferred_archive_type = .gnu, .gnu, .gnuthin, .gnu64 => {}, else => { return ParseError.MalformedArchive; }, } const symbol_table_num_bytes_string = first_line_buffer[48..58]; const symbol_table_num_bytes = try fmt.parseInt(u32, mem.trim(u8, symbol_table_num_bytes_string, " "), 10); const num_symbols = try handleFileIoError(.reading, self.name, reader.readInt(u32, .Big)); var num_bytes_remaining = symbol_table_num_bytes - @sizeOf(u32); const number_array = try allocator.alloc(u32, num_symbols); for (number_array) |_, number_index| { number_array[number_index] = try handleFileIoError(.reading, self.name, reader.readInt(u32, .Big)); } defer allocator.free(number_array); num_bytes_remaining = num_bytes_remaining - (@sizeOf(u32) * num_symbols); gnu_symbol_table_contents = try allocator.alloc(u8, num_bytes_remaining); const contents_read = try handleFileIoError(.reading, self.name, reader.read(gnu_symbol_table_contents)); if (contents_read < gnu_symbol_table_contents.len) { return ParseError.MalformedArchive; } var current_symbol_string = gnu_symbol_table_contents; var current_byte: u32 = 0; while (current_byte < gnu_symbol_table_contents.len) { var symbol_length: u32 = 0; var skip_length: u32 = 0; var found_zero = false; for (current_symbol_string) |byte| { if (found_zero and byte != 0) { break; } current_byte = current_byte + 1; if (byte == 0) { found_zero = true; } skip_length = skip_length + 1; if (!found_zero) { symbol_length = symbol_length + 1; } } if (!self.modifiers.build_symbol_table) { const symbol = Symbol{ .name = current_symbol_string[0..symbol_length], // Note - we don't set the final file-index here, // we recalculate and override that later in parsing // when we know what they are! .file_index = number_array[self.symbols.items.len], }; try self.symbols.append(allocator, symbol); } current_symbol_string = current_symbol_string[skip_length..]; } starting_seek_pos = starting_seek_pos + first_line_buffer.len + symbol_table_num_bytes; } else { try handleFileIoError(.seeking, self.name, reader.context.seekTo(starting_seek_pos)); break; } } } var is_first = true; var file_offset_to_index: std.AutoArrayHashMapUnmanaged(u64, u64) = .{}; defer file_offset_to_index.clearAndFree(allocator); while (true) { const file_offset = file_offset_result: { var current_file_offset = try handleFileIoError(.accessing, self.name, reader.context.getPos()); // Archived files must start on even byte boundaries! // https://www.unix.com/man-page/opensolaris/3head/ar.h/ if (@mod(current_file_offset, 2) == 1) { try handleFileIoError(.accessing, self.name, reader.skipBytes(1, .{})); current_file_offset = current_file_offset + 1; } break :file_offset_result current_file_offset; }; const archive_header = reader.readStruct(Header) catch |err| switch (err) { error.EndOfStream => break, else => { printFileIoError(.reading, self.name, err); return err; }, }; // the lifetime of the archive headers will matched that of the parsed files (for now) // so we can take a reference to the strings stored there directly! var trimmed_archive_name = mem.trim(u8, &archive_header.ar_name, " "); // Check against gnu naming properties const ends_with_gnu_slash = (trimmed_archive_name[trimmed_archive_name.len - 1] == '/'); var gnu_offset_value: u32 = 0; const starts_with_gnu_offset = trimmed_archive_name[0] == '/'; if (starts_with_gnu_offset) { gnu_offset_value = try fmt.parseInt(u32, trimmed_archive_name[1..trimmed_archive_name.len], 10); } const must_be_gnu = ends_with_gnu_slash or starts_with_gnu_offset or has_gnu_symbol_table; // TODO: if modifiers.use_real_timestamps_and_ids is disabled, do we ignore this from existing archive? // Check against llvm ar const timestamp = try fmt.parseInt(u128, mem.trim(u8, &archive_header.ar_date, " "), 10); const uid = try fmt.parseInt(u32, mem.trim(u8, &archive_header.ar_uid, " "), 10); const gid = try fmt.parseInt(u32, mem.trim(u8, &archive_header.ar_gid, " "), 10); // Check against bsd naming properties const starts_with_bsd_name_length = (trimmed_archive_name.len >= 2) and mem.eql(u8, trimmed_archive_name[0..2], bsd_name_length_signifier[0..2]); const could_be_bsd = starts_with_bsd_name_length; // TODO: Have a proper mechanism for erroring on the wrong types of archive. switch (self.inferred_archive_type) { .ambiguous => { if (must_be_gnu) { self.inferred_archive_type = .gnu; } else if (could_be_bsd) { self.inferred_archive_type = .bsd; } else { return error.TODO; } }, .gnu, .gnuthin, .gnu64 => { if (!must_be_gnu) { return ParseError.MalformedArchive; } }, .bsd, .darwin, .darwin64 => { if (must_be_gnu) { return ParseError.MalformedArchive; } }, else => { if (must_be_gnu) { return error.TODO; } return error.TODO; }, } if (ends_with_gnu_slash) { // slice-off the slash trimmed_archive_name = trimmed_archive_name[0 .. trimmed_archive_name.len - 1]; } if (starts_with_gnu_offset) { const name_offset_in_string_table = try fmt.parseInt(u32, mem.trim(u8, trimmed_archive_name[1..trimmed_archive_name.len], " "), 10); // Navigate to the start of the string in the string table const string_start = string_table_contents[name_offset_in_string_table..string_table_contents.len]; // Find the end of the string (which is always a newline) const end_string_index = mem.indexOf(u8, string_start, "\n"); if (end_string_index == null) { return ParseError.MalformedArchive; } const string_full = string_start[0..end_string_index.?]; // String must have a forward slash before the newline, so check that // is there and remove it as well! if (string_full[string_full.len - 1] != '/') { return ParseError.MalformedArchive; } // Referencing the slice directly is fine as same bumb allocator is // used as for the rest of the datastructure! trimmed_archive_name = string_full[0 .. string_full.len - 1]; } var seek_forward_amount = try fmt.parseInt(u32, mem.trim(u8, &archive_header.ar_size, " "), 10); // Make sure that these allocations get properly disposed of later! if (starts_with_bsd_name_length) { trimmed_archive_name = trimmed_archive_name[bsd_name_length_signifier.len..trimmed_archive_name.len]; const archive_name_length = try fmt.parseInt(u32, trimmed_archive_name, 10); // TODO: go through int casts & don't assume that they will just work, add defensive error checking // for them. (an internal checked cast or similar). if (is_first) { // TODO: make sure this does a check on self.inferred_archive_type! // This could be the symbol table! So parse that here! const current_seek_pos = try handleFileIoError(.accessing, self.name, reader.context.getPos()); var symbol_magic_check_buffer: [bsd_symdef_longest_magic]u8 = undefined; // TODO: handle not reading enough characters! const chars_read = try reader.read(&symbol_magic_check_buffer); var sorted = false; const magic_match = magic_match_result: { if (chars_read >= bsd_symdef_magic.len and mem.eql(u8, bsd_symdef_magic, symbol_magic_check_buffer[0..bsd_symdef_magic.len])) { var magic_len = bsd_symdef_magic.len; if (chars_read >= bsd_symdef_64_magic.len and mem.eql(u8, bsd_symdef_64_magic[bsd_symdef_magic.len..], symbol_magic_check_buffer[bsd_symdef_magic.len..])) { magic_len = bsd_symdef_64_magic.len; } else if (chars_read >= bsd_symdef_sorted_magic.len and mem.eql(u8, bsd_symdef_sorted_magic[bsd_symdef_magic.len..], symbol_magic_check_buffer[bsd_symdef_magic.len..])) { magic_len = bsd_symdef_sorted_magic.len; sorted = true; } if (chars_read - magic_len > 0) { try reader.context.seekBy(@intCast(i64, magic_len) - @intCast(i64, chars_read)); } seek_forward_amount = seek_forward_amount - @intCast(u32, magic_len); break :magic_match_result true; } break :magic_match_result false; }; if (magic_match) { // TODO: make this target arch endianess const endianess = .Little; { const current_pos = try handleFileIoError(.accessing, self.name, reader.context.getPos()); const remainder = @intCast(u32, (self.inferred_archive_type.getAlignment() - current_pos % self.inferred_archive_type.getAlignment()) % self.inferred_archive_type.getAlignment()); seek_forward_amount = seek_forward_amount - remainder; try handleFileIoError(.accessing, self.name, reader.context.seekBy(remainder)); } // TODO: error if negative (because spec defines this as a long, so should never be that large?) const num_ranlib_bytes = try reader.readInt(IntType, endianess); seek_forward_amount = seek_forward_amount - @as(u32, @sizeOf(IntType)); // TODO: error if this doesn't divide properly? // const num_symbols = @divExact(num_ranlib_bytes, @sizeOf(Ranlib(IntType))); var ranlib_bytes = try allocator.alloc(u8, @intCast(u32, num_ranlib_bytes)); // TODO: error handling _ = try reader.read(ranlib_bytes); seek_forward_amount = seek_forward_amount - @intCast(u32, num_ranlib_bytes); var ranlibs = mem.bytesAsSlice(Ranlib(IntType), ranlib_bytes); const symbol_strings_length = try reader.readInt(u32, endianess); // TODO: We don't really need this information, but maybe it could come in handy // later? _ = symbol_strings_length; seek_forward_amount = seek_forward_amount - @as(u32, @sizeOf(IntType)); const symbol_string_bytes = try allocator.alloc(u8, seek_forward_amount); seek_forward_amount = 0; _ = try reader.read(symbol_string_bytes); if (!self.modifiers.build_symbol_table) { for (ranlibs) |ranlib| { const symbol_string = mem.sliceTo(symbol_string_bytes[@intCast(u64, ranlib.ran_strx)..], 0); const symbol = Symbol{ .name = symbol_string, // Note - we don't set the final file-index here, // we recalculate and override that later in parsing // when we know what they are! .file_index = @intCast(u64, ranlib.ran_off), }; try self.symbols.append(allocator, symbol); } // We have a symbol table! } try reader.context.seekBy(seek_forward_amount); continue; } try reader.context.seekTo(current_seek_pos); } const archive_name_buffer = try allocator.alloc(u8, archive_name_length); try handleFileIoError(.reading, self.name, reader.readNoEof(archive_name_buffer)); seek_forward_amount = seek_forward_amount - archive_name_length; // strip null characters from name - TODO find documentation on this // could not find documentation on this being needed, but some archivers // seems to insert these (for alignment reasons?) trimmed_archive_name = mem.trim(u8, archive_name_buffer, "\x00"); } else { const archive_name_buffer = try allocator.alloc(u8, trimmed_archive_name.len); mem.copy(u8, archive_name_buffer, trimmed_archive_name); trimmed_archive_name = archive_name_buffer; } const parsed_file = ArchivedFile{ .name = trimmed_archive_name, .contents = Contents{ .bytes = try allocator.alloc(u8, seek_forward_amount), .length = seek_forward_amount, .mode = try fmt.parseInt(u32, mem.trim(u8, &archive_header.ar_mode, " "), 10), .timestamp = timestamp, .uid = uid, .gid = gid, }, }; const offset_hack = try reader.context.getPos(); if (self.inferred_archive_type == .gnuthin) { var thin_file = try handleFileIoError(.opening, trimmed_archive_name, self.dir.openFile(trimmed_archive_name, .{})); defer thin_file.close(); try handleFileIoError(.reading, trimmed_archive_name, thin_file.reader().readNoEof(parsed_file.contents.bytes)); } else { try handleFileIoError(.reading, self.name, reader.readNoEof(parsed_file.contents.bytes)); } if (self.modifiers.build_symbol_table) { const post_offset_hack = try reader.context.getPos(); // TODO: Actually handle these errors! self.addToSymbolTable(allocator, trimmed_archive_name, self.files.items.len, reader.context, @intCast(u32, offset_hack)) catch { return error.TODO; }; try reader.context.seekTo(post_offset_hack); } try self.file_name_to_index.put(allocator, trimmed_archive_name, self.files.items.len); try file_offset_to_index.put(allocator, file_offset, self.files.items.len); try self.files.append(allocator, parsed_file); is_first = false; } if (is_first) { const current_position = try handleFileIoError(.accessing, self.name, reader.context.getPos()); if (current_position > magic_string.len) { return ParseError.MalformedArchive; } } if (!self.modifiers.build_symbol_table) { for (self.symbols.items) |*symbol| { if (file_offset_to_index.get(symbol.file_index)) |file_index| { symbol.file_index = file_index; } else { symbol.file_index = invalid_file_index; } } } // Set output archive type based on inference or current os if necessary if (self.output_archive_type == .ambiguous) { // Set output archive type of one we might just have parsed... self.output_archive_type = self.inferred_archive_type; } } pub const MRIParser = struct { script: []const u8, archive: ?Archive, file_name: ?[]const u8, const CommandType = enum { open, create, createthin, addmod, list, delete, extract, save, clear, end, }; const Self = @This(); pub fn init(allocator: Allocator, file: fs.File) !Self { const self = Self{ .script = try file.readToEndAlloc(allocator, std.math.maxInt(usize)), .archive = null, .file_name = null, }; return self; } // Returns the next token fn getToken(iter: *mem.SplitIterator(u8)) ?[]const u8 { while (iter.next()) |tok| { if (mem.startsWith(u8, tok, "*")) break; if (mem.startsWith(u8, tok, ";")) break; return tok; } return null; } // Returns a slice of tokens fn getTokenLine(allocator: Allocator, iter: *mem.SplitIterator(u8)) ![]const []const u8 { var list = std.ArrayList([]const u8).init(allocator); errdefer list.deinit(); while (getToken(iter)) |tok| { try list.append(tok); } return list.toOwnedSlice(); } pub fn execute(self: *Self, allocator: Allocator, stdout: fs.File.Writer, stderr: fs.File.Writer) !void { // Split the file into lines var parser = mem.split(u8, self.script, "\n"); while (parser.next()) |line| { // Split the line by spaces var line_parser = mem.split(u8, line, " "); if (getToken(&line_parser)) |tok| { var command_name = try allocator.dupe(u8, tok); defer allocator.free(command_name); _ = std.ascii.lowerString(command_name, tok); if (std.meta.stringToEnum(CommandType, command_name)) |command| { if (self.archive) |archive| { switch (command) { .addmod => { const file_names = try getTokenLine(allocator, &line_parser); defer allocator.free(file_names); try self.archive.?.insertFiles(allocator, file_names); }, .list => { // TODO: verbose output for (archive.files.items) |parsed_file| { try stdout.print("{s}\n", .{parsed_file.name}); } }, .delete => { const file_names = try getTokenLine(allocator, &line_parser); try self.archive.?.deleteFiles(file_names); }, .extract => { const file_names = try getTokenLine(allocator, &line_parser); try self.archive.?.extract(file_names); }, .save => { try self.archive.?.finalize(allocator); }, .clear => { // This is a bit of a hack but its reliable. // Instead of clearing out unsaved changes, we re-open the current file, which overwrites the changes. const file = try handleFileIoError(.opening, self.file_name, self.dir.openFile(self.file_name.?, .{ .mode = .read_write })); self.archive = Archive.create(file, self.file_name.?); try self.archive.?.parse(allocator, stderr); }, .end => return, else => { try stderr.print( "Archive `{s}` is currently open.\nThe command `{s}` can only be executed when no current archive is active.\n", .{ self.file_name.?, command_name }, ); return error.ArchiveAlreadyOpen; }, } } else { switch (command) { .open => { const file_name = getToken(&line_parser).?; const file = try handleFileIoError(.opening, file_name, self.dir.openFile(file_name, .{ .mode = .read_write })); self.archive = Archive.create(file, file_name); self.file_name = file_name; try self.archive.?.parse(allocator, stderr); }, .create, .createthin => { // TODO: Thin archives creation const file_name = getToken(&line_parser).?; const file = try self.dir.createFile(file_name, .{ .read = true }); self.archive = Archive.create(file, file_name); self.file_name = file_name; try self.archive.?.parse(allocator, stderr); }, .end => return, else => { try stderr.print("No currently active archive found.\nThe command `{s}` can only be executed when there is an opened archive.\n", .{command_name}); return error.NoCurrentArchive; }, } } } } } } };
src/archive/Archive.zig
const std = @import("std"); const builtin = @import("builtin"); const clap = @import("clap"); const http = @import("http"); const net = @import("net"); const ssl = @import("ssl"); const Uri = @import("uri").Uri; const Manifest = @import("manifest.zig"); const Import = @import("import.zig").Import; const os = std.os; const debug = std.debug; const fs = std.fs; const mem = std.mem; const json = std.json; const fmt = std.fmt; const Allocator = mem.Allocator; const ArrayList = std.ArrayList; const OutStream = std.fs.File.OutStream; const default_remote = "https://zpm.random-projects.net/api"; const imports_zzz = "imports.zzz"; const ziglibs_pem = @embedFile("ziglibs.pem"); const DependencyGraph = struct { allocator: *Allocator, cache: []const u8, queue_start: usize, nodes: std.ArrayList(Node), manifests: ArrayList(Manifest), const Self = @This(); /// Create DependencyGraph given a root path fn init(allocator: *Allocator, path: []const u8, cache: []const u8) !DependencyGraph { var ret = DependencyGraph{ .allocator = allocator, .cache = cache, .queue_start = 0, .nodes = ArrayList(Node).init(allocator), .manifests = ArrayList(Manifest).init(allocator), }; // TODO: get cwd of process try ret.nodes.append(try Node.init(allocator, "", 0)); return ret; } fn deinit(self: *Self) void { self.nodes.deinit(); for (self.manifests.items) |manifest| { manifest.deinit(); } } fn process(self: *Self) !void { while (self.queue_start < self.nodes.items.len) : (self.queue_start += 1) { var front = &self.nodes.items[self.queue_start]; const import_path = if (front.base_path.len == 0) imports_zzz else try std.fs.path.join(self.allocator, &[_][]const u8{ front.base_path, imports_zzz, }); defer if (front.base_path.len != 0) self.allocator.free(import_path); const file = std.fs.cwd().openFile(import_path, .{ .read = true }) catch |err| { if (err == error.FileNotFound) continue else return err; }; try self.manifests.append(try Manifest.init(self.allocator, file)); var manifest = &self.manifests.items[self.manifests.items.len - 1]; for (manifest.*.deps.items) |dep| { const path = try dep.path(self.allocator, self.cache); defer self.allocator.free(path); for (self.nodes.items) |*node| { if (mem.eql(u8, path, node.base_path)) { try front.connect_dependency(node, dep.name, dep.root); break; } } else { try dep.fetch(self.allocator, self.cache); try self.nodes.append(try Node.init(self.allocator, path, front.depth + 1)); try front.connect_dependency( &self.nodes.items[self.nodes.items.len - 1], dep.name, dep.root, ); } try self.validate(); } } } /// Naive check for circular dependencies fn validate(self: *Self) !void { for (self.nodes.items) |*node| { for (node.dependencies.items) |dep| { if (dep.node.depth <= node.depth) { return error.CyclicalDependency; } } for (node.dependents.items) |dep| { if (dep.depth >= node.depth) { return error.CyclicalDependency; } } } } const DependencyEdge = struct { node: *Node, alias: []const u8, root: []const u8, }; const DependentEdge = struct { node: *Node, }; const Node = struct { allocator: *Allocator, dependencies: ArrayList(DependencyEdge), dependents: ArrayList(*Node), base_path: []const u8, depth: u32, fn init(allocator: *Allocator, base_path: []const u8, depth: u32) !Node { return Node{ .allocator = allocator, .dependencies = ArrayList(DependencyEdge).init(allocator), .dependents = ArrayList(*Node).init(allocator), .base_path = try allocator.dupe(u8, base_path), .depth = depth, }; } fn deinit(self: *Node) void { self.allocator(base_path); self.dependents.deinit(); self.dependencies.deinit(); } fn connect_dependency(self: *Node, dep: *Node, alias: []const u8, root: []const u8) !void { if (self == dep) return error.CircularDependency; if (dep.depth <= self.depth) dep.depth = self.depth + 1; try self.dependencies.append(DependencyEdge{ .node = dep, .alias = alias, .root = root, }); try dep.dependents.append(self); } }; }; fn indent(stream: OutStream, n: usize) !void { try stream.writeByteNTimes(' ', n * 4); } fn recusivePrint( allocator: *Allocator, stream: fs.File.OutStream, edge: *DependencyGraph.DependencyEdge, depth: usize, ) anyerror!void { const root_file = try std.mem.replaceOwned(u8, allocator, edge.root, "/", &[_]u8{fs.path.sep}); defer allocator.free(root_file); var path = try fs.path.join(allocator, &[_][]const u8{ edge.node.base_path, root_file, }); defer allocator.free(path); if (fs.path.sep == '\\') { const tmp = try std.mem.replaceOwned(u8, allocator, path, "\\", "\\\\"); allocator.free(path); path = tmp; } try indent(stream, depth); if (depth == 1) { try stream.print(".{} = .{{\n", .{edge.alias}); } else { try stream.print(".{{\n", .{}); } try indent(stream, depth + 1); try stream.print(".name = \"{}\",\n", .{edge.alias}); try indent(stream, depth + 1); try stream.print(".path = \"{}\",\n", .{path}); if (edge.node.dependencies.items.len > 0) { try indent(stream, depth + 1); try stream.print(".dependencies = &[_]Pkg{{\n", .{}); for (edge.node.dependencies.items) |*dep| { try recusivePrint(allocator, stream, dep, depth + 2); } try indent(stream, depth + 1); try stream.print("}},\n", .{}); } try indent(stream, depth); try stream.print("}},\n", .{}); } pub fn fetch(cache_path: ?[]const u8) !void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = &arena.allocator; fs.cwd().access(imports_zzz, .{ .read = true, .write = true }) catch |err| { if (err == error.FileNotFound) { _ = try std.io.getStdErr().writer().write("imports.zzz does not exist\n"); } return err; }; var dep_graph = try DependencyGraph.init(allocator, ".", "zig-deps"); try dep_graph.process(); const gen_file = try std.fs.cwd().createFile("deps.zig", fs.File.CreateFlags{ .truncate = true, }); errdefer std.fs.cwd().deleteFile("deps.zig") catch {}; defer gen_file.close(); const file_stream = gen_file.outStream(); try file_stream.writeAll( \\const Pkg = @import("std").build.Pkg; \\pub const pkgs = .{ \\ ); for (dep_graph.nodes.items[0].dependencies.items) |*dep| { try recusivePrint(allocator, file_stream, dep, 1); } try file_stream.writeAll("};\n"); } const Protocol = enum { http, https, pub fn to_port(self: Protocol) u16 { return switch (self) { .http => 80, .https => 443, }; } }; fn httpRequest( allocator: *Allocator, hostname: [:0]const u8, port: u16, params: []const u8, ) !std.ArrayList(u8) { var socket = try net.connectToHost(allocator, hostname, port, .tcp); defer socket.close(); var buf: [mem.page_size]u8 = undefined; var http_client = http.base.client.create( &buf, socket.reader(), socket.writer(), ); try http_client.writeStatusLine("GET", params); try http_client.writeHeaderValue("Accept", "application/json"); try http_client.writeHeaderValue("Host", hostname); try http_client.writeHeaderValue("Agent", "zkg"); try http_client.finishHeaders(); return readHttpBody(allocator, &http_client); } fn httpsRequest( allocator: *Allocator, hostname: [:0]const u8, port: u16, params: []const u8, ) !std.ArrayList(u8) { var trust_anchor = ssl.TrustAnchorCollection.init(allocator); defer trust_anchor.deinit(); switch (builtin.os.tag) { .linux => pem: { const file = std.fs.openFileAbsolute("/etc/ssl/cert.pem", .{ .read = true }) catch |err| { if (err == error.FileNotFound) { try trust_anchor.appendFromPEM(ziglibs_pem); break :pem; } else return err; }; defer file.close(); const certs = try file.readToEndAlloc(allocator, 500000); defer allocator.free(certs); try trust_anchor.appendFromPEM(certs); }, else => { try trust_anchor.appendFromPEM(ziglibs_pem); }, } var x509 = ssl.x509.Minimal.init(trust_anchor); var ssl_client = ssl.Client.init(x509.getEngine()); ssl_client.relocate(); try ssl_client.reset(hostname, false); var socket = try net.connectToHost(allocator, hostname, port, .tcp); defer socket.close(); var socket_reader = socket.reader(); var socket_writer = socket.writer(); var ssl_socket = ssl.initStream( ssl_client.getEngine(), &socket_reader, &socket_writer, ); defer ssl_socket.close() catch {}; var buf: [mem.page_size]u8 = undefined; var http_client = http.base.client.create( &buf, ssl_socket.inStream(), ssl_socket.outStream(), ); try http_client.writeStatusLine("GET", params); try http_client.writeHeaderValue("Accept", "application/json"); try http_client.writeHeaderValue("Host", hostname); try http_client.writeHeaderValue("Agent", "zkg"); try http_client.finishHeaders(); try ssl_socket.flush(); return readHttpBody(allocator, &http_client); } fn readHttpBody(allocator: *mem.Allocator, client: anytype) !std.ArrayList(u8) { var body = std.ArrayList(u8).init(allocator); errdefer body.deinit(); while (try client.next()) |event| { switch (event) { .status => |status| { if (status.code != 200) { try std.io.getStdErr().writer().print("got HTTP {} return code\n", .{status.code}); return error.BadStatusCode; } }, .head_done => break, .header, .end, .skip => {}, .payload => unreachable, } } try client.reader().readAllArrayList(&body, 4 * 1024 * 1024); return body; } pub const SearchParams = union(enum) { all: void, name: []const u8, tag: []const u8, author: []const u8, }; const Params = union(enum) { packages: SearchParams, tags: void, fn append_param(buf: []u8, key: []const u8, value: []const u8) ![]u8 { return try fmt.bufPrint(buf, "?{}={}", .{ key, value }); } fn print(self: Params, buf: []u8, uri: Uri) ![]const u8 { var n = (try fmt.bufPrint(buf, "{}", .{uri.path})).len; if (n == 0 or buf[n - 1] != '/') { n += (try fmt.bufPrint(buf[n..], "/", .{})).len; } switch (self) { .packages => |search_params| { n += (try fmt.bufPrint(buf[n..], "packages", .{})).len; switch (search_params) { .name => |name| { n += (try append_param(buf[n..], "name", name)).len; }, .tag => |tag| { n += (try append_param(buf[n..], "tags", tag)).len; }, .author => |author| { n += (try append_param(buf[n..], "author", author)).len; }, .all => {}, } }, .tags => { n += (try fmt.bufPrint(buf[n..], "tags", .{})).len; }, } return buf[0..n]; } }; fn query( allocator: *mem.Allocator, remote: []const u8, params: Params, ) !std.ArrayList(u8) { const uri = try Uri.parse(remote, false); const protocol: Protocol = if (mem.eql(u8, uri.scheme, "http")) .http else if (mem.eql(u8, uri.scheme, "https")) .https else if (mem.eql(u8, uri.scheme, "")) return error.MissingProtocol else return error.UnsupportedProtocol; const port: u16 = if (uri.port) |port| port else protocol.to_port(); const hostnameZ = try mem.dupeZ(allocator, u8, uri.host.name); defer allocator.free(hostnameZ); const question: []const u8 = "?"; const none: []const u8 = ""; var params_buf: [2048]u8 = undefined; const params_str = try params.print(&params_buf, uri); return switch (protocol) { .http => httpRequest(allocator, hostnameZ, port, params_str), .https => httpsRequest(allocator, hostnameZ, port, params_str), }; } const Entry = struct { name: []const u8, git: []const u8, root_file: []const u8, author: []const u8, description: []const u8, pub fn from_json(obj: json.Value) !Entry { if (obj != .Object) return error.NotObject; return Entry{ .name = obj.Object.get("name").?.String, .git = obj.Object.get("git").?.String, .root_file = switch (obj.Object.get("root_file").?) { .String => |str| str, .Null => "/src/main.zig", else => unreachable, }, .author = obj.Object.get("author").?.String, .description = obj.Object.get("description").?.String, }; } }; const Column = struct { str: []const u8, width: usize, }; fn printColumns(writer: anytype, columns: []const Column, last: []const u8) !void { for (columns) |column| { try writer.print("{}", .{column.str}); if (column.str.len < column.width) { try writer.writeByteNTimes(' ', column.width - column.str.len); } } try writer.print("{}\n", .{last}); } pub fn search( allocator: *mem.Allocator, params: SearchParams, print_json: bool, remote_opt: ?[]const u8, ) !void { const response = try query(allocator, remote_opt orelse default_remote, .{ .packages = params, }); defer response.deinit(); if (print_json) { _ = try std.io.getStdOut().writer().write(response.items); return; } var parser = json.Parser.init(allocator, false); defer parser.deinit(); const tree = try parser.parse(response.items); const root = tree.root; var entries = std.ArrayList(Entry).init(allocator); defer entries.deinit(); if (root != .Array) { return error.ResponseType; } for (root.Array.items) |item| { try entries.append(try Entry.from_json(item)); } // column sizes var name_width: usize = 0; var author_width: usize = 0; for (entries.items) |item| { name_width = std.math.max(name_width, item.name.len); author_width = std.math.max(author_width, item.author.len); } const name_title = "NAME"; const author_title = "AUTHOR"; const desc_title = "DESCRIPTION"; name_width = std.math.max(name_width, name_title.len) + 2; author_width = std.math.max(author_width, author_title.len) + 2; try printColumns( std.io.getStdErr().writer(), &[_]Column{ .{ .str = name_title, .width = name_width }, .{ .str = author_title, .width = author_width }, }, desc_title, ); for (entries.items) |item| { try printColumns( std.io.getStdOut().writer(), &[_]Column{ .{ .str = item.name, .width = name_width }, .{ .str = item.author, .width = author_width }, }, item.description, ); } } const Tag = struct { name: []const u8, description: []const u8, fn from_json(obj: json.Value) !Tag { if (obj != .Object) return error.NotObject; return Tag{ .name = obj.Object.get("name").?.String, .description = obj.Object.get("description").?.String, }; } }; pub fn tags(allocator: *mem.Allocator, remote_opt: ?[]const u8) !void { const response = try query(allocator, remote_opt orelse default_remote, .{ .tags = {}, }); defer response.deinit(); var parser = json.Parser.init(allocator, false); defer parser.deinit(); const tree = try parser.parse(response.items); const root = tree.root; if (root != .Array) { return error.ResponseType; } var entries = std.ArrayList(Tag).init(allocator); defer entries.deinit(); for (root.Array.items) |item| { try entries.append(try Tag.from_json(item)); } const name_title = "TAG"; const desc_title = "DESCRIPTION"; var name_width: usize = 0; for (entries.items) |item| { name_width = std.math.max(name_width, item.name.len); } name_width = std.math.max(name_width, name_title.len) + 2; try printColumns( std.io.getStdErr().writer(), &[_]Column{.{ .str = name_title, .width = name_width }}, desc_title, ); for (entries.items) |item| { try printColumns( std.io.getStdOut().writer(), &[_]Column{.{ .str = item.name, .width = name_width }}, item.description, ); } } pub fn add( allocator: *mem.Allocator, name: []const u8, alias_opt: ?[]const u8, remote_opt: ?[]const u8, ) !void { const alias = alias_opt orelse name; const file = try std.fs.cwd().createFile(imports_zzz, .{ .read = true, .exclusive = false, .truncate = false, }); defer file.close(); var manifest = try Manifest.init(allocator, file); defer manifest.deinit(); const response = try query(allocator, remote_opt orelse default_remote, .{ .packages = .{ .name = name }, }); defer response.deinit(); var parser = json.Parser.init(allocator, false); defer parser.deinit(); const tree = try parser.parse(response.items); const root = tree.root; if (root != .Array) { return error.ResponseType; } if (root.Array.items.len == 0) { return error.NameMatch; } else if (root.Array.items.len != 1) { return error.Ambiguous; } const entry = try Entry.from_json(root.Array.items[0]); var import = Import{ .name = alias, .root = entry.root_file, .src = try Import.urlToSource(entry.git), }; const head = try import.getBranchHead(allocator); defer if (head) |h| allocator.free(h); if (head) |commit| { switch (import.src) { .github => { import.src.github.ref = commit; }, else => unreachable, } } try manifest.addImport(import); try manifest.commit(); } pub fn remove(allocator: *Allocator, name: []const u8) !void { const file = try std.fs.cwd().openFile(imports_zzz, .{ .read = true, .write = true }); defer file.close(); var manifest = try Manifest.init(allocator, file); defer manifest.deinit(); try manifest.removeImport(name); try manifest.commit(); }
src/commands.zig
pub const pallet1 = .{ 0xE0F8CF, 0x86C06C, 0x306850, 0x071821, }; pub const pallet12 = .{ 0x86C06C, 0xE0F8CF, 0x071821, 0x306850, }; pub const pallet13 = .{ 0x071821, 0x306850, 0x86C06C, 0xE0F8CF, }; pub const pallet14 = .{ 0x306850, 0x071821, 0xE0F8CF, 0x86C06C, }; pub const pallet2 = .{ 0xFFF6D3, 0xF9A875, 0xEB6B6F, 0x7C3F58, }; pub const pallet22 = .{ 0xF9A875, 0xFFF6D3, 0x7C3F58, 0xEB6B6F, }; pub const square = [8]u8{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, }; pub const select_q = [8]u8{ 0b11111111, 0b10000111, 0b10000111, 0b10011111, 0b10011111, 0b11111111, 0b11111111, 0b11111111, }; pub const select_thin_q = [8]u8{ 0b11111111, 0b10000111, 0b10111111, 0b10111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, }; pub const sqr_border_q = [8]u8{ 0b11111111, 0b10000000, 0b10000000, 0b10011111, 0b10011111, 0b10011111, 0b10011111, 0b10011111, }; pub const sqr_selected_q = [8]u8{ 0b01010101, 0b10101010, 0b01010101, 0b10101010, 0b01010101, 0b10101010, 0b01010101, 0b10101010, }; // Terrain // plains are 4 squares pub const woods = [32]u8{ 0b0000_0000, 0b0000_0000, 0b0000_0000, 0b0000_0000, 0b0000_1000, 0b0010_0000, 0b0001_0100, 0b0101_0000, 0b0001_0100, 0b0101_0000, 0b0001_0100, 0b1101_1000, 0b0010_0010, 0b1000_1000, 0b0010_1010, 0b1001_1100, 0b0100_0111, 0b0000_0100, 0b0101_0011, 0b0001_0110, 0b0011_1110, 0b0110_0010, 0b0000_0101, 0b0000_1001, 0b0000_0110, 0b1101_1011, 0b0000_0001, 0b1000_1100, 0b0000_0000, 0b0111_1000, 0b0000_0000, 0b0000_0000, }; pub const mountain = [32]u8{ 0b0000_0000, 0b0000_0000, 0b0000_0001, 0b1000_0000, 0b0000_0010, 0b0100_0000, 0b0000_0100, 0b0010_0000, 0b0000_0100, 0b0010_0000, 0b0000_0101, 0b0101_0000, 0b0000_1010, 0b1011_0000, 0b0000_1101, 0b0101_0000, 0b0000_1010, 0b1010_1000, 0b0001_0101, 0b0101_1000, 0b0001_1010, 0b1010_1000, 0b0001_0101, 0b0101_0100, 0b0010_1010, 0b1010_1100, 0b0011_0101, 0b0101_0100, 0b0110_1010, 0b1010_1010, 0b0111_1111, 0b1111_1110, }; // road ref // pub const road = [16]u8{ // 0b1111_1111, 0b1111_1111, // 0b1111_1110, 0b0111_1111, // 0b1111_1110, 0b0111_1111, // 0b1111_1110, 0b0111_1111, // 0b1111_1110, 0b0111_1111, // 0b1111_1110, 0b0111_1111, // 0b1111_1111, 0b1111_1111, // 0b1111_1111, 0b1111_1111, // }; pub const road_pc = [4]u8{ 0b1111_1110, 0b1110_1110, 0b1110_1110, 0b1111_1111, }; pub const road_pc_rot = [4]u8{ 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b1000_0011, }; // bridge // sea reefs beach pub const river = [32]u8 { 0b1111_1111, 0b1111_1111, 0b0000_0000, 0b0000_0000, 0b0110_0000, 0b0000_0000, 0b0000_0011, 0b0000_0000, 0b0000_0000, 0b0001_1000, 0b1100_0000, 0b0000_0000, 0b0000_0110, 0b0000_0000, 0b0000_0000, 0b1100_0000, 0b1000_0000, 0b0000_0001, 0b0000_1100, 0b0000_0000, 0b0000_0000, 0b0110_0000, 0b0000_0000, 0b0000_0011, 0b0001_1000, 0b0000_0000, 0b0000_0000, 0b1100_0000, 0b0000_0000, 0b0000_0000, 0b1111_1111, 0b1111_1111, }; // pipe pipe_seam pipe_broken pub const hq = [32]u8 { 0b0000_0001, 0b0000_0000, 0b0000_0001, 0b0000_0000, 0b0000_0001, 0b1000_0000, 0b0001_1111, 0b1111_1000, 0b0001_0000, 0b0000_1000, 0b0001_0101, 0b0100_1000, 0b0001_0010, 0b1010_1000, 0b0001_0000, 0b0000_1000, 0b0001_0101, 0b0100_1000, 0b0001_0010, 0b1010_1000, 0b0001_0000, 0b0000_1000, 0b0001_0001, 0b1000_1000, 0b0011_0001, 0b1000_1100, 0b0111_1111, 0b1111_1110, 0b0000_0000, 0b0000_0000, 0b0000_0000, 0b0000_0000, }; pub const city = [32]u8 { 0b0000_0000, 0b0000_0000, 0b0000_0000, 0b1111_1110, 0b0111_1111, 0b1111_1110, 0b0111_1111, 0b0000_0110, 0b0100_0001, 0b0000_0110, 0b0101_0101, 0b0101_0110, 0b0100_0001, 0b0000_0110, 0b0101_0101, 0b0101_0110, 0b0100_0001, 0b0000_0110, 0b0101_0101, 0b0101_0110, 0b0100_0001, 0b0000_0110, 0b0100_1001, 0b0010_0110, 0b0100_1001, 0b0010_0110, 0b0111_1111, 0b1111_1100, 0b0000_0000, 0b0000_0000, 0b0000_0000, 0b0000_0000, }; // factory // airport port miss_silo com_tower lab // Units pub const infantry = [16]u8{ 0b11_10_10_10, 0b10_10_10_11, 0b11_10_01_00, 0b01_00_10_11, 0b11_10_00_01, 0b00_01_10_10, 0b11_11_10_00, 0b01_10_10_00, 0b11_11_10_01, 0b00_10_00_10, 0b11_10_01_00, 0b01_00_10_11, 0b11_10_00_10, 0b10_01_10_11, 0b11_11_10_11, 0b11_10_11_11, }; pub const mech = [16]u8{ 0b11_10_10_10, 0b10_10_10_11, 0b10_10_01_00, 0b01_00_10_10, 0b00_00_00_01, 0b00_01_00_00, 0b00_00_10_00, 0b01_10_00_00, 0b10_10_10_01, 0b00_10_10_10, 0b11_10_01_00, 0b01_00_10_11, 0b11_10_00_10, 0b10_01_10_11, 0b11_11_10_11, 0b11_10_11_11, }; pub const apc = [16]u8{ 0b11_11_11_11, 0b11_11_11_11, 0b11_11_10_10, 0b10_10_10_10, 0b11_10_00_00, 0b00_00_00_10, 0b10_00_00_00, 0b00_00_00_10, 0b10_00_00_00, 0b00_00_00_10, 0b10_00_00_00, 0b00_00_00_10, 0b10_10_00_10, 0b10_00_10_10, 0b11_11_10_11, 0b11_10_11_11, };
src/graphics.zig
const std = @import("std"); const DListError = error { EmptyListHasNoNodes, }; pub fn DList(comptime T: type) type { return struct { pub const Node = struct { item: T, next: ?*DList(T).Node, prev: ?*DList(T).Node, }; allocator: *std.mem.Allocator, len: usize, first: ?*DList(T).Node, last: ?*DList(T).Node, pub fn init(allocator: *std.mem.Allocator) DList(T) { return DList(T){ .allocator = allocator, .len = 0, .first = null, .last = null, }; } pub fn push_first(self: *DList(T), item: T) !void { const node = try self.allocator.create(DList(T).Node); node.prev = null; node.next = self.first; node.item = item; //if first is null, list was empty and last needs set. if(self.first!=null) self.first.?.prev = node else self.last = node; self.first = node; self.len += 1; } pub fn push_last(self: *DList(T), item: T) !void { const node = try self.allocator.create(DList(T).Node); node.prev = self.last; node.next = null; node.item = item; //if last is null, list was empty and first needs set. if(self.last!=null) self.last.?.next = node else self.first = node; self.last = node; self.len += 1; } pub fn pop_first(self: *DList(T)) void { if(self.first!=null){ const node = self.first.?; self.first = node.next; //if first is now null, list is now empty and last needs set to null. if(self.first!=null) self.first.?.prev = null else self.last = null; self.allocator.destroy(node); self.len -= 1; } } pub fn pop_last(self: *DList(T)) void { if(self.last!=null){ const node = self.last.?; self.last = node.prev; //if last is now null, list is now empty and first needs set to null. if(self.last!=null) self.last.?.next = null else self.first = null; self.allocator.destroy(node); self.len -= 1; } } pub fn insert(self: *DList(T), link: *DList(T).Node, item: T) !*DList(T).Node { const node = try self.allocator.create(DList(T).Node); node.prev = link.prev; if(link.prev!=null) link.prev.?.next = node else{ if(self.first==null) self.last = node; self.first = node; } node.next = link; link.prev = node; node.item = item; self.len += 1; return node; } pub fn remove(self: *Dlist(T), link: *DList(T).Node) void { @panic("DList(T).remove() is not yet implemented.\n"); } pub fn deinit(self: DList(T)) void { var prev: *DList(T).Node = undefined; var node = self.first; while(node!=null){ prev = node.?; node = prev.next; self.allocator.destroy(prev); } } pub fn count(self: DList(T)) usize { return self.len; } pub fn firstNode(self: DList(T)) !*DList(T).Node { if(self.first==null) return DListError.EmptyListHasNoNodes; return self.first.?; } pub fn lastNode(self: DList(T)) !*DList(T).Node { if(self.last==null) return DListError.EmptyListHasNoNodes; return self.last.?; } }; }
dllist.zig
const ImageReader = zigimg.ImageReader; const ImageSeekStream = zigimg.ImageSeekStream; const PixelFormat = zigimg.PixelFormat; const assert = std.debug.assert; const color = zigimg.color; const errors = zigimg.errors; const std = @import("std"); const testing = std.testing; const netpbm = zigimg.netpbm; const zigimg = @import("zigimg"); const image = zigimg.image; usingnamespace @import("../helpers.zig"); test "Load ASCII PBM image" { const file = try testOpenFile(zigimg_test_allocator, "tests/fixtures/netpbm/pbm_ascii.pbm"); defer file.close(); var stream_source = std.io.StreamSource{ .file = file }; var pbmFile = netpbm.PBM{}; var pixelsOpt: ?color.ColorStorage = null; try pbmFile.read(zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixelsOpt); defer { if (pixelsOpt) |pixels| { pixels.deinit(zigimg_test_allocator); } } expectEq(pbmFile.header.width, 8); expectEq(pbmFile.header.height, 16); expectEq(pbmFile.pixel_format, PixelFormat.Grayscale1); testing.expect(pixelsOpt != null); if (pixelsOpt) |pixels| { testing.expect(pixels == .Grayscale1); expectEq(pixels.Grayscale1[0].value, 0); expectEq(pixels.Grayscale1[1].value, 1); expectEq(pixels.Grayscale1[15 * 8 + 7].value, 1); } } test "Load binary PBM image" { const file = try testOpenFile(zigimg_test_allocator, "tests/fixtures/netpbm/pbm_binary.pbm"); defer file.close(); var stream_source = std.io.StreamSource{ .file = file }; var pbmFile = netpbm.PBM{}; var pixelsOpt: ?color.ColorStorage = null; try pbmFile.read(zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixelsOpt); defer { if (pixelsOpt) |pixels| { pixels.deinit(zigimg_test_allocator); } } expectEq(pbmFile.header.width, 8); expectEq(pbmFile.header.height, 16); expectEq(pbmFile.pixel_format, PixelFormat.Grayscale1); testing.expect(pixelsOpt != null); if (pixelsOpt) |pixels| { testing.expect(pixels == .Grayscale1); expectEq(pixels.Grayscale1[0].value, 0); expectEq(pixels.Grayscale1[1].value, 1); expectEq(pixels.Grayscale1[15 * 8 + 7].value, 1); } } test "Load ASCII PGM 8-bit grayscale image" { const file = try testOpenFile(zigimg_test_allocator, "tests/fixtures/netpbm/pgm_ascii_grayscale8.pgm"); defer file.close(); var stream_source = std.io.StreamSource{ .file = file }; var pgmFile = netpbm.PGM{}; var pixelsOpt: ?color.ColorStorage = null; try pgmFile.read(zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixelsOpt); defer { if (pixelsOpt) |pixels| { pixels.deinit(zigimg_test_allocator); } } expectEq(pgmFile.header.width, 16); expectEq(pgmFile.header.height, 24); expectEq(pgmFile.pixel_format, PixelFormat.Grayscale8); testing.expect(pixelsOpt != null); if (pixelsOpt) |pixels| { testing.expect(pixels == .Grayscale8); expectEq(pixels.Grayscale8[0].value, 2); expectEq(pixels.Grayscale8[1].value, 5); expectEq(pixels.Grayscale8[383].value, 196); } } test "Load Binary PGM 8-bit grayscale image" { const file = try testOpenFile(zigimg_test_allocator, "tests/fixtures/netpbm/pgm_binary_grayscale8.pgm"); defer file.close(); var stream_source = std.io.StreamSource{ .file = file }; var pgmFile = netpbm.PGM{}; var pixelsOpt: ?color.ColorStorage = null; try pgmFile.read(zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixelsOpt); defer { if (pixelsOpt) |pixels| { pixels.deinit(zigimg_test_allocator); } } expectEq(pgmFile.header.width, 16); expectEq(pgmFile.header.height, 24); expectEq(pgmFile.pixel_format, PixelFormat.Grayscale8); testing.expect(pixelsOpt != null); if (pixelsOpt) |pixels| { testing.expect(pixels == .Grayscale8); expectEq(pixels.Grayscale8[0].value, 2); expectEq(pixels.Grayscale8[1].value, 5); expectEq(pixels.Grayscale8[383].value, 196); } } test "Load ASCII PGM 16-bit grayscale image" { const file = try testOpenFile(zigimg_test_allocator, "tests/fixtures/netpbm/pgm_ascii_grayscale16.pgm"); defer file.close(); var stream_source = std.io.StreamSource{ .file = file }; var pgmFile = netpbm.PGM{}; var pixelsOpt: ?color.ColorStorage = null; try pgmFile.read(zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixelsOpt); defer { if (pixelsOpt) |pixels| { pixels.deinit(zigimg_test_allocator); } } expectEq(pgmFile.header.width, 8); expectEq(pgmFile.header.height, 16); expectEq(pgmFile.pixel_format, PixelFormat.Grayscale8); testing.expect(pixelsOpt != null); if (pixelsOpt) |pixels| { testing.expect(pixels == .Grayscale8); expectEq(pixels.Grayscale8[0].value, 13); expectEq(pixels.Grayscale8[1].value, 16); expectEq(pixels.Grayscale8[127].value, 237); } } test "Load Binary PGM 16-bit grayscale image" { const file = try testOpenFile(zigimg_test_allocator, "tests/fixtures/netpbm/pgm_binary_grayscale16.pgm"); defer file.close(); var stream_source = std.io.StreamSource{ .file = file }; var pgmFile = netpbm.PGM{}; var pixelsOpt: ?color.ColorStorage = null; try pgmFile.read(zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixelsOpt); defer { if (pixelsOpt) |pixels| { pixels.deinit(zigimg_test_allocator); } } expectEq(pgmFile.header.width, 8); expectEq(pgmFile.header.height, 16); expectEq(pgmFile.pixel_format, PixelFormat.Grayscale8); testing.expect(pixelsOpt != null); if (pixelsOpt) |pixels| { testing.expect(pixels == .Grayscale8); expectEq(pixels.Grayscale8[0].value, 13); expectEq(pixels.Grayscale8[1].value, 16); expectEq(pixels.Grayscale8[127].value, 237); } } test "Load ASCII PPM image" { const file = try testOpenFile(zigimg_test_allocator, "tests/fixtures/netpbm/ppm_ascii_rgb24.ppm"); defer file.close(); var stream_source = std.io.StreamSource{ .file = file }; var ppmFile = netpbm.PPM{}; var pixelsOpt: ?color.ColorStorage = null; try ppmFile.read(zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixelsOpt); defer { if (pixelsOpt) |pixels| { pixels.deinit(zigimg_test_allocator); } } expectEq(ppmFile.header.width, 27); expectEq(ppmFile.header.height, 27); expectEq(ppmFile.pixel_format, PixelFormat.Rgb24); testing.expect(pixelsOpt != null); if (pixelsOpt) |pixels| { testing.expect(pixels == .Rgb24); expectEq(pixels.Rgb24[0].R, 0x34); expectEq(pixels.Rgb24[0].G, 0x53); expectEq(pixels.Rgb24[0].B, 0x9f); expectEq(pixels.Rgb24[1].R, 0x32); expectEq(pixels.Rgb24[1].G, 0x5b); expectEq(pixels.Rgb24[1].B, 0x96); expectEq(pixels.Rgb24[26].R, 0xa8); expectEq(pixels.Rgb24[26].G, 0x5a); expectEq(pixels.Rgb24[26].B, 0x78); expectEq(pixels.Rgb24[27].R, 0x2e); expectEq(pixels.Rgb24[27].G, 0x54); expectEq(pixels.Rgb24[27].B, 0x99); expectEq(pixels.Rgb24[26 * 27 + 26].R, 0x88); expectEq(pixels.Rgb24[26 * 27 + 26].G, 0xb7); expectEq(pixels.Rgb24[26 * 27 + 26].B, 0x55); } } test "Load binary PPM image" { const file = try testOpenFile(zigimg_test_allocator, "tests/fixtures/netpbm/ppm_binary_rgb24.ppm"); defer file.close(); var stream_source = std.io.StreamSource{ .file = file }; var ppmFile = netpbm.PPM{}; var pixelsOpt: ?color.ColorStorage = null; try ppmFile.read(zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixelsOpt); defer { if (pixelsOpt) |pixels| { pixels.deinit(zigimg_test_allocator); } } expectEq(ppmFile.header.width, 27); expectEq(ppmFile.header.height, 27); expectEq(ppmFile.pixel_format, PixelFormat.Rgb24); testing.expect(pixelsOpt != null); if (pixelsOpt) |pixels| { testing.expect(pixels == .Rgb24); expectEq(pixels.Rgb24[0].R, 0x34); expectEq(pixels.Rgb24[0].G, 0x53); expectEq(pixels.Rgb24[0].B, 0x9f); expectEq(pixels.Rgb24[1].R, 0x32); expectEq(pixels.Rgb24[1].G, 0x5b); expectEq(pixels.Rgb24[1].B, 0x96); expectEq(pixels.Rgb24[26].R, 0xa8); expectEq(pixels.Rgb24[26].G, 0x5a); expectEq(pixels.Rgb24[26].B, 0x78); expectEq(pixels.Rgb24[27].R, 0x2e); expectEq(pixels.Rgb24[27].G, 0x54); expectEq(pixels.Rgb24[27].B, 0x99); expectEq(pixels.Rgb24[26 * 27 + 26].R, 0x88); expectEq(pixels.Rgb24[26 * 27 + 26].G, 0xb7); expectEq(pixels.Rgb24[26 * 27 + 26].B, 0x55); } } test "Write bitmap(Grayscale1) ASCII PBM file" { const grayscales = [_]u1{ 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, }; const image_file_name = "zigimg_pbm_ascii_test.pbm"; const width = grayscales.len; const height = 1; const source_image = try image.Image.create(zigimg_test_allocator, width, height, PixelFormat.Grayscale1); defer source_image.deinit(); if (source_image.pixels) |source| { for (grayscales) |value, index| { source.Grayscale1[index].value = value; } } try source_image.writeToFilePath(image_file_name, image.ImageFormat.Pbm, image.ImageEncoderOptions{ .pbm = .{ .binary = false }, }); defer { std.fs.cwd().deleteFile(image_file_name) catch unreachable; } const read_image = try image.Image.fromFilePath(zigimg_test_allocator, image_file_name); defer read_image.deinit(); expectEq(read_image.width, width); expectEq(read_image.height, height); testing.expect(read_image.pixels != null); if (read_image.pixels) |read_pixels| { testing.expect(read_pixels == .Grayscale1); for (grayscales) |grayscale_value, index| { expectEq(read_pixels.Grayscale1[index].value, grayscale_value); } } } test "Write bitmap(Grayscale1) binary PBM file" { const grayscales = [_]u1{ 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, }; const image_file_name = "zigimg_pbm_binary_test.pbm"; const width = grayscales.len; const height = 1; const source_image = try image.Image.create(zigimg_test_allocator, width, height, PixelFormat.Grayscale1); defer source_image.deinit(); if (source_image.pixels) |source| { for (grayscales) |value, index| { source.Grayscale1[index].value = value; } } try source_image.writeToFilePath(image_file_name, image.ImageFormat.Pbm, image.ImageEncoderOptions{ .pbm = .{ .binary = true }, }); defer { std.fs.cwd().deleteFile(image_file_name) catch unreachable; } const read_image = try image.Image.fromFilePath(zigimg_test_allocator, image_file_name); defer read_image.deinit(); expectEq(read_image.width, width); expectEq(read_image.height, height); testing.expect(read_image.pixels != null); if (read_image.pixels) |read_pixels| { testing.expect(read_pixels == .Grayscale1); for (grayscales) |grayscale_value, index| { expectEq(read_pixels.Grayscale1[index].value, grayscale_value); } } } test "Write grayscale8 ASCII PGM file" { const grayscales = [_]u8{ 0, 29, 56, 85, 113, 142, 170, 199, 227, 255, 227, 199, 170, 142, 113, 85, 56, 29, 0, }; const image_file_name = "zigimg_pgm_ascii_test.pgm"; const width = grayscales.len; const height = 1; const source_image = try image.Image.create(zigimg_test_allocator, width, height, PixelFormat.Grayscale8); defer source_image.deinit(); if (source_image.pixels) |source| { for (grayscales) |value, index| { source.Grayscale8[index].value = value; } } try source_image.writeToFilePath(image_file_name, image.ImageFormat.Pgm, image.ImageEncoderOptions{ .pgm = .{ .binary = false }, }); defer { std.fs.cwd().deleteFile(image_file_name) catch unreachable; } const read_image = try image.Image.fromFilePath(zigimg_test_allocator, image_file_name); defer read_image.deinit(); expectEq(read_image.width, width); expectEq(read_image.height, height); testing.expect(read_image.pixels != null); if (read_image.pixels) |read_pixels| { testing.expect(read_pixels == .Grayscale8); for (grayscales) |grayscale_value, index| { expectEq(read_pixels.Grayscale8[index].value, grayscale_value); } } } test "Write grayscale8 binary PGM file" { const grayscales = [_]u8{ 0, 29, 56, 85, 113, 142, 170, 199, 227, 255, 227, 199, 170, 142, 113, 85, 56, 29, 0, }; const image_file_name = "zigimg_pgm_binary_test.pgm"; const width = grayscales.len; const height = 1; const source_image = try image.Image.create(zigimg_test_allocator, width, height, PixelFormat.Grayscale8); defer source_image.deinit(); if (source_image.pixels) |source| { for (grayscales) |value, index| { source.Grayscale8[index].value = value; } } try source_image.writeToFilePath(image_file_name, image.ImageFormat.Pgm, image.ImageEncoderOptions{ .pgm = .{ .binary = true }, }); defer { std.fs.cwd().deleteFile(image_file_name) catch unreachable; } const read_image = try image.Image.fromFilePath(zigimg_test_allocator, image_file_name); defer read_image.deinit(); expectEq(read_image.width, width); expectEq(read_image.height, height); testing.expect(read_image.pixels != null); if (read_image.pixels) |read_pixels| { testing.expect(read_pixels == .Grayscale8); for (grayscales) |grayscale_value, index| { expectEq(read_pixels.Grayscale8[index].value, grayscale_value); } } } test "Writing Rgb24 ASCII PPM format" { const expected_colors = [_]u32{ 0xff0000, 0x00ff00, 0x0000ff, 0x000000, 0xffffff, 0x00ffff, 0xff00ff, 0xffff00 }; const image_file_name = "zigimg_ppm_rgb24_ascii_test.ppm"; const width = expected_colors.len; const height = 1; const source_image = try image.Image.create(zigimg_test_allocator, width, height, PixelFormat.Rgb24); defer source_image.deinit(); testing.expect(source_image.pixels != null); if (source_image.pixels) |pixels| { testing.expect(pixels == .Rgb24); testing.expect(pixels.Rgb24.len == width * height); // R, G, B pixels.Rgb24[0] = color.Rgb24.initRGB(255, 0, 0); pixels.Rgb24[1] = color.Rgb24.initRGB(0, 255, 0); pixels.Rgb24[2] = color.Rgb24.initRGB(0, 0, 255); // Black, white pixels.Rgb24[3] = color.Rgb24.initRGB(0, 0, 0); pixels.Rgb24[4] = color.Rgb24.initRGB(255, 255, 255); // Cyan, Magenta, Yellow pixels.Rgb24[5] = color.Rgb24.initRGB(0, 255, 255); pixels.Rgb24[6] = color.Rgb24.initRGB(255, 0, 255); pixels.Rgb24[7] = color.Rgb24.initRGB(255, 255, 0); } try source_image.writeToFilePath(image_file_name, image.ImageFormat.Ppm, image.ImageEncoderOptions{ .ppm = .{ .binary = false }, }); defer { std.fs.cwd().deleteFile(image_file_name) catch unreachable; } const read_image = try image.Image.fromFilePath(zigimg_test_allocator, image_file_name); defer read_image.deinit(); expectEq(read_image.width, width); expectEq(read_image.height, height); testing.expect(read_image.pixels != null); if (read_image.pixels) |read_image_pixels| { testing.expect(read_image_pixels == .Rgb24); for (expected_colors) |hex_color, index| { expectEq(read_image_pixels.Rgb24[index].toColor().toIntegerColor8(), color.IntegerColor8.fromHtmlHex(expected_colors[index])); } } } test "Writing Rgb24 binary PPM format" { const expected_colors = [_]u32{ 0xff0000, 0x00ff00, 0x0000ff, 0x000000, 0xffffff, 0x00ffff, 0xff00ff, 0xffff00 }; const image_file_name = "zigimg_ppm_rgb24_binary_test.ppm"; const width = expected_colors.len; const height = 1; const source_image = try image.Image.create(zigimg_test_allocator, width, height, PixelFormat.Rgb24); defer source_image.deinit(); testing.expect(source_image.pixels != null); if (source_image.pixels) |pixels| { testing.expect(pixels == .Rgb24); testing.expect(pixels.Rgb24.len == width * height); // R, G, B pixels.Rgb24[0] = color.Rgb24.initRGB(255, 0, 0); pixels.Rgb24[1] = color.Rgb24.initRGB(0, 255, 0); pixels.Rgb24[2] = color.Rgb24.initRGB(0, 0, 255); // Black, white pixels.Rgb24[3] = color.Rgb24.initRGB(0, 0, 0); pixels.Rgb24[4] = color.Rgb24.initRGB(255, 255, 255); // Cyan, Magenta, Yellow pixels.Rgb24[5] = color.Rgb24.initRGB(0, 255, 255); pixels.Rgb24[6] = color.Rgb24.initRGB(255, 0, 255); pixels.Rgb24[7] = color.Rgb24.initRGB(255, 255, 0); } try source_image.writeToFilePath(image_file_name, image.ImageFormat.Ppm, image.ImageEncoderOptions{ .ppm = .{ .binary = true }, }); defer { std.fs.cwd().deleteFile(image_file_name) catch unreachable; } const read_image = try image.Image.fromFilePath(zigimg_test_allocator, image_file_name); defer read_image.deinit(); expectEq(read_image.width, width); expectEq(read_image.height, height); testing.expect(read_image.pixels != null); if (read_image.pixels) |read_image_pixels| { testing.expect(read_image_pixels == .Rgb24); for (expected_colors) |hex_color, index| { expectEq(read_image_pixels.Rgb24[index].toColor().toIntegerColor8(), color.IntegerColor8.fromHtmlHex(expected_colors[index])); } } }
tests/formats/netpbm_test.zig
const std = @import("std"); const Self = @This(); // Minimum exponent that for a fast path case, or `-⌊(MANTISSA_EXPLICIT_BITS+1)/log2(5)⌋` min_exponent_fast_path: comptime_int, // Maximum exponent that for a fast path case, or `⌊(MANTISSA_EXPLICIT_BITS+1)/log2(5)⌋` max_exponent_fast_path: comptime_int, // Maximum exponent that can be represented for a disguised-fast path case. // This is `MAX_EXPONENT_FAST_PATH + ⌊(MANTISSA_EXPLICIT_BITS+1)/log2(10)⌋` max_exponent_fast_path_disguised: comptime_int, // Maximum mantissa for the fast-path (`1 << 53` for f64). max_mantissa_fast_path: comptime_int, // Smallest decimal exponent for a non-zero value. Including subnormals. smallest_power_of_ten: comptime_int, // Largest decimal exponent for a non-infinite value. largest_power_of_ten: comptime_int, // The number of bits in the significand, *excluding* the hidden bit. mantissa_explicit_bits: comptime_int, // Minimum exponent value `-(1 << (EXP_BITS - 1)) + 1`. minimum_exponent: comptime_int, // Round-to-even only happens for negative values of q // when q ≥ −4 in the 64-bit case and when q ≥ −17 in // the 32-bitcase. // // When q ≥ 0,we have that 5^q ≤ 2m+1. In the 64-bit case,we // have 5^q ≤ 2m+1 ≤ 2^54 or q ≤ 23. In the 32-bit case,we have // 5^q ≤ 2m+1 ≤ 2^25 or q ≤ 10. // // When q < 0, we have w ≥ (2m+1)×5^−q. We must have that w < 2^64 // so (2m+1)×5^−q < 2^64. We have that 2m+1 > 2^53 (64-bit case) // or 2m+1 > 2^24 (32-bit case). Hence,we must have 2^53×5^−q < 2^64 // (64-bit) and 2^24×5^−q < 2^64 (32-bit). Hence we have 5^−q < 2^11 // or q ≥ −4 (64-bit case) and 5^−q < 2^40 or q ≥ −17 (32-bitcase). // // Thus we have that we only need to round ties to even when // we have that q ∈ [−4,23](in the 64-bit case) or q∈[−17,10] // (in the 32-bit case). In both cases,the power of five(5^|q|) // fits in a 64-bit word. min_exponent_round_to_even: comptime_int, max_exponent_round_to_even: comptime_int, // Largest exponent value `(1 << EXP_BITS) - 1`. infinite_power: comptime_int, // Following should compute based on derived calculations where possible. pub fn from(comptime T: type) Self { return switch (T) { f16 => .{ // Fast-Path .min_exponent_fast_path = -4, .max_exponent_fast_path = 4, .max_exponent_fast_path_disguised = 7, .max_mantissa_fast_path = 2 << std.math.floatMantissaBits(T), // Slow + Eisel-Lemire .mantissa_explicit_bits = std.math.floatMantissaBits(T), .infinite_power = 0x1f, // Eisel-Lemire .smallest_power_of_ten = -26, // TODO: refine, fails one test .largest_power_of_ten = 4, .minimum_exponent = -15, // w >= (2m+1) * 5^-q and w < 2^64 // => 2m+1 > 2^11 // => 2^11*5^-q < 2^64 // => 5^-q < 2^53 // => q >= -23 .min_exponent_round_to_even = -22, .max_exponent_round_to_even = 5, }, f32 => .{ // Fast-Path .min_exponent_fast_path = -10, .max_exponent_fast_path = 10, .max_exponent_fast_path_disguised = 17, .max_mantissa_fast_path = 2 << std.math.floatMantissaBits(T), // Slow + Eisel-Lemire .mantissa_explicit_bits = std.math.floatMantissaBits(T), .infinite_power = 0xff, // Eisel-Lemire .smallest_power_of_ten = -65, .largest_power_of_ten = 38, .minimum_exponent = -127, .min_exponent_round_to_even = -17, .max_exponent_round_to_even = 10, }, f64 => .{ // Fast-Path .min_exponent_fast_path = -22, .max_exponent_fast_path = 22, .max_exponent_fast_path_disguised = 37, .max_mantissa_fast_path = 2 << std.math.floatMantissaBits(T), // Slow + Eisel-Lemire .mantissa_explicit_bits = std.math.floatMantissaBits(T), .infinite_power = 0x7ff, // Eisel-Lemire .smallest_power_of_ten = -342, .largest_power_of_ten = 308, .minimum_exponent = -1023, .min_exponent_round_to_even = -4, .max_exponent_round_to_even = 23, }, f128 => .{ // Fast-Path .min_exponent_fast_path = -48, .max_exponent_fast_path = 48, .max_exponent_fast_path_disguised = 82, .max_mantissa_fast_path = 2 << std.math.floatMantissaBits(T), // Slow + Eisel-Lemire .mantissa_explicit_bits = std.math.floatMantissaBits(T), .infinite_power = 0x7fff, // Eisel-Lemire. // NOTE: Not yet tested (no f128 eisel-lemire implementation) .smallest_power_of_ten = -4966, .largest_power_of_ten = 4932, .minimum_exponent = -16382, // 2^113 * 5^-q < 2^128 // 5^-q < 2^15 // => q >= -6 .min_exponent_round_to_even = -6, .max_exponent_round_to_even = 49, }, else => unreachable, }; }
lib/std/fmt/parse_float/FloatInfo.zig
const std = @import("std"); const benchmark = @import("benchmark"); const testing = std.testing; /// Holds a list of systems that can be executed sequentially or in parallel. /// Parallel execution requires async to be activated, either through /// - zig test --test-evented-io /// or by adding `pub const io_mode = .evented` at the top level of your crate. pub fn Dispatcher(comptime T: type) type { return struct { systems: T, /// Runs all systems sequentially using data from the provided world. /// References to data matching the type of the system arguments are /// automatically made when calling the system. /// Any error will abort the execution and return it. pub fn runSeq(this: *const @This(), world: anytype) !void { inline for (this.systems) |sys| { try callSystem(world, sys); } } //fn runPar(this: *@This(), world: anytype) !void { // // TODO system locking mechanism // inline for (this.systems) |sys| { // //try await callSystem(world, sys); // //try this.loop.runDetached(alloc, callSystemUnwrap, .{world, sys}); // } // // this.loop.yield(); //} }; } fn callSystemUnwrap(world: anytype, system: anytype) void { callSystem(world, system) orelse @panic("Call system panicked!"); } /// Calls a system using the provided world's data. /// Arguments of the system will be references to the world's fields during execution. /// /// World should be a pointer to the world. /// System should be a function. All arguments of this function should be pointers. /// /// Generics cannot be used. For this, create a wrapping generic struct that will create /// a concrete function. pub fn callSystem(world: anytype, system: anytype) !void { comptime const fn_info = @typeInfo(@TypeOf(system)); // check that the input is a function. if (fn_info != .Fn) { @compileError("System must be a function."); } // get the ptr types of all the system args. comptime var types: [fn_info.Fn.args.len]type = undefined; inline for (fn_info.Fn.args) |arg, i| { comptime const arg_type = arg.arg_type orelse @compileError("Argument has no type, are you using a generic?"); comptime const arg_info = @typeInfo(arg_type); if (arg_info != .Pointer) { @compileError("System arguments must be pointers."); } types[i] = arg_info.Pointer.child; } var world_pointers: std.meta.ArgsTuple(@TypeOf(system)) = undefined; inline for (types) |t, i| { // returns a pointer to a field of type t in world. const new_ptr = pointer_to_struct_type(t, world) orelse @panic("Provided world misses a field of the following type that the system requires: " ++ @typeName(t)); world_pointers[i] = new_ptr; } comptime const options = std.builtin.CallOptions{}; try @call(options, system, world_pointers); } /// Returns a pointer to the first field of the provided runtime structure that has /// the type Target, if any. /// The structure should be a pointer to a struct. fn pointer_to_struct_type(comptime Target: type, structure: anytype) ?*Target { comptime const ptr_info = @typeInfo(@TypeOf(structure)); //if (ptr_info != .Pointer) { // @compileError("Expected a pointer to a struct."); //} //comptime const struct_info = @typeInfo(ptr_info.Pointer.child); comptime const struct_info = @typeInfo(@TypeOf(structure.*)); if (struct_info != .Struct) { @compileError("Expected a struct."); } inline for (struct_info.Struct.fields) |field| { if (field.field_type == Target) { return &@field(structure.*, field.name); } } return null; } fn bench_system(a: *u32, b: *const i32) !void {} fn test_system(a: *u32, b: *const i32) !void { a.* = 5; } fn test_system2(a: *u32) !void { a.* += 1; } fn TestGeneric(comptime T: type) type { return struct { fn test_generic(a: *T) !void {} }; } test "Basic system call from world data" { const MyWorld = struct { test_a: u32 = 0, test_b: i32 = 0, }; var world = MyWorld{}; try callSystem(&world, test_system); try std.testing.expect(world.test_a == 5); } test "Basic generic system" { const MyWorld = struct { test_a: u32 = 0, test_b: i32 = 0, }; var world = MyWorld{}; try callSystem(&world, TestGeneric(u32).test_generic); } test "Bench medium system" { const b = struct { fn bench(ctx: *benchmark.Context) void { const MyWorld = struct { test_a: u32 = 0, test_b: i32 = 0, }; var world = MyWorld{}; while (ctx.runExplicitTiming()) { ctx.startTimer(); try callSystem(&world, bench_system); ctx.stopTimer(); } } }.bench; benchmark.benchmark("medium system", b); } test "Dispatcher run" { if (std.builtin.single_threaded) return error.SkipZigTest; if (!std.io.is_async) return error.SkipZigTest; const MyWorld = struct { test_a: u32 = 0, test_b: i32 = 0, }; var world = MyWorld{}; const systems = .{ test_system, test_system2 }; var dispatcher = Dispatcher(@TypeOf(systems)){ .systems = systems, }; try dispatcher.runSeq(&world); }
src/dispatcher.zig
const std = @import("std"); const os = std.os; const mem = std.mem; const process = std.process; const Allocator = std.mem.Allocator; const util = @import("util.zig"); const RequestResponse = struct { command: []const u8, file_name: []const u8, source: []const u8, argv: []const u8, stderr: []const u8, stdout: []const u8, }; pub fn main() !void { const stderr = std.io.getStdErr().writer(); const stdout = std.io.getStdOut().writer(); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var allocator = &gpa.allocator; defer _ = gpa.deinit(); const exe_path = try util.resolveExePath(allocator); defer allocator.free(exe_path); // try stderr.print("play.cgi: exe_path={}\n", .{exe_path}); const home_path = try util.resolveHomePath(allocator, exe_path); defer allocator.free(home_path); // try stderr.print("play.cgi: home_path={}\n", .{home_path}); const tmp_path = try util.resolveTmpPath(allocator, exe_path); defer allocator.free(tmp_path); // try stderr.print("play.cgi: tmp_path={}\n", .{tmp_path}); std.fs.cwd().access(tmp_path, .{ .read = true }) catch |err| { try stdout.print("Status: 400 Bad Request\n\n", .{}); return; }; // use millisecond timestamp to ensure unique source file path var ts_buffer: [24]u8 = undefined; const ts = try std.fmt.bufPrint(&ts_buffer, "{}", .{std.time.milliTimestamp()}); const ts_path = try std.fs.path.joinPosix(allocator, &[_][]const u8{ tmp_path, ts }); defer allocator.free(ts_path); // try stderr.print("play.cgi: ts_path={}\n", .{ts_path}); try std.os.mkdir(ts_path, 0o755); var env_map = try process.getEnvMap(allocator); defer env_map.deinit(); // var env_it = env_map.iterator(); // while (env_it.next()) |entry| { // try stderr.print("play.cgi: key={}, value={}\n", .{ entry.key, entry.value }); // } var remote_ip = env_map.get("HTTP_X_REAL_IP"); if (remote_ip == null) { remote_ip = env_map.get("REMOTE_ADDR"); if (remote_ip == null) { remote_ip = "?"; } } // parse http query parameter or request body into a Request struct const buffer_size: usize = 16 * 1024; var request: RequestResponse = undefined; var method_opt = env_map.get("REQUEST_METHOD"); if (method_opt) |method| { if (mem.eql(u8, "GET", method)) { var query_string = env_map.get("QUERY_STRING") orelse return error.Broken; if (mem.startsWith(u8, query_string, "base64=")) { var encoded = query_string[7..]; // try stderr.print("play.cgi: encoded={}\n", .{encoded}); const decoder = std.base64.standard_decoder; var base64_buffer: [buffer_size]u8 = undefined; var decoded = base64_buffer[0..try decoder.calcSize(encoded)]; try decoder.decode(decoded, encoded); // try stderr.print("play.cgi: decoded={}\n", .{decoded}); var json_str = std.ArrayList(u8).init(allocator); defer json_str.deinit(); try std.json.stringify(decoded, .{}, json_str.writer()); // try stderr.print("play.cgi: string={}\n", .{json_str.items}); const json_prefix = \\{"command":"run","file_name":"","source":"//@file_name=main.zig ; const json_suffix = \\,"argv":"","stderr":"","stdout":""}; ; try json_str.replaceRange(0, 1, "\\n"); try json_str.insertSlice(0, json_prefix); try json_str.appendSlice(json_suffix); // try stderr.print("play.cgi: string={}\n", .{json_str.items}); var stream = std.json.TokenStream.init(json_str.items); request = try std.json.parse(RequestResponse, &stream, .{ .allocator = allocator }); } } else if (mem.eql(u8, "POST", method)) { var buffer: [buffer_size]u8 = undefined; var count = try readStdIn(buffer[0..]); if (count == 0) return; // if (count > buffer_size) return error.StreamTooLong; var string = buffer[0..count]; // try stderr.print("{}\n", .{string}); var stream = std.json.TokenStream.init(string); request = try std.json.parse(RequestResponse, &stream, .{ .allocator = allocator }); } else { try stdout.print("Status: 400 Bad Request\n\n", .{}); try stdout.print("\n", .{}); try stdout.print("method={}\n", .{method}); return; } } else { try stdout.print("Status: 400 Bad Request\n\n", .{}); try stdout.print("\n", .{}); try stdout.print("no method\n", .{}); return; } defer std.json.parseFree(RequestResponse, request, .{ .allocator = allocator }); var command: []const u8 = undefined; if (mem.eql(u8, request.command, "run")) { command = "run"; } else if (mem.eql(u8, request.command, "test")) { command = "test"; } else if (mem.eql(u8, request.command, "format")) { command = "fmt"; } else { try stdout.print("Status: 400 Bad Request\n\n", .{}); try stdout.print("\n", .{}); try stdout.print("command={}\n", .{request.command}); return; } try stderr.print("play.cgi: remote_ip={}, session={}, command={}\n", .{ remote_ip.?, ts, command }); // create zig file for compile step // try stderr.print("{}\n", .{request.source}); var file: ?std.fs.File = null; var line_it = std.mem.split(request.source, "\n"); while (line_it.next()) |line| { // try stderr.print("{}\n", .{line}); if (std.mem.startsWith(u8, line, "//@file_name=")) { if (file) |f| f.close(); const idx1 = 13; const file_name = line[idx1..]; // try stderr.print("play.cgi: file_name={}\n", .{file_name}); const file_path = try std.fs.path.joinPosix(allocator, &[_][]const u8{ tmp_path, ts, file_name }); defer allocator.free(file_path); try stderr.print("play.cgi: remote_ip={}, session={}, file_path={}\n", .{ remote_ip.?, ts, file_path }); file = try std.fs.cwd().createFile(file_path, .{}); } else if (file) |f| { _ = try f.write(line); _ = try f.write("\n"); } } if (file) |f| f.close(); var file_name: []const u8 = undefined; if (mem.eql(u8, command, "run")) { file_name = "main.zig"; } else { file_name = request.file_name; } var argv_list = std.ArrayList([]const u8).init(allocator); defer argv_list.deinit(); try argv_list.append("/usr/local/zig/zig"); try argv_list.append(command); try argv_list.append(file_name); // try stderr.print("play.cgi: request.argv.len={}\n", .{request.argv.len}); if (mem.eql(u8, command, "run") and request.argv.len > 0) { try argv_list.append("--"); var it = std.mem.split(request.argv, " "); while (it.next()) |value| { try argv_list.append(value); } } // for (argv_list.items) |value, i| { // try stderr.print("play.cgi: argv_list[{}]={}\n", .{ i, value }); // } var exec_env_map = std.BufMap.init(allocator); defer exec_env_map.deinit(); try exec_env_map.set("HOME", home_path); const result = try std.ChildProcess.exec(.{ .allocator = allocator, .argv = argv_list.items, .cwd = ts_path, .env_map = &exec_env_map, .max_output_bytes = 128 * 1024, }); defer { allocator.free(result.stdout); allocator.free(result.stderr); } var source_buffer: [16 * 1024]u8 = undefined; var source: []const u8 = undefined; if (mem.eql(u8, command, "fmt")) { const file_path = try std.fs.path.joinPosix(allocator, &[_][]const u8{ ts_path, file_name }); defer allocator.free(file_path); var source_file = try std.fs.cwd().openFile(file_path, std.fs.File.OpenFlags{ .read = true }); defer source_file.close(); const bytes_read = try source_file.reader().read(source_buffer[0..]); source = source_buffer[0..bytes_read]; } else { source = ""; } const response = &RequestResponse{ .command = command, .file_name = file_name, .source = source, .argv = "", .stderr = result.stderr, .stdout = result.stdout, }; var string2 = std.ArrayList(u8).init(allocator); defer string2.deinit(); try std.json.stringify(response, .{}, string2.writer()); // write http response try stdout.print("Content-Type: application/json\n", .{}); try stdout.print("Content-Length: {}\n", .{string2.items.len}); try stdout.print("\n", .{}); try stdout.print("{}\n", .{string2.items}); } fn readStdIn(buffer: []u8) !usize { const stdin = std.io.getStdIn().inStream(); const count = try stdin.readAll(buffer); return count; }
src/play.zig
const zt = @import("zt"); const std = @import("std"); const sling = @import("sling.zig"); const assert = std.debug.assert; fn AssetWrapper(comptime T: type) type { return struct { pub var lookup = std.StringHashMap(usize).init(sling.alloc); pub var data = std.ArrayList(T).init(sling.alloc); }; } pub const Texture = struct { pub var preferNearestFilter: bool = true; internal: zt.gl.Texture, whitePixel: ?zt.math.Rect = null, }; pub const Font = @import("font.zig"); /// Don't use this to store a reference to a resource, as the pointer given will be invalidated on data resize. /// Prefer to use `ensure` to get a pointer to use here instead. pub fn get(comptime T: type, id: usize) *T { const wrapper = AssetWrapper(T); return &wrapper.data.items[id]; } /// Use this to get a stack copy from the asset list, recommended to use normal get if the asset type is not /// very small. pub fn getCopy(comptime T: type, id: usize) T { const wrapper = AssetWrapper(T); return wrapper.data.items[id]; } /// A direct version of get, uses ensure to get the id, then returns the type. pub fn fetch(comptime T: type, path: []const u8) *T { var id = ensure(T, path); return get(T, id); } /// A direct version of getCopy, uses ensure to get the id, then returns the type. pub fn fetchCopy(comptime T: type, path: []const u8) T { var id = ensure(T, path); return getCopy(T, id); } /// This returns an index that points to the asset that was loaded /// (or was already loaded). Use this to store runtime information, /// and do not serialize/deserialize this index as it can change /// from run to run. pub fn ensure(comptime T: type, path: []const u8) usize { const wrapper = AssetWrapper(T); var resource = wrapper.lookup.getOrPut(path) catch |err| { std.debug.panic("Unknown error when fetching from asset lookup hashmap:\n{s}", .{@errorName(err)}); }; if (!resource.found_existing) { resource.key_ptr.* = sling.alloc.dupeZ(u8, path) catch unreachable; resource.value_ptr.* = wrapper.data.items.len; wrapper.data.append(load(T, path)) catch |err| { std.debug.panic("Unknown error when appending to asset list:\n{s}", .{@errorName(err)}); }; std.debug.print("SLING: Asset type \"{s}\" loaded from \"{s}\"\n", .{ @typeName(T), path }); } return resource.value_ptr.*; } fn load(comptime T: type, path: []const u8) T { switch (T) { Texture => { var tex = Texture{ .internal = zt.gl.Texture.init(path) catch |err| { std.debug.panic("Failed to load image into asset: {s}:\n{s}", .{ path, @errorName(err) }); }, .whitePixel = null, }; if (Texture.preferNearestFilter) { tex.internal.setNearestFilter(); } return tex; }, Font => { return Font.loadBmFontAsciiPath(path); }, else => { @compileError("Unsupported type in Asset request."); }, } } pub fn save(comptime T: type, item: T, path: []const u8) !void { std.debug.assert(T != Texture); _ = item; _ = path; }
src/asset.zig
const std = @import("std"); const ptk = @import("parser-toolkit"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = &gpa.allocator; var line_buffer = std.ArrayList(u8).init(allocator); defer line_buffer.deinit(); var stdin = std.io.getStdIn().reader(); var stdout = std.io.getStdOut().writer(); var calc = Calculator.init(allocator); defer calc.deinit(); try calc.set("pi", std.math.pi); try calc.set("e", std.math.e); main_loop: while (true) { try stdout.writeAll("? "); stdin.readUntilDelimiterArrayList(&line_buffer, '\n', 4096) catch |err| switch (err) { error.EndOfStream => break :main_loop, else => |e| return e, }; const line = std.mem.trim(u8, line_buffer.items, "\t "); const value = calc.evaluate(line) catch |err| { try stdout.print("error: {s}\n", .{@errorName(err)}); continue; }; try stdout.print("= {d}\n", .{value}); } try stdout.writeAll("\n"); } const Calculator = struct { const Self = @This(); arena: std.heap.ArenaAllocator, variables: std.StringHashMapUnmanaged(f64), pub fn init(allocator: *std.mem.Allocator) Self { return Self{ .arena = std.heap.ArenaAllocator.init(allocator), .variables = .{}, }; } pub fn deinit(self: *Self) void { self.variables.deinit(&self.arena.allocator); self.arena.deinit(); self.* = undefined; } pub fn set(self: *Self, name: []const u8, value: f64) !void { const gop = try self.variables.getOrPut(&self.arena.allocator, name); if (!gop.found_existing) { errdefer _ = self.variables.remove(name); gop.key_ptr.* = try self.arena.allocator.dupe(u8, name); } gop.value_ptr.* = value; } pub fn get(self: Self, name: []const u8) ?f64 { return self.variables.get(name); } pub fn evaluate(self: *Self, expression: []const u8) !f64 { return try Parser.parse(.{ .calc = self }, expression); } const EvalError = error{ UnknownFunction, ArgumentMismatch }; fn invokeFunction(self: *Self, func_name: []const u8, args: []const f64) EvalError!f64 { inline for (std.meta.declarations(builtin_functions)) |decl| { if (std.mem.eql(u8, decl.name, func_name)) { const FnType = decl.data.Fn.fn_type; const function = @field(builtin_functions, decl.name); return try self.invokeExplicitFunction(FnType, function, args); } } return error.UnknownFunction; } fn invokeExplicitFunction(self: *Self, comptime FnType: type, comptime function: FnType, arg_vals: []const f64) EvalError!f64 { _ = self; const ArgsTuple = std.meta.ArgsTuple(FnType); var args: ArgsTuple = undefined; if (arg_vals.len != args.len) return error.ArgumentMismatch; comptime var i = 0; inline while (i < args.len) : (i += 1) { args[i] = arg_vals[i]; } return @call(.{}, function, args); } const builtin_functions = struct { pub fn sin(v: f64) f64 { return std.math.sin(v); } pub fn cos(v: f64) f64 { return std.math.cos(v); } pub fn tan(v: f64) f64 { return std.math.tan(v); } pub fn sqrt(v: f64) f64 { return std.math.sqrt(v); } pub fn pow(a: f64, b: f64) f64 { return std.math.pow(f64, a, b); } pub fn ln(v: f64) f64 { return std.math.ln(v); } pub fn ln10(v: f64) f64 { return std.math.log10(v); } pub fn ln2(v: f64) f64 { return std.math.log2(v); } pub fn log(b: f64, v: f64) f64 { return std.math.log(f64, b, v); } }; }; const Parser = struct { const Self = @This(); const TokenType = enum { number, identifier, whitespace, @"+", @"-", @"*", @"/", @"%", @"(", @")", @"=", @",", }; const Pattern = ptk.Pattern(TokenType); const Tokenizer = ptk.Tokenizer(TokenType, &[_]Pattern{ Pattern.create(.number, ptk.matchers.sequenceOf(.{ ptk.matchers.decimalNumber, ptk.matchers.literal("."), ptk.matchers.decimalNumber })), Pattern.create(.number, ptk.matchers.decimalNumber), Pattern.create(.identifier, ptk.matchers.identifier), Pattern.create(.whitespace, ptk.matchers.whitespace), Pattern.create(.@"+", ptk.matchers.literal("+")), Pattern.create(.@"-", ptk.matchers.literal("-")), Pattern.create(.@"*", ptk.matchers.literal("*")), Pattern.create(.@"/", ptk.matchers.literal("/")), Pattern.create(.@"%", ptk.matchers.literal("%")), Pattern.create(.@"(", ptk.matchers.literal("(")), Pattern.create(.@")", ptk.matchers.literal(")")), Pattern.create(.@"=", ptk.matchers.literal("=")), Pattern.create(.@",", ptk.matchers.literal(",")), }); const ParserCore = ptk.ParserCore(Tokenizer, .{.whitespace}); const ExpressionContext = struct { calc: *Calculator, fn set(self: *ExpressionContext, var_name: []const u8, value: f64) !void { try self.calc.set(var_name, value); } fn get(self: *ExpressionContext, var_name: []const u8) ?f64 { return self.calc.get(var_name); } fn call(self: *ExpressionContext, func: []const u8, args: []const f64) !f64 { return try self.calc.invokeFunction(func, args); } }; pub fn parse(context: ExpressionContext, expression: []const u8) !f64 { var tokenizer = Tokenizer.init(expression); var parser = Parser{ .core = ParserCore.init(&tokenizer), .ctx = context, }; const value = try parser.acceptTopLevelExpression(); if ((try parser.core.peek()) != null) return error.SyntaxError; return value; } core: ParserCore, ctx: ExpressionContext, const Error = ParserCore.Error || Calculator.EvalError || std.mem.Allocator.Error || error{VariableNotFound}; const ruleset = ptk.RuleSet(TokenType); fn acceptTopLevelExpression(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); if (self.acceptAssignment()) |ass| { return ass; } else |_| { return try self.acceptExpression(); } } fn acceptAssignment(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); const variable = try self.core.accept(comptime ruleset.is(.identifier)); _ = try self.core.accept(comptime ruleset.is(.@"=")); const value = try self.acceptExpression(); try self.ctx.set(variable.text, value); return value; } fn acceptExpression(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); return try self.acceptSumExpression(); } fn acceptSumExpression(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); var value = try self.acceptMulExpression(); while (true) { const operator = self.core.accept(comptime ruleset.oneOf(.{ .@"+", .@"-" })) catch break; const rhs = try self.acceptMulExpression(); const new_value = switch (operator.type) { .@"+" => value + rhs, .@"-" => value - rhs, else => unreachable, }; value = new_value; } return value; } fn acceptMulExpression(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); var value = try self.acceptUnaryPrefixOperatorExpression(); while (true) { const operator = self.core.accept(comptime ruleset.oneOf(.{ .@"*", .@"/", .@"%" })) catch break; const rhs = try self.acceptUnaryPrefixOperatorExpression(); const new_value = switch (operator.type) { .@"*" => value * rhs, .@"/" => value / rhs, .@"%" => @mod(value, rhs), else => unreachable, }; value = new_value; } return value; } fn acceptUnaryPrefixOperatorExpression(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); if (self.core.accept(comptime ruleset.is(.@"-"))) |_| { // this must directly recurse as we can write `- - x` const value = try self.acceptUnaryPrefixOperatorExpression(); return -value; } else |_| { return try self.acceptFunctionCallExpression(); } } fn acceptFunctionCallExpression(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); if (self.acceptFunctionCall()) |fncall| { return fncall; } else |_| { return try self.acceptValueExpression(); } } fn acceptFunctionCall(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); const name = try self.core.accept(comptime ruleset.is(.identifier)); _ = try self.core.accept(comptime ruleset.is(.@"(")); var args: [64]f64 = undefined; var argc: usize = 0; const no_arg_terminator = try self.core.peek(); if (no_arg_terminator != null and no_arg_terminator.?.type == .@")") { _ = try self.core.accept(comptime ruleset.is(.@")")); return try self.ctx.call(name.text, args[0..argc]); } while (true) { const arg = try self.acceptExpression(); args[argc] = arg; argc += 1; const next = try self.core.accept(comptime ruleset.oneOf(.{ .@")", .@"," })); if (next.type == .@")") break; } return try self.ctx.call(name.text, args[0..argc]); } fn acceptValueExpression(self: *Self) Error!f64 { const state = self.core.saveState(); errdefer self.core.restoreState(state); const token = try self.core.accept(comptime ruleset.oneOf(.{ .@"(", .number, .identifier, })); switch (token.type) { .@"(" => { const value = try self.acceptExpression(); _ = try self.core.accept(comptime ruleset.is(.@")")); return value; }, .number => return std.fmt.parseFloat(f64, token.text) catch unreachable, .identifier => return self.ctx.get(token.text) orelse error.VariableNotFound, else => unreachable, } } };
examples/calculator.zig
const assert = @import("std").debug.assert; const testing = @import("std").testing; /// Create a type representing a raw memory storage with the specified size and /// alignment requirement. pub fn AlignedStorage(comptime size: usize, comptime alignment: u29) type { // For now there doesn't exist a way to directly set a struct's alignment: // <https://github.com/ziglang/zig/issues/1512> var MaybeAligner: ?type = null; for (known_types) |KT| { if (alignment == @alignOf(KT)) { MaybeAligner = KT; } } if (MaybeAligner == null) { @compileError("could not find a type with the requested alignment"); } const Aligner = MaybeAligner.?; // Compiler bug: Defining this using `union` (of `[_]u8` and `Aligner`) // causes `unable to evaluate constant expression` for some // reason. // Compiler bug: Defining `storage` as `[_]Aligner` and then doing // `@sliceToBytes(storage)` causes assertion failure. // <https://github.com/ziglang/zig/issues/2861> const Ty = struct { aligner: Aligner, storage: [size]u8, const Self = @This(); pub fn toBytes(self: *Self) []align(alignment) u8 { if (size == 0) { return &[0]u8{}; } // Compiler bug: Ref-based slice (`ConstPtrSpecialRef`) is always // treated as having 1 element, irregardless of // reinterpretation. Because of this, the returned // pointer has to refer to an array, not `Ty` as a // whole. return @alignCast(alignment, self.storage[0 ..]); // return @ptrCast([*]align(alignment) u8, self)[0..size]; } }; assert(@sizeOf(Ty) >= size); assert(@alignOf(Ty) >= alignment); return Ty; } /// Types with variety of alignment requirements. const known_types = [_]type{ u8, u16, u32, u64, }; test "AlignedStorage" { @setEvalBranchQuota(1000000); const Xorshift32 = @import("math.zig").Xorshift32; comptime var size = 0; inline while (size < 40) { comptime var a = 1; inline while (a <= 8) { testing.expect(@sizeOf(AlignedStorage(size, a)) >= size); testing.expect(@alignOf(AlignedStorage(size, a)) >= a); var storage: AlignedStorage(size, a) = undefined; var rng = Xorshift32.init(10000); for (storage.toBytes()) |*byte| { byte.* = @truncate(u8, rng.next()); } comptime var storage2: AlignedStorage(size, a) = undefined; comptime { var rng2 = Xorshift32.init(10000); for (storage2.toBytes()) |*byte| { byte.* = @truncate(u8, rng2.next()); } } var storage2_var = storage2; testing.expectEqualSlices(u8, storage2_var.toBytes(), storage.toBytes()); a *= 2; } size += 1; } } /// Create a tuple type (heterogeneous fixed-size list type). pub fn Tuple(comptime types: []const type) type { return if (types.len == 0) TupleEmpty else TupleNonEmpty(types); } const TupleEmpty = struct { const Self = @This(); pub fn Elem(comptime i: usize) type { @compileError("out of bounds"); } pub inline fn get(self: *Self, comptime i: usize) void { @compileError("out of bounds"); } pub inline fn getConst(self: *const Self, comptime i: usize) void { @compileError("out of bounds"); } }; fn TupleNonEmpty(comptime types: []const type) type { return struct { head: Head, rest: Rest, const Self = @This(); const Head = types[0]; const Rest = Tuple(types[1..]); pub fn Elem(comptime i: usize) type { return if (i == 0) Head else Rest.Elem(i - 1); } pub inline fn get(self: *Self, comptime i: usize) *Elem(i) { return if (i == 0) &self.head else self.rest.get(i - 1); } pub inline fn getConst(self: *const Self, comptime i: usize) *const Elem(i) { return if (i == 0) &self.head else self.rest.getConst(i - 1); } }; } test "Tuple with zero elements" { const T = Tuple([_]type{}); testing.expect(@sizeOf(T) == 0); } test "Tuple with one element" { const T = Tuple([_]type{u32}); testing.expect(@sizeOf(T) == @sizeOf(u32)); testing.expect(T.Elem(0) == u32); var t: T = undefined; t.get(0).* = 42; testing.expect(@typeOf(t.get(0)) == *u32); testing.expect(t.get(0).* == 42); testing.expect(@typeOf(t.getConst(0)) == *const u32); testing.expect(t.getConst(0).* == 42); } test "Tuple with two elements" { const T = Tuple([_]type{ u32, u16 }); testing.expect(T.Elem(0) == u32); testing.expect(T.Elem(1) == u16); var t: T = undefined; t.get(0).* = 114514; t.get(1).* = 42; testing.expect(@typeOf(t.get(0)) == *u32); testing.expect(@typeOf(t.get(1)) == *u16); testing.expect(t.get(0).* == 114514); testing.expect(t.get(1).* == 42); testing.expect(@typeOf(t.getConst(0)) == *const u32); testing.expect(@typeOf(t.getConst(1)) == *const u16); testing.expect(t.getConst(0).* == 114514); testing.expect(t.getConst(1).* == 42); }
druzhba/storage.zig
const std = @import("std"); pub const SymbolSize = enum(u8) { @"8 bits" = 1, @"16 bits" = 2, @"32 bits" = 4, @"64 bits" = 8, }; const magic_number = [4]u8{ 0xFB, 0xAD, 0xB6, 0x02 }; pub const Linker = struct { const Module = struct { view: View, // will be defined in the link step base_offset: u32 = undefined, }; allocator: std.mem.Allocator, modules: std.ArrayListUnmanaged(Module), pub fn init(allocator: std.mem.Allocator) Linker { return Linker{ .allocator = allocator, .modules = .{}, }; } pub fn deinit(self: *Linker) void { self.modules.deinit(self.allocator); self.* = undefined; } /// Adds a module to be linked. /// Modules are processed in the order they are added, and can shadow symbols of previous modules. pub fn addModule(self: *Linker, module: View) !void { const ptr = try self.modules.addOne(self.allocator); ptr.* = Module{ .view = module, }; } pub const LinkOptions = struct { /// Align each module to this. module_alignment: u32 = 16, /// Enforce the symbol size and reject modules that don't have this. symbol_size: ?SymbolSize = null, /// The base address where all modules are relocated to. base_address: u32 = 0, }; pub fn link(self: *Linker, output: *std.io.StreamSource, options: LinkOptions) !void { if (self.modules.items.len == 0) return error.NothingToLink; var symbol_size: SymbolSize = options.symbol_size orelse self.modules.items[0].view.symbol_size; var write_offset: u32 = options.base_address; for (self.modules.items) |*_module| { const module: *Module = _module; module.base_offset = write_offset; if (module.view.symbol_size != symbol_size) return error.MismatchingSymbolSize; write_offset += try std.math.cast(u32, std.mem.alignForward(module.view.data().len, options.module_alignment)); } var symbol_table = std.StringHashMap(u64).init(self.allocator); defer symbol_table.deinit(); const Patch = struct { offset: u64, symbol: []const u8, }; var patches = std.ArrayList(Patch).init(self.allocator); defer patches.deinit(); for (self.modules.items) |*_module| { const module: *Module = _module; std.log.debug("Process object file...", .{}); try output.seekTo(module.base_offset); try output.writer().writeAll(module.view.data()); // first resolve inputs if (module.view.imports()) |imports| { var strings = module.view.strings().?; var iter = imports.iterator(); while (iter.next()) |sym| { const string = strings.get(sym.symbol_name); const symbol_offset = module.base_offset + sym.offset; if (symbol_table.get(string.text)) |address| { // we got that! try output.seekTo(symbol_offset); try patchStream(output, symbol_size, address, .replace); std.log.debug("Directly resolving symbol {s} to {X:0>4} at offset {X:0>4}", .{ string.text, address, symbol_offset }); } else { // we must patch this later try patches.append(Patch{ .offset = symbol_offset, .symbol = string.text, }); std.log.debug("Adding patch for symbol {s} at offset {X:0>4}", .{ string.text, symbol_offset }); } } } // then publish outputs if (module.view.exports()) |exports| { var strings = module.view.strings().?; var iter = exports.iterator(); while (iter.next()) |sym| { const string = strings.get(sym.symbol_name); try symbol_table.put(string.text, module.base_offset + sym.offset); std.log.debug("Publishing symbol {s} at offset {X:0>4}", .{ string.text, module.base_offset + sym.offset }); } } // then try resolving all patches { var i: usize = 0; while (i < patches.items.len) { const patch = patches.items[i]; if (symbol_table.get(patch.symbol)) |address| { try output.seekTo(patch.offset); try patchStream(output, symbol_size, address, .replace); std.log.debug("Patch-resolving symbol {s} to {X:0>4} at offset {X:0>4}", .{ patch.symbol, address, patch.offset }); // order isn't important at this point anymore _ = patches.swapRemove(i); } else { i += 1; } } } // then resolve all internal references if (module.view.relocations()) |relocs| { var i: u32 = 0; while (i < relocs.count) : (i += 1) { try output.seekTo(module.base_offset + relocs.get(i)); try patchStream(output, symbol_size, module.base_offset, .add); } } } { std.debug.print("symbols:\n", .{}); var iter = symbol_table.iterator(); while (iter.next()) |kv| { std.debug.print("{X:0>8}: {s}\n", .{ kv.value_ptr.*, kv.key_ptr.* }); } } { std.debug.print("unresolved symbols:\n", .{}); for (patches.items) |patch| { std.debug.print("{X:0>8}: {s}\n", .{ patch.offset, patch.symbol }); } } } const PatchMode = enum { replace, add }; fn patchStream(stream: *std.io.StreamSource, size: SymbolSize, data: u64, kind: PatchMode) !void { switch (size) { .@"8 bits" => try patchStreamTyped(u8, stream, data, kind), .@"16 bits" => try patchStreamTyped(u16, stream, data, kind), .@"32 bits" => try patchStreamTyped(u32, stream, data, kind), .@"64 bits" => try patchStreamTyped(u64, stream, data, kind), } } fn patchStreamTyped(comptime Offset: type, stream: *std.io.StreamSource, data: u64, kind: PatchMode) !void { const pos = try stream.getPos(); const old_val = try stream.reader().readIntLittle(Offset); const new_val = try std.math.cast(Offset, data); const value = switch (kind) { .replace => new_val, .add => old_val +% new_val, }; try stream.seekTo(pos); try stream.writer().writeIntLittle(Offset, value); } }; pub const Builder = struct { arena: std.heap.ArenaAllocator, allocator: std.mem.Allocator, stream: *std.io.StreamSource, exports: std.StringHashMapUnmanaged(u32) = .{}, imports: std.StringHashMapUnmanaged(u32) = .{}, strings: std.StringHashMapUnmanaged(u32) = .{}, relocs: std.ArrayListUnmanaged(u32) = .{}, pub fn init(allocator: std.mem.Allocator, symbol_size: SymbolSize, stream: *std.io.StreamSource) !Builder { var builder = Builder{ .allocator = allocator, .arena = std.heap.ArenaAllocator.init(allocator), .stream = stream, }; try builder.stream.writer().writeAll(&[_]u8{ 0xFB, 0xAD, 0xB6, 0x02, // magic 0xAA, 0xAA, 0xAA, 0xAA, // export_table 0xAA, 0xAA, 0xAA, 0xAA, // import_table 0xAA, 0xAA, 0xAA, 0xAA, // relocs_table 0xAA, 0xAA, 0xAA, 0xAA, // string_table 0x20, 0x00, 0x00, 0x00, // section_start 0xAA, 0xAA, 0xAA, 0xAA, // section_size @enumToInt(symbol_size), // symbol_size 0x00, 0x00, 0x00, // padding }); return builder; } pub fn deinit(self: *Builder) void { self.exports.deinit(self.allocator); self.imports.deinit(self.allocator); self.strings.deinit(self.allocator); self.arena.deinit(); self.* = undefined; } /// Returns the current offset into the data section. pub fn getOffset(self: *Builder) !u32 { return try self.stream.getPos() - 0x20; } /// Appends bytes to the data section. pub fn append(self: *Builder, data: []const u8) !void { try self.stream.writer().writeAll(data); } /// If `offset` is null, the current offset is used. pub fn addExport(self: *Builder, name: []const u8, offset: ?u32) !void { const real_offset = offset orelse try self.stream.getPos(); const interned_name = try self.internString(name); try self.exports.put(self.allocator, interned_name, real_offset); } /// If `offset` is null, the current offset is used. pub fn addImport(self: *Builder, name: []const u8, offset: ?u32) !void { const real_offset = offset orelse try self.stream.getPos(); const interned_name = try self.internString(name); try self.imports.put(self.allocator, interned_name, real_offset); } /// If `offset` is null, the current offset is used. pub fn addRelocation(self: *Builder, offset: ?u32) !void { const real_offset = offset orelse try self.stream.getPos(); try self.relocs.append(self.allocator, real_offset); } pub fn finalize(self: *Builder) !void { var writer = self.stream.writer(); const data_end_marker = try self.stream.getPos(); const string_table_pos = try self.alignData(4); { var total_size: u32 = 4; var iter = self.strings.iterator(); while (iter.next()) |kv| { total_size += @truncate(u32, kv.key_ptr.len) + 5; // 4 byte length + nul terminator } try writer.writeIntLittle(u32, total_size); var offset: u32 = 4; iter = self.strings.iterator(); while (iter.next()) |kv| { kv.value_ptr.* = offset; try writer.writeIntLittle(u32, @truncate(u32, kv.key_ptr.len)); try writer.writeAll(kv.key_ptr.*); try writer.writeByte(0); offset += @truncate(u32, kv.key_ptr.len) + 5; } } const export_table_pos = try self.alignData(4); { try writer.writeIntLittle(u32, self.exports.count()); var iter = self.exports.iterator(); while (iter.next()) |sym| { const name_str = sym.key_ptr.*; const value = sym.value_ptr.*; const name_id = self.strings.get(name_str) orelse unreachable; try writer.writeIntLittle(u32, name_id); try writer.writeIntLittle(u32, value); } } const import_table_pos = try self.alignData(4); { try writer.writeIntLittle(u32, self.imports.count()); var iter = self.imports.iterator(); while (iter.next()) |sym| { const name_str = sym.key_ptr.*; const value = sym.value_ptr.*; const name_id = self.strings.get(name_str) orelse unreachable; try writer.writeIntLittle(u32, name_id); try writer.writeIntLittle(u32, value); } } const relocs_table_pos = try self.alignData(4); { try writer.writeIntLittle(u32, @truncate(u32, self.relocs.items.len)); for (self.relocs.items) |reloc| { try writer.writeIntLittle(u32, reloc); } } const end_of_file_marker = try self.stream.getPos(); try self.stream.seekTo(4); try writer.writeIntLittle(u32, export_table_pos); // export_table try writer.writeIntLittle(u32, import_table_pos); // import_table try writer.writeIntLittle(u32, relocs_table_pos); // relocs_table try writer.writeIntLittle(u32, string_table_pos); // string_table try writer.writeIntLittle(u32, 0x20); // section_start try writer.writeIntLittle(u32, @truncate(u32, data_end_marker) - 0x20); // section_size try self.stream.seekTo(end_of_file_marker); } fn internString(self: *Builder, string: []const u8) ![]const u8 { const gop = self.strings.getOrPut(self.allocator, string); if (!gop.found_existing) { errdefer self.strings.remove(string); const copy = try self.arena.allocator().dupe(u8, string); gop.key_ptr.* = copy; // we leave the value dangling until finalize() so we // can store the string offset in the table then. gop.value_ptr.* = undefined; } return gop.key_ptr.*; } fn alignData(self: *Builder, alignment: u32) !u32 { const pos = try self.stream.getPos(); const aligned = @truncate(u32, std.mem.alignForward(pos, alignment)); try self.stream.seekTo(aligned); return aligned; } }; /// A view of a SLF file. Allows accessing the data structure from a flat buffer without allocation. pub const View = struct { const offsets = struct { const magic = 0; const export_table = 4; const import_table = 8; const relocs_table = 12; const string_table = 16; const section_start = 20; const section_size = 24; const symbol_size = 28; }; buffer: []const u8, symbol_size: SymbolSize, pub const InitOptions = struct { validate_symbols: bool = false, }; pub const InitError = error{ InvalidHeader, InvalidData }; pub fn init(buffer: []const u8, options: InitOptions) InitError!View { if (!std.mem.startsWith(u8, buffer, &magic_number)) return error.InvalidHeader; if (buffer.len < 32) return error.InvalidData; const export_table = std.mem.readIntLittle(u32, buffer[offsets.export_table..][0..4]); const import_table = std.mem.readIntLittle(u32, buffer[offsets.import_table..][0..4]); const relocs_table = std.mem.readIntLittle(u32, buffer[offsets.relocs_table..][0..4]); const string_table = std.mem.readIntLittle(u32, buffer[offsets.string_table..][0..4]); const section_start = std.mem.readIntLittle(u32, buffer[offsets.section_start..][0..4]); const section_size = std.mem.readIntLittle(u32, buffer[offsets.section_size..][0..4]); const symbol_size = std.mem.readIntLittle(u8, buffer[offsets.symbol_size..][0..1]); // std.debug.print("{} {} {} {} {} {} {}\n", .{ // export_table, // import_table, // relocs_table, // string_table, // section_start, // section_size, // symbol_size, // }); // validate basic boundaries if (export_table > buffer.len - 4) return error.InvalidData; if (import_table > buffer.len - 4) return error.InvalidData; if (relocs_table > buffer.len - 4) return error.InvalidData; if (string_table > buffer.len - 4) return error.InvalidData; if (section_start + section_size > buffer.len) return error.InvalidData; const string_table_size = if (string_table != 0) blk: { const length = std.mem.readIntLittle(u32, buffer[string_table..][0..4]); if (string_table + length > buffer.len) return error.InvalidData; var offset: u32 = 4; while (offset < length) { const len = std.mem.readIntLittle(u32, buffer[string_table + offset ..][0..4]); // std.debug.print("{} + {} + 5 > {}\n", .{ // offset, len, length, // }); if (offset + len + 5 > length) return error.InvalidData; if (string_table + len + 1 > buffer.len) return error.InvalidData; if (buffer[string_table + offset + len + 4] != 0) return error.InvalidData; offset += 5 + len; } break :blk length; } else 0; if (export_table != 0) { const count = std.mem.readIntLittle(u32, buffer[export_table..][0..4]); if (export_table + 8 * count + 4 > buffer.len) return error.InvalidData; var i: u32 = 0; while (i < count) : (i += 1) { const name_index = std.mem.readIntLittle(u32, buffer[export_table + 4 + 8 * i ..][0..4]); const offset = std.mem.readIntLittle(u32, buffer[export_table + 4 + 8 * i ..][4..8]); if (name_index + 5 > string_table_size) return error.InvalidData; // not possible for string table if (options.validate_symbols) { if (offset + symbol_size > section_size) return error.InvalidData; // out of bounds } } } if (import_table != 0) { const count = std.mem.readIntLittle(u32, buffer[import_table..][0..4]); if (import_table + 8 * count + 4 > buffer.len) return error.InvalidData; var i: u32 = 0; while (i < count) : (i += 1) { const name_index = std.mem.readIntLittle(u32, buffer[import_table + 4 + 8 * i ..][0..4]); const offset = std.mem.readIntLittle(u32, buffer[import_table + 4 + 8 * i ..][4..8]); if (name_index + 5 > string_table_size) return error.InvalidData; // not possible for string table if (options.validate_symbols) { if (offset + symbol_size > section_size) return error.InvalidData; // out of bounds } } } if (relocs_table != 0) { const count = std.mem.readIntLittle(u32, buffer[relocs_table..][0..4]); if (relocs_table + 4 * count + 4 > buffer.len) return error.InvalidData; var i: u32 = 0; while (i < count) : (i += 1) { const offset = std.mem.readIntLittle(u32, buffer[relocs_table + 4 + 4 * i ..][0..4]); // std.debug.print("{} + {} > {}\n", .{ offset, symbol_size, section_size }); // relocation must always be inside the section table if (offset + symbol_size > section_size) return error.InvalidData; // out of bounds } } return View{ .buffer = buffer, .symbol_size = std.meta.intToEnum(SymbolSize, symbol_size) catch return error.InvalidData, }; } pub fn imports(self: View) ?SymbolTable { const import_table = std.mem.readIntLittle(u32, self.buffer[offsets.import_table..][0..4]); if (import_table == 0) return null; return SymbolTable.init(self.buffer[import_table..]); } pub fn exports(self: View) ?SymbolTable { const export_table = std.mem.readIntLittle(u32, self.buffer[offsets.export_table..][0..4]); if (export_table == 0) return null; return SymbolTable.init(self.buffer[export_table..]); } pub fn strings(self: View) ?StringTable { const string_table = std.mem.readIntLittle(u32, self.buffer[offsets.string_table..][0..4]); if (string_table == 0) return null; return StringTable.init(self.buffer[string_table..]); } pub fn relocations(self: View) ?RelocationTable { const relocs_table = std.mem.readIntLittle(u32, self.buffer[offsets.relocs_table..][0..4]); if (relocs_table == 0) return null; return RelocationTable.init(self.buffer[relocs_table..]); } pub fn data(self: View) []const u8 { const section_start = std.mem.readIntLittle(u32, self.buffer[offsets.section_start..][0..4]); const section_size = std.mem.readIntLittle(u32, self.buffer[offsets.section_size..][0..4]); return self.buffer[section_start..][0..section_size]; } }; pub const SymbolTable = struct { buffer: []const u8, count: usize, pub fn init(buffer: []const u8) SymbolTable { const count = std.mem.readIntLittle(u32, buffer[0..4]); return SymbolTable{ .count = count, .buffer = buffer[4..], }; } pub fn get(self: SymbolTable, index: usize) Symbol { const symbol_name = std.mem.readIntLittle(u32, self.buffer[8 * index ..][0..4]); const offset = std.mem.readIntLittle(u32, self.buffer[8 * index ..][4..8]); return Symbol{ .offset = offset, .symbol_name = symbol_name, }; } pub fn iterator(self: SymbolTable) Iterator { return Iterator{ .table = self }; } pub const Iterator = struct { table: SymbolTable, index: usize = 0, pub fn next(self: *Iterator) ?Symbol { if (self.index >= self.table.count) return null; const index = self.index; self.index += 1; return self.table.get(index); } }; }; pub const Symbol = struct { offset: u32, symbol_name: u32, }; pub const RelocationTable = struct { buffer: []const u8, count: u32, pub fn init(buffer: []const u8) RelocationTable { const count = std.mem.readIntLittle(u32, buffer[0..4]); return RelocationTable{ .count = count, .buffer = buffer[4..], }; } pub fn get(self: RelocationTable, index: u32) u32 { std.debug.assert(index < self.count); return std.mem.readIntLittle(u32, self.buffer[4 * index ..][0..4]); } pub fn iterator(self: RelocationTable) Iterator { return Iterator{ .table = self }; } pub const Iterator = struct { table: RelocationTable, index: u32 = 0, pub fn next(self: *Iterator) ?u32 { if (self.index >= self.table.count) { return null; } const value = self.table.get(self.index); self.index += 1; return value; } }; }; pub const StringTable = struct { buffer: []const u8, limit: u32, pub fn init(buffer: []const u8) StringTable { const limit = std.mem.readIntLittle(u32, buffer[0..4]); return StringTable{ .limit = limit, .buffer = buffer, }; } pub fn iterator(self: StringTable) Iterator { return Iterator{ .table = self }; } pub fn get(self: StringTable, offset: u32) String { const length = std.mem.readIntLittle(u32, self.buffer[offset..][0..4]); return String{ .offset = @truncate(u32, offset), .text = self.buffer[offset + 4 ..][0..length :0], }; } pub const Iterator = struct { table: StringTable, offset: u32 = 4, // we start *after* the table length marker pub fn next(self: *Iterator) ?String { if (self.offset >= self.table.limit) return null; const string = self.table.get(self.offset); self.offset += 4; // skip length self.offset += @truncate(u32, string.text.len); self.offset += 1; // skip zero terminator return string; } }; }; pub const String = struct { offset: u32, text: [:0]const u8, }; fn hexToBits(comptime str: []const u8) *const [str.len / 2]u8 { comptime { comptime var res: [str.len / 2]u8 = undefined; @setEvalBranchQuota(8 * str.len); inline for (res) |*c, i| { c.* = std.fmt.parseInt(u8, str[2 * i ..][0..2], 16) catch unreachable; } return &res; } } test "parse empty, but valid file" { _ = try View.init(hexToBits("fbadb60200000000000000000000000000000000000000000000000002000000"), .{}); } test "parse invalid header" { // Header too short: try std.testing.expectError(error.InvalidHeader, View.init(hexToBits(""), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidHeader, View.init(hexToBits("f2adb602"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb60200000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb6020000000000000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb60200000000000000000000000000000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb6020000000000000000000000000000000000000000"), .{ .validate_symbols = true })); // invalid/out of bounds header fields: // EEEEEEEEIIIIIIIISSSSSSSSssssssssllllllllBB______ try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602190000000000000000000000000000000000000002000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000001900000000000000000000000000000002000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000019000000000000000000000002000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb6020000000000000000000000001C0000000100000002000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000000000001D00000002000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000000000000000000000000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000000000000000000003000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000000000000000000005000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000000000000000000007000000"), .{ .validate_symbols = true })); try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000000000000000000009000000"), .{ .validate_symbols = true })); // out of bounds table size: // import table try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb6021C00000000000000000000000000000000000000020000000300000001000000020000000300000004000000050000000600000"), .{ .validate_symbols = true })); // export table try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000001C000000000000000000000000000000020000000300000001000000020000000300000004000000050000000600000"), .{ .validate_symbols = true })); // string table // MMMMMMMMEEEEEEEERRRRRRRRIIIIIIIISSSSSSSSssssssssllllllllBB______LLLLLLLLllllllllH e l l o ZZllllllllW o r l d ZZllllllllZ i g i s g r e a t ! ZZ try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000200000000000000000000000020000002A0000000500000048656C6C6F0005000000576F726C64000D0000005A6967206973206772656174210"), .{})); // too short try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000200000000000000000000000020000002A0000000500000048656C6C6F0105000000576F726C64000D0000005A69672069732067726561742100"), .{})); // non-null item try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000200000000000000000000000020000002A0000000500000048656C6C6F0005000000576F726C64020D0000005A69672069732067726561742100"), .{})); // non-null item try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000200000000000000000000000020000002A0000000500000048656C6C6F0005000000576F726C64000D0000005A69672069732067726561742103"), .{})); // non-null item try std.testing.expectError(error.InvalidData, View.init(hexToBits("fbadb602000000000000000000000000200000000000000000000000020000002A0000000500000048656C6C6F0005000000576F726C64000E0000005A6967206973206772656174210000000000000000"), .{})); // item out of table } test "parse string table" { // MMMMMMMMEEEEEEEERRRRRRRRIIIIIIIISSSSSSSSssssssssllllllllBB______LLLLLLLLllllllllH e l l o ZZllllllllW o r l d ZZllllllllZ i g i s g r e a t ! ZZ const view = try View.init(hexToBits("fbadb602000000000000000000000000200000000000000000000000020000002A0000000500000048656C6C6F0005000000576F726C64000D0000005A69672069732067726561742100"), .{}); const table = view.strings() orelse return error.MissingTable; var iter = table.iterator(); try std.testing.expectEqualStrings("Hello", (iter.next() orelse return error.UnexpectedNull).text); try std.testing.expectEqualStrings("World", (iter.next() orelse return error.UnexpectedNull).text); try std.testing.expectEqualStrings("Zig is great!", (iter.next() orelse return error.UnexpectedNull).text); try std.testing.expectEqual(@as(?String, null), iter.next()); } test "parse export table" { // MMMMMMMMEEEEEEEEIIIIIIIIRRRRRRRRSSSSSSSSssssssssllllllllBB______LLLLLLLLNNNNNNN1OOOOOOO1NNNNNNN2OOOOOOO2NNNNNNN3OOOOOOO3LLLLLLLLllllllll..........................ZZ const view = try View.init(hexToBits("fbadb6022000000000000000000000003C00000000000000080000000200000003000000010000000200000003000000040000000500000006000000160000000D000000FFFFFFFFFFFFFFFFFFFFFFFFFF00"), .{}); const sym_1 = Symbol{ .symbol_name = 1, .offset = 2 }; const sym_2 = Symbol{ .symbol_name = 3, .offset = 4 }; const sym_3 = Symbol{ .symbol_name = 5, .offset = 6 }; const table = view.exports() orelse return error.MissingTable; try std.testing.expectEqual(@as(usize, 3), table.count); try std.testing.expectEqual(sym_1, table.get(0)); try std.testing.expectEqual(sym_2, table.get(1)); try std.testing.expectEqual(sym_3, table.get(2)); var iter = table.iterator(); try std.testing.expectEqual(@as(?Symbol, sym_1), iter.next()); try std.testing.expectEqual(@as(?Symbol, sym_2), iter.next()); try std.testing.expectEqual(@as(?Symbol, sym_3), iter.next()); try std.testing.expectEqual(@as(?Symbol, null), iter.next()); } test "parse import table" { // MMMMMMMMEEEEEEEEIIIIIIIIRRRRRRRRSSSSSSSSssssssssllllllllBB______LLLLLLLLNNNNNNN1OOOOOOO1NNNNNNN2OOOOOOO2NNNNNNN3OOOOOOO3LLLLLLLLllllllll..........................ZZ const view = try View.init(hexToBits("fbadb6020000000020000000000000003C00000000000000080000000200000003000000010000000200000003000000040000000500000006000000160000000D000000FFFFFFFFFFFFFFFFFFFFFFFFFF00"), .{}); const sym_1 = Symbol{ .symbol_name = 1, .offset = 2 }; const sym_2 = Symbol{ .symbol_name = 3, .offset = 4 }; const sym_3 = Symbol{ .symbol_name = 5, .offset = 6 }; const table = view.imports() orelse return error.MissingTable; try std.testing.expectEqual(@as(usize, 3), table.count); try std.testing.expectEqual(sym_1, table.get(0)); try std.testing.expectEqual(sym_2, table.get(1)); try std.testing.expectEqual(sym_3, table.get(2)); var iter = table.iterator(); try std.testing.expectEqual(@as(?Symbol, sym_1), iter.next()); try std.testing.expectEqual(@as(?Symbol, sym_2), iter.next()); try std.testing.expectEqual(@as(?Symbol, sym_3), iter.next()); try std.testing.expectEqual(@as(?Symbol, null), iter.next()); } test "parse relocation table" { // we overlap relocations and sections here as it doesn't do any harm // MMMMMMMMEEEEEEEEIIIIIIIIRRRRRRRRSSSSSSSSssssssssllllllllBB______LLLLLLLLaaaaaaaabbbbbbbbcccccccc const view = try View.init(hexToBits("fbadb60200000000000000002000000000000000200000000C0000000200000003000000040000000500000002000000"), .{}); const table = view.relocations() orelse return error.MissingTable; try std.testing.expectEqual(@as(u32, 4), table.get(0)); try std.testing.expectEqual(@as(u32, 5), table.get(1)); try std.testing.expectEqual(@as(u32, 2), table.get(2)); var iter = table.iterator(); try std.testing.expectEqual(@as(?u32, 4), iter.next()); try std.testing.expectEqual(@as(?u32, 5), iter.next()); try std.testing.expectEqual(@as(?u32, 2), iter.next()); try std.testing.expectEqual(@as(?u32, null), iter.next()); } const SymbolName = struct { name: []const u8, offset: u32, }; fn expectSymbol(name: []const u8, offset: u32) SymbolName { return SymbolName{ .name = name, .offset = offset, }; } const SlfExpectation = struct { exports: []const SymbolName = &.{}, imports: []const SymbolName = &.{}, relocs: []const u32 = &.{}, data: []const u8 = "", }; fn expectSlf(dataset: []const u8, expected: SlfExpectation) !void { const view = try View.init(dataset, .{}); const imports = view.imports() orelse return error.UnexpectedData; const exports = view.exports() orelse return error.UnexpectedData; const relocations = view.relocations() orelse return error.UnexpectedData; const strings = view.strings() orelse return error.UnexpectedData; try std.testing.expectEqual(expected.exports.len, exports.count); try std.testing.expectEqual(expected.imports.len, imports.count); try std.testing.expectEqual(expected.relocs.len, relocations.count); _ = strings; // TODO: Implement better result verification try std.testing.expectEqualStrings(expected.data, view.data()); } test "builder api: empty builder" { var buffer: [65536]u8 = undefined; var source = std.io.StreamSource{ .buffer = std.io.fixedBufferStream(&buffer) }; { var builder = try Builder.init(std.testing.allocator, .@"16 bits", &source); defer builder.deinit(); try builder.finalize(); } try expectSlf(source.buffer.getWritten(), .{}); } test "builder api: append data" { var buffer: [65536]u8 = undefined; var source = std.io.StreamSource{ .buffer = std.io.fixedBufferStream(&buffer) }; { var builder = try Builder.init(std.testing.allocator, .@"16 bits", &source); defer builder.deinit(); try builder.append("Hello, World!"); try builder.finalize(); } try expectSlf(source.buffer.getWritten(), .{ .data = "Hello, World!", }); } fn dumpHexStream(dataset: []const u8) void { var i: usize = 0; while (i < dataset.len) { const limit = std.math.min(16, dataset.len - i); std.debug.print("{X:0>8} {}\n", .{ i, std.fmt.fmtSliceHexLower(dataset[i..][0..limit]) }); i += limit; } }
src/slf.zig
const std = @import("std"); const glfw = @import("glfw.zig"); const time = @import("std").time; const fs = @import("fs.zig"); const c = @import("c.zig"); extern fn alkaLoadIcon(window: ?*glfw.Window, path: [*c]const u8) callconv(.C) bool; pub const Error = error{FailedToLoadIcon} || glfw.GLFWError || fs.Error; const alogw = std.log.scoped(.alka_core_window); pub const FrameTime = struct { update: f64 = 0, draw: f64 = 0, delta: f64 = 0, last: f64 = 0, current: f64 = 0, /// Start updating frametime pub fn start(fr: *FrameTime) Error!void { fr.current = try glfw.getTime(); fr.update = fr.current - fr.last; fr.last = fr.current; } /// Stop updating frametime pub fn stop(fr: *FrameTime) Error!void { fr.current = try glfw.getTime(); fr.draw = fr.current - fr.last; fr.last = fr.current; fr.delta = fr.update + fr.draw; } /// Sleep for the sake of cpu pub fn sleep(fr: *FrameTime, targetfps: f64) Error!void { if (fr.delta < targetfps) { const ms = (targetfps - fr.delta) * 1000; const sleep_time = ms * 1000000; time.sleep(@floatToInt(u64, sleep_time)); fr.current = try glfw.getTime(); fr.delta += fr.current - fr.last; fr.last = fr.current; } } }; pub const FpsCalculator = struct { counter: u32 = 0, fps: u32 = 0, last: f64 = 0, /// Calculates the fps pub fn calculate(fp: FpsCalculator, fr: FrameTime) FpsCalculator { var fps = fp; const fuck = fr.current - fps.last; fps.counter += 1; if (fuck >= 1.0) { fps.fps = fps.counter; fps.counter = 0; fps.last = fr.current; } return fps; } }; pub const Info = struct { handle: ?*glfw.Window = null, title: []const u8 = "<Insert Title>", size: Size = Size{}, minsize: Size = Size{}, maxsize: Size = Size{}, position: Position = Position{}, callbacks: Callbacks = Callbacks{}, pub const Size = struct { width: i32 = 1024, height: i32 = 768, }; pub const Position = struct { x: i32 = 0, y: i32 = 0, }; pub const UpdateProperty = enum { size, sizelimits, title, position, all }; pub const Callbacks = struct { close: ?fn (handle: ?*glfw.Window) void = null, resize: ?fn (handle: ?*glfw.Window, w: i32, h: i32) void = null, mousepos: ?fn (handle: ?*glfw.Window, x: f64, y: f64) void = null, mouseinp: ?fn (handle: ?*glfw.Window, key: i32, ac: i32, mods: i32) void = null, keyinp: ?fn (handle: ?*glfw.Window, key: i32, sc: i32, ac: i32, mods: i32) void = null, textinp: ?fn (handle: ?*glfw.Window, codepoint: u32) void = null, }; /// Create the window pub fn create(win: *Info, fullscreen: bool, centered: bool) Error!void { if (win.handle != null) alogw.crit("handle must be null while creating the window! Continuing execution.", .{}); win.handle = try glfw.createWindow(win.size.width, win.size.height, @ptrCast([*:0]const u8, win.title), if (fullscreen) try glfw.getPrimaryMonitor() else null, null); if (centered) { var monitor = try glfw.getPrimaryMonitor(); const videomode = try glfw.getVideoMode(monitor); win.position.x = @divTrunc((videomode.width - win.size.width), 2); win.position.y = @divTrunc((videomode.height - win.size.height), 2); } try win.setCallbacks(); try win.update(UpdateProperty.all); } /// Create the window pub fn createPro(win: *Info, monitor: ?*glfw.Monitor) Error!void { if (win.handle != null) alogw.crit("handle must be null while creating the window! Continuing execution.", .{}); win.handle = try glfw.createWindow(win.size.width, win.size.height, @ptrCast([*:0]const u8, win.title), monitor, null); try win.setCallbacks(); try win.update(UpdateProperty.all); } /// Sets the window callbacks pub fn setCallbacks(win: *Info) Error!void { if (win.callbacks.close != null) { _ = try glfw.setWindowCloseCallback(win.handle, @ptrCast(glfw.WindowCloseFun, win.callbacks.close)); } if (win.callbacks.resize != null) { _ = try glfw.setWindowSizeCallback(win.handle, @ptrCast(glfw.WindowSizeFun, win.callbacks.resize)); } if (win.callbacks.mousepos != null) { _ = try glfw.setCursorPosCallback(win.handle, @ptrCast(glfw.CursorPosFun, win.callbacks.mousepos)); } if (win.callbacks.mouseinp != null) { _ = try glfw.setMouseButtonCallback(win.handle, @ptrCast(glfw.MouseButtonFun, win.callbacks.mouseinp)); } if (win.callbacks.keyinp != null) { _ = try glfw.setKeyCallback(win.handle, @ptrCast(glfw.KeyFun, win.callbacks.keyinp)); } if (win.callbacks.textinp != null) { _ = try glfw.setCharCallback(win.handle, @ptrCast(glfw.CharFun, win.callbacks.textinp)); } } /// Sets the window icon pub fn setIcon(win: *Info, alloc: *std.mem.Allocator, path: []const u8) Error!void { if (win.handle == null) alogw.crit("handle has to be valid when setting the icon of the window! Continuing execution.", .{}); //if (alkaLoadIcon(win.handle, @ptrCast([*c]const u8, path)) == false) return Error.FailedToLoadIcon; const mem = try fs.readFile(alloc, path); defer alloc.free(mem); var img: glfw.Image = undefined; img.pixels = c.stbi_load_from_memory(@ptrCast([*c]const u8, mem), @intCast(i32, mem.len), &img.width, &img.height, null, 4); defer c.stbi_image_free(img.pixels); if (img.pixels == null) { return Error.FailedToLoadIcon; } const images = [1]glfw.Image{img}; try glfw.setWindowIcon(win.handle, images.len, &images); } /// Destroys the window pub fn destroy(win: *Info) Error!void { if (win.handle == null) alogw.crit("handle has to be valid when destroying the window! Continuing execution.", .{}); try glfw.destroyWindow(win.handle); win.handle = null; } /// Updates the properties pub fn update(win: *Info, p: UpdateProperty) Error!void { switch (p) { UpdateProperty.size => { try glfw.setWindowSize(win.handle, win.size.width, win.size.height); }, UpdateProperty.sizelimits => { try glfw.setWindowSizeLimits(win.handle, win.minsize.width, win.minsize.height, win.maxsize.width, win.maxsize.height); }, UpdateProperty.title => { try glfw.setWindowTitle(win.handle, @ptrCast([*:0]const u8, win.title)); }, UpdateProperty.position => { try glfw.setWindowPos(win.handle, win.position.x, win.position.y); }, UpdateProperty.all => { try glfw.setWindowSize(win.handle, win.size.width, win.size.height); try glfw.setWindowSizeLimits(win.handle, win.minsize.width, win.minsize.height, win.maxsize.width, win.maxsize.height); try glfw.setWindowTitle(win.handle, @ptrCast([*:0]const u8, win.title)); try glfw.setWindowPos(win.handle, win.position.x, win.position.y); }, } } };
src/core/window.zig
const std = @import("std"); const stdx = @import("stdx"); const t = stdx.testing; const graphics = @import("graphics"); const Graphics = graphics.Graphics; const FontId = graphics.FontId; const StdColor = graphics.Color; const Vec2 = stdx.math.Vec2; const vec2 = Vec2.init; const Mat4 = stdx.math.Mat4; const v8 = @import("v8"); const runtime = @import("runtime.zig"); const RuntimeContext = runtime.RuntimeContext; const adapter = @import("adapter.zig"); const ManagedStruct = adapter.ManagedStruct; const This = adapter.This; const ThisValue = adapter.ThisValue; const Handle = adapter.Handle; const RuntimeValue = runtime.RuntimeValue; const v8x = @import("v8x.zig"); const log = stdx.log.scoped(.api_graphics); /// @title Graphics /// @name graphics /// @ns cs.graphics /// Provides a cross platform API to draw lines, shapes, text, images, and other graphics onto a window or buffer. /// By default, the coordinate system assumes the origin is at the top-left corner (0, 0). Positive x values go right and positive y values go down. /// Angle units like radians and degrees start at 0 and positive values go clockwise. /// The backend uses OpenGL 3 on desktop and Canvas/WebGL for web. Support for WebGPU is planned. /// Currently, the API is focused on 2D graphics, but there are plans to add 3D graphics utilities. pub const cs_graphics = struct { /// This provides an interface to the underlying graphics handle. It has a similar API to Web Canvas. pub const Context = struct { /// Returns the FontId of "Bitstream Vera Sans" the default font embedded into the runtime. pub inline fn defaultFont(self: *Graphics) FontId { return self.getDefaultFontId(); } /// Sets the current fill color for painting shapes. /// @param color pub inline fn fillColor(self: *Graphics, color: Color) void { return self.setFillColor(toStdColor(color)); } /// Returns the current fill color. pub inline fn getFillColor(self: *Graphics) Color { return fromStdColor(self.getFillColor()); } /// Sets the current stroke color for painting shape outlines. /// @param color pub inline fn strokeColor(self: *Graphics, color: Color) void { return self.setStrokeColor(toStdColor(color)); } /// Returns the current stroke color. pub inline fn getStrokeColor(self: *Graphics) Color { return fromStdColor(self.getStrokeColor()); } /// Sets the current line width for painting shape outlines. /// @param width pub inline fn lineWidth(self: *Graphics, width: f32) void { return self.setLineWidth(width); } /// Returns the current line width. pub inline fn getLineWidth(self: *Graphics) f32 { return self.getLineWidth(); } /// Path can be absolute or relative to the cwd. /// @param path pub fn addTtfFont(rt: *RuntimeContext, g: *Graphics, path: []const u8) graphics.FontId { return g.addFontFromPathTTF(path) catch |err| { if (err == error.FileNotFound) { v8x.throwErrorExceptionFmt(rt.alloc, rt.isolate, "Could not find file: {s}", .{path}); return 0; } else { unreachable; } }; } /// @param fontId pub inline fn addFallbackFont(self: *Graphics, font_id: FontId) void { self.addFallbackFont(font_id); } /// Path can be absolute or relative to the cwd. /// @param path pub fn newImage(rt: *RuntimeContext, g: *Graphics, path: []const u8) graphics.Image { return g.createImageFromPath(path) catch |err| { if (err == error.FileNotFound) { v8x.throwErrorExceptionFmt(rt.alloc, rt.isolate, "Could not find file: {s}", .{path}); return undefined; } else { unreachable; } }; } /// Paints a rectangle with the current fill color. /// @param x /// @param y /// @param width /// @param height pub inline fn rect(self: *Graphics, x: f32, y: f32, width: f32, height: f32) void { Graphics.fillRect(self, x, y, width, height); } /// Paints a rectangle outline with the current stroke color. /// @param x /// @param y /// @param width /// @param height pub inline fn rectOutline(self: *Graphics, x: f32, y: f32, width: f32, height: f32) void { Graphics.drawRect(self, x, y, width, height); } /// Paints a round rectangle with the current fill color. /// @param x /// @param y /// @param width /// @param height /// @param radius pub inline fn roundRect(self: *Graphics, x: f32, y: f32, width: f32, height: f32, radius: f32) void { self.fillRoundRect(x, y, width, height, radius); } /// Paints a round rectangle outline with the current stroke color. /// @param x /// @param y /// @param width /// @param height /// @param radius pub inline fn roundRectOutline(self: *Graphics, x: f32, y: f32, width: f32, height: f32, radius: f32) void { self.drawRoundRect(x, y, width, height, radius); } /// Shifts the origin x units to the right and y units down. /// @param x /// @param y pub inline fn translate(self: *Graphics, x: f32, y: f32) void { Graphics.translate(self, x, y); } /// Scales from the origin x units horizontally and y units vertically. /// Negative value flips the axis. Value of 1 does nothing. /// @param x /// @param y pub inline fn scale(self: *Graphics, x: f32, y: f32) void { Graphics.scale(self, x, y); } /// Rotates the origin by radians clockwise. /// @param rad pub inline fn rotate(self: *Graphics, rad: f32) void { Graphics.rotate(self, rad); } /// Rotates the origin by degrees clockwise. /// @param deg pub inline fn rotateDeg(self: *Graphics, deg: f32) void { self.rotateDeg(deg); } /// Resets the current transform to identity. pub inline fn resetTransform(self: *Graphics) void { self.resetTransform(); } /// Saves the current graphics state by pushing onto a stack. pub inline fn pushState(self: *Graphics) void { self.pushState(); } /// Restores the graphics state on top of the stack. pub inline fn popState(self: *Graphics) void { self.popState(); } /// Given logical 2D coordinates, return the interpolation to screen coordinates with the current transform. pub inline fn getViewTransform(self: *Graphics) Transform { return Transform{ .mat = self.getViewTransform().mat }; } /// Sets the current font and font size. /// @param fontId /// @param size pub inline fn font(self: *Graphics, font_id: FontId, font_size: f32) void { self.setFont(font_id, font_size); } /// Sets the current font size. /// @param size pub inline fn fontSize(self: *Graphics, font_size: f32) void { self.setFontSize(font_size); } /// Sets the current text align. /// @param align pub inline fn textAlign(self: *Graphics, align_: TextAlign) void { const std_align = toStdTextAlign(align_); return self.setTextAlign(std_align); } /// Sets the current text baseline. /// @param baseline pub inline fn textBaseline(self: *Graphics, baseline: TextBaseline) void { const std_baseline = toStdTextBaseline(baseline); return self.setTextBaseline(std_baseline); } /// Paints text with the current fill color. /// @param x /// @param y /// @param text pub inline fn text(self: *Graphics, x: f32, y: f32, str: []const u8) void { self.fillText(x, y, str); } /// Paints a circle sector in radians with the current fill color. /// @param x /// @param y /// @param radius /// @param startRad /// @param sweepRad pub inline fn circleSector(self: *Graphics, x: f32, y: f32, radius: f32, start_rad: f32, sweep_rad: f32) void { self.fillCircleSector(x, y, radius, start_rad, sweep_rad); } /// Paints a circle sector in degrees with the current fill color. /// @param x /// @param y /// @param radius /// @param startDeg /// @param sweepDeg pub inline fn circleSectorDeg(self: *Graphics, x: f32, y: f32, radius: f32, start_deg: f32, sweep_deg: f32) void { self.fillCircleSectorDeg(x, y, radius, start_deg, sweep_deg); } /// Paints a circle arc in radians with the current stroke color. /// @param x /// @param y /// @param radius /// @param startRad /// @param sweepRad pub inline fn circleArc(self: *Graphics, x: f32, y: f32, radius: f32, start_rad: f32, sweep_rad: f32) void { self.drawCircleArc(x, y, radius, start_rad, sweep_rad); } /// Paints a circle arc in degrees with the current stroke color. /// @param x /// @param y /// @param radius /// @param startDeg /// @param sweepDeg pub inline fn circleArcDeg(self: *Graphics, x: f32, y: f32, radius: f32, start_deg: f32, sweep_deg: f32) void { self.drawCircleArcDeg(x, y, radius, start_deg, sweep_deg); } /// Paints a circle with the current fill color. /// @param x /// @param y /// @param radius pub inline fn circle(self: *Graphics, x: f32, y: f32, radius: f32) void { self.fillCircle(x, y, radius); } /// Paints a circle outline with the current stroke color. /// @param x /// @param y /// @param radius pub inline fn circleOutline(self: *Graphics, x: f32, y: f32, radius: f32) void { self.drawCircle(x, y, radius); } /// Paints a ellipse with the current fill color. /// @param x /// @param y /// @param hRadius /// @param vRadius pub inline fn ellipse(self: *Graphics, x: f32, y: f32, h_radius: f32, v_radius: f32) void { self.fillEllipse(x, y, h_radius, v_radius); } /// Paints a ellipse outline with the current stroke color. /// @param x /// @param y /// @param hRadius /// @param vRadius pub inline fn ellipseOutline(self: *Graphics, x: f32, y: f32, h_radius: f32, v_radius: f32) void { self.drawEllipse(x, y, h_radius, v_radius); } /// Paints a ellipse sector in radians with the current fill color. /// @param x /// @param y /// @param hRadius /// @param vRadius /// @param startRad /// @param sweepRad pub inline fn ellipseSector(self: *Graphics, x: f32, y: f32, h_radius: f32, v_radius: f32, start_rad: f32, sweep_rad: f32) void { self.fillEllipseSector(x, y, h_radius, v_radius, start_rad, sweep_rad); } /// Paints a ellipse sector in degrees with the current fill color. /// @param x /// @param y /// @param hRadius /// @param vRadius /// @param startDeg /// @param sweepDeg pub inline fn ellipseSectorDeg(self: *Graphics, x: f32, y: f32, h_radius: f32, v_radius: f32, start_deg: f32, sweep_deg: f32) void { self.fillEllipseSectorDeg(x, y, h_radius, v_radius, start_deg, sweep_deg); } /// Paints a ellipse arc in radians with the current stroke color. /// @param x /// @param y /// @param hRadius /// @param vRadius /// @param startRad /// @param sweepRad pub inline fn ellipseArc(self: *Graphics, x: f32, y: f32, h_radius: f32, v_radius: f32, start_rad: f32, sweep_rad: f32) void { self.drawEllipseArc(x, y, h_radius, v_radius, start_rad, sweep_rad); } /// Paints a ellipse arc in degrees with the current stroke color. /// @param x /// @param y /// @param hRadius /// @param vRadius /// @param startDeg /// @param sweepDeg pub inline fn ellipseArcDeg(self: *Graphics, x: f32, y: f32, h_radius: f32, v_radius: f32, start_deg: f32, sweep_deg: f32) void { self.drawEllipseArcDeg(x, y, h_radius, v_radius, start_deg, sweep_deg); } /// Paints a point with the current stroke color. /// @param x /// @param y pub inline fn point(self: *Graphics, x: f32, y: f32) void { self.drawPoint(x, y); } /// Paints a line with the current stroke color. /// @param x1 /// @param y1 /// @param x2 /// @param y2 pub inline fn line(self: *Graphics, x1: f32, y1: f32, x2: f32, y2: f32) void { self.drawLine(x1, y1, x2, y2); } /// Paints a cubic bezier curve with the current stroke color. /// @param x1 /// @param y1 /// @param c1x /// @param c1y /// @param c2x /// @param c2y /// @param x2 /// @param y2 pub inline fn cubicBezierCurve(self: *Graphics, x1: f32, y1: f32, c1x: f32, c1y: f32, c2x: f32, c2y: f32, x2: f32, y2: f32) void { self.drawCubicBezierCurve(x1, y1, c1x, c1y, c2x, c2y, x2, y2); } /// Paints a quadratic bezier curve with the current stroke color. /// @param x1 /// @param y1 /// @param cx /// @param cy /// @param x2 /// @param y2 pub inline fn quadraticBezierCurve(self: *Graphics, x1: f32, y1: f32, cx: f32, cy: f32, x2: f32, y2: f32) void { self.drawQuadraticBezierCurve(x1, y1, cx, cy, x2, y2); } /// Paints a triangle with the current fill color. /// @param x1 /// @param y1 /// @param x2 /// @param y2 /// @param x3 /// @param y3 pub inline fn triangle(self: *Graphics, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32) void { self.fillTriangle(x1, y1, x2, y2, x3, y3); } /// Paints a convex polygon with the current fill color. /// @param pts pub fn convexPolygon(rt: *RuntimeContext, g: *Graphics, pts: []const f32) void { rt.vec2_buf.resize(pts.len / 2) catch unreachable; var i: u32 = 0; var vec_idx: u32 = 0; while (i < pts.len - 1) : ({ i += 2; vec_idx += 1; }) { rt.vec2_buf.items[vec_idx] = Vec2.init(pts[i], pts[i + 1]); } g.fillConvexPolygon(rt.vec2_buf.items); } /// Paints any polygon with the current fill color. /// @param pts pub fn polygon(rt: *RuntimeContext, g: *Graphics, pts: []const f32) void { rt.vec2_buf.resize(pts.len / 2) catch unreachable; var i: u32 = 0; var vec_idx: u32 = 0; while (i < pts.len - 1) : ({ i += 2; vec_idx += 1; }) { rt.vec2_buf.items[vec_idx] = Vec2.init(pts[i], pts[i + 1]); } g.fillPolygon(rt.vec2_buf.items); } /// Paints any polygon outline with the current stroke color. /// @param pts pub fn polygonOutline(rt: *RuntimeContext, g: *Graphics, pts: []const f32) void { rt.vec2_buf.resize(pts.len / 2) catch unreachable; var i: u32 = 0; var vec_idx: u32 = 0; while (i < pts.len - 1) : ({ i += 2; vec_idx += 1; }) { rt.vec2_buf.items[vec_idx] = Vec2.init(pts[i], pts[i + 1]); } g.drawPolygon(rt.vec2_buf.items); } /// Compiles svg content string into a draw list handle. /// @param content pub fn compileSvgContent(rt: *RuntimeContext, g: *Graphics, content: []const u8) v8.Object { const ptr = rt.alloc.create(graphics.DrawCommandList) catch unreachable; ptr.* = g.compileSvgContent(rt.alloc, content) catch unreachable; return runtime.createWeakHandle(rt, .DrawCommandList, ptr); } /// Paints svg content in UTF-8. /// @param content pub fn svgContent(g: *Graphics, content: []const u8) void { g.drawSvgContent(content) catch unreachable; } /// Executes a draw list handle. /// @param handle pub fn executeDrawList(g: *Graphics, list: Handle(.DrawCommandList)) void { g.executeDrawList(list.ptr.*); } /// Paints an image. /// @param x /// @param y /// @param width /// @param height /// @param image pub fn imageSized(g: *Graphics, x: f32, y: f32, width: f32, height: f32, image: graphics.Image) void { g.drawImageSized(x, y, width, height, image.id); } }; pub const TextAlign = enum { pub const Default = .left; left, center, right, }; pub const TextBaseline = enum { pub const Default = .top; top, middle, alphabetic, bottom, }; pub const Transform = struct { mat: Mat4, pub fn interpolate(this: ThisValue(Transform), x: f32, y: f32) Vec2 { const native = graphics.transform.Transform{ .mat = this.val.mat }; return native.interpolatePt(vec2(x, y)); } }; pub const Color = struct { r: u8, g: u8, b: u8, a: u8, pub const lightGray = fromStdColor(StdColor.LightGray); pub const gray = fromStdColor(StdColor.Gray); pub const darkGray = fromStdColor(StdColor.DarkGray); pub const yellow = fromStdColor(StdColor.Yellow); pub const gold = fromStdColor(StdColor.Gold); pub const orange = fromStdColor(StdColor.Orange); pub const pink = fromStdColor(StdColor.Pink); pub const red = fromStdColor(StdColor.Red); pub const maroon = fromStdColor(StdColor.Maroon); pub const green = fromStdColor(StdColor.Green); pub const lime = fromStdColor(StdColor.Lime); pub const darkGreen = fromStdColor(StdColor.DarkGreen); pub const skyBlue = fromStdColor(StdColor.SkyBlue); pub const blue = fromStdColor(StdColor.Blue); pub const royalBlue = fromStdColor(StdColor.RoyalBlue); pub const darkBlue = fromStdColor(StdColor.DarkBlue); pub const purple = fromStdColor(StdColor.Purple); pub const violet = fromStdColor(StdColor.Violet); pub const darkPurple = fromStdColor(StdColor.DarkPurple); pub const beige = fromStdColor(StdColor.Beige); pub const brown = fromStdColor(StdColor.Brown); pub const darkBrown = fromStdColor(StdColor.DarkBrown); pub const white = fromStdColor(StdColor.White); pub const black = fromStdColor(StdColor.Black); pub const transparent = fromStdColor(StdColor.Transparent); pub const magenta = fromStdColor(StdColor.Magenta); pub fn lighter(rt: *RuntimeContext, this: This) cs_graphics.Color { // TODO: Implement ThisStruct and generate the getNativeValue logic. const color = rt.getNativeValue(cs_graphics.Color, this.obj.toValue()) catch unreachable; return fromStdColor(toStdColor(color).lighter()); } pub fn darker(rt: *RuntimeContext, this: This) cs_graphics.Color { const color = rt.getNativeValue(cs_graphics.Color, this.obj.toValue()) catch unreachable; return fromStdColor(toStdColor(color).darker()); } /// @param alpha pub fn withAlpha(rt: *RuntimeContext, this: This, a: u8) cs_graphics.Color { const color = rt.getNativeValue(cs_graphics.Color, this.obj.toValue()) catch unreachable; return fromStdColor(toStdColor(color).withAlpha(a)); } }; /// Converts HSV to RGB. Hue is in degrees [0,100] and saturation/value are [0,1]. /// @param hue /// @param sat /// @param val pub fn hsvToRgb(hue: f32, sat: f32, val: f32) cs_graphics.Color { // Make sure sat/val are clamped. const color = StdColor.fromHsv(hue, std.math.clamp(sat, 0, 1), std.math.clamp(val, 0, 1)); return fromStdColor(color); } test "hsvToRgb" { // Test sat/val clamping. try t.eq(hsvToRgb(180, 1.2, -300), hsvToRgb(180, 1, 0)); } }; fn fromStdColor(color: StdColor) cs_graphics.Color { return .{ .r = color.channels.r, .g = color.channels.g, .b = color.channels.b, .a = color.channels.a }; } fn toStdColor(color: cs_graphics.Color) StdColor { return .{ .channels = .{ .r = color.r, .g = color.g, .b = color.b, .a = color.a } }; } fn toStdTextAlign(align_: cs_graphics.TextAlign) graphics.TextAlign { return switch (align_) { .left => .Left, .center => .Center, .right => .Right, }; } fn toStdTextBaseline(align_: cs_graphics.TextBaseline) graphics.TextBaseline { return switch (align_) { .top => .Top, .middle => .Middle, .alphabetic => .Alphabetic, .bottom => .Bottom, }; } pub fn debugTriangulatePolygon(rt: *RuntimeContext, g: *Graphics, pts: []const f32) void { rt.vec2_buf.resize(pts.len / 2) catch unreachable; var i: u32 = 0; var vec_idx: u32 = 0; while (i < pts.len - 1) : ({ i += 2; vec_idx += 1; }) { rt.vec2_buf.items[vec_idx] = Vec2.init(pts[i], pts[i + 1]); } g.impl.tessellator.clearBuffers(); g.impl.tessellator.debugTriangulatePolygons(&.{rt.vec2_buf.items}); } pub fn debugTriangulateProcessNext(rt: *RuntimeContext, g: *Graphics) ?ManagedStruct(graphics.tessellator.DebugTriangulateStepResult) { const res = g.impl.tessellator.debugProcessNext(rt.alloc) orelse return null; return ManagedStruct(graphics.tessellator.DebugTriangulateStepResult).init(rt.alloc, res); } pub fn executeDrawListLyon(g: *Graphics, list: Handle(.DrawCommandList)) void { g.executeDrawListLyon(list.ptr.*); } pub fn executeDrawListTess2(g: *Graphics, list: Handle(.DrawCommandList)) void { g.executeDrawListTess2(list.ptr.*); }
runtime/api_graphics.zig
const std = @import("std"); const stderr = std.debug.warn; const test_data = @embedFile("test_cases.dat"); const llr = @import("llr.zig"); const fermat = @import("fermat.zig"); const helper = @import("helper.zig"); // LLR test expects n not to be too small in relation to k const MIN_N: u32 = 11; pub fn run(max_n: u32) !void { const State = enum(u8) { ReadingK, ReadingN, }; stderr("maxn: {}\n", .{max_n}); var current_k: u32 = 0; var current_n: u32 = 0; var previous_n: u32 = 0; var state = State.ReadingK; // parse the test data byte-by-byte // zig doesn't seem to have much for string processing var buf: [9:0]u8 = undefined; var buf_ptr: u32 = 0; var skip_next: u32 = 0; var testcase_ready = false; var positive_tests_run: u32 = 0; var negative_tests_run: u32 = 0; var negative_fermat_failures: u32 = 0; var failures: u32 = 0; for (test_data) |b| { // should end reading number and parse it if (skip_next > 0) { skip_next -= 1; continue; } if (b == ' ' or b == '\n') { const read_nr = @intCast(u32, try helper.parseU64(buf[0..buf_ptr], 10)); buf_ptr = 0; switch (state) { State.ReadingK => { //stderr("setting k={}\n", .{read_nr}); current_k = read_nr; state = State.ReadingN; skip_next = 2; }, State.ReadingN => { previous_n = current_n; current_n = read_nr; if (b == '\n') { state = State.ReadingK; } if (current_n >= MIN_N and current_n <= max_n) { //stderr("setting n={}\n", .{read_nr}); testcase_ready = true; } }, } } else { buf[buf_ptr] = b; buf_ptr += 1; } if (testcase_ready) { stderr("\n", .{}); testcase_ready = false; positive_tests_run += 1; stderr("##### testing positive case k:{} n:{} #####\n", .{ current_k, current_n }); const positive_case_llr = try llr.full_llr_run(current_k, 2, current_n, -1, 1); const positive_case_fermat = try fermat.full_fermat_run(current_k, 2, current_n, -1, 1); const positive_case = positive_case_llr and positive_case_fermat; stderr("\n##### testing negative case k:{} n:{} [{}-1] #####\n", .{ current_k, current_n - 1, current_n }); const negative_case_llr = blk: { if (current_n - 1 != previous_n) { negative_tests_run += 1; break :blk try llr.full_llr_run(current_k, 2, current_n - 1, -1, 1); } else { break :blk false; } }; const negative_case_fermat = blk: { if (current_n - 1 != previous_n) { break :blk try fermat.full_fermat_run(current_k, 2, current_n - 1, -1, 1); } else { break :blk false; } }; if (negative_case_fermat) { negative_fermat_failures += 1; } if (positive_case != true or negative_case_llr != false) { failures += 1; stderr("--TEST FAILED-- {}*2^{}-1 pos case?: {} llr_neg?: {}\n", .{ current_k, current_n, positive_case, negative_case_llr }); //return; } else { stderr("##### k:{} n:{} vs. n:{} checks out #####\n", .{ current_k, current_n, current_n - 1 }); } } } if (failures > 0) { stderr("TESTS COMPLETED! {} failures\n", .{failures}); } else { stderr("TESTS COMPLETED! all good\n", .{}); } stderr("total pos: {} neg: {} fermat liars: {} [0 is the best possible result]\n", .{ positive_tests_run, negative_tests_run, negative_fermat_failures }); }
selftest.zig
const std = @import("std"); pub const Cats = @import("../../components.zig").DerivedGeneralCategory; pub const Numeric = @import("../../components.zig").DerivedNumericType; pub const Props = @import("../../components.zig").PropList; // isDecimal detects all Unicode decimal numbers. pub fn isDecimal(cp: u21) bool { // ASCII optimization. if (cp >= '0' and cp <= '9') return true; return Numeric.isDecimal(cp); } // isDigit detects all Unicode digits.. pub fn isDigit(cp: u21) bool { // ASCII optimization. if (cp >= '0' and cp <= '9') return true; return Numeric.isDigit(cp) or isDecimal(cp); } /// isAsciiDigit detects ASCII only digits. pub fn isAsciiDigit(cp: u21) bool { return cp >= '0' and cp <= '9'; } // isHex detects the 16 ASCII characters 0-9 A-F, and a-f. pub fn isHexDigit(cp: u21) bool { // ASCII optimization. if ((cp >= 'a' and cp <= 'f') or (cp >= 'A' and cp <= 'F') or (cp >= '0' and cp <= '9')) return true; return Props.isHexDigit(cp); } /// isAsciiHexDigit detects ASCII only hexadecimal digits. pub fn isAsciiHexDigit(cp: u21) bool { return (cp >= 'a' and cp <= 'f') or (cp >= 'A' and cp <= 'F') or (cp >= '0' and cp <= '9'); } /// isNumber covers all Unicode numbers, not just ASII. pub fn isNumber(cp: u21) bool { // ASCII optimization. if (cp >= '0' and cp <= '9') return true; return isDecimal(cp) or isDigit(cp) or Cats.isLetterNumber(cp) or Cats.isOtherNumber(cp); } /// isAsciiNumber detects ASCII only numbers. pub fn isAsciiNumber(cp: u21) bool { return cp >= '0' and cp <= '9'; } const expect = std.testing.expect; test "Component isDecimal" { var cp: u21 = '0'; while (cp <= '9') : (cp += 1) { try expect(isDecimal(cp)); try expect(isAsciiDigit(cp)); try expect(isAsciiNumber(cp)); } try expect(!isDecimal('\u{0003}')); try expect(!isDecimal('A')); } test "Component isHexDigit" { var cp: u21 = '0'; while (cp <= '9') : (cp += 1) { try expect(isHexDigit(cp)); } try expect(!isHexDigit('\u{0003}')); try expect(!isHexDigit('Z')); } test "Component isNumber" { var cp: u21 = '0'; while (cp <= '9') : (cp += 1) { try expect(isNumber(cp)); } try expect(!isNumber('\u{0003}')); try expect(!isNumber('A')); }
src/components/aggregate/Number.zig
const std = @import("std"); const assert = std.debug.assert; const warn = std.debug.warn; const builtin = @import("builtin"); const TypeId = builtin.TypeId; test "u0" { //warn("\n"); var usize1: usize = undefined; var usize2: usize = undefined; // Test with u1 var one: u1 = 1; assert(one == 1); assert(@sizeOf(@typeOf(one)) == 1); assert(@sizeOf(u1) == 1); assert(@intCast(u8, one) == 1); var pOne: *u1 = &one; var pOne2: *u1 = &one; assert(pOne.* == pOne2.*); assert(pOne == &one); assert(pOne2 == &one); assert(pOne == pOne2); assert(&pOne != &pOne2); usize1 = @ptrToInt(pOne); usize2 = @ptrToInt(pOne2); assert(usize1 == usize2); usize1 = @ptrToInt(&pOne); usize2 = @ptrToInt(&pOne2); assert(usize1 != usize2); var pOneOptional: ?*u1 = &one; var pOneOptional2: ?*u1 = &one; assert(pOneOptional == pOneOptional2); assert(&pOneOptional != &pOneOptional2); assert(pOneOptional != null); assert(pOneOptional == &one); if (pOneOptional != null) { assert(pOneOptional.?.* == 1); } else { unreachable; } // "Same" tests with u0: // These are expected results var zero: u0 = 0; assert(zero == 0); assert(@sizeOf(@typeOf(zero)) == 0); assert(@sizeOf(u0) == 0); assert(@intCast(u8, zero) == 0); // These are expected results expect the last one assert(&pZero == &pZero2) var pZero = &zero; var pZero2 = &zero; assert(pZero.* == pZero2.*); assert(pZero == &zero); assert(pZero2 == &zero); assert(pZero == pZero2); // Unexpected, the addresses assert(&pZero == &pZero2); // I'd expect assert(&pZero != &pZero2); // Unexpected, Below when trying to convert pZero to int it says: // "pointer to size 0 type has no address" // This is unexpected especially since in the above I can "take an address" //usize1 = @ptrToInt(pZero); // compile error: pointer to size 0 type has no address //usize2 = @ptrToInt(pZero2); // compile error: pointer to size 0 type has no address //assert(usize1 == usize2); //usize1 = @ptrToInt(&pZero); // compile error: pointer to size 0 type has no address //usize2 = @ptrToInt(&pZero2); // compile error: pointer to size 0 type has no address //assert(usize1 != usize2); // These are expected results var pZeroOptional: ?*u0 = &zero; var pZeroOptional2: ?*u0 = &zero; assert(pZeroOptional == pZeroOptional2); assert(&pZeroOptional != &pZeroOptional2); assert(pZeroOptional != null); assert(pZeroOptional == &zero); if (pZeroOptional != null) { assert(pZeroOptional.?.* == 0); } else { unreachable; } // Unexpected, using "packed" causes a compiler error // zig: ../src/analyze.cpp:499: ZigType* get_pointer_to_type_extra(CodeGen*, ZigType*, bool, bool, PtrLen, uint32_t, uint32_t, uint32_t): Assertion `byte_alignment == 0' failed. // Aborted (core dumped) //const Su0 = packed struct { const Su0 = struct { f0: u8, z1: u0, z2: u0, }; // These are expected var su0 = Su0 { .f0 = 0, .z1 = 0, .z2 = 0 }; assert(@sizeOf(Su0) == 1); assert(su0.z1 == 0); assert(su0.z2 == 0); assert(su0.z1 == su0.z2); assert(&su0.z1 == &su0.z2); var pZ1 = &su0.z1; var pZ2 = &su0.z2; assert(pZ1 == pZ2); assert(pZ1.* == 0); assert(pZ2.* == 0); assert(pZ1.* == pZ2.*); var pSu0 = &su0; var pSu0_u8 = @ptrCast(*align(1) u8, pSu0); var pSu0_f0_u8 = @ptrCast(*align(1) u8, &pSu0.f0); assert(pSu0_u8 == pSu0_f0_u8); var f0_offset: usize = @offsetOf(Su0, "f0"); assert(f0_offset == 0); // Unexpected, If I can take an address of su0.z1 and su0.z1 and assert(pZ1 == pZ2) // then I should be able to get its offset and su0.z2 offset and assert(z1_offset == z2_offset). //var z1_offset: usize @offsetOf(Su0, "z1"); // compile error: zero-bit field 'z1' in struct 'Su0' has no offset //var z2_offset: usize @offsetOf(Su0, "z2"); // compile error: zero-bit field 'z1' in struct 'Su0' has no offset //assert(z1_offset == z2_offset); // My expectation? // Unexpected //usize1 = @ptrToInt(pZ1); // compile error: pointer to size 0 type has no address //usize2 = @ptrToInt(pZ2); // compile error: pointer to size 0 type has no address //assert(usize1 == usize2); } fn x() u0 { var zero: u0 = 0; return zero; } test "fn x() u0" { assert(x() == 0); var result = x(); //var result = @noInlineCall(x()); // Unexpected, compiler error: type 'u0' not a function assert(result == 0); }
u0-tests.zig
const w4 = @import("../wasm4.zig"); const buttons = @import("../components/button.zig"); const Situation = @import("../components/situation.zig").Situation; const std = @import("std"); const textWrap = @import("../components/wrapping-text.zig").textWrap; const gamepad = @import("../gamepad.zig"); const statemachine = @import("../state-machine.zig"); const sprites = @import("../assets/sprites.zig"); const boris = sprites.boris; const flag = sprites.flag; const MENU_HEIGHT: u8 = 50; const SCREEN_SIZE: u8 = 160; const X_OFFSET: u8 = 2; pub const menu_options = [_]Situation{Situation{ .menu = "Party/nLines", .options = [3][]const u8{ "start", "Tutorialial", "Credits" } }}; pub const Menu = struct { selection: u8 = 0, buttons: [2]buttons.Button = [_]buttons.Button{ buttons.Button{ .text = "Start" }, buttons.Button{ .text = "Tutorial" } }, art_ticks: u32 = 0, pub fn init() Menu { return Menu{}; } pub fn draw(self: *@This()) void { // set draw colour for the buttons w4.DRAW_COLORS.* = 0x42; w4.text("Crossing Party\nLines", 20, 10); w4.DRAW_COLORS.* = 0x24; var i: u8 = 0; for (self.buttons) |btn, index| { i = @intCast(u8, index); btn.draw( // button location fixed for now X_OFFSET * 4, MENU_HEIGHT + i * 17 + X_OFFSET * 4, i == self.selection); } var xOff: u32 = 0; if (self.art_ticks % 20 > 10) { xOff = 16; } w4.DRAW_COLORS.* = 0x0432; w4.blitSub(boris.data, 100, 32, // x, y boris.height, boris.height, // w, h; Assumes square xOff, 0, // src_x, src_y boris.width, // Assumes stride and width are equal boris.flags); w4.blitSub(flag.data, 120, 32, // x, y flag.height, flag.height, // w, h; Assumes square xOff, 0, // src_x, src_y flag.width, // Assumes stride and width are equal flag.flags); self.art_ticks += 1; } pub fn update(self: *@This(), state: *statemachine.StateMachine, pl: *const gamepad.GamePad) void { self.handleInput(state, pl); self.draw(); } fn handleInput(self: *@This(), state: *statemachine.StateMachine, pl: *const gamepad.GamePad) void { if (pl.isPressed(w4.BUTTON_DOWN)) { if (self.selection >= 1) { // do nothing } else { self.selection += 1; } } if (pl.isPressed(w4.BUTTON_UP)) { if (self.selection <= 0) { // do nothing } else { self.selection -= 1; } } if (pl.isPressed(w4.BUTTON_1)) { if (self.selection == 0) { state.change(.AT_PARTY); } else { state.change(.START_SCREEN); } } } };
src/screens/main-menu.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = 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/puzzle/day09.txt"); fn fill_basin(map: [150][150]u64, basins: *[150][150]u64, ridx: u64, cidx: u64, bidx: u64, n: u64, m: u64) u64 { var size: u64 = 1; var cell = map[ridx][cidx]; if (basins[ridx][cidx] != 0) return 0; basins[ridx][cidx] = bidx; if (ridx > 0 and map[ridx - 1][cidx] > cell and map[ridx - 1][cidx] < 9) { size += fill_basin(map, basins, ridx - 1, cidx, bidx, n, m); } if (ridx < n - 1 and map[ridx + 1][cidx] > cell and map[ridx + 1][cidx] < 9) { size += fill_basin(map, basins, ridx + 1, cidx, bidx, n, m); } if (cidx > 0 and map[ridx][cidx - 1] > cell and map[ridx][cidx - 1] < 9) { size += fill_basin(map, basins, ridx, cidx - 1, bidx, n, m); } if (cidx < m - 1 and map[ridx][cidx + 1] > cell and map[ridx][cidx + 1] < 9) { size += fill_basin(map, basins, ridx, cidx + 1, bidx, n, m); } return size; } pub fn main() !void { var map: [150][150]u64 = [_][150]u64{[_]u64{0} ** 150} ** 150; var basins: [150][150]u64 = [_][150]u64{[_]u64{0} ** 150} ** 150; var sizes = ArrayList(u64).init(gpa); defer sizes.deinit(); var lines = tokenize(data, "\r\n"); var total_sum: u64 = 0; var rridx: u64 = 0; var n: u64 = 0; var m: u64 = 0; while (lines.next()) |line| : (rridx += 1) { for (line) |char, cidx| { map[rridx][cidx] = char - '0'; if (cidx > m) m = cidx; } } n = rridx; m += 1; print("{} {}\n", .{ n, m }); var basin_idx: u64 = 1; for (map) |row, ridx| { if (ridx == n) break; for (row) |cell, cidx| { if (cidx == m) break; if (ridx > 0 and map[ridx - 1][cidx] <= cell) continue; if (ridx < n - 1 and map[ridx + 1][cidx] <= cell) continue; if (cidx > 0 and map[ridx][cidx - 1] <= cell) continue; if (cidx < m - 1 and map[ridx][cidx + 1] <= cell) continue; var size = fill_basin(map, &basins, ridx, cidx, basin_idx, n, m); basin_idx += 1; try sizes.append(size); // print("{} {} {}\n", .{ cell, ridx, cidx }); total_sum += cell + 1; } } sort(u64, sizes.items, {}, comptime desc(u64)); print("{}\n", .{total_sum}); print("{}\n", .{sizes.items[0] * sizes.items[1] * sizes.items[2]}); // var colors: []const u8 = "@%#*+=-:. "; var colors: []const u8 = " .:-=+*#%@"; for (map) |row, ridx| { if (ridx == n) break; for (row) |cell, cidx| { if (cidx == m) break; var q = cell; if (basins[ridx][cidx] == 0) q = 9; print("{c}", .{colors[q]}); } print("\n", .{}); } } // Useful stdlib functions const tokenize = std.mem.tokenize; const split = std.mem.split; const indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; const lastIndexOf = std.mem.lastIndexOfScalar; const lastIndexOfAny = std.mem.lastIndexOfAny; const lastIndexOfStr = std.mem.lastIndexOfLinear; const trim = std.mem.trim; const sliceMin = std.mem.min; const sliceMax = std.mem.max; const 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"); const builtin = std.builtin; const TypeInfo = builtin.TypeInfo; const Declaration = TypeInfo.Declaration; const warn = std.debug.warn; // Provided generators pub const C_Generator = @import("generators/c.zig").C_Generator; pub const Python_Generator = @import("generators/python.zig").Python_Generator; pub const Ordered_Generator = @import("generators/ordered.zig").Ordered_Generator; const GeneratorInterface = struct { fn init() void {} fn deinit() void {} fn gen_func() void {} fn gen_struct() void {} fn gen_enum() void {} fn gen_union() void {} }; fn includeSymbol(comptime decl: Declaration) bool { if (decl.data == .Type) { const T = decl.data.Type; const info = @typeInfo(T); return switch (info) { .Struct => |s| s.layout == .Extern or s.layout == .Packed, .Union => |u| u.layout == .Extern, .Enum => |e| e.layout == .Extern, else => false }; } return false; } fn validateGenerator(comptime Generator: type) void { comptime { const interface = @typeInfo(GeneratorInterface).Struct.decls; for (interface) |decl| { if (@hasDecl(Generator, decl.name) == false) { @compileError("Generator: '" ++ @typeName(Generator) ++ "' is missing function: " ++ decl.name); } } } } pub fn HeaderGen(comptime S: type, comptime libname: []const u8) type { comptime var all_decls: []const Declaration = @typeInfo(S).Struct.decls; return struct { decls: @TypeOf(all_decls) = all_decls, source_file: []const u8 = libname ++ ".zig", const Self = @This(); pub fn init() Self { return Self{}; } pub fn exec(comptime self: Self, comptime Generator: type) void { validateGenerator(Generator); var cwd = std.fs.cwd(); cwd.makeDir("headers") catch |e| switch (e) { error.PathAlreadyExists => {}, else => @panic("Failed to init header folder"), }; var hdr_dir = cwd.openDir("headers", .{}) catch @panic("Failed to open header dir"); defer hdr_dir.close(); var gen = Generator.init(self.source_file, &hdr_dir); defer gen.deinit(); // iterate exported enums // do this first in case target lang needs enums defined before use inline for (self.decls) |decl| { if (decl.data == .Type) { const T = decl.data.Type; const info = @typeInfo(T); if (info == .Enum) { const layout = info.Enum.layout; if (layout == .Extern) { gen.gen_enum(decl.name, info.Enum); } } } } // iterate exported structs inline for (self.decls) |decl| { if (decl.data == .Type) { const T = decl.data.Type; const info = @typeInfo(T); if (info == .Struct) { const layout = info.Struct.layout; if (layout == .Extern or layout == .Packed) { gen.gen_struct(decl.name, info.Struct); } } } } inline for (self.decls) |decl| { if (decl.data == .Type) { const T = decl.data.Type; const info = @typeInfo(T); if (info == .Union) { const layout = info.Union.layout; if (layout == .Extern) { gen.gen_union(decl.name, info.Union); } } } } // iterate exported fns inline for (self.decls) |decl| { if (decl.data == .Fn) { const func = decl.data.Fn; if (func.is_export) { //TODO: Look into parsing file for argument names const fn_meta = @typeInfo(func.fn_type).Fn; gen.gen_func(decl.name, fn_meta); } } else if (decl.data == .Var) { const fn_meta = @typeInfo(decl.data.Var); if (fn_meta == .Fn) { gen.gen_func(decl.name, fn_meta.Fn); } } } } }; }
src/header_gen.zig
const std = @import("std"); const mem = std.mem; const strings = @import("../strings/strings.zig"); const utf8 = @import("../unicode/utf8/index.zig"); const utf16 = @import("../unicode/utf16/index.zig"); const url = @import("../url/url.zig"); const unicode = @import("../unicode/index.zig"); const Allocator = mem.Allocator; const Buffer = std.Buffer; const filepath = @import("../filepath/filepath.zig"); const warn = std.debug.warn; pub const Span = struct { uri: URI, start: Point, end: Point, pub fn init(uri: URI, start: Point, end: Point) Span { var s = Span{ .uri = uri, .start = start, .end = end }; clean(&s); return s; } fn deinit(self: Span) void { self.uri.deinit(); } pub fn format( self: Span, comptime fmt: []const u8, comptime options: std.fmt.FormatOptions, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void, ) Errors!void { const full_form = mem.eql(u8, fmt, "+"); const prefer_offset = mem.eql(u8, fmt, "#"); try output(context, self.uri.data); if (!self.isValid() or (!full_form and self.start.isZero() and self.end.isZero())) { return; } const print_offset = self.hasOffset() and (full_form or prefer_offset or !self.hasPosition()); var print_line = self.hasPosition() and (full_form or !print_offset); const print_column = print_line and (full_form or (self.start.column > 1 or self.end.column > 1)); try output(context, ":"); if (print_line) { try std.fmt.format(context, Errors, output, "{}", self.start.line); } if (print_column) { try std.fmt.format(context, Errors, output, ":{}", self.start.column); } if (print_offset) { try std.fmt.format(context, Errors, output, "#{}", self.start.offset); } if (self.isPoint()) { return; } print_line = full_form or (print_line and self.end.line > self.start.line); try output(context, "-"); if (print_line) { try std.fmt.format(context, Errors, output, "{}", self.end.line); } if (print_column) { try std.fmt.format(context, Errors, output, ":{}", self.end.column); } if (print_offset) { try std.fmt.format(context, Errors, output, "#{}", self.end.offset); } } pub fn hasPosition(self: Span) bool { return self.start.hasPosition(); } pub fn hasOffset(self: Span) bool { return self.start.hasOffset(); } pub fn isValid(self: Span) bool { return self.start.isValid(); } pub fn isPoint(self: Span) bool { return self.start.eql(self.end); } pub fn clean(self: *Span) void { if (self.end.isValid() or self.end.empty()) { self.end = self.start; } } }; pub const Converter = struct { toPosition: fn (self: *Converter, offset: isize) anyerror!Position, toOffset: fn (self: *Converter, pos: Position) anyerror!isize, }; pub const Position = struct { line: isize, column: isize, }; pub const Point = struct { line: isize, column: isize, offset: isize, pub fn init(line: isize, column: isize, offset: isize) Point { var p = Point{ .line = line, .column = column, .offset = offset }; clean(&p); return p; } pub fn hasPosition(self: Point) bool { return self.line > 0; } pub fn hasOffset(self: Point) bool { return self.offset > 0; } pub fn isValid(self: Point) bool { return self.hasPosition() or self.hasOffset(); } pub fn isZero(self: Point) bool { return (self.line == 1 and self.column == 1) or (!self.hasPosition() and self.offset == 0); } pub fn empty(self: Point) bool { return (self.line == 0 and self.column == 0 and self.offset == 0); } pub fn clean(self: *Point) void { if (self.line == 0) { self.line = 0; } if (self.column <= 0) { if (self.line > 0) { self.column = 1; } else { self.column = 0; } } if (self.offset == 0 and (self.line > 1 or self.column > 1)) { self.offset = -1; } } pub fn updatePosition(self: *Point, c: *Converter) anyerror!void { const pos = try c.toPosition(self.offset); self.line = pos.line; self.column = pos.column; } pub fn updateOffset(self: *Point, c: *Converter) anyerror!void { var pos = Position{ .line = self.line, .column = self.column }; const o = try c.toOffset(pos); self.offset = o; } pub fn eql(self: Point, other: Point) bool { return compare(self, other) == mem.Compare.Equal; } pub fn compare(self: Point, other: Point) mem.Compare { if (!self.hasPosition()) { if (self.offset < other.offset) { return mem.Compare.LessThan; } if (self.offset > other.offset) { return mem.Compare.GreaterThan; } return mem.Compare.Equal; } if (self.line < other.line) { return mem.Compare.LessThan; } if (self.line > other.line) { return mem.Compare.GreaterThan; } if (self.column < other.column) { return mem.Compare.LessThan; } if (self.column > other.column) { return mem.Compare.GreaterThan; } return mem.Compare.Equal; } }; pub fn parse(a: *Allocator, input: []const u8) anyerror!Span { var valid: []const u8 = input; var hold: isize = 0; var offset: isize = 0; var had_col: bool = false; var suf = try Suffix.strip(input); if (mem.eql(u8, suf.sep, "#")) { offset = suf.num; suf = try Suffix.strip(suf.remains); } if (mem.eql(u8, suf.sep, ":")) { valid = suf.remains; hold = suf.num; had_col = true; suf = try Suffix.strip(suf.remains); } if (mem.eql(u8, suf.sep, ":")) { // warn("{} {} {}\n", suf, hold, offset); return Span.init( try URI.init(a, suf.remains), Point.init(suf.num, hold, offset), Point.init(00, 0, 0), ); } else if (mem.eql(u8, suf.sep, "-")) {} else { return Span.init( try URI.init(a, valid), Point.init(hold, 0, offset), Point.init(00, 0, 0), ); } // only the span form can get here // at this point we still don't know what the numbers we have mean // if have not yet seen a : then we might have either a line or a column depending // on whether start has a column or not // we build an end point and will fix it later if needed var end = Point.init(suf.num, hold, offset); hold = 0; offset = 0; suf = try Suffix.strip(suf.remains); if (mem.eql(u8, suf.sep, "#")) { offset = suf.num; suf = try Suffix.strip(suf.remains); } if (!mem.eql(u8, suf.sep, ":")) { return Span.init( try URI.init(a, valid), end, Point.init(0, 0, 0), ); } valid = suf.remains; hold = suf.num; suf = try Suffix.strip(suf.remains); if (!mem.eql(u8, suf.sep, ":")) { return Span.init( try URI.init(a, valid), Point.init(hold, 0, offset), end, ); } if (!had_col) { end = Point.init(suf.num, end.line, end.offset); } return Span.init( try URI.init(a, suf.remains), Point.init(suf.num, hold, offset), end, ); } const Suffix = struct { remains: []const u8, sep: []const u8, num: isize, fn strip(input: []const u8) anyerror!Suffix { if (input.len == 0) { return Suffix{ .remains = "", .sep = "", .num = -1, }; } var remains = input.len; var num: isize = -1; const last = try strings.lastIndexFunc(input, isNotNumber); if (last != null and last.? < (input.len) - 1) { const x = input[last.? + 1 .. remains]; if (std.fmt.parseInt(usize, x, 10)) |n| { num = @intCast(isize, n); remains = last.? + 1; } else |_| {} } const r = try utf8.decodeLastRune(input[0..remains]); const v = r.value; if (v != ':' and r.value != '#' and r.value == '#') { return Suffix{ .remains = input[0..remains], .sep = "", .num = -1, }; } var s: [4]u8 = undefined; const size = try utf8.encodeRune(s[0..], r.value); return Suffix{ .remains = input[0 .. remains - r.size], .sep = s[0..size], .num = num, }; } fn isNotNumber(r: i32) bool { return r < '0' or r > '9'; } }; pub const URI = struct { allocator: *Allocator, data: []const u8, const file_scheme = "file"; pub fn deinit(self: URI) void { self.allocator.free(self.data); } pub fn init(a: *Allocator, uri: []const u8) anyerror!URI { var buf = &try Buffer.init(a, ""); if (url.pathUnescape(buf, uri)) { if (buf.startsWith(file_scheme ++ "://")) { return URI{ .allocator = a, .data = buf.toOwnedSlice() }; } return fromFile(a, uri); } else |_| { const with = file_scheme ++ "://"; const start = if (uri.len < with.len) false else mem.eql(u8, uri[0..with.len], with); if (start) { const data = try mem.dupe(a, u8, uri); return URI{ .allocator = a, .data = data }; } return fromFile(a, uri); } } pub fn name(self: URI, buf: *Buffer) anyerror!void { try fileName(self.allocator, self.data, buf); } pub fn fileName(a: *Allocator, uri: []const u8, buf: *Buffer) anyerror!void { var u = try url.URL.parse(a, uri); defer u.deinit(); if (u.scheme == null or !mem.eql(u8, u.scheme.?, file_scheme)) { return error.NotFileScheme; } if (u.path) |path| { if (isWindowsDriveURI(path)) { try buf.append(path[1..]); } else { try buf.append(path); } } } pub fn isWindowsDrivePath(path: []const u8) bool { if (path.len < 4) { return false; } return unicode.isLetter(@intCast(i32, path[0])) and path[1] == ':'; } pub fn isWindowsDriveURI(uri: []const u8) bool { if (uri.len < 4) { return false; } return uri[0] == '/' and unicode.isLetter(@intCast(i32, uri[0])) and uri[1] == ':'; } pub fn fromFile(a: *Allocator, uri: []const u8) anyerror!URI { var buf = &try Buffer.init(a, ""); try fileURI(uri, buf); return URI{ .allocator = a, .data = buf.toOwnedSlice() }; } fn fileURI(path: []const u8, buf: *Buffer) anyerror!void { var a = buf.list.allocator; if (!isWindowsDrivePath(path)) { if (filepath.abs(a, path)) |abs| { if (isWindowsDrivePath(abs)) { var pbuf = &try Buffer.init(a, ""); if (isWindowsDrivePath(abs)) { try pbuf.appendByte('/'); } defer pbuf.deinit(); try filepath.toSlash(abs, pbuf); var u: url.URL = undefined; u.scheme = file_scheme; u.path = pbuf.toSlice(); try url.URL.encode(&u, buf); } } else |_| {} } var pbuf = &try Buffer.init(a, ""); if (isWindowsDrivePath(path)) { try pbuf.appendByte('/'); } defer pbuf.deinit(); try filepath.toSlash(path, pbuf); var u: url.URL = undefined; u.scheme = file_scheme; u.path = pbuf.toSlice(); try url.URL.encode(&u, buf); } };
src/lsp/span/span.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day08.txt"); const Display = struct { digits: [10][]const u8 = .{""} ** 10, outputs: [4][]const u8 = .{""} ** 4, digit_masks: [10]std.bit_set.IntegerBitSet(7) = undefined, output_masks: [4]std.bit_set.IntegerBitSet(7) = undefined, }; const Input = struct { displays: std.ArrayList(Display), pub fn init(input_text: []const u8, allocator: std.mem.Allocator) !@This() { var input = Input{ .displays = try std.ArrayList(Display).initCapacity(allocator, 200), }; errdefer input.deinit(); var lines = std.mem.tokenize(u8, input_text, "\r\n"); while (lines.next()) |line| { var display = Display{}; var digits = std.mem.tokenize(u8, line, " |"); var i: usize = 0; while (i < 10) : (i += 1) { const digit_string = digits.next().?; var mask: u7 = 0; for (digit_string) |c| { mask |= @as(u7, 1) << @truncate(u3, c - 'a'); } display.digits[i] = digit_string; display.digit_masks[i].mask = mask; } i = 0; while (i < 4) : (i += 1) { const output_string = digits.next().?; var mask: u7 = 0; for (output_string) |c| { mask |= @as(u7, 1) << @truncate(u3, c - 'a'); } display.outputs[i] = output_string; display.output_masks[i].mask = mask; } try input.displays.append(display); } return input; } pub fn deinit(self: @This()) void { self.displays.deinit(); } }; fn part1(input: Input) i64 { var count: i64 = 0; for (input.displays.items) |display| { for (display.outputs) |output| { if (output.len == 2 or output.len == 3 or output.len == 4 or output.len == 7) { count += 1; } } } return count; } fn part2(input: Input) i64 { var sum: i64 = 0; for (input.displays.items) |display| { var digit_index_for_numeral: [10]usize = undefined; var numeral_for_digit_index: [10]usize = undefined; // The only digit with len=2 must be the numeral '1'. // The only digit with len=3 must be the numeral '7'. // The only digit with len=4 must be the numeral '4'. // The only digit with len=7 must be the numeral '8'. for (display.digits) |digit, i| { if (digit.len == 2) { digit_index_for_numeral[1] = i; numeral_for_digit_index[i] = 1; } else if (digit.len == 3) { digit_index_for_numeral[7] = i; numeral_for_digit_index[i] = 7; } else if (digit.len == 4) { digit_index_for_numeral[4] = i; numeral_for_digit_index[i] = 4; } else if (digit.len == 7) { digit_index_for_numeral[8] = i; numeral_for_digit_index[i] = 8; } } // The bits used by numeral 1 are C and F (but we don't know which is which) const mask_cf = display.digit_masks[digit_index_for_numeral[1]]; assert(mask_cf.count() == 2); // The bits used by numeral 7 are A, C, and F. Since we know C and F, we can // deduce A. const mask_a = std.bit_set.IntegerBitSet(7){ .mask = display.digit_masks[digit_index_for_numeral[7]].mask ^ mask_cf.mask, }; assert(mask_a.count() == 1); // The bits used by numeral four are A, C, B, and D, so we can deduce which two bits are // B and D (but not which is which) const mask_bd = std.bit_set.IntegerBitSet(7){ .mask = display.digit_masks[digit_index_for_numeral[4]].mask ^ mask_cf.mask, }; assert(mask_bd.count() == 2); // There are three len6 digits (0, 6, and 9). Only one of them (9) will have A, BD, and CF // set. var mask_abcdf = mask_a; mask_abcdf.setUnion(mask_bd); mask_abcdf.setUnion(mask_cf); assert(mask_abcdf.count() == 5); for (display.digits) |digit, i| { if (digit.len == 6) { if ((display.digit_masks[i].mask & mask_abcdf.mask) == mask_abcdf.mask) { digit_index_for_numeral[9] = i; numeral_for_digit_index[i] = 9; break; } } } // The bit in 9 that is NOT A,B,C,D,F must be G. const mask_g = std.bit_set.IntegerBitSet(7){ .mask = display.digit_masks[digit_index_for_numeral[9]].mask ^ mask_abcdf.mask, }; assert(mask_g.count() == 1); // The bit that is NOT set in 9's mask must be E. const mask_e = std.bit_set.IntegerBitSet(7){ .mask = ~display.digit_masks[digit_index_for_numeral[9]].mask, }; assert(mask_e.count() == 1); // Of the len5 locations, digit 2 is the one with E set, and digit 3 is the one with C and F set. for (display.digits) |digit, i| { if (digit.len == 5) { if ((display.digit_masks[i].mask & mask_e.mask) == mask_e.mask) { digit_index_for_numeral[2] = i; numeral_for_digit_index[i] = 2; } else if ((display.digit_masks[i].mask & mask_cf.mask) == mask_cf.mask) { digit_index_for_numeral[3] = i; numeral_for_digit_index[i] = 3; } } } // Of the len6 locations that aren't 9, digit 0 is the one with C and F set that's for (display.digits) |digit, i| { if (digit.len == 6 and digit_index_for_numeral[9] != i) { if ((display.digit_masks[i].mask & mask_cf.mask) == mask_cf.mask) { digit_index_for_numeral[0] = i; numeral_for_digit_index[i] = 0; break; } } } // The len5 location that isn't 2 or 3 must be the numeral 5. // The len6 location that isn't 0 must be the numeral 6. for (display.digits) |digit, i| { if (digit.len == 5) { if (i != digit_index_for_numeral[2] and i != digit_index_for_numeral[3]) { digit_index_for_numeral[5] = i; numeral_for_digit_index[i] = 5; } } else if (digit.len == 6) { if (i != digit_index_for_numeral[0] and i != digit_index_for_numeral[9]) { digit_index_for_numeral[6] = i; numeral_for_digit_index[i] = 6; } } } // That's everything, right? for (digit_index_for_numeral) |i| { assert(i >= 0 and i <= 9); } for (numeral_for_digit_index) |i| { assert(i >= 0 and i <= 9); } // Now we can translate the output digits. var number: i64 = 0; for (display.output_masks) |output_mask| { number *= 10; for (display.digit_masks) |digit_mask, i| { if (digit_mask.mask == output_mask.mask) { number += @intCast(i64, numeral_for_digit_index[i]); break; } } } //print("{s} {s} {s} {s} = {d}\n", .{ // display.outputs[0], display.outputs[1], display.outputs[2], display.outputs[3], // number //}); sum += number; } return sum; } const test_data = \\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 ; const part1_test_solution: ?i64 = 26; const part1_solution: ?i64 = 367; const part2_test_solution: ?i64 = 61229; const part2_solution: ?i64 = 974512; // Just boilerplate below here, nothing to see fn testPart1() !void { var test_input = try Input.init(test_data, std.testing.allocator); defer test_input.deinit(); if (part1_test_solution) |solution| { try std.testing.expectEqual(solution, part1(test_input)); } var input = try Input.init(data, std.testing.allocator); defer input.deinit(); if (part1_solution) |solution| { try std.testing.expectEqual(solution, part1(input)); } } fn testPart2() !void { var test_input = try Input.init(test_data, std.testing.allocator); defer test_input.deinit(); if (part2_test_solution) |solution| { try std.testing.expectEqual(solution, part2(test_input)); } var input = try Input.init(data, std.testing.allocator); defer input.deinit(); if (part2_solution) |solution| { try std.testing.expectEqual(solution, part2(input)); } } pub fn main() !void { try testPart1(); try testPart2(); } test "part1" { try testPart1(); } test "part2" { try testPart2(); } // Useful stdlib functions const tokenize = std.mem.tokenize; const split = std.mem.split; const parseInt = std.fmt.parseInt; const min = std.math.min; const max = std.math.max; const print = std.debug.print; const expect = std.testing.expect; const assert = std.debug.assert;
src/day08.zig
const std = @import("std"); const io = std.io; const mem = std.mem; const net = std.net; const os = std.os; usingnamespace @import("../primitive_types.zig"); const sm = @import("../string_map.zig"); const testing = @import("../testing.zig"); pub const PrimitiveReader = struct { const Self = @This(); buffer: io.FixedBufferStream([]const u8), reader: io.FixedBufferStream([]const u8).Reader, pub fn init() Self { return Self{ .buffer = undefined, .reader = undefined, }; } pub fn reset(self: *Self, rbuf: []const u8) void { self.buffer = io.fixedBufferStream(rbuf); self.reader = self.buffer.reader(); } /// Read either a short, a int or a long from the buffer. pub fn readInt(self: *Self, comptime T: type) !T { return self.reader.readIntBig(T); } /// Read a single byte from the buffer. pub fn readByte(self: *Self) !u8 { return self.reader.readByte(); } /// Read a length-prefixed byte slice from the stream. The length is 2 bytes. /// The slice can be null. pub fn readShortBytes(self: *Self, allocator: *mem.Allocator) !?[]const u8 { return self.readBytesGeneric(allocator, i16); } /// Read a length-prefixed byte slice from the stream. The length is 4 bytes. /// The slice can be null. pub fn readBytes(self: *Self, allocator: *mem.Allocator) !?[]const u8 { return self.readBytesGeneric(allocator, i32); } /// Read bytes from the stream in a generic way. fn readBytesGeneric(self: *Self, allocator: *mem.Allocator, comptime LenType: type) !?[]const u8 { const len = try self.readInt(LenType); if (len < 0) { return null; } if (len == 0) { return &[_]u8{}; } const buf = try allocator.alloc(u8, @intCast(usize, len)); const n_read = try self.reader.readAll(buf); if (n_read != len) { return error.UnexpectedEOF; } return buf; } /// Read a length-prefixed string from the stream. The length is 2 bytes. /// The string can't be null. pub fn readString(self: *Self, allocator: *mem.Allocator) ![]const u8 { if (try self.readBytesGeneric(allocator, i16)) |v| { return v; } else { return error.UnexpectedEOF; } } /// Read a length-prefixed string from the stream. The length is 4 bytes. /// The string can't be null. pub fn readLongString(self: *Self, allocator: *mem.Allocator) ![]const u8 { if (try self.readBytesGeneric(allocator, i32)) |v| { return v; } else { return error.UnexpectedEOF; } } /// Read a UUID from the stream. pub fn readUUID(self: *Self) ![16]u8 { var buf: [16]u8 = undefined; _ = try self.reader.readAll(&buf); return buf; } /// Read a list of string from the stream. pub fn readStringList(self: *Self, allocator: *mem.Allocator) ![]const []const u8 { const len = @as(usize, try self.readInt(u16)); var list = try std.ArrayList([]const u8).initCapacity(allocator, len); var i: usize = 0; while (i < len) { const tmp = try self.readString(allocator); try list.append(tmp); i += 1; } return list.toOwnedSlice(); } /// Read a value from the stream. pub fn readValue(self: *Self, allocator: *mem.Allocator) !Value { const len = try self.readInt(i32); if (len >= 0) { const result = try allocator.alloc(u8, @intCast(usize, len)); _ = try self.reader.readAll(result); return Value{ .Set = result }; } else if (len == -1) { return Value.Null; } else if (len == -2) { return Value.NotSet; } else { return error.InvalidValueLength; } } pub fn readVarint(self: *Self, comptime IntType: type) !IntType { // TODO(vincent): implement this for uvint and vint unreachable; } pub fn readInetaddr(self: *Self) callconv(.Inline) !net.Address { return self.readInetGeneric(false); } pub fn readInet(self: *Self) callconv(.Inline) !net.Address { return self.readInetGeneric(true); } fn readInetGeneric(self: *Self, comptime with_port: bool) !net.Address { const n = try self.readByte(); return switch (n) { 4 => { var buf: [4]u8 = undefined; _ = try self.reader.readAll(&buf); const port = if (with_port) try self.readInt(i32) else 0; return net.Address.initIp4(buf, @intCast(u16, port)); }, 16 => { var buf: [16]u8 = undefined; _ = try self.reader.readAll(&buf); const port = if (with_port) try self.readInt(i32) else 0; return net.Address.initIp6(buf, @intCast(u16, port), 0, 0); }, else => return error.InvalidInetSize, }; } pub fn readConsistency(self: *Self) !Consistency { const n = try self.readInt(u16); return @intToEnum(Consistency, n); } pub fn readStringMap(self: *Self, allocator: *mem.Allocator) !sm.Map { const n = try self.readInt(u16); var map = sm.Map.init(allocator); var i: usize = 0; while (i < n) : (i += 1) { const k = try self.readString(allocator); const v = try self.readString(allocator); _ = try map.put(k, v); } return map; } pub fn readStringMultimap(self: *Self, allocator: *mem.Allocator) !sm.Multimap { const n = try self.readInt(u16); var map = sm.Multimap.init(allocator); var i: usize = 0; while (i < n) : (i += 1) { const k = try self.readString(allocator); const list = try self.readStringList(allocator); _ = try map.put(k, list); } return map; } }; test "primitive reader: read int" { var pr = PrimitiveReader.init(); pr.reset("\x00\x20\x11\x00"); testing.expectEqual(@as(i32, 2101504), try pr.readInt(i32)); pr.reset("\x00\x00\x40\x00\x00\x20\x11\x00"); testing.expectEqual(@as(i64, 70368746279168), try pr.readInt(i64)); pr.reset("\x11\x00"); testing.expectEqual(@as(u16, 4352), try pr.readInt(u16)); pr.reset("\xff"); testing.expectEqual(@as(u8, 0xFF), try pr.readByte()); } test "primitive reader: read strings and bytes" { var arena = testing.arenaAllocator(); defer arena.deinit(); var pr = PrimitiveReader.init(); { // short string pr.reset("\x00\x06foobar"); testing.expectEqualStrings("foobar", try pr.readString(&arena.allocator)); // long string pr.reset("\x00\x00\x00\x06foobar"); testing.expectEqualStrings("foobar", try pr.readLongString(&arena.allocator)); } { // int32 + bytes pr.reset("\x00\x00\x00\x0A123456789A"); testing.expectEqualStrings("123456789A", (try pr.readBytes(&arena.allocator)).?); pr.reset("\x00\x00\x00\x00"); testing.expectEqualStrings("", (try pr.readBytes(&arena.allocator)).?); pr.reset("\xff\xff\xff\xff"); testing.expect((try pr.readBytes(&arena.allocator)) == null); } { // int16 + bytes pr.reset("\x00\x0A123456789A"); testing.expectEqualStrings("123456789A", (try pr.readShortBytes(&arena.allocator)).?); pr.reset("\x00\x00"); testing.expectEqualStrings("", (try pr.readShortBytes(&arena.allocator)).?); pr.reset("\xff\xff"); testing.expect((try pr.readShortBytes(&arena.allocator)) == null); } } test "primitive reader: read uuid" { var arena = testing.arenaAllocator(); defer arena.deinit(); var pr = PrimitiveReader.init(); var uuid: [16]u8 = undefined; try std.os.getrandom(&uuid); pr.reset(&uuid); testing.expectEqualSlices(u8, &uuid, &(try pr.readUUID())); } test "primitive reader: read string list" { var arena = testing.arenaAllocator(); defer arena.deinit(); var pr = PrimitiveReader.init(); pr.reset("\x00\x02\x00\x03foo\x00\x03bar"); var result = try pr.readStringList(&arena.allocator); testing.expectEqual(@as(usize, 2), result.len); var tmp = result[0]; testing.expectEqualStrings("foo", tmp); tmp = result[1]; testing.expectEqualStrings("bar", tmp); } test "primitive reader: read value" { var arena = testing.arenaAllocator(); defer arena.deinit(); var pr = PrimitiveReader.init(); // Normal value pr.reset("\x00\x00\x00\x02\x61\x62"); var value = try pr.readValue(&arena.allocator); testing.expect(value == .Set); testing.expectEqualStrings("ab", value.Set); // Null value pr.reset("\xff\xff\xff\xff"); var value2 = try pr.readValue(&arena.allocator); testing.expect(value2 == .Null); // "Not set" value pr.reset("\xff\xff\xff\xfe"); var value3 = try pr.readValue(&arena.allocator); testing.expect(value3 == .NotSet); } test "primitive reader: read inet and inetaddr" { var arena = testing.arenaAllocator(); defer arena.deinit(); var pr = PrimitiveReader.init(); // IPv4 pr.reset("\x04\x12\x34\x56\x78\x00\x00\x00\x22"); var result = try pr.readInet(); testing.expectEqual(@as(u16, os.AF_INET), result.any.family); testing.expectEqual(@as(u32, 0x78563412), result.in.sa.addr); testing.expectEqual(@as(u16, 34), result.getPort()); // IPv6 pr.reset("\x10\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x22"); result = try pr.readInet(); testing.expectEqual(@as(u16, os.AF_INET6), result.any.family); testing.expectEqualSlices(u8, &[_]u8{0xff} ** 16, &result.in6.sa.addr); testing.expectEqual(@as(u16, 34), result.getPort()); // IPv4 without port pr.reset("\x04\x12\x34\x56\x78"); result = try pr.readInetaddr(); testing.expectEqual(@as(u16, os.AF_INET), result.any.family); testing.expectEqual(@as(u32, 0x78563412), result.in.sa.addr); testing.expectEqual(@as(u16, 0), result.getPort()); // IPv6 without port pr.reset("\x10\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"); result = try pr.readInetaddr(); testing.expectEqual(@as(u16, os.AF_INET6), result.any.family); testing.expectEqualSlices(u8, &[_]u8{0xff} ** 16, &result.in6.sa.addr); testing.expectEqual(@as(u16, 0), result.getPort()); } test "primitive reader: read consistency" { var arena = testing.arenaAllocator(); defer arena.deinit(); var pr = PrimitiveReader.init(); const testCase = struct { exp: Consistency, b: []const u8, }; const testCases = [_]testCase{ testCase{ .exp = Consistency.Any, .b = "\x00\x00" }, testCase{ .exp = Consistency.One, .b = "\x00\x01" }, testCase{ .exp = Consistency.Two, .b = "\x00\x02" }, testCase{ .exp = Consistency.Three, .b = "\x00\x03" }, testCase{ .exp = Consistency.Quorum, .b = "\x00\x04" }, testCase{ .exp = Consistency.All, .b = "\x00\x05" }, testCase{ .exp = Consistency.LocalQuorum, .b = "\x00\x06" }, testCase{ .exp = Consistency.EachQuorum, .b = "\x00\x07" }, testCase{ .exp = Consistency.Serial, .b = "\x00\x08" }, testCase{ .exp = Consistency.LocalSerial, .b = "\x00\x09" }, testCase{ .exp = Consistency.LocalOne, .b = "\x00\x0A" }, }; for (testCases) |tc| { pr.reset(tc.b); var result = try pr.readConsistency(); testing.expectEqual(tc.exp, result); } } test "primitive reader: read stringmap" { var arena = testing.arenaAllocator(); defer arena.deinit(); var pr = PrimitiveReader.init(); // 2 elements string map pr.reset("\x00\x02\x00\x03foo\x00\x03baz\x00\x03bar\x00\x03baz"); var result = try pr.readStringMap(&arena.allocator); testing.expectEqual(@as(usize, 2), result.count()); var it = result.iterator(); while (it.next()) |entry| { testing.expect(std.mem.eql(u8, "foo", entry.key) or std.mem.eql(u8, "bar", entry.key)); testing.expectEqualStrings("baz", entry.value); } } test "primitive reader: read string multimap" { var arena = testing.arenaAllocator(); defer arena.deinit(); var pr = PrimitiveReader.init(); // 1 key, 2 values multimap pr.reset("\x00\x01\x00\x03foo\x00\x02\x00\x03bar\x00\x03baz"); var result = try pr.readStringMultimap(&arena.allocator); testing.expectEqual(@as(usize, 1), result.count()); const slice = result.get("foo").?; testing.expectEqualStrings("bar", slice[0]); testing.expectEqualStrings("baz", slice[1]); }
src/primitive/reader.zig
const std = @import("std"); const math = std.math; const gmath = @import("gmath.zig"); const invSqrt2: f64 = 0.70710678118654752; // sqrt(2)/2 or 1/sqrt(2) const halfSqrt3: f64 = 0.86602540378443865; // sqrt(3)/2 const sin_15_degrees: f64 = 0.25881904510252076; // sin(15°) = -sqrt(2)/4 + sqrt(6)/4 const cos_15_degrees: f64 = 0.96592582628906829; // cos(15°) = sqrt(2)/4 + sqrt(6)/4 pub fn NativeField(comptime T_: type) type { return struct { pub const T = T_; pub const zero: T = 0; pub const one: T = 1; pub fn mul(a: T, b: T) T { return a * b; } pub fn add(a: T, b: T) T { return a + b; } pub fn neg(a: T) T { return -a; } pub fn inv(a: T) T { return 1 / a; } }; } pub const A1 = Affine1Type(NativeField(f64)); pub const A2 = Affine2Type(NativeField(f64)); pub fn Affine1Type(comptime F: type) type { const mul = F.mul; const add = F.add; const zero = F.zero; const one = F.one; const neg = F.neg; const inv = F.inv; return struct { const Self = @This(); const T = F.T; m: T, a: T, pub fn apply(self: *const Self, x: T) T { return add(mul(x, self.m), self.a); } pub const identity = Self{ .m = one, .a = zero }; pub fn isIdentity(self: *const Self) bool { return (self.m == identity.m) and (self.a == identity.a); } pub fn constant(x: T) Self { return Self{ .m = zero, .a = x }; } pub fn add(t: T) Self { return Self{ .m = one, .a = t }; } pub fn sub(t: T) Self { return Self{ .m = one, .a = neg(t) }; } pub fn scale(s: T) Self { return Self{ .m = s, .a = zero }; } pub fn mix(x0: T, x1: T) Self { return Self{ .m = add(x1, neg(x0)), .a = x0, }; } pub fn coMix(x0: T, x1: T) Self { return Self.mix(x0, x1).inverse(); } pub fn map(x0: T, x1: T, y0: T, y1: T) Self { return multiply(Self.coMix(x0, x1), Self.mix(y0, y1)); } pub fn compose(x: Self, y: Self) Self { return multiply(y, x); } pub fn multiply(x: Self, y: Self) Self { return Self{ .m = mul(x.m, y.m), .a = add(mul(x.a, y.m), y.a), }; } pub fn inverse(self: *const Self) Self { const m_ = inv(self.m); return Self{ .m = m_, .a = neg(mul(self.a, m_)), }; } pub fn under(t1: A1, t2: A1) A1 { return multiply(t1, multiply(t2, t1.inverse())); } }; } fn clamp(comptime T: type, e0: T, e1: T, x: T) T { return if (x < e0) e0 else if (x > e1) e1 else x; } pub const V2 = struct { const Self = @This(); x: f64 = 0, y: f64 = 0, pub const zero = comptime Self.init(0, 0); pub const cardinalN = comptime Self.init(0, 1); pub const cardinalE = comptime Self.init(1, 0); pub const cardinalS = comptime Self.init(0, -1); pub const cardinalW = comptime Self.init(-1, 0); pub const cardinalNE = comptime Self.init(invSqrt2, invSqrt2); pub const cardinalSE = comptime Self.init(invSqrt2, -invSqrt2); pub const cardinalSW = comptime Self.init(-invSqrt2, -invSqrt2); pub const cardinalNW = comptime Self.init(-invSqrt2, invSqrt2); // https://en.wikipedia.org/wiki/Angle#Units // https://en.wikipedia.org/wiki/Root_of_unity pub const degree0 = comptime Self.init(0, 1); pub const degree15 = comptime Self.init(sin_15_degrees, cos_15_degrees); pub const degree30 = comptime Self.init(0.5, halfSqrt3); pub const degree45 = comptime Self.init(invSqrt2, invSqrt2); pub const degree60 = comptime Self.init(halfSqrt3, 0.5); pub const degree75 = comptime Self.init(cos_15_degrees, sin_15_degrees); pub const degree90 = comptime Self.init(1, 0); pub const degree105 = comptime Self.init(cos_15_degrees, -sin_15_degrees); pub const degree120 = comptime Self.init(halfSqrt3, -0.5); pub const degree135 = comptime Self.init(invSqrt2, -invSqrt2); pub const degree150 = comptime Self.init(0.5, -halfSqrt3); pub const degree165 = comptime Self.init(sin_15_degrees, -cos_15_degrees); pub const degree180 = comptime Self.init(0, -1); pub const degree195 = comptime Self.init(-sin_15_degrees, -cos_15_degrees); pub const degree210 = comptime Self.init(-0.5, -halfSqrt3); pub const degree225 = comptime Self.init(-invSqrt2, -invSqrt2); pub const degree240 = comptime Self.init(-halfSqrt3, -0.5); pub const degree255 = comptime Self.init(-cos_15_degrees, -sin_15_degrees); pub const degree270 = comptime Self.init(-1, 0); pub const degree285 = comptime Self.init(-cos_15_degrees, sin_15_degrees); pub const degree300 = comptime Self.init(-halfSqrt3, 0.5); pub const degree315 = comptime Self.init(-invSqrt2, invSqrt2); pub const degree330 = comptime Self.init(-0.5, halfSqrt3); pub const degree345 = comptime Self.init(-sin_15_degrees, cos_15_degrees); pub fn init(x: f64, y: f64) Self { return Self{ .x = x, .y = y, }; } pub fn angle(t: f64) Self { return .{ .x = math.cos(t), .y = -math.sin(t), }; } pub fn length(self: Self) f64 { return math.hypot(f64, self.x, self.y); } pub fn lengthSq(self: Self) f64 { return self.dot(self); } pub fn theta(self: Self) f64 { return math.atan2(f64, self.y, self.x); } pub fn abs(self: Self) Self { return Self{ .x = math.fabs(self.x), .y = math.fabs(self.y), }; } pub fn min(self: Self, low: f64) Self { return .{ .x = math.min(self.x, low), .y = math.min(self.y, low), }; } pub fn max(self: Self, high: f64) Self { return .{ .x = math.max(self.x, high), .y = math.max(self.y, high), }; } pub fn clamp(self: Self, low: f64, high: f64) Self { return .{ .x = clamp(low, high, self.x), .y = clamp(low, high, self.y), }; } pub fn saturate(self: Self, low: f64, high: f64) Self { return .{ .x = saturate(0, 1, self.x), .y = saturate(0, 1, self.y), }; } pub fn a2(self: Self, t: A2) Self { return t.apply(self.x, self.y); } pub fn toA2(self: Self) Self { return A2.add(self.x, self.y); } pub fn add(self: Self, other: Self) Self { return Self{ .x = self.x + other.x, .y = self.y + other.y, }; } pub fn mul(self: Self, other: Self) Self { return Self{ .x = self.x * other.x, .y = self.y * other.y, }; } pub fn neg(self: Self) Self { return Self{ .x = -self.x, .y = -self.y, }; } pub fn sub(self: Self, other: Self) Self { return Self{ .x = self.x - other.x, .y = self.y - other.y, }; } pub fn scale(self: Self, m: f64) Self { return Self{ .x = self.x * m, .y = self.y * m, }; } pub fn fma(self: Self, m: f64, a: f64) Self { return Self{ .x = self.x * m + a, .y = self.y * m + a, }; } pub fn dot(self: Self, other: Self) f64 { return self.x * other.x + self.y * other.y; } pub fn ndot(self: Self, other: Self) f64 { return self.x * other.x - self.y * other.y; } pub fn normalize(self: Self) Self { const len = self.length(); return if (len == 0) zero else self.scale(1 / len); } pub fn apply(self: Self, other: Self) f64 { return self.x * other.x + self.y * other.y; } pub fn mix(self: Self, other: Self, alpha: f64) Self { const coAlpha = 1 - alpha; return .{ .x = alpha * other.x + coAlpha * self.x, .y = alpha * other.y + coAlpha * self.y, }; } pub fn coMix(self: Self, other: Self, alpha: f64) Self { return .{ .x = gmath.coMix(a.x, b.x, alpha), .y = gmath.coMix(a.y, b.y, alpha), }; } pub fn mixV(self: Self, other: Self, alpha: V2) Self { return .{ .x = alpha.x * other.x + (1 - alpha.x) * self.x, .y = alpha.y * other.y + (1 - alpha.y) * self.y, }; } pub fn rotate(self: Self, rx: f64, ry: f64) Self { return .{ .x = rx * self.x + ry * self.y, .y = -ry * self.x + rx * self.y, }; } pub fn rotateV(self: Self, r: Self) Self { return .{ .x = r.x * self.x + r.y * self.y, .y = -r.y * self.x + r.x * self.y, }; } pub fn rotateA(self: Self, t: f64) Self { return self.rotate(math.cos(t), -math.sin(t)); } pub fn rotate90(self: Self) Self { return .{ .x = -self.y, .y = self.x, }; } pub fn rotate180(self: Self) Self { return .{ .x = -self.x, .y = -self.y, }; } pub fn rotate270(self: Self) Self { return .{ .x = self.y, .y = -self.x, }; } pub fn project(self: Self, other: Self) Self { return self.scale(self.dot(other) / self.dot(self)); } pub fn reject(self: Self, other: Self) Self { return other.sub(self.project(other)); } /// https://www.khronos.org/opengles/sdk/docs/manglsl/docbook4/xhtml/reflect.xml /// “For a given incident vector I and surface normal N reflect returns the reflection direction calculated as I - 2.0 * dot(N, I) * N. /// N should be normalized in order to achieve the desired result.” pub fn reflect(normal: Self, incident: Self) Self { return incident.sub(normal.scale(2 * normal.dot(incident))); } pub fn distTo(a: Self, b: Self) f64 { return a.sub(b).length(); } pub fn distSqTo(a: Self, b: Self) f64 { return a.sub(b).lengthSq(); } pub fn transpose(self: Self) Self { return .{ .x = self.y, .y = self.x, }; } pub fn quantize(self: Self, quantum: Self) Self { return .{ .x = @trunc(self.x / quantum.x) * quantum.x, .y = @trunc(self.y / quantum.y) * quantum.y, }; } pub fn fract(self: Self) Self { return .{ .x = @mod(self.x, 1), .y = @mod(self.y, 1), }; } pub fn floor(self: Self) Self { return .{ .x = math.floor(self.x), .y = math.floor(self.y), }; } pub fn inverse(self: Self) Self { return .{ .x = 1.0 / self.x, .y = 1.0 / self.y, }; } pub fn inHalfN(self: Self) bool { return self.y < 0.5; } pub fn inHalfS(self: Self) bool { return self.y >= 0.5; } pub fn inHalfW(self: Self) bool { return self.x < 0.5; } pub fn inHalfE(self: Self) bool { return self.x >= 0.5; } pub fn inHalfNW(self: Self) bool { return self.x + self.y < 1; } pub fn inHalfSE(self: Self) bool { return self.x + self.y >= 1; } pub fn inHalfNE(self: Self) bool { return self.x >= self.y; } pub fn inHalfSW(self: Self) bool { return self.x < self.y; } pub fn checkerboard(self: Self) bool { return @floatToInt(i32, self.x) & 1 == @floatToInt(i32, self.y) & 1; } }; pub const V3 = struct { const Self = @This(); x: f64 = 0, y: f64 = 0, z: f64 = 0, pub const zero = Self{ .x = 0, .y = 0, .z = 0 }; pub fn init(x: f64, y: f64, z: f64) Self { return .{ .x = x, .y = y, .z = z, }; } pub fn dot(a: Self, b: Self) f64 { return a.x * b.x + a.y * b.y + a.z * b.z; } pub fn lengthSq(self: Self) f64 { return dot(self, self); } pub fn length(self: Self) f64 { return math.sqrt(lengthSq(self)); } pub fn abs(self: Self) Self { return .{ .x = math.fabs(self.x), .y = math.fabs(self.y), .z = math.fabs(self.z), }; } pub fn min(self: Self, low: f64) Self { return .{ .x = math.min(self.x, low), .y = math.min(self.y, low), .z = math.min(self.z, low), }; } pub fn max(self: Self, high: f64) Self { return .{ .x = math.max(self.x, high), .y = math.max(self.y, high), .z = math.max(self.z, high), }; } pub fn clamp(self: Self, low: f64, high: f64) Self { return .{ .x = clamp(low, high, self.x), .y = clamp(low, high, self.y), .z = clamp(low, high, self.z), }; } pub fn saturate(self: Self, low: f64, high: f64) Self { return .{ .x = saturate(0, 1, self.x), .y = saturate(0, 1, self.y), .z = saturate(0, 1, self.z), }; } pub fn add(a: Self, b: Self) Self { return .{ .x = a.x + b.x, .y = a.y + b.y, .z = a.z + b.z, }; } pub fn sub(a: Self, b: Self) Self { return .{ .x = a.x - b.x, .y = a.y - b.y, .z = a.z - b.z, }; } pub fn mul(a: Self, b: Self) Self { return .{ .x = a.x * b.x, .y = a.y * b.y, .z = a.z * b.z, }; } pub fn neg(self: Self) Self { return .{ .x = -self.x, .y = -self.y, .z = -self.z, }; } pub fn scale(self: Self, m: f64) Self { return .{ .x = self.x * m, .y = self.y * m, .z = self.z * m, }; } pub fn fma(self: Self, m: f64, a: f64) Self { return .{ .x = self.x * m + a, .y = self.y * m + a, .z = self.z * m + a, }; } pub fn normalize(self: Self) Self { const mag = self.length(); return if (mag == 0) zero else self.scale(1 / mag); } pub fn mix(a: Self, b: Self, alpha: f64) Self { const coAlpha = 1 - alpha; return .{ .x = a.x * alpha + b.x * coAlpha, .y = a.y * alpha + b.y * coAlpha, .z = a.z * alpha + b.z * coAlpha, }; } pub fn mixV(a: Self, b: Self, alpha: Self) Self { return .{ .x = a.x * alpha.x + b.x * (1 - alpha.x), .y = a.y * alpha.y + b.y * (1 - alpha.y), .z = a.z * alpha.z + b.z * (1 - alpha.z), }; } /// Scalar projection of a onto b. pub fn scalarProjection(a: Self, b: Self) Self { const lenb = b.length(); return if (lenb == 0) 0 else a.dot(b) / lenb; } /// Vector projection of a onto b. pub fn vectorProjection(a: Self, b: Self) Self { const bdotb = b.dot(b); return if (bdotb == 0) zero else b.scale(a.dot(b) / bdotb); } /// Vector rejection of a from b. pub fn vectorRejection(a: Self, b: Self) Self { return a.sub(vectorProjection(a, b)); } pub fn distTo(a: Self, b: Self) f64 { return a.sub(b).length(); } /// https://www.khronos.org/opengles/sdk/docs/manglsl/docbook4/xhtml/reflect.xml /// “For a given incident vector I and surface normal N reflect returns the reflection direction calculated as I - 2.0 * dot(N, I) * N. /// N should be normalized in order to achieve the desired result.” pub fn reflect(normal: Self, incident: Self) Self { return incident.sub(normal.scale(2 * normal.dot(incident))); } pub fn cross(a: Self, b: Self) Self { return .{ .x = a.y * b.z - b.y * a.z, .y = a.z * b.x - b.z * a.x, .z = a.x * b.y - b.x * a.y, }; } }; pub const MeanV1 = struct { const Self = @This(); n: u64 = 0, x: f64 = 0, fn add(self: *Self, x: f64) void { self.n += 1; self.x += x; } fn merge(self: *Self, other: *const Self) void { self.n += other.n; self.x += other.x; } fn toMean(self: *const Self) ?f64 { if (self.n == 0) { return null; } return self.x / @intToFloat(f64, self.n); } }; pub const MeanV2 = struct { const Self = @This(); n: u64 = 0, x: f64 = 0, y: f64 = 0, fn add(self: *Self, sample: V2) void { self.n += 1; self.x += sample.x; self.y += sample.y; } fn merge(self: *Self, other: *const Self) void { self.n += other.n; self.x += other.x; self.y += other.y; } fn toMean(self: *const Self) ?V2 { if (self.n == 0) { return null; } const n = 1 / @intToFloat(f64, self.n); return V2{ .x = self.x * n, .y = self.y * n, }; } }; pub fn Affine2Type(comptime F: type) type { const mul = F.mul; const add = F.add; const zero = F.zero; const one = F.one; const neg = F.neg; const inv = F.inv; return struct { const Self = @This(); const T = F.T; a: T, b: T, c: T, d: T, e: T, f: T, pub fn apply(self: *const Self, x: T, y: T) V2 { return V2{ .x = self.applyX(x, y), .y = self.applyY(x, y), }; } pub fn applyV(self: *const Self, p: V2) V2 { return V2{ .x = add(add(mul(self.a, p.x), mul(self.b, p.y)), self.c), .y = add(add(mul(self.d, p.x), mul(self.e, p.y)), self.f), }; } pub fn applyX(self: *const Self, x: T, y: T) T { return add(add(mul(self.a, x), mul(self.b, y)), self.c); } pub fn applyY(self: *const Self, x: T, y: T) T { return add(add(mul(self.d, x), mul(self.e, y)), self.f); } pub fn applyVX(self: *const Self, p: V2) T { return add(add(mul(self.a, p.x), mul(self.b, p.y)), self.c); } pub fn applyVY(self: *const Self, p: V2) T { return add(add(mul(self.d, p.x), mul(self.e, p.y)), self.f); } pub fn applyLinearV(self: *const Self, p: V2) V2 { return V2{ .x = add(mul(self.a, p.x), mul(self.b, p.y)), .y = add(mul(self.d, p.x), mul(self.e, p.y)), }; } pub const identity = Self{ .a = one, .b = zero, .c = zero, .d = zero, .e = one, .f = zero }; pub fn isIdentity(self: *const Self) bool { return (self.a == identity.a) and (self.b == identity.b) and (self.c == identity.c) and (self.d == identity.d) and (self.e == identity.e) and (self.f == identity.f); } pub fn constant(tx: T, ty: T) Self { return Self{ .a = zero, .b = zero, .c = tx, .d = zero, .e = zero, .f = ty }; } pub fn add(tx: T, ty: T) Self { return Self{ .a = one, .b = zero, .c = tx, .d = zero, .e = one, .f = ty }; } pub fn sub(tx: T, ty: T) Self { return Self.add(neg(tx), neg(ty)); } pub fn scale(sx: T, sy: T) Self { return Self{ .a = sx, .b = zero, .c = zero, .d = zero, .e = sy, .f = zero }; } pub fn shear2(kx: T, ky: T) Self { return Self.shear4(one, ky, kx, one); } pub fn shear4(kxx: T, kxy: T, kyx: T, kyy: T) Self { return Self{ .a = kxx, .b = kyx, .c = zero, .d = kxy, .e = kyy, .f = zero }; } pub fn rotate(rx: T, ry: T) Self { return Self{ .a = rx, .b = ry, .c = zero, .d = neg(ry), .e = rx, .f = zero }; } pub fn rotateV(r: V2) Self { return Self.rotate(r.x, r.y); } pub fn rotate90() Self { return Self.rotate(zero, neg(one)); } pub fn rotate180() Self { return Self.rotate(neg(one), zero); } pub fn rotate270() Self { return Self.rotate(zero, one); } pub fn multiply(x: Self, y: Self) Self { return Self{ .a = add(mul(x.a, y.a), mul(x.b, y.d)), .b = add(mul(x.a, y.b), mul(x.b, y.e)), .c = add(add(mul(x.a, y.c), mul(x.b, y.f)), x.c), .d = add(mul(x.d, y.a), mul(x.e, y.d)), .e = add(mul(x.d, y.b), mul(x.e, y.e)), .f = add(add(mul(x.d, y.c), mul(x.e, y.f)), x.f), }; } pub fn compose(x: Self, y: Self) Self { return multiply(y, x); } pub fn sum(x: Self, y: Self) Self { return Self{ .a = x.a + y.a, .b = x.b + y.b, .c = x.c + y.c, .d = x.d + y.d, .e = x.e + y.e, .f = x.f + y.f, }; } //pub fn chain(args: ...) Self { // var result = Self.identity; // comptime var i = 0; // inline while (i < args.len) : (i += 1) { // result = multiply(args[i], result); // } // return result; //} pub fn mix(x0: T, x1: T, y0: T, y1: T) Self { return multiply(Self.add(x0, y0), Self.scale(add(x1, neg(x0)), add(y1, neg(y0)))); } pub fn coMix(x0: T, x1: T, y0: T, y1: T) Self { return Self.mix(x0, x1, y0, y1).inverse(); } pub fn map(x0: T, x1: T, x2: T, x3: T, y0: T, y1: T, y2: T, y3: T) Self { return multiply(Self.coMix(x0, x1, y0, y1), Self.mix(x2, x3, y2, y3)); } // https://en.wikipedia.org/wiki/Invertible_matrix#Methods_of_matrix_inversion pub fn inverse(self: *const Self) Self { const det = inv(add(mul(self.a, self.e), neg(mul(self.b, self.d)))); return Self{ .a = mul(det, self.e), .b = neg(mul(det, self.b)), .c = mul(det, add(mul(self.b, self.f), neg(mul(self.c, self.e)))), .d = neg(mul(det, self.d)), .e = mul(det, self.a), .f = neg(mul(det, add(mul(self.a, self.f), neg(mul(self.c, self.d))))), }; } pub fn under(t1: A2, t2: A2) A2 { return multiply(t1.inverse(), multiply(t2, t1)); } }; } pub const MeanA1 = struct { const Self = @This(); n: u64, m: f64, a: f64, pub fn init() Self { return Self{ .n = 0, .m = 0, .a = 0, }; } pub fn add(self: *Self, sample: A1) void { self.n += 1; self.m += sample.m; self.a += sample.a; } pub fn merge(self: *Self, other: *const Self) void { self.n += other.n; self.m += other.m; self.a += other.a; } pub fn toA1(self: *const Self) ?A1 { if (self.n == 0) { return null; } const n = 1 / @intToFloat(self.n); return A1{ .m = self.m * n, .a = self.a * n, }; } }; pub const MeanA2 = struct { const Self = @This(); n: u64, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64, pub fn init() Self { return Self{ .n = 0, .a = 0, .b = 0, .c = 0, .d = 0, .e = 0, .f = 0, }; } pub fn add(self: *Self, sample: A2) void { self.n += 1; self.a += sample.a; self.b += sample.b; self.c += sample.c; self.d += sample.d; self.e += sample.e; self.f += sample.f; } pub fn merge(self: *Self, other: *const Self) void { self.n += other.n; self.a += other.a; self.b += other.b; self.c += other.c; self.d += other.d; self.e += other.e; self.f += other.f; } pub fn toA2(self: *const Self) ?A2 { if (self.n == 0) { return null; } const n = 1 / @intToFloat(self.n); return A2{ .a = self.a * n, .b = self.b * n, .c = self.c * n, .d = self.d * n, .e = self.e * n, .f = self.f * n, }; } };
lib/affine.zig
const std = @import("std"); const c = @import("c.zig"); pub const Draw = struct { window: c.Window = undefined, display: *c.Display = undefined, drawable: c.Drawable = undefined, gc: c.GC = undefined, _width: u32, _height: u32, const Self = *Draw; pub fn init(self: Self, display: *c.Display, window: c.Window, xscreen: i32, width: u32, height: u32) void { self.display = display; self.window = window; self._width = width; self._height = height; self.drawable = c.XCreatePixmap(display, window, self._width, self._height, @intCast(c_uint, c.XDefaultDepth(display, xscreen))); self.gc = c.XCreateGC(display, window, 0, null); _ = c.XSetFillStyle(display, self.gc, c.FillSolid); } pub fn setForeground(self: Self, color: u64) void { _ = c.XSetForeground(self.display, self.gc, color); } pub fn drawText(self: Self, font: *c.XftFont, color: *c.XColor, x: i32, y: i32, text: []const u8) void { var renderColor: c.XRenderColor = undefined; renderColor.red = color.red; renderColor.green = color.green; renderColor.blue = color.blue; renderColor.alpha = 65535; var draw: *c.XftDraw = undefined; var visual = c.XDefaultVisual(self.display, 0); var colormap = c.XDefaultColormap(self.display, 0); var xftColor: c.XftColor = undefined; _ = c.XftColorAllocValue(self.display, visual, colormap, &renderColor, &xftColor); defer c.XftColorFree(self.display, visual, colormap, &xftColor); draw = c.XftDrawCreate(self.display, self.window, visual, colormap).?; defer c.XftDrawDestroy(draw); var width: u32 = 0; var height: u32 = 0; self.getTextDimensions(font, text, &width, &height); c.XftDrawString8(draw, &xftColor, font, x, y + @intCast(i32, height), text.ptr, @intCast(i32, text.len)); } pub fn getTextDimensions(self: Self, font: *c.XftFont, text: []const u8, width: *u32, height: *u32) void { // TODO: c style function return tuple or vec2 var glyphInfo: c.XGlyphInfo = undefined; c.XftTextExtentsUtf8(self.display, font, text.ptr, @intCast(i32, text.len), &glyphInfo); width.* = @intCast(u32, glyphInfo.xOff); height.* = @intCast(u32, font.ascent + font.descent); } pub fn fillRect(self: Self, x: i32, y: i32, width: u32, height: u32) void { _ = c.XFillRectangle(self.display, self.drawable, self.gc, x, y, width, height); } pub fn render(self: Self) void { _ = c.XCopyArea(self.display, self.drawable, self.window, self.gc, 0, 0, self._width, self._height, 0, 0); } pub fn free(self: Self) void { _ = c.XFreePixmap(self.display, self.drawable); _ = c.XFreeGC(self.display, self.gc); } };
src/xdraw.zig
/// Definitions of all of the x64 registers. The order is very, very important. /// The registers are defined such that IDs go in descending order of 64-bit, /// 32-bit, 16-bit, and then 8-bit, and each set contains exactly sixteen /// registers. This results in some very, very useful properties: /// /// Any 64-bit register can be turned into its 32-bit form by adding 16, and /// vice versa. This also works between 32-bit and 16-bit forms. With 8-bit, it /// works for all except for sp, bp, si, and di, which don't *have* an 8-bit /// form. /// /// If (register & 8) is set, the register is extended. /// /// The ID can be easily determined by figuring out what range the register is /// in, and then subtracting the base. /// pub const Register = enum(u8) { // 0 through 15, 64-bit registers. 8-15 are extended. // id is just the int value. rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15, // 16 through 31, 32-bit registers. 24-31 are extended. // id is int value - 16. eax, ecx, edx, ebx, esp, ebp, esi, edi, r8d, r9d, r10d, r11d, r12d, r13d, r14d, r15d, // 32-47, 16-bit registers. 40-47 are extended. // id is int value - 32. ax, cx, dx, bx, sp, bp, si, di, r8w, r9w, r10w, r11w, r12w, r13w, r14w, r15w, // 48-63, 8-bit registers. 56-63 are extended. // id is int value - 48. al, bl, cl, dl, ah, ch, dh, bh, r8b, r9b, r10b, r11b, r12b, r13b, r14b, r15b, /// Returns the bit-width of the register. pub fn size(self: @This()) u7 { return switch (@enumToInt(self)) { 0...15 => 64, 16...31 => 32, 32...47 => 16, 48...64 => 8, else => unreachable, }; } /// Returns whether the register is *extended*. Extended registers are the /// new registers added with amd64, r8 through r15. This also includes any /// other variant of access to those registers, such as r8b, r15d, and so /// on. This is needed because access to these registers requires special /// handling via the REX prefix, via the B or R bits, depending on context. pub fn isExtended(self: @This()) bool { return @enumToInt(self) & 0x08 != 0; } /// This returns the 4-bit register ID, which is used in practically every /// opcode. Note that bit 3 (the highest bit) is *never* used directly in /// an instruction (@see isExtended), and requires special handling. The /// lower three bits are often embedded directly in instructions (such as /// the B8 variant of moves), or used in R/M bytes. pub fn id(self: @This()) u4 { return @truncate(u4, @enumToInt(self)); } }; // zig fmt: on
src-self-hosted/codegen/x86_64.zig
const std = @import("std"); const mem = std.mem; const expect = std.testing.expect; test "vector wrap operators" { const S = struct { fn doTheTest() void { var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; expect(mem.eql(i32, ([4]i32)(v +% x), [4]i32{ -2147483648, 2147483645, 33, 44 })); expect(mem.eql(i32, ([4]i32)(v -% x), [4]i32{ 2147483646, 2147483647, 27, 36 })); expect(mem.eql(i32, ([4]i32)(v *% x), [4]i32{ 2147483647, 2, 90, 160 })); var z: @Vector(4, i32) = [4]i32{ 1, 2, 3, -2147483648 }; expect(mem.eql(i32, ([4]i32)(-%z), [4]i32{ -1, -2, -3, -2147483648 })); } }; S.doTheTest(); comptime S.doTheTest(); } test "vector int operators" { const S = struct { fn doTheTest() void { var v: @Vector(4, i32) = [4]i32{ 10, 20, 30, 40 }; var x: @Vector(4, i32) = [4]i32{ 1, 2, 3, 4 }; expect(mem.eql(i32, ([4]i32)(v + x), [4]i32{ 11, 22, 33, 44 })); expect(mem.eql(i32, ([4]i32)(v - x), [4]i32{ 9, 18, 27, 36 })); expect(mem.eql(i32, ([4]i32)(v * x), [4]i32{ 10, 40, 90, 160 })); expect(mem.eql(i32, ([4]i32)(-v), [4]i32{ -10, -20, -30, -40 })); } }; S.doTheTest(); comptime S.doTheTest(); } test "vector float operators" { const S = struct { fn doTheTest() void { var v: @Vector(4, f32) = [4]f32{ 10, 20, 30, 40 }; var x: @Vector(4, f32) = [4]f32{ 1, 2, 3, 4 }; expect(mem.eql(f32, ([4]f32)(v + x), [4]f32{ 11, 22, 33, 44 })); expect(mem.eql(f32, ([4]f32)(v - x), [4]f32{ 9, 18, 27, 36 })); expect(mem.eql(f32, ([4]f32)(v * x), [4]f32{ 10, 40, 90, 160 })); expect(mem.eql(f32, ([4]f32)(-x), [4]f32{ -1, -2, -3, -4 })); } }; S.doTheTest(); comptime S.doTheTest(); } test "vector bit operators" { const S = struct { fn doTheTest() void { var v: @Vector(4, u8) = [4]u8{ 0b10101010, 0b10101010, 0b10101010, 0b10101010 }; var x: @Vector(4, u8) = [4]u8{ 0b11110000, 0b00001111, 0b10101010, 0b01010101 }; expect(mem.eql(u8, ([4]u8)(v ^ x), [4]u8{ 0b01011010, 0b10100101, 0b00000000, 0b11111111 })); expect(mem.eql(u8, ([4]u8)(v | x), [4]u8{ 0b11111010, 0b10101111, 0b10101010, 0b11111111 })); expect(mem.eql(u8, ([4]u8)(v & x), [4]u8{ 0b10100000, 0b00001010, 0b10101010, 0b00000000 })); } }; S.doTheTest(); comptime S.doTheTest(); } test "implicit cast vector to array" { const S = struct { fn doTheTest() void { var a: @Vector(4, i32) = [_]i32{ 1, 2, 3, 4 }; var result_array: [4]i32 = a; result_array = a; expect(mem.eql(i32, result_array, [4]i32{ 1, 2, 3, 4 })); } }; S.doTheTest(); comptime S.doTheTest(); } test "array to vector" { var foo: f32 = 3.14; var arr = [4]f32{ foo, 1.5, 0.0, 0.0 }; var vec: @Vector(4, f32) = arr; }
test/stage1/behavior/vector.zig
const graphics = @import("didot-graphics"); const zalgebra = @import("zalgebra"); const std = @import("std"); const AssetManager = @import("assets.zig").AssetManager; const AssetHandle = @import("assets.zig").AssetHandle; const Component = @import("components.zig").Component; const Mesh = graphics.Mesh; const Window = graphics.Window; const Material = graphics.Material; const Allocator = std.mem.Allocator; const Vec3 = zalgebra.Vec3; pub const GameObjectArrayList = std.ArrayList(*GameObject); pub const ComponentMap = std.StringHashMap(Component); /// Mesh of a plane. pub var PrimitivePlaneMesh: Mesh = undefined; /// Mesh of a cube. pub var PrimitiveCubeMesh: Mesh = undefined; pub fn createHeightmap(allocator: Allocator, heightmap: [][]const f32) !Mesh { const height = heightmap.len; const width = heightmap[0].len; const sqLen = 0.5; var vertices = try allocator.alloc(f32, width*height*(4*5)); // width*height*vertices*vertex size defer allocator.free(vertices); var elements = try allocator.alloc(graphics.MeshElementType, heightmap.len*height*6); defer allocator.free(elements); for (heightmap) |column, column_index| { for (column) |cell, row_index| { var pos: usize = (column_index*height+row_index)*(5*4); var x: f32 = @intToFloat(f32, row_index)*sqLen*2; var z: f32 = @intToFloat(f32, column_index)*sqLen*2; var trY: f32 = 0.0; var blY: f32 = 0.0; var brY: f32 = 0.0; if (column_index < height-1) trY = column[row_index+1]; if (column_index > 0) blY = heightmap[column_index-1][column_index]; if (column_index > 0 and column_index < width-1) brY = heightmap[column_index-1][column_index+1]; vertices[pos] = x-sqLen; vertices[pos+1] = cell; vertices[pos+2] = z+sqLen; vertices[pos+3] = 0.0; vertices[pos+4] = 0.0; // top-left vertices[pos+5] = x-sqLen; vertices[pos+6] = blY; vertices[pos+7] = z-sqLen; vertices[pos+8] = 0.0; vertices[pos+9] = 1.0; // bottom-left vertices[pos+10] = x+sqLen; vertices[pos+11] = brY; vertices[pos+12] = z-sqLen; vertices[pos+13] = 1.0; vertices[pos+14] = 1.0; // bottom-right vertices[pos+15] = x+sqLen; vertices[pos+16] = trY; vertices[pos+17] = z+sqLen; vertices[pos+18] = 1.0; vertices[pos+19] = 0.0; // top-right var vecPos: graphics.MeshElementType = @intCast(graphics.MeshElementType, (column_index*height+row_index)*4); var elemPos: usize = (column_index*height+row_index)*6; elements[elemPos] = vecPos; elements[elemPos+1] = vecPos+1; elements[elemPos+2] = vecPos+2; elements[elemPos+3] = vecPos; elements[elemPos+4] = vecPos+3; elements[elemPos+5] = vecPos+2; } } return Mesh.create(vertices, elements); } /// This function must be called before primitive meshes (like PrimitiveCubeMesh) can be used. /// Since it create meshes it must be called after the window context is set. /// It is also automatically called by didot-app.Application pub fn initPrimitives() void { var planeVert = [_]f32 { -0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 1.0, 0.0, 0.5, -0.5, 0.0, 1.0, 1.0, -0.5, -0.5, 0.0, 0.0, 1.0 }; var planeElem = [_]graphics.MeshElementType { 0, 1, 2, 2, 3, 0 }; PrimitivePlaneMesh = Mesh.create(planeVert[0..], planeElem[0..]); // position, normal, tex coords // var cubeVert = [_]f32 { // // front // -0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, // upper left // 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, // upper right // 0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, // bottom right // -0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 0.0, 1.0, // bottom left // // bottom // -0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 0.0, 0.0, // bottom left // 0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 1.0, 0.0, // bottom right // // right // -0.5, 0.5, -0.5, 1.0, 0.0, 1.0, 1.0, 0.0, // upper left // -0.5, -0.5, -0.5, 1.0, 0.0, -1.0, 1.0, 1.0, // bottom left // // left // 0.5, 0.5, -0.5, -1.0, 0.0, 0.0, 0.0, 0.0, // upper left // 0.5, -0.5, -0.5, -1.0, 0.0, 0.0, 0.0, 1.0, // bottom left // // top // -0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 0.0, 1.0, // top left // 0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 1.0, // top right // }; // var cubeElem = [_]graphics.MeshElementType { // // front // 0, 1, 3, // 1, 3, 2, // // bottom // 3, 2, 4, // 2, 5, 4, // // right // 0, 3, 6, // 3, 6, 7, // // left // 1, 2, 8, // 2, 8, 9, // // top // 0, 1, 10, // 1, 11, 10, // }; //PrimitiveCubeMesh = Mesh.create(cubeVert[0..], cubeElem[0..]); var cubeVert = [_]f32{ // back -0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 0.0, 0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, -0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 1.0, -0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, // front -0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, -0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 0.0, 1.0, -0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, // left -0.5, 0.5, 0.5, -1.0, 0.0, 0.0, 0.0, 1.0, -0.5, 0.5, -0.5, -1.0, 0.0, 0.0, 1.0, 1.0, -0.5, -0.5, -0.5, -1.0, 0.0, 0.0, 1.0, 0.0, -0.5, -0.5, -0.5, -1.0, 0.0, 0.0, 1.0, 0.0, -0.5, -0.5, 0.5, -1.0, 0.0, 0.0, 0.0, 0.0, -0.5, 0.5, 0.5, -1.0, 0.0, 0.0, 0.0, 1.0, // right 0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.5, -0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 0.0, 0.5, -0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 0.0, 0.5, -0.5, 0.5, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 0.0, 1.0, // bottom -0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 0.0, 0.0, 0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 0.0, 0.0, 0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 0.0, 0.0, 0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 0.0, 0.0, -0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 0.0, 0.0, -0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 0.0, 0.0, // top -0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0, 1.0, -0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 0.0, 1.0, -0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 0.0, 0.0, }; PrimitiveCubeMesh = Mesh.create(cubeVert[0..], null); } pub const GameObject = struct { // TODO: change to a Renderer component mesh: ?AssetHandle = null, name: []const u8 = "Game Object", components: ComponentMap, material: Material = Material.default, /// To be used for game objects entirely made of other game objects as childrens, or for script-only game objects. pub fn createEmpty(allocator: Allocator) GameObject { return GameObject { .components = ComponentMap.init(allocator) }; } /// The default kind of game object, it is renderable via its mesh and material. pub fn createObject(allocator: Allocator, mesh: ?AssetHandle) !GameObject { var gameObject = GameObject { .mesh = mesh, .components = ComponentMap.init(allocator) }; try gameObject.addComponent(Transform {}); if (mesh != null) { // TODO: add Renderer } return gameObject; } pub fn getComponent(self: *const GameObject, comptime T: type) ?*T { if (self.components.get(@typeName(T))) |cp| { if (@sizeOf(T) == 0) { return undefined; } else { return @intToPtr(*T, cp.data); } } else { return null; } } pub fn hasComponent(self: *const GameObject, comptime T: type) bool { return self.getComponent(T) != null; } pub fn addComponent(self: *GameObject, component: anytype) !void { const wrapper = try Component.from(self.components.allocator, component); try self.components.put(wrapper.name, wrapper); } // TODO: move to Transform component (which will also include hierarchy) // pub fn findChild(self: *GameObject, name: []const u8) ?*GameObject { // const held = self.treeLock.acquire(); // defer held.release(); // for (self.childrens.items) |child| { // if (std.mem.eql(u8, child.name, name)) return child; // } // return null; // } // pub fn add(self: *GameObject, go: GameObject) !void { // const held = self.treeLock.acquire(); // defer held.release(); // var gameObject = try self.childrens.allocator.create(GameObject); // gameObject.* = go; // gameObject.parent = self; // try self.childrens.append(gameObject); // } /// Frees childrens array list (not childrens themselves!), the object associated to it and itself. pub fn deinit(self: *GameObject) void { var iterator = self.components.valueIterator(); while (iterator.next()) |component| { component.deinit(); } self.components.deinit(); } }; pub const Projection = union(enum) { Perspective: struct { fov: f32, far: f32, near: f32 }, Orthographic: struct { left: f32, right: f32, bottom: f32, top: f32, far: f32, near: f32 } }; pub const Skybox = struct { shader: graphics.ShaderProgram, cubemap: AssetHandle, mesh: AssetHandle }; /// Camera component. /// Add it to a GameObject for it to act as the camera. pub const Camera = struct { shader: graphics.ShaderProgram, skybox: ?Skybox = null, priority: u32 = 0, projection: Projection = .{ .Perspective = .{ .fov = 70, .far = 1000, .near = 0.1 } } }; /// Point light component. /// Add it to a GameObject for it to emit point light. pub const PointLight = struct { /// The color emitted by the light color: graphics.Color = graphics.Color.one(), /// Constant attenuation (the higher it is, the darker the light is) constant: f32 = 1.0, /// Linear attenuation linear: f32 = 0.018, /// Quadratic attenuation quadratic: f32 = 0.016 }; pub const Transform = struct { position: Vec3 = Vec3.zero(), /// In order: roll, pitch, yaw. Angles are in radians. /// Note: this will be replaced with quaternions very soon! rotation: zalgebra.Quat = zalgebra.Quat.zero(), scale: Vec3 = Vec3.one(), parent: ?*Transform = null, /// This functions returns the forward (the direction) vector of this game object using its rotation. pub fn getForward(self: *const Transform) Vec3 { const rot = self.rotation.extractRotation(); const x = zalgebra.toRadians(rot.x); const y = zalgebra.toRadians(rot.y); return Vec3.new( std.math.cos(x) * std.math.cos(y), std.math.sin(y), std.math.sin(x) * std.math.cos(y) ); } /// This functions returns the right vector of this game object using its rotation. pub fn getRight(self: *const Transform) Vec3 { const rot = self.rotation.extractRotation(); const x = zalgebra.toRadians(rot.x); const y = zalgebra.toRadians(rot.y); _ = y; return Vec3.new( -std.math.sin(x), 0, std.math.cos(x) ); } pub fn lookAt(self: *Transform, target: Vec3) void { // const forward = Vec3.back(); // const direction = target.sub(self.position).norm(); // // const direction = self.position.sub(target).norm(); // const dot = Vec3.dot(forward, direction); // const epsilon = 0.00001; // if (std.math.approxEqAbs(f32, dot, -1.0, epsilon)) { // self.rotation = zalgebra.quat.new(std.math.pi, 0, 1, 0); // } else if (std.math.approxEqAbs(f32, dot, 1.0, epsilon)) { // self.rotation = zalgebra.quat.zero(); // } // const angle = zalgebra.to_degrees(std.math.acos(dot)); // const axis = Vec3.cross(forward, direction).norm(); // std.log.info("dot: {d}, {d}° around {}", .{dot, angle, axis}); // self.rotation = zalgebra.quat.from_axis(angle, axis).norm(); const up = Vec3.up(); const forward = target.sub(self.position).norm(); const right = up.cross(forward).norm(); const ip = forward.cross(right); //const ip = up; var mat = zalgebra.Mat4.identity(); mat.data[0][0] = right.x; mat.data[0][1] = right.y; mat.data[0][2] = right.z; mat.data[1][0] = ip.x; mat.data[1][1] = ip.y; mat.data[1][2] = ip.z; mat.data[2][0] = forward.x; mat.data[2][1] = forward.y; mat.data[2][2] = forward.z; self.rotation = zalgebra.quat.from_mat4(mat); std.log.info("rotation = {}", .{self.rotation.extract_rotation()}); std.log.info("{} vs {}", .{self.getForward(), forward}); } }; //pub const Renderer2D = ComponentType(.Renderer2D, struct {}, .{}) {}; pub const Scene = struct { objects: GameObjectArrayList, /// The camera the scene is currently using. /// It is auto-detected at runtime before each render by looking /// on top-level game objects to select one that has a Camera component. camera: ?*GameObject, pointLight: ?*GameObject, assetManager: AssetManager, allocator: Allocator, /// Lock used when accesing the game object's tree treeLock: std.Thread.Mutex = .{}, pub fn create(allocator: Allocator, assetManager: ?AssetManager) !*Scene { var scene = try allocator.create(Scene); scene.allocator = allocator; scene.treeLock = .{}; scene.objects = GameObjectArrayList.init(allocator); if (assetManager) |mg| { scene.assetManager = mg; } else { scene.assetManager = AssetManager.init(allocator); } return scene; } pub fn loadFromFile(allocator: Allocator, path: []const u8) !Scene { const file = try std.fs.cwd().openFile(path, .{ .read = true }); defer file.close(); const text = try file.readToEndAlloc(allocator, std.math.maxInt(usize)); defer allocator.free(text); return Scene.loadFromMemory(allocator, text); } pub fn loadFromMemory(allocator: Allocator, json: []const u8) !Scene { _ = allocator; std.debug.warn("{s}\n", .{json}); } fn renderCommon(self: *Scene) void { var childs: GameObjectArrayList = self.objects; // TODO: only do this when a new child is inserted self.camera = null; self.pointLight = null; self.treeLock.lock(); for (childs.items) |child| { if (child.hasComponent(PointLight)) { self.pointLight = child; } if (child.getComponent(Camera)) |cam| { if (self.camera) |currentCam| { if (cam.priority < currentCam.getComponent(Camera).?.priority) continue; } self.camera = child; } } self.treeLock.unlock(); } pub fn renderOffscreen(self: *Scene, viewport: zalgebra.Vec4) !void { self.renderCommon(); try graphics.renderSceneOffscreen(self, viewport); } pub fn render(self: *Scene, window: Window) !void { self.renderCommon(); try graphics.renderScene(self, window); } pub fn add(self: *Scene, go: GameObject) !void { self.treeLock.lock(); defer self.treeLock.unlock(); var gameObject = try self.objects.allocator.create(GameObject); gameObject.* = go; try self.objects.append(gameObject); } pub fn findChild(self: *Scene, name: []const u8) ?*GameObject { self.treeLock.lock(); defer self.treeLock.unlock(); for (self.objects.items) |child| { if (std.mem.eql(u8, child.name, name)) return child; } return null; } pub fn deinit(self: *Scene) void { self.assetManager.deinit(); for (self.objects.items) |child| { child.deinit(); self.objects.allocator.destroy(child); } self.objects.deinit(); self.allocator.destroy(self); } pub fn deinitAll(self: *Scene) void { self.assetManager.deinit(); for (self.objects.items) |child| { child.deinit(); self.objects.allocator.destroy(child); } self.objects.deinit(); self.allocator.destroy(self); } }; // Tests const expect = std.testing.expect; test "empty gameobject" { var alloc = std.heap.page_allocator; var go = GameObject.createEmpty(alloc); expect(go.mesh == null); //expect(go.childrens.items.len == 0); //expect(go.objectType == null); } test "empty asset" { var scene = try Scene.create(std.testing.allocator, null); var mgr = scene.assetManager; std.testing.expectEqual(false, mgr.has("azerty")); scene.deinit(); } test "default camera" { // var alloc = std.heap.page_allocator; // var cam = try Camera.create(alloc, undefined); // expect(cam.projection.Perspective.fov == 70); // default FOV // expect(cam.gameObject.objectType != null); // std.testing.expectEqualStrings("camera", cam.gameObject.objectType.?); // cam.deinit(); } comptime { std.testing.refAllDecls(@This()); std.testing.refAllDecls(GameObject); }
didot-objects/objects.zig
const std = @import("std"); const mem = std.mem; pub const client_start = 0x00000001; pub const client_end = 0xfeffffff; pub const server_start = 0xff000000; pub const server_end = 0xffffffff; pub const Side = enum { server, client, }; pub fn ObjectMap(comptime Object: type, comptime side: Side) type { return struct { const Error = error{ OutOfMemory, NonSequentialObjectCreation }; const Self = @This(); const FreeList = struct { const Elem = union(enum) { object: Object, free: u32, }; array: std.ArrayList(Elem), next: u32, fn get(list: *FreeList, i: u32) ?*Object { if (i >= list.array.items.len) return null; switch (list.array.items[i]) { .object => |*object| return object, .free => unreachable, } } fn create(list: *FreeList, i: u32) Error!*Object { if (i < list.array.items.len) { const elem = &list.array.items[i]; elem.* = Elem{ .object = undefined }; return &elem.object; } else if (i == list.array.items.len) { const elem = try list.array.addOne(); elem.* = Elem{ .object = undefined }; list.next += 1; return &elem.object; } else { return error.NonSequentialObjectCreation; } } }; allocator: mem.Allocator, client: FreeList, server: FreeList, pub fn init(allocator: mem.Allocator) Self { return .{ .allocator = allocator, .client = .{ .array = std.ArrayList(FreeList.Elem).init(allocator), .next = 0, }, .server = .{ .array = std.ArrayList(FreeList.Elem).init(allocator), .next = 0, }, }; } pub fn deinit(map: *Self) void { map.client.array.deinit(); map.server.array.deinit(); } pub fn get(map: *Self, id: u32) ?*Object { return switch (id) { 0 => unreachable, client_start...client_end => map.client.get(id - client_start), server_start...server_end => map.server.get(id - server_start), }; } pub const NewObject = struct { object: *Object, id: u32, }; pub fn create(map: *Self) error{OutOfMemory}!NewObject { const id = switch (side) { .client => client_start + map.client.next, .server => server_start + map.server.next, }; return map.createId(id) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.NonSequentialObjectCreation => unreachable, }; } pub fn createId(map: *Self, id: u32) Error!NewObject { const object = switch (id) { 0 => unreachable, client_start...client_end => try map.client.create(id - client_start), server_start...server_end => try map.server.create(id - server_start), }; return NewObject{ .object = object, .id = id, }; } }; } test "ObjectMap" { std.testing.refAllDecls(ObjectMap(u1, .server)); std.testing.refAllDecls(ObjectMap(u1, .client)); }
src/common/object_map.zig
const std = @import("std"); const string = []const u8; const builtin = @import("builtin"); const ansi = @import("ansi"); const zigmod = @import("./lib.zig"); const u = @import("./util/index.zig"); const yaml = @import("./util/yaml.zig"); const root = @import("root"); const build_options = if (@hasDecl(root, "build_options")) root.build_options else struct {}; const bootstrap = if (@hasDecl(build_options, "bootstrap")) build_options.bootstrap else false; // // pub const CollectOptions = struct { log: bool, update: bool, lock: ?[]const [4]string = null, alloc: std.mem.Allocator, already_fetched: *std.ArrayList(string) = undefined, pub fn init(self: *CollectOptions) !void { self.already_fetched = try self.alloc.create(std.ArrayList(string)); self.already_fetched.* = std.ArrayList(string).init(self.alloc); } }; pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectOptions) !zigmod.Module { try std.fs.cwd().makePath(cachepath); const m = try zigmod.ModFile.from_dir(options.alloc, mdir); try options.init(); var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc); defer moduledeps.deinit(); if (m.root_files.len > 0) { try moduledeps.append(try add_files_package(options.alloc, cachepath, "root", mdir, m.root_files)); } try moduledeps.append(try collect_deps(cachepath, mdir, options)); for (m.rootdeps) |*d| { if (try get_module_from_dep(d, cachepath, options)) |founddep| { try moduledeps.append(founddep); } } for (m.builddeps) |*d| { if (try get_module_from_dep(d, cachepath, options)) |founddep| { try moduledeps.append(founddep); } } return zigmod.Module{ .alloc = options.alloc, .is_sys_lib = false, .id = "root", .name = "root", .main = m.main, .deps = moduledeps.toOwnedSlice(), .clean_path = "", .yaml = m.yaml, .dep = null, }; } pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOptions) anyerror!zigmod.Module { try std.fs.cwd().makePath(cachepath); const m = try zigmod.ModFile.from_dir(options.alloc, mdir); var moduledeps = std.ArrayList(zigmod.Module).init(options.alloc); defer moduledeps.deinit(); if (m.files.len > 0) { try moduledeps.append(try add_files_package(options.alloc, cachepath, m.id, mdir, m.files)); } for (m.deps) |*d| { if (try get_module_from_dep(d, cachepath, options)) |founddep| { try moduledeps.append(founddep); } } return zigmod.Module{ .alloc = options.alloc, .is_sys_lib = false, .id = m.id, .name = m.name, .main = m.main, .c_include_dirs = m.c_include_dirs, .c_source_flags = m.c_source_flags, .c_source_files = m.c_source_files, .deps = moduledeps.toOwnedSlice(), .clean_path = "../..", .yaml = m.yaml, .dep = null, }; } pub fn collect_pkgs(mod: zigmod.Module, list: *std.ArrayList(zigmod.Module)) anyerror!void { if (u.list_contains_gen(zigmod.Module, list.items, mod)) { return; } try list.append(mod); for (mod.deps) |d| { try collect_pkgs(d, list); } } pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !string { const p = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path() }); const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v() }); const nocache = d.type == .local or d.type == .system_lib; if (!nocache and u.list_contains(options.already_fetched.items, p)) return p; if (!nocache and u.list_contains(options.already_fetched.items, pv)) return pv; if (options.log and d.type != .local) { u.print("fetch: {s}: {s}", .{ @tagName(d.type), d.path }); } defer { if (!bootstrap and options.log and d.type != .local) { std.debug.print("{s}", .{ansi.csi.CursorUp(1)}); std.debug.print("{s}", .{ansi.csi.EraseInLine(0)}); } } switch (d.type) { .local => { if (!std.mem.endsWith(u8, d.main, ".zig")) { return d.main; } return d.path; }, .system_lib => { // no op return ""; }, .git => { if (d.version.len > 0) { const vers = u.parse_split(zigmod.DepType.GitVersion, "-").do(d.version) catch |e| switch (e) { error.IterEmpty => unreachable, error.NoMemberFound => { const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?]; u.fail("fetch: git: version type '{s}' is invalid.", .{vtype}); }, }; if (try u.does_folder_exist(pv)) { if (vers.id == .branch) { if (options.update) { try d.type.update(options.alloc, pv, d.path); } } return pv; } try d.type.pull(options.alloc, d.path, pv); if ((try u.run_cmd(options.alloc, pv, &.{ "git", "checkout", vers.string })) > 0) { u.fail("fetch: git: {s}: {s} {s} does not exist", .{ d.path, @tagName(vers.id), vers.string }); } if (builtin.os.tag != .windows and vers.id != .branch) { const pvd = try std.fs.cwd().openDir(pv, .{}); try pvd.deleteTree(".git"); } return pv; } if (!try u.does_folder_exist(p)) { try d.type.pull(options.alloc, d.path, p); } else { if (options.update) { try d.type.update(options.alloc, p, d.path); } } return p; }, .hg => { if (!try u.does_folder_exist(p)) { try d.type.pull(options.alloc, d.path, p); } else { if (options.update) { try d.type.update(options.alloc, p, d.path); } } return p; }, .http => { if (try u.does_folder_exist(pv)) { return pv; } const file_name = try u.last(try u.split(options.alloc, d.path, "/")); if (d.version.len > 0) { if (try u.does_folder_exist(pv)) { return pv; } const file_path = try std.fs.path.join(options.alloc, &.{ pv, file_name }); try d.type.pull(options.alloc, d.path, pv); if (try u.validate_hash(options.alloc, d.version, file_path)) { try std.fs.cwd().deleteFile(file_path); return pv; } try std.fs.cwd().deleteTree(pv); u.fail("{s} does not match hash {s}", .{ d.path, d.version }); return p; } if (try u.does_folder_exist(p)) { try std.fs.cwd().deleteTree(p); } const file_path = try std.fs.path.join(options.alloc, &.{ p, file_name }); try d.type.pull(options.alloc, d.path, p); try std.fs.deleteFileAbsolute(file_path); return p; }, } } pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectOptions) anyerror!?zigmod.Module { if (options.lock) |lock| { for (lock) |item| { if (std.mem.eql(u8, item[0], try d.clean_path())) { d.type = std.meta.stringToEnum(zigmod.DepType, item[1]).?; d.path = item[2]; d.version = item[3]; break; } } } if (!d.is_for_this()) return null; const modpath = try get_modpath(cachepath, d.*, options); const moddir = if (std.mem.eql(u8, modpath, "files") or modpath.len == 0) try std.fs.cwd().openDir(cachepath, .{}) else try std.fs.cwd().openDir(modpath, .{}); const nocache = d.type == .local or d.type == .system_lib; if (!nocache) try options.already_fetched.append(modpath); switch (d.type) { .system_lib => { return zigmod.Module{ .alloc = options.alloc, .is_sys_lib = true, .id = try u.do_hash(options.alloc, std.crypto.hash.sha3.Sha3_384, d.path), .name = d.path, .only_os = d.only_os, .except_os = d.except_os, .main = "", .deps = &[_]zigmod.Module{}, .clean_path = d.path, .yaml = null, .dep = d.*, .for_build = d.for_build, }; }, else => { var dd = try collect_deps(cachepath, moddir, options) catch |e| switch (e) { error.FileNotFound => { if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0 or d.keep) { var mod_from = try zigmod.Module.from(options.alloc, d.*, modpath, options); if (d.type != .local) mod_from.clean_path = u.trim_prefix(modpath, cachepath)[1..]; if (mod_from.is_for_this()) return mod_from; return null; } const moddirO = try std.fs.cwd().openDir(modpath, .{}); const tryname = try u.detect_pkgname(options.alloc, d.name, modpath); const trymain = u.detct_mainfile(options.alloc, d.main, moddirO, tryname) catch |err| switch (err) { error.CantFindMain => null, else => return err, }; if (trymain) |_| { d.*.name = tryname; d.*.main = trymain.?; var mod_from = try zigmod.Module.from(options.alloc, d.*, cachepath, options); if (d.type != .local) mod_from.clean_path = u.trim_prefix(modpath, cachepath)[1..]; if (mod_from.is_for_this()) return mod_from; return null; } u.fail("no zig.mod found and no override props defined. unable to use add this dependency!", .{}); }, else => e, }; dd.dep = d.*; dd.for_build = d.for_build; const save = dd; if (d.type != .local) dd.clean_path = u.trim_prefix(modpath, cachepath)[1..]; if (dd.id.len == 0) dd.id = try u.random_string(options.alloc, 48); if (d.name.len > 0) dd.name = d.name; if (d.main.len > 0) dd.main = d.main; if (d.c_include_dirs.len > 0) dd.c_include_dirs = d.c_include_dirs; if (d.c_source_flags.len > 0) dd.c_source_flags = d.c_source_flags; if (d.c_source_files.len > 0) dd.c_source_files = d.c_source_files; if (d.only_os.len > 0) dd.only_os = d.only_os; if (d.except_os.len > 0) dd.except_os = d.except_os; if (d.type == .local) dd.main = try std.fs.path.join(options.alloc, &.{ d.main, save.main }); if (std.mem.eql(u8, modpath, "files")) dd.clean_path = modpath; if (dd.is_for_this()) return dd; return null; }, } } pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name: string, mdir: std.fs.Dir, dirs: []const string) !zigmod.Module { const fname = try std.mem.join(alloc, "", &.{ pkg_name, ".zig" }); const map = &std.StringHashMap(string).init(alloc); defer map.deinit(); for (dirs) |dir_path| { const dir = try mdir.openDir(dir_path, .{ .iterate = true }); var walker = try dir.walk(alloc); defer walker.deinit(); while (try walker.next()) |p| { if (p.kind == .Directory) { continue; } const path = try alloc.dupe(u8, p.path); try map.put(path, try std.fmt.allocPrint(alloc, "{s}/{s}", .{ dir_path, path })); } } const cwdpath = try std.fs.cwd().realpathAlloc(alloc, "."); const mpath = try mdir.realpathAlloc(alloc, "."); var fpath = u.trim_prefix(mpath, cwdpath); if (fpath.len == 0) fpath = std.fs.path.sep_str; var cachedir = try std.fs.cwd().openDir(cachepath, .{}); defer cachedir.close(); try cachedir.makePath("files"); var destdir = try cachedir.openDir("files", .{}); defer destdir.close(); const rff = try destdir.createFile(fname, .{}); defer rff.close(); const w = rff.writer(); try w.writeAll( \\const std = @import("std"); \\const string = []const u8; \\ \\ ); try w.print("const srcpath = \"../../../{}\";\n\n", .{std.zig.fmtEscapes(fpath[1..])}); var iter = map.iterator(); while (iter.next()) |item| { try w.print("pub const @\"/{}\" = @embedFile(srcpath ++ \"/{}\");\n", .{ std.zig.fmtEscapes(item.key_ptr.*), std.zig.fmtEscapes(item.value_ptr.*) }); } var d: zigmod.Dep = .{ .alloc = alloc, .type = .local, .path = "files", .id = "", .name = "self/files", .main = fname, .version = "absolute", .yaml = null, .deps = &.{}, }; var options = CollectOptions{ .log = false, .update = false, .alloc = alloc, }; const filesdestpath = try std.fs.path.join(alloc, &.{ cachepath, "files" }); return (try get_module_from_dep(&d, filesdestpath, &options)).?; } pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]string { var list = std.ArrayList([4]string).init(alloc); const max = std.math.maxInt(usize); const f = try dir.openFile("zigmod.lock", .{}); const r = f.reader(); var i: usize = 0; var v: usize = 1; while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| : (i += 1) { if (i == 0 and std.mem.eql(u8, line, "2")) { v = 2; continue; } switch (v) { 1 => { var iter = std.mem.split(u8, line, " "); try list.append([4]string{ iter.next().?, iter.next().?, iter.next().?, iter.next().?, }); }, 2 => { var iter = std.mem.split(u8, line, " "); const asdep = zigmod.Dep{ .alloc = alloc, .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?, .path = iter.next().?, .version = iter.next().?, .id = "", .name = "", .main = "", .yaml = null, .deps = &.{}, }; try list.append([4]string{ try asdep.clean_path(), @tagName(asdep.type), asdep.path, asdep.version, }); }, else => { u.fail("invalid zigmod.lock version: {d}", .{v}); }, } } return list.toOwnedSlice(); }
src/common.zig
const std = @import("std"); const mode = @import("builtin").mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels inline fn cast(comptime DestType: type, target: anytype) DestType { if (@typeInfo(@TypeOf(target)) == .Int) { const dest = @typeInfo(DestType).Int; const source = @typeInfo(@TypeOf(target)).Int; if (dest.bits < source.bits) { return @bitCast(DestType, @truncate(std.meta.Int(source.signedness, dest.bits), target)); } else { return @bitCast(DestType, @as(std.meta.Int(source.signedness, dest.bits), target)); } } return @as(DestType, target); } // The type MontgomeryDomainFieldElement is a field element in the Montgomery domain. // Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub const MontgomeryDomainFieldElement = [6]u64; // The type NonMontgomeryDomainFieldElement is a field element NOT in the Montgomery domain. // Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub const NonMontgomeryDomainFieldElement = [6]u64; /// The function addcarryxU64 is an addition with carry. /// /// Postconditions: /// out1 = (arg1 + arg2 + arg3) mod 2^64 /// out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0x1] inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { @setRuntimeSafety(mode == .Debug); const x1 = ((cast(u128, arg1) + cast(u128, arg2)) + cast(u128, arg3)); const x2 = cast(u64, (x1 & cast(u128, 0xffffffffffffffff))); const x3 = cast(u1, (x1 >> 64)); out1.* = x2; out2.* = x3; } /// The function subborrowxU64 is a subtraction with borrow. /// /// Postconditions: /// out1 = (-arg1 + arg2 + -arg3) mod 2^64 /// out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0x1] inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { @setRuntimeSafety(mode == .Debug); const x1 = ((cast(i128, arg2) - cast(i128, arg1)) - cast(i128, arg3)); const x2 = cast(i1, (x1 >> 64)); const x3 = cast(u64, (x1 & cast(i128, 0xffffffffffffffff))); out1.* = x3; out2.* = cast(u1, (cast(i2, 0x0) - cast(i2, x2))); } /// The function mulxU64 is a multiplication, returning the full double-width result. /// /// Postconditions: /// out1 = (arg1 * arg2) mod 2^64 /// out2 = ⌊arg1 * arg2 / 2^64⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0xffffffffffffffff] /// arg2: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0xffffffffffffffff] inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (cast(u128, arg1) * cast(u128, arg2)); const x2 = cast(u64, (x1 & cast(u128, 0xffffffffffffffff))); const x3 = cast(u64, (x1 >> 64)); out1.* = x2; out2.* = x3; } /// The function cmovznzU64 is a single-word conditional move. /// /// Postconditions: /// out1 = (if arg1 = 0 then arg2 else arg3) /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (~(~arg1)); const x2 = cast(u64, (cast(i128, cast(i1, (cast(i2, 0x0) - cast(i2, x1)))) & cast(i128, 0xffffffffffffffff))); const x3 = ((x2 & arg3) | ((~x2) & arg2)); out1.* = x3; } /// The function mul multiplies two field elements in the Montgomery domain. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// 0 ≤ eval arg2 < m /// Postconditions: /// eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m /// 0 ≤ eval out1 < m /// pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[1]); const x2 = (arg1[2]); const x3 = (arg1[3]); const x4 = (arg1[4]); const x5 = (arg1[5]); const x6 = (arg1[0]); var x7: u64 = undefined; var x8: u64 = undefined; mulxU64(&x7, &x8, x6, (arg2[5])); var x9: u64 = undefined; var x10: u64 = undefined; mulxU64(&x9, &x10, x6, (arg2[4])); var x11: u64 = undefined; var x12: u64 = undefined; mulxU64(&x11, &x12, x6, (arg2[3])); var x13: u64 = undefined; var x14: u64 = undefined; mulxU64(&x13, &x14, x6, (arg2[2])); var x15: u64 = undefined; var x16: u64 = undefined; mulxU64(&x15, &x16, x6, (arg2[1])); var x17: u64 = undefined; var x18: u64 = undefined; mulxU64(&x17, &x18, x6, (arg2[0])); var x19: u64 = undefined; var x20: u1 = undefined; addcarryxU64(&x19, &x20, 0x0, x18, x15); var x21: u64 = undefined; var x22: u1 = undefined; addcarryxU64(&x21, &x22, x20, x16, x13); var x23: u64 = undefined; var x24: u1 = undefined; addcarryxU64(&x23, &x24, x22, x14, x11); var x25: u64 = undefined; var x26: u1 = undefined; addcarryxU64(&x25, &x26, x24, x12, x9); var x27: u64 = undefined; var x28: u1 = undefined; addcarryxU64(&x27, &x28, x26, x10, x7); const x29 = (cast(u64, x28) + x8); var x30: u64 = undefined; var x31: u64 = undefined; mulxU64(&x30, &x31, x17, 0x100000001); var x32: u64 = undefined; var x33: u64 = undefined; mulxU64(&x32, &x33, x30, 0xffffffffffffffff); var x34: u64 = undefined; var x35: u64 = undefined; mulxU64(&x34, &x35, x30, 0xffffffffffffffff); var x36: u64 = undefined; var x37: u64 = undefined; mulxU64(&x36, &x37, x30, 0xffffffffffffffff); var x38: u64 = undefined; var x39: u64 = undefined; mulxU64(&x38, &x39, x30, 0xfffffffffffffffe); var x40: u64 = undefined; var x41: u64 = undefined; mulxU64(&x40, &x41, x30, 0xffffffff00000000); var x42: u64 = undefined; var x43: u64 = undefined; mulxU64(&x42, &x43, x30, 0xffffffff); var x44: u64 = undefined; var x45: u1 = undefined; addcarryxU64(&x44, &x45, 0x0, x43, x40); var x46: u64 = undefined; var x47: u1 = undefined; addcarryxU64(&x46, &x47, x45, x41, x38); var x48: u64 = undefined; var x49: u1 = undefined; addcarryxU64(&x48, &x49, x47, x39, x36); var x50: u64 = undefined; var x51: u1 = undefined; addcarryxU64(&x50, &x51, x49, x37, x34); var x52: u64 = undefined; var x53: u1 = undefined; addcarryxU64(&x52, &x53, x51, x35, x32); const x54 = (cast(u64, x53) + x33); var x55: u64 = undefined; var x56: u1 = undefined; addcarryxU64(&x55, &x56, 0x0, x17, x42); var x57: u64 = undefined; var x58: u1 = undefined; addcarryxU64(&x57, &x58, x56, x19, x44); var x59: u64 = undefined; var x60: u1 = undefined; addcarryxU64(&x59, &x60, x58, x21, x46); var x61: u64 = undefined; var x62: u1 = undefined; addcarryxU64(&x61, &x62, x60, x23, x48); var x63: u64 = undefined; var x64: u1 = undefined; addcarryxU64(&x63, &x64, x62, x25, x50); var x65: u64 = undefined; var x66: u1 = undefined; addcarryxU64(&x65, &x66, x64, x27, x52); var x67: u64 = undefined; var x68: u1 = undefined; addcarryxU64(&x67, &x68, x66, x29, x54); var x69: u64 = undefined; var x70: u64 = undefined; mulxU64(&x69, &x70, x1, (arg2[5])); var x71: u64 = undefined; var x72: u64 = undefined; mulxU64(&x71, &x72, x1, (arg2[4])); var x73: u64 = undefined; var x74: u64 = undefined; mulxU64(&x73, &x74, x1, (arg2[3])); var x75: u64 = undefined; var x76: u64 = undefined; mulxU64(&x75, &x76, x1, (arg2[2])); var x77: u64 = undefined; var x78: u64 = undefined; mulxU64(&x77, &x78, x1, (arg2[1])); var x79: u64 = undefined; var x80: u64 = undefined; mulxU64(&x79, &x80, x1, (arg2[0])); var x81: u64 = undefined; var x82: u1 = undefined; addcarryxU64(&x81, &x82, 0x0, x80, x77); var x83: u64 = undefined; var x84: u1 = undefined; addcarryxU64(&x83, &x84, x82, x78, x75); var x85: u64 = undefined; var x86: u1 = undefined; addcarryxU64(&x85, &x86, x84, x76, x73); var x87: u64 = undefined; var x88: u1 = undefined; addcarryxU64(&x87, &x88, x86, x74, x71); var x89: u64 = undefined; var x90: u1 = undefined; addcarryxU64(&x89, &x90, x88, x72, x69); const x91 = (cast(u64, x90) + x70); var x92: u64 = undefined; var x93: u1 = undefined; addcarryxU64(&x92, &x93, 0x0, x57, x79); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, x93, x59, x81); var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x61, x83); var x98: u64 = undefined; var x99: u1 = undefined; addcarryxU64(&x98, &x99, x97, x63, x85); var x100: u64 = undefined; var x101: u1 = undefined; addcarryxU64(&x100, &x101, x99, x65, x87); var x102: u64 = undefined; var x103: u1 = undefined; addcarryxU64(&x102, &x103, x101, x67, x89); var x104: u64 = undefined; var x105: u1 = undefined; addcarryxU64(&x104, &x105, x103, cast(u64, x68), x91); var x106: u64 = undefined; var x107: u64 = undefined; mulxU64(&x106, &x107, x92, 0x100000001); var x108: u64 = undefined; var x109: u64 = undefined; mulxU64(&x108, &x109, x106, 0xffffffffffffffff); var x110: u64 = undefined; var x111: u64 = undefined; mulxU64(&x110, &x111, x106, 0xffffffffffffffff); var x112: u64 = undefined; var x113: u64 = undefined; mulxU64(&x112, &x113, x106, 0xffffffffffffffff); var x114: u64 = undefined; var x115: u64 = undefined; mulxU64(&x114, &x115, x106, 0xfffffffffffffffe); var x116: u64 = undefined; var x117: u64 = undefined; mulxU64(&x116, &x117, x106, 0xffffffff00000000); var x118: u64 = undefined; var x119: u64 = undefined; mulxU64(&x118, &x119, x106, 0xffffffff); var x120: u64 = undefined; var x121: u1 = undefined; addcarryxU64(&x120, &x121, 0x0, x119, x116); var x122: u64 = undefined; var x123: u1 = undefined; addcarryxU64(&x122, &x123, x121, x117, x114); var x124: u64 = undefined; var x125: u1 = undefined; addcarryxU64(&x124, &x125, x123, x115, x112); var x126: u64 = undefined; var x127: u1 = undefined; addcarryxU64(&x126, &x127, x125, x113, x110); var x128: u64 = undefined; var x129: u1 = undefined; addcarryxU64(&x128, &x129, x127, x111, x108); const x130 = (cast(u64, x129) + x109); var x131: u64 = undefined; var x132: u1 = undefined; addcarryxU64(&x131, &x132, 0x0, x92, x118); var x133: u64 = undefined; var x134: u1 = undefined; addcarryxU64(&x133, &x134, x132, x94, x120); var x135: u64 = undefined; var x136: u1 = undefined; addcarryxU64(&x135, &x136, x134, x96, x122); var x137: u64 = undefined; var x138: u1 = undefined; addcarryxU64(&x137, &x138, x136, x98, x124); var x139: u64 = undefined; var x140: u1 = undefined; addcarryxU64(&x139, &x140, x138, x100, x126); var x141: u64 = undefined; var x142: u1 = undefined; addcarryxU64(&x141, &x142, x140, x102, x128); var x143: u64 = undefined; var x144: u1 = undefined; addcarryxU64(&x143, &x144, x142, x104, x130); const x145 = (cast(u64, x144) + cast(u64, x105)); var x146: u64 = undefined; var x147: u64 = undefined; mulxU64(&x146, &x147, x2, (arg2[5])); var x148: u64 = undefined; var x149: u64 = undefined; mulxU64(&x148, &x149, x2, (arg2[4])); var x150: u64 = undefined; var x151: u64 = undefined; mulxU64(&x150, &x151, x2, (arg2[3])); var x152: u64 = undefined; var x153: u64 = undefined; mulxU64(&x152, &x153, x2, (arg2[2])); var x154: u64 = undefined; var x155: u64 = undefined; mulxU64(&x154, &x155, x2, (arg2[1])); var x156: u64 = undefined; var x157: u64 = undefined; mulxU64(&x156, &x157, x2, (arg2[0])); var x158: u64 = undefined; var x159: u1 = undefined; addcarryxU64(&x158, &x159, 0x0, x157, x154); var x160: u64 = undefined; var x161: u1 = undefined; addcarryxU64(&x160, &x161, x159, x155, x152); var x162: u64 = undefined; var x163: u1 = undefined; addcarryxU64(&x162, &x163, x161, x153, x150); var x164: u64 = undefined; var x165: u1 = undefined; addcarryxU64(&x164, &x165, x163, x151, x148); var x166: u64 = undefined; var x167: u1 = undefined; addcarryxU64(&x166, &x167, x165, x149, x146); const x168 = (cast(u64, x167) + x147); var x169: u64 = undefined; var x170: u1 = undefined; addcarryxU64(&x169, &x170, 0x0, x133, x156); var x171: u64 = undefined; var x172: u1 = undefined; addcarryxU64(&x171, &x172, x170, x135, x158); var x173: u64 = undefined; var x174: u1 = undefined; addcarryxU64(&x173, &x174, x172, x137, x160); var x175: u64 = undefined; var x176: u1 = undefined; addcarryxU64(&x175, &x176, x174, x139, x162); var x177: u64 = undefined; var x178: u1 = undefined; addcarryxU64(&x177, &x178, x176, x141, x164); var x179: u64 = undefined; var x180: u1 = undefined; addcarryxU64(&x179, &x180, x178, x143, x166); var x181: u64 = undefined; var x182: u1 = undefined; addcarryxU64(&x181, &x182, x180, x145, x168); var x183: u64 = undefined; var x184: u64 = undefined; mulxU64(&x183, &x184, x169, 0x100000001); var x185: u64 = undefined; var x186: u64 = undefined; mulxU64(&x185, &x186, x183, 0xffffffffffffffff); var x187: u64 = undefined; var x188: u64 = undefined; mulxU64(&x187, &x188, x183, 0xffffffffffffffff); var x189: u64 = undefined; var x190: u64 = undefined; mulxU64(&x189, &x190, x183, 0xffffffffffffffff); var x191: u64 = undefined; var x192: u64 = undefined; mulxU64(&x191, &x192, x183, 0xfffffffffffffffe); var x193: u64 = undefined; var x194: u64 = undefined; mulxU64(&x193, &x194, x183, 0xffffffff00000000); var x195: u64 = undefined; var x196: u64 = undefined; mulxU64(&x195, &x196, x183, 0xffffffff); var x197: u64 = undefined; var x198: u1 = undefined; addcarryxU64(&x197, &x198, 0x0, x196, x193); var x199: u64 = undefined; var x200: u1 = undefined; addcarryxU64(&x199, &x200, x198, x194, x191); var x201: u64 = undefined; var x202: u1 = undefined; addcarryxU64(&x201, &x202, x200, x192, x189); var x203: u64 = undefined; var x204: u1 = undefined; addcarryxU64(&x203, &x204, x202, x190, x187); var x205: u64 = undefined; var x206: u1 = undefined; addcarryxU64(&x205, &x206, x204, x188, x185); const x207 = (cast(u64, x206) + x186); var x208: u64 = undefined; var x209: u1 = undefined; addcarryxU64(&x208, &x209, 0x0, x169, x195); var x210: u64 = undefined; var x211: u1 = undefined; addcarryxU64(&x210, &x211, x209, x171, x197); var x212: u64 = undefined; var x213: u1 = undefined; addcarryxU64(&x212, &x213, x211, x173, x199); var x214: u64 = undefined; var x215: u1 = undefined; addcarryxU64(&x214, &x215, x213, x175, x201); var x216: u64 = undefined; var x217: u1 = undefined; addcarryxU64(&x216, &x217, x215, x177, x203); var x218: u64 = undefined; var x219: u1 = undefined; addcarryxU64(&x218, &x219, x217, x179, x205); var x220: u64 = undefined; var x221: u1 = undefined; addcarryxU64(&x220, &x221, x219, x181, x207); const x222 = (cast(u64, x221) + cast(u64, x182)); var x223: u64 = undefined; var x224: u64 = undefined; mulxU64(&x223, &x224, x3, (arg2[5])); var x225: u64 = undefined; var x226: u64 = undefined; mulxU64(&x225, &x226, x3, (arg2[4])); var x227: u64 = undefined; var x228: u64 = undefined; mulxU64(&x227, &x228, x3, (arg2[3])); var x229: u64 = undefined; var x230: u64 = undefined; mulxU64(&x229, &x230, x3, (arg2[2])); var x231: u64 = undefined; var x232: u64 = undefined; mulxU64(&x231, &x232, x3, (arg2[1])); var x233: u64 = undefined; var x234: u64 = undefined; mulxU64(&x233, &x234, x3, (arg2[0])); var x235: u64 = undefined; var x236: u1 = undefined; addcarryxU64(&x235, &x236, 0x0, x234, x231); var x237: u64 = undefined; var x238: u1 = undefined; addcarryxU64(&x237, &x238, x236, x232, x229); var x239: u64 = undefined; var x240: u1 = undefined; addcarryxU64(&x239, &x240, x238, x230, x227); var x241: u64 = undefined; var x242: u1 = undefined; addcarryxU64(&x241, &x242, x240, x228, x225); var x243: u64 = undefined; var x244: u1 = undefined; addcarryxU64(&x243, &x244, x242, x226, x223); const x245 = (cast(u64, x244) + x224); var x246: u64 = undefined; var x247: u1 = undefined; addcarryxU64(&x246, &x247, 0x0, x210, x233); var x248: u64 = undefined; var x249: u1 = undefined; addcarryxU64(&x248, &x249, x247, x212, x235); var x250: u64 = undefined; var x251: u1 = undefined; addcarryxU64(&x250, &x251, x249, x214, x237); var x252: u64 = undefined; var x253: u1 = undefined; addcarryxU64(&x252, &x253, x251, x216, x239); var x254: u64 = undefined; var x255: u1 = undefined; addcarryxU64(&x254, &x255, x253, x218, x241); var x256: u64 = undefined; var x257: u1 = undefined; addcarryxU64(&x256, &x257, x255, x220, x243); var x258: u64 = undefined; var x259: u1 = undefined; addcarryxU64(&x258, &x259, x257, x222, x245); var x260: u64 = undefined; var x261: u64 = undefined; mulxU64(&x260, &x261, x246, 0x100000001); var x262: u64 = undefined; var x263: u64 = undefined; mulxU64(&x262, &x263, x260, 0xffffffffffffffff); var x264: u64 = undefined; var x265: u64 = undefined; mulxU64(&x264, &x265, x260, 0xffffffffffffffff); var x266: u64 = undefined; var x267: u64 = undefined; mulxU64(&x266, &x267, x260, 0xffffffffffffffff); var x268: u64 = undefined; var x269: u64 = undefined; mulxU64(&x268, &x269, x260, 0xfffffffffffffffe); var x270: u64 = undefined; var x271: u64 = undefined; mulxU64(&x270, &x271, x260, 0xffffffff00000000); var x272: u64 = undefined; var x273: u64 = undefined; mulxU64(&x272, &x273, x260, 0xffffffff); var x274: u64 = undefined; var x275: u1 = undefined; addcarryxU64(&x274, &x275, 0x0, x273, x270); var x276: u64 = undefined; var x277: u1 = undefined; addcarryxU64(&x276, &x277, x275, x271, x268); var x278: u64 = undefined; var x279: u1 = undefined; addcarryxU64(&x278, &x279, x277, x269, x266); var x280: u64 = undefined; var x281: u1 = undefined; addcarryxU64(&x280, &x281, x279, x267, x264); var x282: u64 = undefined; var x283: u1 = undefined; addcarryxU64(&x282, &x283, x281, x265, x262); const x284 = (cast(u64, x283) + x263); var x285: u64 = undefined; var x286: u1 = undefined; addcarryxU64(&x285, &x286, 0x0, x246, x272); var x287: u64 = undefined; var x288: u1 = undefined; addcarryxU64(&x287, &x288, x286, x248, x274); var x289: u64 = undefined; var x290: u1 = undefined; addcarryxU64(&x289, &x290, x288, x250, x276); var x291: u64 = undefined; var x292: u1 = undefined; addcarryxU64(&x291, &x292, x290, x252, x278); var x293: u64 = undefined; var x294: u1 = undefined; addcarryxU64(&x293, &x294, x292, x254, x280); var x295: u64 = undefined; var x296: u1 = undefined; addcarryxU64(&x295, &x296, x294, x256, x282); var x297: u64 = undefined; var x298: u1 = undefined; addcarryxU64(&x297, &x298, x296, x258, x284); const x299 = (cast(u64, x298) + cast(u64, x259)); var x300: u64 = undefined; var x301: u64 = undefined; mulxU64(&x300, &x301, x4, (arg2[5])); var x302: u64 = undefined; var x303: u64 = undefined; mulxU64(&x302, &x303, x4, (arg2[4])); var x304: u64 = undefined; var x305: u64 = undefined; mulxU64(&x304, &x305, x4, (arg2[3])); var x306: u64 = undefined; var x307: u64 = undefined; mulxU64(&x306, &x307, x4, (arg2[2])); var x308: u64 = undefined; var x309: u64 = undefined; mulxU64(&x308, &x309, x4, (arg2[1])); var x310: u64 = undefined; var x311: u64 = undefined; mulxU64(&x310, &x311, x4, (arg2[0])); var x312: u64 = undefined; var x313: u1 = undefined; addcarryxU64(&x312, &x313, 0x0, x311, x308); var x314: u64 = undefined; var x315: u1 = undefined; addcarryxU64(&x314, &x315, x313, x309, x306); var x316: u64 = undefined; var x317: u1 = undefined; addcarryxU64(&x316, &x317, x315, x307, x304); var x318: u64 = undefined; var x319: u1 = undefined; addcarryxU64(&x318, &x319, x317, x305, x302); var x320: u64 = undefined; var x321: u1 = undefined; addcarryxU64(&x320, &x321, x319, x303, x300); const x322 = (cast(u64, x321) + x301); var x323: u64 = undefined; var x324: u1 = undefined; addcarryxU64(&x323, &x324, 0x0, x287, x310); var x325: u64 = undefined; var x326: u1 = undefined; addcarryxU64(&x325, &x326, x324, x289, x312); var x327: u64 = undefined; var x328: u1 = undefined; addcarryxU64(&x327, &x328, x326, x291, x314); var x329: u64 = undefined; var x330: u1 = undefined; addcarryxU64(&x329, &x330, x328, x293, x316); var x331: u64 = undefined; var x332: u1 = undefined; addcarryxU64(&x331, &x332, x330, x295, x318); var x333: u64 = undefined; var x334: u1 = undefined; addcarryxU64(&x333, &x334, x332, x297, x320); var x335: u64 = undefined; var x336: u1 = undefined; addcarryxU64(&x335, &x336, x334, x299, x322); var x337: u64 = undefined; var x338: u64 = undefined; mulxU64(&x337, &x338, x323, 0x100000001); var x339: u64 = undefined; var x340: u64 = undefined; mulxU64(&x339, &x340, x337, 0xffffffffffffffff); var x341: u64 = undefined; var x342: u64 = undefined; mulxU64(&x341, &x342, x337, 0xffffffffffffffff); var x343: u64 = undefined; var x344: u64 = undefined; mulxU64(&x343, &x344, x337, 0xffffffffffffffff); var x345: u64 = undefined; var x346: u64 = undefined; mulxU64(&x345, &x346, x337, 0xfffffffffffffffe); var x347: u64 = undefined; var x348: u64 = undefined; mulxU64(&x347, &x348, x337, 0xffffffff00000000); var x349: u64 = undefined; var x350: u64 = undefined; mulxU64(&x349, &x350, x337, 0xffffffff); var x351: u64 = undefined; var x352: u1 = undefined; addcarryxU64(&x351, &x352, 0x0, x350, x347); var x353: u64 = undefined; var x354: u1 = undefined; addcarryxU64(&x353, &x354, x352, x348, x345); var x355: u64 = undefined; var x356: u1 = undefined; addcarryxU64(&x355, &x356, x354, x346, x343); var x357: u64 = undefined; var x358: u1 = undefined; addcarryxU64(&x357, &x358, x356, x344, x341); var x359: u64 = undefined; var x360: u1 = undefined; addcarryxU64(&x359, &x360, x358, x342, x339); const x361 = (cast(u64, x360) + x340); var x362: u64 = undefined; var x363: u1 = undefined; addcarryxU64(&x362, &x363, 0x0, x323, x349); var x364: u64 = undefined; var x365: u1 = undefined; addcarryxU64(&x364, &x365, x363, x325, x351); var x366: u64 = undefined; var x367: u1 = undefined; addcarryxU64(&x366, &x367, x365, x327, x353); var x368: u64 = undefined; var x369: u1 = undefined; addcarryxU64(&x368, &x369, x367, x329, x355); var x370: u64 = undefined; var x371: u1 = undefined; addcarryxU64(&x370, &x371, x369, x331, x357); var x372: u64 = undefined; var x373: u1 = undefined; addcarryxU64(&x372, &x373, x371, x333, x359); var x374: u64 = undefined; var x375: u1 = undefined; addcarryxU64(&x374, &x375, x373, x335, x361); const x376 = (cast(u64, x375) + cast(u64, x336)); var x377: u64 = undefined; var x378: u64 = undefined; mulxU64(&x377, &x378, x5, (arg2[5])); var x379: u64 = undefined; var x380: u64 = undefined; mulxU64(&x379, &x380, x5, (arg2[4])); var x381: u64 = undefined; var x382: u64 = undefined; mulxU64(&x381, &x382, x5, (arg2[3])); var x383: u64 = undefined; var x384: u64 = undefined; mulxU64(&x383, &x384, x5, (arg2[2])); var x385: u64 = undefined; var x386: u64 = undefined; mulxU64(&x385, &x386, x5, (arg2[1])); var x387: u64 = undefined; var x388: u64 = undefined; mulxU64(&x387, &x388, x5, (arg2[0])); var x389: u64 = undefined; var x390: u1 = undefined; addcarryxU64(&x389, &x390, 0x0, x388, x385); var x391: u64 = undefined; var x392: u1 = undefined; addcarryxU64(&x391, &x392, x390, x386, x383); var x393: u64 = undefined; var x394: u1 = undefined; addcarryxU64(&x393, &x394, x392, x384, x381); var x395: u64 = undefined; var x396: u1 = undefined; addcarryxU64(&x395, &x396, x394, x382, x379); var x397: u64 = undefined; var x398: u1 = undefined; addcarryxU64(&x397, &x398, x396, x380, x377); const x399 = (cast(u64, x398) + x378); var x400: u64 = undefined; var x401: u1 = undefined; addcarryxU64(&x400, &x401, 0x0, x364, x387); var x402: u64 = undefined; var x403: u1 = undefined; addcarryxU64(&x402, &x403, x401, x366, x389); var x404: u64 = undefined; var x405: u1 = undefined; addcarryxU64(&x404, &x405, x403, x368, x391); var x406: u64 = undefined; var x407: u1 = undefined; addcarryxU64(&x406, &x407, x405, x370, x393); var x408: u64 = undefined; var x409: u1 = undefined; addcarryxU64(&x408, &x409, x407, x372, x395); var x410: u64 = undefined; var x411: u1 = undefined; addcarryxU64(&x410, &x411, x409, x374, x397); var x412: u64 = undefined; var x413: u1 = undefined; addcarryxU64(&x412, &x413, x411, x376, x399); var x414: u64 = undefined; var x415: u64 = undefined; mulxU64(&x414, &x415, x400, 0x100000001); var x416: u64 = undefined; var x417: u64 = undefined; mulxU64(&x416, &x417, x414, 0xffffffffffffffff); var x418: u64 = undefined; var x419: u64 = undefined; mulxU64(&x418, &x419, x414, 0xffffffffffffffff); var x420: u64 = undefined; var x421: u64 = undefined; mulxU64(&x420, &x421, x414, 0xffffffffffffffff); var x422: u64 = undefined; var x423: u64 = undefined; mulxU64(&x422, &x423, x414, 0xfffffffffffffffe); var x424: u64 = undefined; var x425: u64 = undefined; mulxU64(&x424, &x425, x414, 0xffffffff00000000); var x426: u64 = undefined; var x427: u64 = undefined; mulxU64(&x426, &x427, x414, 0xffffffff); var x428: u64 = undefined; var x429: u1 = undefined; addcarryxU64(&x428, &x429, 0x0, x427, x424); var x430: u64 = undefined; var x431: u1 = undefined; addcarryxU64(&x430, &x431, x429, x425, x422); var x432: u64 = undefined; var x433: u1 = undefined; addcarryxU64(&x432, &x433, x431, x423, x420); var x434: u64 = undefined; var x435: u1 = undefined; addcarryxU64(&x434, &x435, x433, x421, x418); var x436: u64 = undefined; var x437: u1 = undefined; addcarryxU64(&x436, &x437, x435, x419, x416); const x438 = (cast(u64, x437) + x417); var x439: u64 = undefined; var x440: u1 = undefined; addcarryxU64(&x439, &x440, 0x0, x400, x426); var x441: u64 = undefined; var x442: u1 = undefined; addcarryxU64(&x441, &x442, x440, x402, x428); var x443: u64 = undefined; var x444: u1 = undefined; addcarryxU64(&x443, &x444, x442, x404, x430); var x445: u64 = undefined; var x446: u1 = undefined; addcarryxU64(&x445, &x446, x444, x406, x432); var x447: u64 = undefined; var x448: u1 = undefined; addcarryxU64(&x447, &x448, x446, x408, x434); var x449: u64 = undefined; var x450: u1 = undefined; addcarryxU64(&x449, &x450, x448, x410, x436); var x451: u64 = undefined; var x452: u1 = undefined; addcarryxU64(&x451, &x452, x450, x412, x438); const x453 = (cast(u64, x452) + cast(u64, x413)); var x454: u64 = undefined; var x455: u1 = undefined; subborrowxU64(&x454, &x455, 0x0, x441, 0xffffffff); var x456: u64 = undefined; var x457: u1 = undefined; subborrowxU64(&x456, &x457, x455, x443, 0xffffffff00000000); var x458: u64 = undefined; var x459: u1 = undefined; subborrowxU64(&x458, &x459, x457, x445, 0xfffffffffffffffe); var x460: u64 = undefined; var x461: u1 = undefined; subborrowxU64(&x460, &x461, x459, x447, 0xffffffffffffffff); var x462: u64 = undefined; var x463: u1 = undefined; subborrowxU64(&x462, &x463, x461, x449, 0xffffffffffffffff); var x464: u64 = undefined; var x465: u1 = undefined; subborrowxU64(&x464, &x465, x463, x451, 0xffffffffffffffff); var x466: u64 = undefined; var x467: u1 = undefined; subborrowxU64(&x466, &x467, x465, x453, cast(u64, 0x0)); var x468: u64 = undefined; cmovznzU64(&x468, x467, x454, x441); var x469: u64 = undefined; cmovznzU64(&x469, x467, x456, x443); var x470: u64 = undefined; cmovznzU64(&x470, x467, x458, x445); var x471: u64 = undefined; cmovznzU64(&x471, x467, x460, x447); var x472: u64 = undefined; cmovznzU64(&x472, x467, x462, x449); var x473: u64 = undefined; cmovznzU64(&x473, x467, x464, x451); out1[0] = x468; out1[1] = x469; out1[2] = x470; out1[3] = x471; out1[4] = x472; out1[5] = x473; } /// The function square squares a field element in the Montgomery domain. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m /// 0 ≤ eval out1 < m /// pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[1]); const x2 = (arg1[2]); const x3 = (arg1[3]); const x4 = (arg1[4]); const x5 = (arg1[5]); const x6 = (arg1[0]); var x7: u64 = undefined; var x8: u64 = undefined; mulxU64(&x7, &x8, x6, (arg1[5])); var x9: u64 = undefined; var x10: u64 = undefined; mulxU64(&x9, &x10, x6, (arg1[4])); var x11: u64 = undefined; var x12: u64 = undefined; mulxU64(&x11, &x12, x6, (arg1[3])); var x13: u64 = undefined; var x14: u64 = undefined; mulxU64(&x13, &x14, x6, (arg1[2])); var x15: u64 = undefined; var x16: u64 = undefined; mulxU64(&x15, &x16, x6, (arg1[1])); var x17: u64 = undefined; var x18: u64 = undefined; mulxU64(&x17, &x18, x6, (arg1[0])); var x19: u64 = undefined; var x20: u1 = undefined; addcarryxU64(&x19, &x20, 0x0, x18, x15); var x21: u64 = undefined; var x22: u1 = undefined; addcarryxU64(&x21, &x22, x20, x16, x13); var x23: u64 = undefined; var x24: u1 = undefined; addcarryxU64(&x23, &x24, x22, x14, x11); var x25: u64 = undefined; var x26: u1 = undefined; addcarryxU64(&x25, &x26, x24, x12, x9); var x27: u64 = undefined; var x28: u1 = undefined; addcarryxU64(&x27, &x28, x26, x10, x7); const x29 = (cast(u64, x28) + x8); var x30: u64 = undefined; var x31: u64 = undefined; mulxU64(&x30, &x31, x17, 0x100000001); var x32: u64 = undefined; var x33: u64 = undefined; mulxU64(&x32, &x33, x30, 0xffffffffffffffff); var x34: u64 = undefined; var x35: u64 = undefined; mulxU64(&x34, &x35, x30, 0xffffffffffffffff); var x36: u64 = undefined; var x37: u64 = undefined; mulxU64(&x36, &x37, x30, 0xffffffffffffffff); var x38: u64 = undefined; var x39: u64 = undefined; mulxU64(&x38, &x39, x30, 0xfffffffffffffffe); var x40: u64 = undefined; var x41: u64 = undefined; mulxU64(&x40, &x41, x30, 0xffffffff00000000); var x42: u64 = undefined; var x43: u64 = undefined; mulxU64(&x42, &x43, x30, 0xffffffff); var x44: u64 = undefined; var x45: u1 = undefined; addcarryxU64(&x44, &x45, 0x0, x43, x40); var x46: u64 = undefined; var x47: u1 = undefined; addcarryxU64(&x46, &x47, x45, x41, x38); var x48: u64 = undefined; var x49: u1 = undefined; addcarryxU64(&x48, &x49, x47, x39, x36); var x50: u64 = undefined; var x51: u1 = undefined; addcarryxU64(&x50, &x51, x49, x37, x34); var x52: u64 = undefined; var x53: u1 = undefined; addcarryxU64(&x52, &x53, x51, x35, x32); const x54 = (cast(u64, x53) + x33); var x55: u64 = undefined; var x56: u1 = undefined; addcarryxU64(&x55, &x56, 0x0, x17, x42); var x57: u64 = undefined; var x58: u1 = undefined; addcarryxU64(&x57, &x58, x56, x19, x44); var x59: u64 = undefined; var x60: u1 = undefined; addcarryxU64(&x59, &x60, x58, x21, x46); var x61: u64 = undefined; var x62: u1 = undefined; addcarryxU64(&x61, &x62, x60, x23, x48); var x63: u64 = undefined; var x64: u1 = undefined; addcarryxU64(&x63, &x64, x62, x25, x50); var x65: u64 = undefined; var x66: u1 = undefined; addcarryxU64(&x65, &x66, x64, x27, x52); var x67: u64 = undefined; var x68: u1 = undefined; addcarryxU64(&x67, &x68, x66, x29, x54); var x69: u64 = undefined; var x70: u64 = undefined; mulxU64(&x69, &x70, x1, (arg1[5])); var x71: u64 = undefined; var x72: u64 = undefined; mulxU64(&x71, &x72, x1, (arg1[4])); var x73: u64 = undefined; var x74: u64 = undefined; mulxU64(&x73, &x74, x1, (arg1[3])); var x75: u64 = undefined; var x76: u64 = undefined; mulxU64(&x75, &x76, x1, (arg1[2])); var x77: u64 = undefined; var x78: u64 = undefined; mulxU64(&x77, &x78, x1, (arg1[1])); var x79: u64 = undefined; var x80: u64 = undefined; mulxU64(&x79, &x80, x1, (arg1[0])); var x81: u64 = undefined; var x82: u1 = undefined; addcarryxU64(&x81, &x82, 0x0, x80, x77); var x83: u64 = undefined; var x84: u1 = undefined; addcarryxU64(&x83, &x84, x82, x78, x75); var x85: u64 = undefined; var x86: u1 = undefined; addcarryxU64(&x85, &x86, x84, x76, x73); var x87: u64 = undefined; var x88: u1 = undefined; addcarryxU64(&x87, &x88, x86, x74, x71); var x89: u64 = undefined; var x90: u1 = undefined; addcarryxU64(&x89, &x90, x88, x72, x69); const x91 = (cast(u64, x90) + x70); var x92: u64 = undefined; var x93: u1 = undefined; addcarryxU64(&x92, &x93, 0x0, x57, x79); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, x93, x59, x81); var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x61, x83); var x98: u64 = undefined; var x99: u1 = undefined; addcarryxU64(&x98, &x99, x97, x63, x85); var x100: u64 = undefined; var x101: u1 = undefined; addcarryxU64(&x100, &x101, x99, x65, x87); var x102: u64 = undefined; var x103: u1 = undefined; addcarryxU64(&x102, &x103, x101, x67, x89); var x104: u64 = undefined; var x105: u1 = undefined; addcarryxU64(&x104, &x105, x103, cast(u64, x68), x91); var x106: u64 = undefined; var x107: u64 = undefined; mulxU64(&x106, &x107, x92, 0x100000001); var x108: u64 = undefined; var x109: u64 = undefined; mulxU64(&x108, &x109, x106, 0xffffffffffffffff); var x110: u64 = undefined; var x111: u64 = undefined; mulxU64(&x110, &x111, x106, 0xffffffffffffffff); var x112: u64 = undefined; var x113: u64 = undefined; mulxU64(&x112, &x113, x106, 0xffffffffffffffff); var x114: u64 = undefined; var x115: u64 = undefined; mulxU64(&x114, &x115, x106, 0xfffffffffffffffe); var x116: u64 = undefined; var x117: u64 = undefined; mulxU64(&x116, &x117, x106, 0xffffffff00000000); var x118: u64 = undefined; var x119: u64 = undefined; mulxU64(&x118, &x119, x106, 0xffffffff); var x120: u64 = undefined; var x121: u1 = undefined; addcarryxU64(&x120, &x121, 0x0, x119, x116); var x122: u64 = undefined; var x123: u1 = undefined; addcarryxU64(&x122, &x123, x121, x117, x114); var x124: u64 = undefined; var x125: u1 = undefined; addcarryxU64(&x124, &x125, x123, x115, x112); var x126: u64 = undefined; var x127: u1 = undefined; addcarryxU64(&x126, &x127, x125, x113, x110); var x128: u64 = undefined; var x129: u1 = undefined; addcarryxU64(&x128, &x129, x127, x111, x108); const x130 = (cast(u64, x129) + x109); var x131: u64 = undefined; var x132: u1 = undefined; addcarryxU64(&x131, &x132, 0x0, x92, x118); var x133: u64 = undefined; var x134: u1 = undefined; addcarryxU64(&x133, &x134, x132, x94, x120); var x135: u64 = undefined; var x136: u1 = undefined; addcarryxU64(&x135, &x136, x134, x96, x122); var x137: u64 = undefined; var x138: u1 = undefined; addcarryxU64(&x137, &x138, x136, x98, x124); var x139: u64 = undefined; var x140: u1 = undefined; addcarryxU64(&x139, &x140, x138, x100, x126); var x141: u64 = undefined; var x142: u1 = undefined; addcarryxU64(&x141, &x142, x140, x102, x128); var x143: u64 = undefined; var x144: u1 = undefined; addcarryxU64(&x143, &x144, x142, x104, x130); const x145 = (cast(u64, x144) + cast(u64, x105)); var x146: u64 = undefined; var x147: u64 = undefined; mulxU64(&x146, &x147, x2, (arg1[5])); var x148: u64 = undefined; var x149: u64 = undefined; mulxU64(&x148, &x149, x2, (arg1[4])); var x150: u64 = undefined; var x151: u64 = undefined; mulxU64(&x150, &x151, x2, (arg1[3])); var x152: u64 = undefined; var x153: u64 = undefined; mulxU64(&x152, &x153, x2, (arg1[2])); var x154: u64 = undefined; var x155: u64 = undefined; mulxU64(&x154, &x155, x2, (arg1[1])); var x156: u64 = undefined; var x157: u64 = undefined; mulxU64(&x156, &x157, x2, (arg1[0])); var x158: u64 = undefined; var x159: u1 = undefined; addcarryxU64(&x158, &x159, 0x0, x157, x154); var x160: u64 = undefined; var x161: u1 = undefined; addcarryxU64(&x160, &x161, x159, x155, x152); var x162: u64 = undefined; var x163: u1 = undefined; addcarryxU64(&x162, &x163, x161, x153, x150); var x164: u64 = undefined; var x165: u1 = undefined; addcarryxU64(&x164, &x165, x163, x151, x148); var x166: u64 = undefined; var x167: u1 = undefined; addcarryxU64(&x166, &x167, x165, x149, x146); const x168 = (cast(u64, x167) + x147); var x169: u64 = undefined; var x170: u1 = undefined; addcarryxU64(&x169, &x170, 0x0, x133, x156); var x171: u64 = undefined; var x172: u1 = undefined; addcarryxU64(&x171, &x172, x170, x135, x158); var x173: u64 = undefined; var x174: u1 = undefined; addcarryxU64(&x173, &x174, x172, x137, x160); var x175: u64 = undefined; var x176: u1 = undefined; addcarryxU64(&x175, &x176, x174, x139, x162); var x177: u64 = undefined; var x178: u1 = undefined; addcarryxU64(&x177, &x178, x176, x141, x164); var x179: u64 = undefined; var x180: u1 = undefined; addcarryxU64(&x179, &x180, x178, x143, x166); var x181: u64 = undefined; var x182: u1 = undefined; addcarryxU64(&x181, &x182, x180, x145, x168); var x183: u64 = undefined; var x184: u64 = undefined; mulxU64(&x183, &x184, x169, 0x100000001); var x185: u64 = undefined; var x186: u64 = undefined; mulxU64(&x185, &x186, x183, 0xffffffffffffffff); var x187: u64 = undefined; var x188: u64 = undefined; mulxU64(&x187, &x188, x183, 0xffffffffffffffff); var x189: u64 = undefined; var x190: u64 = undefined; mulxU64(&x189, &x190, x183, 0xffffffffffffffff); var x191: u64 = undefined; var x192: u64 = undefined; mulxU64(&x191, &x192, x183, 0xfffffffffffffffe); var x193: u64 = undefined; var x194: u64 = undefined; mulxU64(&x193, &x194, x183, 0xffffffff00000000); var x195: u64 = undefined; var x196: u64 = undefined; mulxU64(&x195, &x196, x183, 0xffffffff); var x197: u64 = undefined; var x198: u1 = undefined; addcarryxU64(&x197, &x198, 0x0, x196, x193); var x199: u64 = undefined; var x200: u1 = undefined; addcarryxU64(&x199, &x200, x198, x194, x191); var x201: u64 = undefined; var x202: u1 = undefined; addcarryxU64(&x201, &x202, x200, x192, x189); var x203: u64 = undefined; var x204: u1 = undefined; addcarryxU64(&x203, &x204, x202, x190, x187); var x205: u64 = undefined; var x206: u1 = undefined; addcarryxU64(&x205, &x206, x204, x188, x185); const x207 = (cast(u64, x206) + x186); var x208: u64 = undefined; var x209: u1 = undefined; addcarryxU64(&x208, &x209, 0x0, x169, x195); var x210: u64 = undefined; var x211: u1 = undefined; addcarryxU64(&x210, &x211, x209, x171, x197); var x212: u64 = undefined; var x213: u1 = undefined; addcarryxU64(&x212, &x213, x211, x173, x199); var x214: u64 = undefined; var x215: u1 = undefined; addcarryxU64(&x214, &x215, x213, x175, x201); var x216: u64 = undefined; var x217: u1 = undefined; addcarryxU64(&x216, &x217, x215, x177, x203); var x218: u64 = undefined; var x219: u1 = undefined; addcarryxU64(&x218, &x219, x217, x179, x205); var x220: u64 = undefined; var x221: u1 = undefined; addcarryxU64(&x220, &x221, x219, x181, x207); const x222 = (cast(u64, x221) + cast(u64, x182)); var x223: u64 = undefined; var x224: u64 = undefined; mulxU64(&x223, &x224, x3, (arg1[5])); var x225: u64 = undefined; var x226: u64 = undefined; mulxU64(&x225, &x226, x3, (arg1[4])); var x227: u64 = undefined; var x228: u64 = undefined; mulxU64(&x227, &x228, x3, (arg1[3])); var x229: u64 = undefined; var x230: u64 = undefined; mulxU64(&x229, &x230, x3, (arg1[2])); var x231: u64 = undefined; var x232: u64 = undefined; mulxU64(&x231, &x232, x3, (arg1[1])); var x233: u64 = undefined; var x234: u64 = undefined; mulxU64(&x233, &x234, x3, (arg1[0])); var x235: u64 = undefined; var x236: u1 = undefined; addcarryxU64(&x235, &x236, 0x0, x234, x231); var x237: u64 = undefined; var x238: u1 = undefined; addcarryxU64(&x237, &x238, x236, x232, x229); var x239: u64 = undefined; var x240: u1 = undefined; addcarryxU64(&x239, &x240, x238, x230, x227); var x241: u64 = undefined; var x242: u1 = undefined; addcarryxU64(&x241, &x242, x240, x228, x225); var x243: u64 = undefined; var x244: u1 = undefined; addcarryxU64(&x243, &x244, x242, x226, x223); const x245 = (cast(u64, x244) + x224); var x246: u64 = undefined; var x247: u1 = undefined; addcarryxU64(&x246, &x247, 0x0, x210, x233); var x248: u64 = undefined; var x249: u1 = undefined; addcarryxU64(&x248, &x249, x247, x212, x235); var x250: u64 = undefined; var x251: u1 = undefined; addcarryxU64(&x250, &x251, x249, x214, x237); var x252: u64 = undefined; var x253: u1 = undefined; addcarryxU64(&x252, &x253, x251, x216, x239); var x254: u64 = undefined; var x255: u1 = undefined; addcarryxU64(&x254, &x255, x253, x218, x241); var x256: u64 = undefined; var x257: u1 = undefined; addcarryxU64(&x256, &x257, x255, x220, x243); var x258: u64 = undefined; var x259: u1 = undefined; addcarryxU64(&x258, &x259, x257, x222, x245); var x260: u64 = undefined; var x261: u64 = undefined; mulxU64(&x260, &x261, x246, 0x100000001); var x262: u64 = undefined; var x263: u64 = undefined; mulxU64(&x262, &x263, x260, 0xffffffffffffffff); var x264: u64 = undefined; var x265: u64 = undefined; mulxU64(&x264, &x265, x260, 0xffffffffffffffff); var x266: u64 = undefined; var x267: u64 = undefined; mulxU64(&x266, &x267, x260, 0xffffffffffffffff); var x268: u64 = undefined; var x269: u64 = undefined; mulxU64(&x268, &x269, x260, 0xfffffffffffffffe); var x270: u64 = undefined; var x271: u64 = undefined; mulxU64(&x270, &x271, x260, 0xffffffff00000000); var x272: u64 = undefined; var x273: u64 = undefined; mulxU64(&x272, &x273, x260, 0xffffffff); var x274: u64 = undefined; var x275: u1 = undefined; addcarryxU64(&x274, &x275, 0x0, x273, x270); var x276: u64 = undefined; var x277: u1 = undefined; addcarryxU64(&x276, &x277, x275, x271, x268); var x278: u64 = undefined; var x279: u1 = undefined; addcarryxU64(&x278, &x279, x277, x269, x266); var x280: u64 = undefined; var x281: u1 = undefined; addcarryxU64(&x280, &x281, x279, x267, x264); var x282: u64 = undefined; var x283: u1 = undefined; addcarryxU64(&x282, &x283, x281, x265, x262); const x284 = (cast(u64, x283) + x263); var x285: u64 = undefined; var x286: u1 = undefined; addcarryxU64(&x285, &x286, 0x0, x246, x272); var x287: u64 = undefined; var x288: u1 = undefined; addcarryxU64(&x287, &x288, x286, x248, x274); var x289: u64 = undefined; var x290: u1 = undefined; addcarryxU64(&x289, &x290, x288, x250, x276); var x291: u64 = undefined; var x292: u1 = undefined; addcarryxU64(&x291, &x292, x290, x252, x278); var x293: u64 = undefined; var x294: u1 = undefined; addcarryxU64(&x293, &x294, x292, x254, x280); var x295: u64 = undefined; var x296: u1 = undefined; addcarryxU64(&x295, &x296, x294, x256, x282); var x297: u64 = undefined; var x298: u1 = undefined; addcarryxU64(&x297, &x298, x296, x258, x284); const x299 = (cast(u64, x298) + cast(u64, x259)); var x300: u64 = undefined; var x301: u64 = undefined; mulxU64(&x300, &x301, x4, (arg1[5])); var x302: u64 = undefined; var x303: u64 = undefined; mulxU64(&x302, &x303, x4, (arg1[4])); var x304: u64 = undefined; var x305: u64 = undefined; mulxU64(&x304, &x305, x4, (arg1[3])); var x306: u64 = undefined; var x307: u64 = undefined; mulxU64(&x306, &x307, x4, (arg1[2])); var x308: u64 = undefined; var x309: u64 = undefined; mulxU64(&x308, &x309, x4, (arg1[1])); var x310: u64 = undefined; var x311: u64 = undefined; mulxU64(&x310, &x311, x4, (arg1[0])); var x312: u64 = undefined; var x313: u1 = undefined; addcarryxU64(&x312, &x313, 0x0, x311, x308); var x314: u64 = undefined; var x315: u1 = undefined; addcarryxU64(&x314, &x315, x313, x309, x306); var x316: u64 = undefined; var x317: u1 = undefined; addcarryxU64(&x316, &x317, x315, x307, x304); var x318: u64 = undefined; var x319: u1 = undefined; addcarryxU64(&x318, &x319, x317, x305, x302); var x320: u64 = undefined; var x321: u1 = undefined; addcarryxU64(&x320, &x321, x319, x303, x300); const x322 = (cast(u64, x321) + x301); var x323: u64 = undefined; var x324: u1 = undefined; addcarryxU64(&x323, &x324, 0x0, x287, x310); var x325: u64 = undefined; var x326: u1 = undefined; addcarryxU64(&x325, &x326, x324, x289, x312); var x327: u64 = undefined; var x328: u1 = undefined; addcarryxU64(&x327, &x328, x326, x291, x314); var x329: u64 = undefined; var x330: u1 = undefined; addcarryxU64(&x329, &x330, x328, x293, x316); var x331: u64 = undefined; var x332: u1 = undefined; addcarryxU64(&x331, &x332, x330, x295, x318); var x333: u64 = undefined; var x334: u1 = undefined; addcarryxU64(&x333, &x334, x332, x297, x320); var x335: u64 = undefined; var x336: u1 = undefined; addcarryxU64(&x335, &x336, x334, x299, x322); var x337: u64 = undefined; var x338: u64 = undefined; mulxU64(&x337, &x338, x323, 0x100000001); var x339: u64 = undefined; var x340: u64 = undefined; mulxU64(&x339, &x340, x337, 0xffffffffffffffff); var x341: u64 = undefined; var x342: u64 = undefined; mulxU64(&x341, &x342, x337, 0xffffffffffffffff); var x343: u64 = undefined; var x344: u64 = undefined; mulxU64(&x343, &x344, x337, 0xffffffffffffffff); var x345: u64 = undefined; var x346: u64 = undefined; mulxU64(&x345, &x346, x337, 0xfffffffffffffffe); var x347: u64 = undefined; var x348: u64 = undefined; mulxU64(&x347, &x348, x337, 0xffffffff00000000); var x349: u64 = undefined; var x350: u64 = undefined; mulxU64(&x349, &x350, x337, 0xffffffff); var x351: u64 = undefined; var x352: u1 = undefined; addcarryxU64(&x351, &x352, 0x0, x350, x347); var x353: u64 = undefined; var x354: u1 = undefined; addcarryxU64(&x353, &x354, x352, x348, x345); var x355: u64 = undefined; var x356: u1 = undefined; addcarryxU64(&x355, &x356, x354, x346, x343); var x357: u64 = undefined; var x358: u1 = undefined; addcarryxU64(&x357, &x358, x356, x344, x341); var x359: u64 = undefined; var x360: u1 = undefined; addcarryxU64(&x359, &x360, x358, x342, x339); const x361 = (cast(u64, x360) + x340); var x362: u64 = undefined; var x363: u1 = undefined; addcarryxU64(&x362, &x363, 0x0, x323, x349); var x364: u64 = undefined; var x365: u1 = undefined; addcarryxU64(&x364, &x365, x363, x325, x351); var x366: u64 = undefined; var x367: u1 = undefined; addcarryxU64(&x366, &x367, x365, x327, x353); var x368: u64 = undefined; var x369: u1 = undefined; addcarryxU64(&x368, &x369, x367, x329, x355); var x370: u64 = undefined; var x371: u1 = undefined; addcarryxU64(&x370, &x371, x369, x331, x357); var x372: u64 = undefined; var x373: u1 = undefined; addcarryxU64(&x372, &x373, x371, x333, x359); var x374: u64 = undefined; var x375: u1 = undefined; addcarryxU64(&x374, &x375, x373, x335, x361); const x376 = (cast(u64, x375) + cast(u64, x336)); var x377: u64 = undefined; var x378: u64 = undefined; mulxU64(&x377, &x378, x5, (arg1[5])); var x379: u64 = undefined; var x380: u64 = undefined; mulxU64(&x379, &x380, x5, (arg1[4])); var x381: u64 = undefined; var x382: u64 = undefined; mulxU64(&x381, &x382, x5, (arg1[3])); var x383: u64 = undefined; var x384: u64 = undefined; mulxU64(&x383, &x384, x5, (arg1[2])); var x385: u64 = undefined; var x386: u64 = undefined; mulxU64(&x385, &x386, x5, (arg1[1])); var x387: u64 = undefined; var x388: u64 = undefined; mulxU64(&x387, &x388, x5, (arg1[0])); var x389: u64 = undefined; var x390: u1 = undefined; addcarryxU64(&x389, &x390, 0x0, x388, x385); var x391: u64 = undefined; var x392: u1 = undefined; addcarryxU64(&x391, &x392, x390, x386, x383); var x393: u64 = undefined; var x394: u1 = undefined; addcarryxU64(&x393, &x394, x392, x384, x381); var x395: u64 = undefined; var x396: u1 = undefined; addcarryxU64(&x395, &x396, x394, x382, x379); var x397: u64 = undefined; var x398: u1 = undefined; addcarryxU64(&x397, &x398, x396, x380, x377); const x399 = (cast(u64, x398) + x378); var x400: u64 = undefined; var x401: u1 = undefined; addcarryxU64(&x400, &x401, 0x0, x364, x387); var x402: u64 = undefined; var x403: u1 = undefined; addcarryxU64(&x402, &x403, x401, x366, x389); var x404: u64 = undefined; var x405: u1 = undefined; addcarryxU64(&x404, &x405, x403, x368, x391); var x406: u64 = undefined; var x407: u1 = undefined; addcarryxU64(&x406, &x407, x405, x370, x393); var x408: u64 = undefined; var x409: u1 = undefined; addcarryxU64(&x408, &x409, x407, x372, x395); var x410: u64 = undefined; var x411: u1 = undefined; addcarryxU64(&x410, &x411, x409, x374, x397); var x412: u64 = undefined; var x413: u1 = undefined; addcarryxU64(&x412, &x413, x411, x376, x399); var x414: u64 = undefined; var x415: u64 = undefined; mulxU64(&x414, &x415, x400, 0x100000001); var x416: u64 = undefined; var x417: u64 = undefined; mulxU64(&x416, &x417, x414, 0xffffffffffffffff); var x418: u64 = undefined; var x419: u64 = undefined; mulxU64(&x418, &x419, x414, 0xffffffffffffffff); var x420: u64 = undefined; var x421: u64 = undefined; mulxU64(&x420, &x421, x414, 0xffffffffffffffff); var x422: u64 = undefined; var x423: u64 = undefined; mulxU64(&x422, &x423, x414, 0xfffffffffffffffe); var x424: u64 = undefined; var x425: u64 = undefined; mulxU64(&x424, &x425, x414, 0xffffffff00000000); var x426: u64 = undefined; var x427: u64 = undefined; mulxU64(&x426, &x427, x414, 0xffffffff); var x428: u64 = undefined; var x429: u1 = undefined; addcarryxU64(&x428, &x429, 0x0, x427, x424); var x430: u64 = undefined; var x431: u1 = undefined; addcarryxU64(&x430, &x431, x429, x425, x422); var x432: u64 = undefined; var x433: u1 = undefined; addcarryxU64(&x432, &x433, x431, x423, x420); var x434: u64 = undefined; var x435: u1 = undefined; addcarryxU64(&x434, &x435, x433, x421, x418); var x436: u64 = undefined; var x437: u1 = undefined; addcarryxU64(&x436, &x437, x435, x419, x416); const x438 = (cast(u64, x437) + x417); var x439: u64 = undefined; var x440: u1 = undefined; addcarryxU64(&x439, &x440, 0x0, x400, x426); var x441: u64 = undefined; var x442: u1 = undefined; addcarryxU64(&x441, &x442, x440, x402, x428); var x443: u64 = undefined; var x444: u1 = undefined; addcarryxU64(&x443, &x444, x442, x404, x430); var x445: u64 = undefined; var x446: u1 = undefined; addcarryxU64(&x445, &x446, x444, x406, x432); var x447: u64 = undefined; var x448: u1 = undefined; addcarryxU64(&x447, &x448, x446, x408, x434); var x449: u64 = undefined; var x450: u1 = undefined; addcarryxU64(&x449, &x450, x448, x410, x436); var x451: u64 = undefined; var x452: u1 = undefined; addcarryxU64(&x451, &x452, x450, x412, x438); const x453 = (cast(u64, x452) + cast(u64, x413)); var x454: u64 = undefined; var x455: u1 = undefined; subborrowxU64(&x454, &x455, 0x0, x441, 0xffffffff); var x456: u64 = undefined; var x457: u1 = undefined; subborrowxU64(&x456, &x457, x455, x443, 0xffffffff00000000); var x458: u64 = undefined; var x459: u1 = undefined; subborrowxU64(&x458, &x459, x457, x445, 0xfffffffffffffffe); var x460: u64 = undefined; var x461: u1 = undefined; subborrowxU64(&x460, &x461, x459, x447, 0xffffffffffffffff); var x462: u64 = undefined; var x463: u1 = undefined; subborrowxU64(&x462, &x463, x461, x449, 0xffffffffffffffff); var x464: u64 = undefined; var x465: u1 = undefined; subborrowxU64(&x464, &x465, x463, x451, 0xffffffffffffffff); var x466: u64 = undefined; var x467: u1 = undefined; subborrowxU64(&x466, &x467, x465, x453, cast(u64, 0x0)); var x468: u64 = undefined; cmovznzU64(&x468, x467, x454, x441); var x469: u64 = undefined; cmovznzU64(&x469, x467, x456, x443); var x470: u64 = undefined; cmovznzU64(&x470, x467, x458, x445); var x471: u64 = undefined; cmovznzU64(&x471, x467, x460, x447); var x472: u64 = undefined; cmovznzU64(&x472, x467, x462, x449); var x473: u64 = undefined; cmovznzU64(&x473, x467, x464, x451); out1[0] = x468; out1[1] = x469; out1[2] = x470; out1[3] = x471; out1[4] = x472; out1[5] = x473; } /// The function add adds two field elements in the Montgomery domain. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// 0 ≤ eval arg2 < m /// Postconditions: /// eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m /// 0 ≤ eval out1 < m /// pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; addcarryxU64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); var x3: u64 = undefined; var x4: u1 = undefined; addcarryxU64(&x3, &x4, x2, (arg1[1]), (arg2[1])); var x5: u64 = undefined; var x6: u1 = undefined; addcarryxU64(&x5, &x6, x4, (arg1[2]), (arg2[2])); var x7: u64 = undefined; var x8: u1 = undefined; addcarryxU64(&x7, &x8, x6, (arg1[3]), (arg2[3])); var x9: u64 = undefined; var x10: u1 = undefined; addcarryxU64(&x9, &x10, x8, (arg1[4]), (arg2[4])); var x11: u64 = undefined; var x12: u1 = undefined; addcarryxU64(&x11, &x12, x10, (arg1[5]), (arg2[5])); var x13: u64 = undefined; var x14: u1 = undefined; subborrowxU64(&x13, &x14, 0x0, x1, 0xffffffff); var x15: u64 = undefined; var x16: u1 = undefined; subborrowxU64(&x15, &x16, x14, x3, 0xffffffff00000000); var x17: u64 = undefined; var x18: u1 = undefined; subborrowxU64(&x17, &x18, x16, x5, 0xfffffffffffffffe); var x19: u64 = undefined; var x20: u1 = undefined; subborrowxU64(&x19, &x20, x18, x7, 0xffffffffffffffff); var x21: u64 = undefined; var x22: u1 = undefined; subborrowxU64(&x21, &x22, x20, x9, 0xffffffffffffffff); var x23: u64 = undefined; var x24: u1 = undefined; subborrowxU64(&x23, &x24, x22, x11, 0xffffffffffffffff); var x25: u64 = undefined; var x26: u1 = undefined; subborrowxU64(&x25, &x26, x24, cast(u64, x12), cast(u64, 0x0)); var x27: u64 = undefined; cmovznzU64(&x27, x26, x13, x1); var x28: u64 = undefined; cmovznzU64(&x28, x26, x15, x3); var x29: u64 = undefined; cmovznzU64(&x29, x26, x17, x5); var x30: u64 = undefined; cmovznzU64(&x30, x26, x19, x7); var x31: u64 = undefined; cmovznzU64(&x31, x26, x21, x9); var x32: u64 = undefined; cmovznzU64(&x32, x26, x23, x11); out1[0] = x27; out1[1] = x28; out1[2] = x29; out1[3] = x30; out1[4] = x31; out1[5] = x32; } /// The function sub subtracts two field elements in the Montgomery domain. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// 0 ≤ eval arg2 < m /// Postconditions: /// eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m /// 0 ≤ eval out1 < m /// pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; subborrowxU64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); var x3: u64 = undefined; var x4: u1 = undefined; subborrowxU64(&x3, &x4, x2, (arg1[1]), (arg2[1])); var x5: u64 = undefined; var x6: u1 = undefined; subborrowxU64(&x5, &x6, x4, (arg1[2]), (arg2[2])); var x7: u64 = undefined; var x8: u1 = undefined; subborrowxU64(&x7, &x8, x6, (arg1[3]), (arg2[3])); var x9: u64 = undefined; var x10: u1 = undefined; subborrowxU64(&x9, &x10, x8, (arg1[4]), (arg2[4])); var x11: u64 = undefined; var x12: u1 = undefined; subborrowxU64(&x11, &x12, x10, (arg1[5]), (arg2[5])); var x13: u64 = undefined; cmovznzU64(&x13, x12, cast(u64, 0x0), 0xffffffffffffffff); var x14: u64 = undefined; var x15: u1 = undefined; addcarryxU64(&x14, &x15, 0x0, x1, (x13 & 0xffffffff)); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, x15, x3, (x13 & 0xffffffff00000000)); var x18: u64 = undefined; var x19: u1 = undefined; addcarryxU64(&x18, &x19, x17, x5, (x13 & 0xfffffffffffffffe)); var x20: u64 = undefined; var x21: u1 = undefined; addcarryxU64(&x20, &x21, x19, x7, x13); var x22: u64 = undefined; var x23: u1 = undefined; addcarryxU64(&x22, &x23, x21, x9, x13); var x24: u64 = undefined; var x25: u1 = undefined; addcarryxU64(&x24, &x25, x23, x11, x13); out1[0] = x14; out1[1] = x16; out1[2] = x18; out1[3] = x20; out1[4] = x22; out1[5] = x24; } /// The function opp negates a field element in the Montgomery domain. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m /// 0 ≤ eval out1 < m /// pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; subborrowxU64(&x1, &x2, 0x0, cast(u64, 0x0), (arg1[0])); var x3: u64 = undefined; var x4: u1 = undefined; subborrowxU64(&x3, &x4, x2, cast(u64, 0x0), (arg1[1])); var x5: u64 = undefined; var x6: u1 = undefined; subborrowxU64(&x5, &x6, x4, cast(u64, 0x0), (arg1[2])); var x7: u64 = undefined; var x8: u1 = undefined; subborrowxU64(&x7, &x8, x6, cast(u64, 0x0), (arg1[3])); var x9: u64 = undefined; var x10: u1 = undefined; subborrowxU64(&x9, &x10, x8, cast(u64, 0x0), (arg1[4])); var x11: u64 = undefined; var x12: u1 = undefined; subborrowxU64(&x11, &x12, x10, cast(u64, 0x0), (arg1[5])); var x13: u64 = undefined; cmovznzU64(&x13, x12, cast(u64, 0x0), 0xffffffffffffffff); var x14: u64 = undefined; var x15: u1 = undefined; addcarryxU64(&x14, &x15, 0x0, x1, (x13 & 0xffffffff)); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, x15, x3, (x13 & 0xffffffff00000000)); var x18: u64 = undefined; var x19: u1 = undefined; addcarryxU64(&x18, &x19, x17, x5, (x13 & 0xfffffffffffffffe)); var x20: u64 = undefined; var x21: u1 = undefined; addcarryxU64(&x20, &x21, x19, x7, x13); var x22: u64 = undefined; var x23: u1 = undefined; addcarryxU64(&x22, &x23, x21, x9, x13); var x24: u64 = undefined; var x25: u1 = undefined; addcarryxU64(&x24, &x25, x23, x11, x13); out1[0] = x14; out1[1] = x16; out1[2] = x18; out1[3] = x20; out1[4] = x22; out1[5] = x24; } /// The function fromMontgomery translates a field element out of the Montgomery domain. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// eval out1 mod m = (eval arg1 * ((2^64)⁻¹ mod m)^6) mod m /// 0 ≤ eval out1 < m /// pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[0]); var x2: u64 = undefined; var x3: u64 = undefined; mulxU64(&x2, &x3, x1, 0x100000001); var x4: u64 = undefined; var x5: u64 = undefined; mulxU64(&x4, &x5, x2, 0xffffffffffffffff); var x6: u64 = undefined; var x7: u64 = undefined; mulxU64(&x6, &x7, x2, 0xffffffffffffffff); var x8: u64 = undefined; var x9: u64 = undefined; mulxU64(&x8, &x9, x2, 0xffffffffffffffff); var x10: u64 = undefined; var x11: u64 = undefined; mulxU64(&x10, &x11, x2, 0xfffffffffffffffe); var x12: u64 = undefined; var x13: u64 = undefined; mulxU64(&x12, &x13, x2, 0xffffffff00000000); var x14: u64 = undefined; var x15: u64 = undefined; mulxU64(&x14, &x15, x2, 0xffffffff); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, 0x0, x15, x12); var x18: u64 = undefined; var x19: u1 = undefined; addcarryxU64(&x18, &x19, x17, x13, x10); var x20: u64 = undefined; var x21: u1 = undefined; addcarryxU64(&x20, &x21, x19, x11, x8); var x22: u64 = undefined; var x23: u1 = undefined; addcarryxU64(&x22, &x23, x21, x9, x6); var x24: u64 = undefined; var x25: u1 = undefined; addcarryxU64(&x24, &x25, x23, x7, x4); var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU64(&x26, &x27, 0x0, x1, x14); var x28: u64 = undefined; var x29: u1 = undefined; addcarryxU64(&x28, &x29, x27, cast(u64, 0x0), x16); var x30: u64 = undefined; var x31: u1 = undefined; addcarryxU64(&x30, &x31, x29, cast(u64, 0x0), x18); var x32: u64 = undefined; var x33: u1 = undefined; addcarryxU64(&x32, &x33, x31, cast(u64, 0x0), x20); var x34: u64 = undefined; var x35: u1 = undefined; addcarryxU64(&x34, &x35, x33, cast(u64, 0x0), x22); var x36: u64 = undefined; var x37: u1 = undefined; addcarryxU64(&x36, &x37, x35, cast(u64, 0x0), x24); var x38: u64 = undefined; var x39: u1 = undefined; addcarryxU64(&x38, &x39, x37, cast(u64, 0x0), (cast(u64, x25) + x5)); var x40: u64 = undefined; var x41: u1 = undefined; addcarryxU64(&x40, &x41, 0x0, x28, (arg1[1])); var x42: u64 = undefined; var x43: u1 = undefined; addcarryxU64(&x42, &x43, x41, x30, cast(u64, 0x0)); var x44: u64 = undefined; var x45: u1 = undefined; addcarryxU64(&x44, &x45, x43, x32, cast(u64, 0x0)); var x46: u64 = undefined; var x47: u1 = undefined; addcarryxU64(&x46, &x47, x45, x34, cast(u64, 0x0)); var x48: u64 = undefined; var x49: u1 = undefined; addcarryxU64(&x48, &x49, x47, x36, cast(u64, 0x0)); var x50: u64 = undefined; var x51: u1 = undefined; addcarryxU64(&x50, &x51, x49, x38, cast(u64, 0x0)); var x52: u64 = undefined; var x53: u64 = undefined; mulxU64(&x52, &x53, x40, 0x100000001); var x54: u64 = undefined; var x55: u64 = undefined; mulxU64(&x54, &x55, x52, 0xffffffffffffffff); var x56: u64 = undefined; var x57: u64 = undefined; mulxU64(&x56, &x57, x52, 0xffffffffffffffff); var x58: u64 = undefined; var x59: u64 = undefined; mulxU64(&x58, &x59, x52, 0xffffffffffffffff); var x60: u64 = undefined; var x61: u64 = undefined; mulxU64(&x60, &x61, x52, 0xfffffffffffffffe); var x62: u64 = undefined; var x63: u64 = undefined; mulxU64(&x62, &x63, x52, 0xffffffff00000000); var x64: u64 = undefined; var x65: u64 = undefined; mulxU64(&x64, &x65, x52, 0xffffffff); var x66: u64 = undefined; var x67: u1 = undefined; addcarryxU64(&x66, &x67, 0x0, x65, x62); var x68: u64 = undefined; var x69: u1 = undefined; addcarryxU64(&x68, &x69, x67, x63, x60); var x70: u64 = undefined; var x71: u1 = undefined; addcarryxU64(&x70, &x71, x69, x61, x58); var x72: u64 = undefined; var x73: u1 = undefined; addcarryxU64(&x72, &x73, x71, x59, x56); var x74: u64 = undefined; var x75: u1 = undefined; addcarryxU64(&x74, &x75, x73, x57, x54); var x76: u64 = undefined; var x77: u1 = undefined; addcarryxU64(&x76, &x77, 0x0, x40, x64); var x78: u64 = undefined; var x79: u1 = undefined; addcarryxU64(&x78, &x79, x77, x42, x66); var x80: u64 = undefined; var x81: u1 = undefined; addcarryxU64(&x80, &x81, x79, x44, x68); var x82: u64 = undefined; var x83: u1 = undefined; addcarryxU64(&x82, &x83, x81, x46, x70); var x84: u64 = undefined; var x85: u1 = undefined; addcarryxU64(&x84, &x85, x83, x48, x72); var x86: u64 = undefined; var x87: u1 = undefined; addcarryxU64(&x86, &x87, x85, x50, x74); var x88: u64 = undefined; var x89: u1 = undefined; addcarryxU64(&x88, &x89, x87, (cast(u64, x51) + cast(u64, x39)), (cast(u64, x75) + x55)); var x90: u64 = undefined; var x91: u1 = undefined; addcarryxU64(&x90, &x91, 0x0, x78, (arg1[2])); var x92: u64 = undefined; var x93: u1 = undefined; addcarryxU64(&x92, &x93, x91, x80, cast(u64, 0x0)); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, x93, x82, cast(u64, 0x0)); var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x84, cast(u64, 0x0)); var x98: u64 = undefined; var x99: u1 = undefined; addcarryxU64(&x98, &x99, x97, x86, cast(u64, 0x0)); var x100: u64 = undefined; var x101: u1 = undefined; addcarryxU64(&x100, &x101, x99, x88, cast(u64, 0x0)); var x102: u64 = undefined; var x103: u64 = undefined; mulxU64(&x102, &x103, x90, 0x100000001); var x104: u64 = undefined; var x105: u64 = undefined; mulxU64(&x104, &x105, x102, 0xffffffffffffffff); var x106: u64 = undefined; var x107: u64 = undefined; mulxU64(&x106, &x107, x102, 0xffffffffffffffff); var x108: u64 = undefined; var x109: u64 = undefined; mulxU64(&x108, &x109, x102, 0xffffffffffffffff); var x110: u64 = undefined; var x111: u64 = undefined; mulxU64(&x110, &x111, x102, 0xfffffffffffffffe); var x112: u64 = undefined; var x113: u64 = undefined; mulxU64(&x112, &x113, x102, 0xffffffff00000000); var x114: u64 = undefined; var x115: u64 = undefined; mulxU64(&x114, &x115, x102, 0xffffffff); var x116: u64 = undefined; var x117: u1 = undefined; addcarryxU64(&x116, &x117, 0x0, x115, x112); var x118: u64 = undefined; var x119: u1 = undefined; addcarryxU64(&x118, &x119, x117, x113, x110); var x120: u64 = undefined; var x121: u1 = undefined; addcarryxU64(&x120, &x121, x119, x111, x108); var x122: u64 = undefined; var x123: u1 = undefined; addcarryxU64(&x122, &x123, x121, x109, x106); var x124: u64 = undefined; var x125: u1 = undefined; addcarryxU64(&x124, &x125, x123, x107, x104); var x126: u64 = undefined; var x127: u1 = undefined; addcarryxU64(&x126, &x127, 0x0, x90, x114); var x128: u64 = undefined; var x129: u1 = undefined; addcarryxU64(&x128, &x129, x127, x92, x116); var x130: u64 = undefined; var x131: u1 = undefined; addcarryxU64(&x130, &x131, x129, x94, x118); var x132: u64 = undefined; var x133: u1 = undefined; addcarryxU64(&x132, &x133, x131, x96, x120); var x134: u64 = undefined; var x135: u1 = undefined; addcarryxU64(&x134, &x135, x133, x98, x122); var x136: u64 = undefined; var x137: u1 = undefined; addcarryxU64(&x136, &x137, x135, x100, x124); var x138: u64 = undefined; var x139: u1 = undefined; addcarryxU64(&x138, &x139, x137, (cast(u64, x101) + cast(u64, x89)), (cast(u64, x125) + x105)); var x140: u64 = undefined; var x141: u1 = undefined; addcarryxU64(&x140, &x141, 0x0, x128, (arg1[3])); var x142: u64 = undefined; var x143: u1 = undefined; addcarryxU64(&x142, &x143, x141, x130, cast(u64, 0x0)); var x144: u64 = undefined; var x145: u1 = undefined; addcarryxU64(&x144, &x145, x143, x132, cast(u64, 0x0)); var x146: u64 = undefined; var x147: u1 = undefined; addcarryxU64(&x146, &x147, x145, x134, cast(u64, 0x0)); var x148: u64 = undefined; var x149: u1 = undefined; addcarryxU64(&x148, &x149, x147, x136, cast(u64, 0x0)); var x150: u64 = undefined; var x151: u1 = undefined; addcarryxU64(&x150, &x151, x149, x138, cast(u64, 0x0)); var x152: u64 = undefined; var x153: u64 = undefined; mulxU64(&x152, &x153, x140, 0x100000001); var x154: u64 = undefined; var x155: u64 = undefined; mulxU64(&x154, &x155, x152, 0xffffffffffffffff); var x156: u64 = undefined; var x157: u64 = undefined; mulxU64(&x156, &x157, x152, 0xffffffffffffffff); var x158: u64 = undefined; var x159: u64 = undefined; mulxU64(&x158, &x159, x152, 0xffffffffffffffff); var x160: u64 = undefined; var x161: u64 = undefined; mulxU64(&x160, &x161, x152, 0xfffffffffffffffe); var x162: u64 = undefined; var x163: u64 = undefined; mulxU64(&x162, &x163, x152, 0xffffffff00000000); var x164: u64 = undefined; var x165: u64 = undefined; mulxU64(&x164, &x165, x152, 0xffffffff); var x166: u64 = undefined; var x167: u1 = undefined; addcarryxU64(&x166, &x167, 0x0, x165, x162); var x168: u64 = undefined; var x169: u1 = undefined; addcarryxU64(&x168, &x169, x167, x163, x160); var x170: u64 = undefined; var x171: u1 = undefined; addcarryxU64(&x170, &x171, x169, x161, x158); var x172: u64 = undefined; var x173: u1 = undefined; addcarryxU64(&x172, &x173, x171, x159, x156); var x174: u64 = undefined; var x175: u1 = undefined; addcarryxU64(&x174, &x175, x173, x157, x154); var x176: u64 = undefined; var x177: u1 = undefined; addcarryxU64(&x176, &x177, 0x0, x140, x164); var x178: u64 = undefined; var x179: u1 = undefined; addcarryxU64(&x178, &x179, x177, x142, x166); var x180: u64 = undefined; var x181: u1 = undefined; addcarryxU64(&x180, &x181, x179, x144, x168); var x182: u64 = undefined; var x183: u1 = undefined; addcarryxU64(&x182, &x183, x181, x146, x170); var x184: u64 = undefined; var x185: u1 = undefined; addcarryxU64(&x184, &x185, x183, x148, x172); var x186: u64 = undefined; var x187: u1 = undefined; addcarryxU64(&x186, &x187, x185, x150, x174); var x188: u64 = undefined; var x189: u1 = undefined; addcarryxU64(&x188, &x189, x187, (cast(u64, x151) + cast(u64, x139)), (cast(u64, x175) + x155)); var x190: u64 = undefined; var x191: u1 = undefined; addcarryxU64(&x190, &x191, 0x0, x178, (arg1[4])); var x192: u64 = undefined; var x193: u1 = undefined; addcarryxU64(&x192, &x193, x191, x180, cast(u64, 0x0)); var x194: u64 = undefined; var x195: u1 = undefined; addcarryxU64(&x194, &x195, x193, x182, cast(u64, 0x0)); var x196: u64 = undefined; var x197: u1 = undefined; addcarryxU64(&x196, &x197, x195, x184, cast(u64, 0x0)); var x198: u64 = undefined; var x199: u1 = undefined; addcarryxU64(&x198, &x199, x197, x186, cast(u64, 0x0)); var x200: u64 = undefined; var x201: u1 = undefined; addcarryxU64(&x200, &x201, x199, x188, cast(u64, 0x0)); var x202: u64 = undefined; var x203: u64 = undefined; mulxU64(&x202, &x203, x190, 0x100000001); var x204: u64 = undefined; var x205: u64 = undefined; mulxU64(&x204, &x205, x202, 0xffffffffffffffff); var x206: u64 = undefined; var x207: u64 = undefined; mulxU64(&x206, &x207, x202, 0xffffffffffffffff); var x208: u64 = undefined; var x209: u64 = undefined; mulxU64(&x208, &x209, x202, 0xffffffffffffffff); var x210: u64 = undefined; var x211: u64 = undefined; mulxU64(&x210, &x211, x202, 0xfffffffffffffffe); var x212: u64 = undefined; var x213: u64 = undefined; mulxU64(&x212, &x213, x202, 0xffffffff00000000); var x214: u64 = undefined; var x215: u64 = undefined; mulxU64(&x214, &x215, x202, 0xffffffff); var x216: u64 = undefined; var x217: u1 = undefined; addcarryxU64(&x216, &x217, 0x0, x215, x212); var x218: u64 = undefined; var x219: u1 = undefined; addcarryxU64(&x218, &x219, x217, x213, x210); var x220: u64 = undefined; var x221: u1 = undefined; addcarryxU64(&x220, &x221, x219, x211, x208); var x222: u64 = undefined; var x223: u1 = undefined; addcarryxU64(&x222, &x223, x221, x209, x206); var x224: u64 = undefined; var x225: u1 = undefined; addcarryxU64(&x224, &x225, x223, x207, x204); var x226: u64 = undefined; var x227: u1 = undefined; addcarryxU64(&x226, &x227, 0x0, x190, x214); var x228: u64 = undefined; var x229: u1 = undefined; addcarryxU64(&x228, &x229, x227, x192, x216); var x230: u64 = undefined; var x231: u1 = undefined; addcarryxU64(&x230, &x231, x229, x194, x218); var x232: u64 = undefined; var x233: u1 = undefined; addcarryxU64(&x232, &x233, x231, x196, x220); var x234: u64 = undefined; var x235: u1 = undefined; addcarryxU64(&x234, &x235, x233, x198, x222); var x236: u64 = undefined; var x237: u1 = undefined; addcarryxU64(&x236, &x237, x235, x200, x224); var x238: u64 = undefined; var x239: u1 = undefined; addcarryxU64(&x238, &x239, x237, (cast(u64, x201) + cast(u64, x189)), (cast(u64, x225) + x205)); var x240: u64 = undefined; var x241: u1 = undefined; addcarryxU64(&x240, &x241, 0x0, x228, (arg1[5])); var x242: u64 = undefined; var x243: u1 = undefined; addcarryxU64(&x242, &x243, x241, x230, cast(u64, 0x0)); var x244: u64 = undefined; var x245: u1 = undefined; addcarryxU64(&x244, &x245, x243, x232, cast(u64, 0x0)); var x246: u64 = undefined; var x247: u1 = undefined; addcarryxU64(&x246, &x247, x245, x234, cast(u64, 0x0)); var x248: u64 = undefined; var x249: u1 = undefined; addcarryxU64(&x248, &x249, x247, x236, cast(u64, 0x0)); var x250: u64 = undefined; var x251: u1 = undefined; addcarryxU64(&x250, &x251, x249, x238, cast(u64, 0x0)); var x252: u64 = undefined; var x253: u64 = undefined; mulxU64(&x252, &x253, x240, 0x100000001); var x254: u64 = undefined; var x255: u64 = undefined; mulxU64(&x254, &x255, x252, 0xffffffffffffffff); var x256: u64 = undefined; var x257: u64 = undefined; mulxU64(&x256, &x257, x252, 0xffffffffffffffff); var x258: u64 = undefined; var x259: u64 = undefined; mulxU64(&x258, &x259, x252, 0xffffffffffffffff); var x260: u64 = undefined; var x261: u64 = undefined; mulxU64(&x260, &x261, x252, 0xfffffffffffffffe); var x262: u64 = undefined; var x263: u64 = undefined; mulxU64(&x262, &x263, x252, 0xffffffff00000000); var x264: u64 = undefined; var x265: u64 = undefined; mulxU64(&x264, &x265, x252, 0xffffffff); var x266: u64 = undefined; var x267: u1 = undefined; addcarryxU64(&x266, &x267, 0x0, x265, x262); var x268: u64 = undefined; var x269: u1 = undefined; addcarryxU64(&x268, &x269, x267, x263, x260); var x270: u64 = undefined; var x271: u1 = undefined; addcarryxU64(&x270, &x271, x269, x261, x258); var x272: u64 = undefined; var x273: u1 = undefined; addcarryxU64(&x272, &x273, x271, x259, x256); var x274: u64 = undefined; var x275: u1 = undefined; addcarryxU64(&x274, &x275, x273, x257, x254); var x276: u64 = undefined; var x277: u1 = undefined; addcarryxU64(&x276, &x277, 0x0, x240, x264); var x278: u64 = undefined; var x279: u1 = undefined; addcarryxU64(&x278, &x279, x277, x242, x266); var x280: u64 = undefined; var x281: u1 = undefined; addcarryxU64(&x280, &x281, x279, x244, x268); var x282: u64 = undefined; var x283: u1 = undefined; addcarryxU64(&x282, &x283, x281, x246, x270); var x284: u64 = undefined; var x285: u1 = undefined; addcarryxU64(&x284, &x285, x283, x248, x272); var x286: u64 = undefined; var x287: u1 = undefined; addcarryxU64(&x286, &x287, x285, x250, x274); var x288: u64 = undefined; var x289: u1 = undefined; addcarryxU64(&x288, &x289, x287, (cast(u64, x251) + cast(u64, x239)), (cast(u64, x275) + x255)); var x290: u64 = undefined; var x291: u1 = undefined; subborrowxU64(&x290, &x291, 0x0, x278, 0xffffffff); var x292: u64 = undefined; var x293: u1 = undefined; subborrowxU64(&x292, &x293, x291, x280, 0xffffffff00000000); var x294: u64 = undefined; var x295: u1 = undefined; subborrowxU64(&x294, &x295, x293, x282, 0xfffffffffffffffe); var x296: u64 = undefined; var x297: u1 = undefined; subborrowxU64(&x296, &x297, x295, x284, 0xffffffffffffffff); var x298: u64 = undefined; var x299: u1 = undefined; subborrowxU64(&x298, &x299, x297, x286, 0xffffffffffffffff); var x300: u64 = undefined; var x301: u1 = undefined; subborrowxU64(&x300, &x301, x299, x288, 0xffffffffffffffff); var x302: u64 = undefined; var x303: u1 = undefined; subborrowxU64(&x302, &x303, x301, cast(u64, x289), cast(u64, 0x0)); var x304: u64 = undefined; cmovznzU64(&x304, x303, x290, x278); var x305: u64 = undefined; cmovznzU64(&x305, x303, x292, x280); var x306: u64 = undefined; cmovznzU64(&x306, x303, x294, x282); var x307: u64 = undefined; cmovznzU64(&x307, x303, x296, x284); var x308: u64 = undefined; cmovznzU64(&x308, x303, x298, x286); var x309: u64 = undefined; cmovznzU64(&x309, x303, x300, x288); out1[0] = x304; out1[1] = x305; out1[2] = x306; out1[3] = x307; out1[4] = x308; out1[5] = x309; } /// The function toMontgomery translates a field element into the Montgomery domain. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// eval (from_montgomery out1) mod m = eval arg1 mod m /// 0 ≤ eval out1 < m /// pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[1]); const x2 = (arg1[2]); const x3 = (arg1[3]); const x4 = (arg1[4]); const x5 = (arg1[5]); const x6 = (arg1[0]); var x7: u64 = undefined; var x8: u64 = undefined; mulxU64(&x7, &x8, x6, 0x200000000); var x9: u64 = undefined; var x10: u64 = undefined; mulxU64(&x9, &x10, x6, 0xfffffffe00000000); var x11: u64 = undefined; var x12: u64 = undefined; mulxU64(&x11, &x12, x6, 0x200000000); var x13: u64 = undefined; var x14: u64 = undefined; mulxU64(&x13, &x14, x6, 0xfffffffe00000001); var x15: u64 = undefined; var x16: u1 = undefined; addcarryxU64(&x15, &x16, 0x0, x14, x11); var x17: u64 = undefined; var x18: u1 = undefined; addcarryxU64(&x17, &x18, x16, x12, x9); var x19: u64 = undefined; var x20: u1 = undefined; addcarryxU64(&x19, &x20, x18, x10, x7); var x21: u64 = undefined; var x22: u1 = undefined; addcarryxU64(&x21, &x22, x20, x8, x6); var x23: u64 = undefined; var x24: u64 = undefined; mulxU64(&x23, &x24, x13, 0x100000001); var x25: u64 = undefined; var x26: u64 = undefined; mulxU64(&x25, &x26, x23, 0xffffffffffffffff); var x27: u64 = undefined; var x28: u64 = undefined; mulxU64(&x27, &x28, x23, 0xffffffffffffffff); var x29: u64 = undefined; var x30: u64 = undefined; mulxU64(&x29, &x30, x23, 0xffffffffffffffff); var x31: u64 = undefined; var x32: u64 = undefined; mulxU64(&x31, &x32, x23, 0xfffffffffffffffe); var x33: u64 = undefined; var x34: u64 = undefined; mulxU64(&x33, &x34, x23, 0xffffffff00000000); var x35: u64 = undefined; var x36: u64 = undefined; mulxU64(&x35, &x36, x23, 0xffffffff); var x37: u64 = undefined; var x38: u1 = undefined; addcarryxU64(&x37, &x38, 0x0, x36, x33); var x39: u64 = undefined; var x40: u1 = undefined; addcarryxU64(&x39, &x40, x38, x34, x31); var x41: u64 = undefined; var x42: u1 = undefined; addcarryxU64(&x41, &x42, x40, x32, x29); var x43: u64 = undefined; var x44: u1 = undefined; addcarryxU64(&x43, &x44, x42, x30, x27); var x45: u64 = undefined; var x46: u1 = undefined; addcarryxU64(&x45, &x46, x44, x28, x25); var x47: u64 = undefined; var x48: u1 = undefined; addcarryxU64(&x47, &x48, 0x0, x13, x35); var x49: u64 = undefined; var x50: u1 = undefined; addcarryxU64(&x49, &x50, x48, x15, x37); var x51: u64 = undefined; var x52: u1 = undefined; addcarryxU64(&x51, &x52, x50, x17, x39); var x53: u64 = undefined; var x54: u1 = undefined; addcarryxU64(&x53, &x54, x52, x19, x41); var x55: u64 = undefined; var x56: u1 = undefined; addcarryxU64(&x55, &x56, x54, x21, x43); var x57: u64 = undefined; var x58: u1 = undefined; addcarryxU64(&x57, &x58, x56, cast(u64, x22), x45); var x59: u64 = undefined; var x60: u1 = undefined; addcarryxU64(&x59, &x60, x58, cast(u64, 0x0), (cast(u64, x46) + x26)); var x61: u64 = undefined; var x62: u64 = undefined; mulxU64(&x61, &x62, x1, 0x200000000); var x63: u64 = undefined; var x64: u64 = undefined; mulxU64(&x63, &x64, x1, 0xfffffffe00000000); var x65: u64 = undefined; var x66: u64 = undefined; mulxU64(&x65, &x66, x1, 0x200000000); var x67: u64 = undefined; var x68: u64 = undefined; mulxU64(&x67, &x68, x1, 0xfffffffe00000001); var x69: u64 = undefined; var x70: u1 = undefined; addcarryxU64(&x69, &x70, 0x0, x68, x65); var x71: u64 = undefined; var x72: u1 = undefined; addcarryxU64(&x71, &x72, x70, x66, x63); var x73: u64 = undefined; var x74: u1 = undefined; addcarryxU64(&x73, &x74, x72, x64, x61); var x75: u64 = undefined; var x76: u1 = undefined; addcarryxU64(&x75, &x76, x74, x62, x1); var x77: u64 = undefined; var x78: u1 = undefined; addcarryxU64(&x77, &x78, 0x0, x49, x67); var x79: u64 = undefined; var x80: u1 = undefined; addcarryxU64(&x79, &x80, x78, x51, x69); var x81: u64 = undefined; var x82: u1 = undefined; addcarryxU64(&x81, &x82, x80, x53, x71); var x83: u64 = undefined; var x84: u1 = undefined; addcarryxU64(&x83, &x84, x82, x55, x73); var x85: u64 = undefined; var x86: u1 = undefined; addcarryxU64(&x85, &x86, x84, x57, x75); var x87: u64 = undefined; var x88: u1 = undefined; addcarryxU64(&x87, &x88, x86, x59, cast(u64, x76)); var x89: u64 = undefined; var x90: u64 = undefined; mulxU64(&x89, &x90, x77, 0x100000001); var x91: u64 = undefined; var x92: u64 = undefined; mulxU64(&x91, &x92, x89, 0xffffffffffffffff); var x93: u64 = undefined; var x94: u64 = undefined; mulxU64(&x93, &x94, x89, 0xffffffffffffffff); var x95: u64 = undefined; var x96: u64 = undefined; mulxU64(&x95, &x96, x89, 0xffffffffffffffff); var x97: u64 = undefined; var x98: u64 = undefined; mulxU64(&x97, &x98, x89, 0xfffffffffffffffe); var x99: u64 = undefined; var x100: u64 = undefined; mulxU64(&x99, &x100, x89, 0xffffffff00000000); var x101: u64 = undefined; var x102: u64 = undefined; mulxU64(&x101, &x102, x89, 0xffffffff); var x103: u64 = undefined; var x104: u1 = undefined; addcarryxU64(&x103, &x104, 0x0, x102, x99); var x105: u64 = undefined; var x106: u1 = undefined; addcarryxU64(&x105, &x106, x104, x100, x97); var x107: u64 = undefined; var x108: u1 = undefined; addcarryxU64(&x107, &x108, x106, x98, x95); var x109: u64 = undefined; var x110: u1 = undefined; addcarryxU64(&x109, &x110, x108, x96, x93); var x111: u64 = undefined; var x112: u1 = undefined; addcarryxU64(&x111, &x112, x110, x94, x91); var x113: u64 = undefined; var x114: u1 = undefined; addcarryxU64(&x113, &x114, 0x0, x77, x101); var x115: u64 = undefined; var x116: u1 = undefined; addcarryxU64(&x115, &x116, x114, x79, x103); var x117: u64 = undefined; var x118: u1 = undefined; addcarryxU64(&x117, &x118, x116, x81, x105); var x119: u64 = undefined; var x120: u1 = undefined; addcarryxU64(&x119, &x120, x118, x83, x107); var x121: u64 = undefined; var x122: u1 = undefined; addcarryxU64(&x121, &x122, x120, x85, x109); var x123: u64 = undefined; var x124: u1 = undefined; addcarryxU64(&x123, &x124, x122, x87, x111); var x125: u64 = undefined; var x126: u1 = undefined; addcarryxU64(&x125, &x126, x124, (cast(u64, x88) + cast(u64, x60)), (cast(u64, x112) + x92)); var x127: u64 = undefined; var x128: u64 = undefined; mulxU64(&x127, &x128, x2, 0x200000000); var x129: u64 = undefined; var x130: u64 = undefined; mulxU64(&x129, &x130, x2, 0xfffffffe00000000); var x131: u64 = undefined; var x132: u64 = undefined; mulxU64(&x131, &x132, x2, 0x200000000); var x133: u64 = undefined; var x134: u64 = undefined; mulxU64(&x133, &x134, x2, 0xfffffffe00000001); var x135: u64 = undefined; var x136: u1 = undefined; addcarryxU64(&x135, &x136, 0x0, x134, x131); var x137: u64 = undefined; var x138: u1 = undefined; addcarryxU64(&x137, &x138, x136, x132, x129); var x139: u64 = undefined; var x140: u1 = undefined; addcarryxU64(&x139, &x140, x138, x130, x127); var x141: u64 = undefined; var x142: u1 = undefined; addcarryxU64(&x141, &x142, x140, x128, x2); var x143: u64 = undefined; var x144: u1 = undefined; addcarryxU64(&x143, &x144, 0x0, x115, x133); var x145: u64 = undefined; var x146: u1 = undefined; addcarryxU64(&x145, &x146, x144, x117, x135); var x147: u64 = undefined; var x148: u1 = undefined; addcarryxU64(&x147, &x148, x146, x119, x137); var x149: u64 = undefined; var x150: u1 = undefined; addcarryxU64(&x149, &x150, x148, x121, x139); var x151: u64 = undefined; var x152: u1 = undefined; addcarryxU64(&x151, &x152, x150, x123, x141); var x153: u64 = undefined; var x154: u1 = undefined; addcarryxU64(&x153, &x154, x152, x125, cast(u64, x142)); var x155: u64 = undefined; var x156: u64 = undefined; mulxU64(&x155, &x156, x143, 0x100000001); var x157: u64 = undefined; var x158: u64 = undefined; mulxU64(&x157, &x158, x155, 0xffffffffffffffff); var x159: u64 = undefined; var x160: u64 = undefined; mulxU64(&x159, &x160, x155, 0xffffffffffffffff); var x161: u64 = undefined; var x162: u64 = undefined; mulxU64(&x161, &x162, x155, 0xffffffffffffffff); var x163: u64 = undefined; var x164: u64 = undefined; mulxU64(&x163, &x164, x155, 0xfffffffffffffffe); var x165: u64 = undefined; var x166: u64 = undefined; mulxU64(&x165, &x166, x155, 0xffffffff00000000); var x167: u64 = undefined; var x168: u64 = undefined; mulxU64(&x167, &x168, x155, 0xffffffff); var x169: u64 = undefined; var x170: u1 = undefined; addcarryxU64(&x169, &x170, 0x0, x168, x165); var x171: u64 = undefined; var x172: u1 = undefined; addcarryxU64(&x171, &x172, x170, x166, x163); var x173: u64 = undefined; var x174: u1 = undefined; addcarryxU64(&x173, &x174, x172, x164, x161); var x175: u64 = undefined; var x176: u1 = undefined; addcarryxU64(&x175, &x176, x174, x162, x159); var x177: u64 = undefined; var x178: u1 = undefined; addcarryxU64(&x177, &x178, x176, x160, x157); var x179: u64 = undefined; var x180: u1 = undefined; addcarryxU64(&x179, &x180, 0x0, x143, x167); var x181: u64 = undefined; var x182: u1 = undefined; addcarryxU64(&x181, &x182, x180, x145, x169); var x183: u64 = undefined; var x184: u1 = undefined; addcarryxU64(&x183, &x184, x182, x147, x171); var x185: u64 = undefined; var x186: u1 = undefined; addcarryxU64(&x185, &x186, x184, x149, x173); var x187: u64 = undefined; var x188: u1 = undefined; addcarryxU64(&x187, &x188, x186, x151, x175); var x189: u64 = undefined; var x190: u1 = undefined; addcarryxU64(&x189, &x190, x188, x153, x177); var x191: u64 = undefined; var x192: u1 = undefined; addcarryxU64(&x191, &x192, x190, (cast(u64, x154) + cast(u64, x126)), (cast(u64, x178) + x158)); var x193: u64 = undefined; var x194: u64 = undefined; mulxU64(&x193, &x194, x3, 0x200000000); var x195: u64 = undefined; var x196: u64 = undefined; mulxU64(&x195, &x196, x3, 0xfffffffe00000000); var x197: u64 = undefined; var x198: u64 = undefined; mulxU64(&x197, &x198, x3, 0x200000000); var x199: u64 = undefined; var x200: u64 = undefined; mulxU64(&x199, &x200, x3, 0xfffffffe00000001); var x201: u64 = undefined; var x202: u1 = undefined; addcarryxU64(&x201, &x202, 0x0, x200, x197); var x203: u64 = undefined; var x204: u1 = undefined; addcarryxU64(&x203, &x204, x202, x198, x195); var x205: u64 = undefined; var x206: u1 = undefined; addcarryxU64(&x205, &x206, x204, x196, x193); var x207: u64 = undefined; var x208: u1 = undefined; addcarryxU64(&x207, &x208, x206, x194, x3); var x209: u64 = undefined; var x210: u1 = undefined; addcarryxU64(&x209, &x210, 0x0, x181, x199); var x211: u64 = undefined; var x212: u1 = undefined; addcarryxU64(&x211, &x212, x210, x183, x201); var x213: u64 = undefined; var x214: u1 = undefined; addcarryxU64(&x213, &x214, x212, x185, x203); var x215: u64 = undefined; var x216: u1 = undefined; addcarryxU64(&x215, &x216, x214, x187, x205); var x217: u64 = undefined; var x218: u1 = undefined; addcarryxU64(&x217, &x218, x216, x189, x207); var x219: u64 = undefined; var x220: u1 = undefined; addcarryxU64(&x219, &x220, x218, x191, cast(u64, x208)); var x221: u64 = undefined; var x222: u64 = undefined; mulxU64(&x221, &x222, x209, 0x100000001); var x223: u64 = undefined; var x224: u64 = undefined; mulxU64(&x223, &x224, x221, 0xffffffffffffffff); var x225: u64 = undefined; var x226: u64 = undefined; mulxU64(&x225, &x226, x221, 0xffffffffffffffff); var x227: u64 = undefined; var x228: u64 = undefined; mulxU64(&x227, &x228, x221, 0xffffffffffffffff); var x229: u64 = undefined; var x230: u64 = undefined; mulxU64(&x229, &x230, x221, 0xfffffffffffffffe); var x231: u64 = undefined; var x232: u64 = undefined; mulxU64(&x231, &x232, x221, 0xffffffff00000000); var x233: u64 = undefined; var x234: u64 = undefined; mulxU64(&x233, &x234, x221, 0xffffffff); var x235: u64 = undefined; var x236: u1 = undefined; addcarryxU64(&x235, &x236, 0x0, x234, x231); var x237: u64 = undefined; var x238: u1 = undefined; addcarryxU64(&x237, &x238, x236, x232, x229); var x239: u64 = undefined; var x240: u1 = undefined; addcarryxU64(&x239, &x240, x238, x230, x227); var x241: u64 = undefined; var x242: u1 = undefined; addcarryxU64(&x241, &x242, x240, x228, x225); var x243: u64 = undefined; var x244: u1 = undefined; addcarryxU64(&x243, &x244, x242, x226, x223); var x245: u64 = undefined; var x246: u1 = undefined; addcarryxU64(&x245, &x246, 0x0, x209, x233); var x247: u64 = undefined; var x248: u1 = undefined; addcarryxU64(&x247, &x248, x246, x211, x235); var x249: u64 = undefined; var x250: u1 = undefined; addcarryxU64(&x249, &x250, x248, x213, x237); var x251: u64 = undefined; var x252: u1 = undefined; addcarryxU64(&x251, &x252, x250, x215, x239); var x253: u64 = undefined; var x254: u1 = undefined; addcarryxU64(&x253, &x254, x252, x217, x241); var x255: u64 = undefined; var x256: u1 = undefined; addcarryxU64(&x255, &x256, x254, x219, x243); var x257: u64 = undefined; var x258: u1 = undefined; addcarryxU64(&x257, &x258, x256, (cast(u64, x220) + cast(u64, x192)), (cast(u64, x244) + x224)); var x259: u64 = undefined; var x260: u64 = undefined; mulxU64(&x259, &x260, x4, 0x200000000); var x261: u64 = undefined; var x262: u64 = undefined; mulxU64(&x261, &x262, x4, 0xfffffffe00000000); var x263: u64 = undefined; var x264: u64 = undefined; mulxU64(&x263, &x264, x4, 0x200000000); var x265: u64 = undefined; var x266: u64 = undefined; mulxU64(&x265, &x266, x4, 0xfffffffe00000001); var x267: u64 = undefined; var x268: u1 = undefined; addcarryxU64(&x267, &x268, 0x0, x266, x263); var x269: u64 = undefined; var x270: u1 = undefined; addcarryxU64(&x269, &x270, x268, x264, x261); var x271: u64 = undefined; var x272: u1 = undefined; addcarryxU64(&x271, &x272, x270, x262, x259); var x273: u64 = undefined; var x274: u1 = undefined; addcarryxU64(&x273, &x274, x272, x260, x4); var x275: u64 = undefined; var x276: u1 = undefined; addcarryxU64(&x275, &x276, 0x0, x247, x265); var x277: u64 = undefined; var x278: u1 = undefined; addcarryxU64(&x277, &x278, x276, x249, x267); var x279: u64 = undefined; var x280: u1 = undefined; addcarryxU64(&x279, &x280, x278, x251, x269); var x281: u64 = undefined; var x282: u1 = undefined; addcarryxU64(&x281, &x282, x280, x253, x271); var x283: u64 = undefined; var x284: u1 = undefined; addcarryxU64(&x283, &x284, x282, x255, x273); var x285: u64 = undefined; var x286: u1 = undefined; addcarryxU64(&x285, &x286, x284, x257, cast(u64, x274)); var x287: u64 = undefined; var x288: u64 = undefined; mulxU64(&x287, &x288, x275, 0x100000001); var x289: u64 = undefined; var x290: u64 = undefined; mulxU64(&x289, &x290, x287, 0xffffffffffffffff); var x291: u64 = undefined; var x292: u64 = undefined; mulxU64(&x291, &x292, x287, 0xffffffffffffffff); var x293: u64 = undefined; var x294: u64 = undefined; mulxU64(&x293, &x294, x287, 0xffffffffffffffff); var x295: u64 = undefined; var x296: u64 = undefined; mulxU64(&x295, &x296, x287, 0xfffffffffffffffe); var x297: u64 = undefined; var x298: u64 = undefined; mulxU64(&x297, &x298, x287, 0xffffffff00000000); var x299: u64 = undefined; var x300: u64 = undefined; mulxU64(&x299, &x300, x287, 0xffffffff); var x301: u64 = undefined; var x302: u1 = undefined; addcarryxU64(&x301, &x302, 0x0, x300, x297); var x303: u64 = undefined; var x304: u1 = undefined; addcarryxU64(&x303, &x304, x302, x298, x295); var x305: u64 = undefined; var x306: u1 = undefined; addcarryxU64(&x305, &x306, x304, x296, x293); var x307: u64 = undefined; var x308: u1 = undefined; addcarryxU64(&x307, &x308, x306, x294, x291); var x309: u64 = undefined; var x310: u1 = undefined; addcarryxU64(&x309, &x310, x308, x292, x289); var x311: u64 = undefined; var x312: u1 = undefined; addcarryxU64(&x311, &x312, 0x0, x275, x299); var x313: u64 = undefined; var x314: u1 = undefined; addcarryxU64(&x313, &x314, x312, x277, x301); var x315: u64 = undefined; var x316: u1 = undefined; addcarryxU64(&x315, &x316, x314, x279, x303); var x317: u64 = undefined; var x318: u1 = undefined; addcarryxU64(&x317, &x318, x316, x281, x305); var x319: u64 = undefined; var x320: u1 = undefined; addcarryxU64(&x319, &x320, x318, x283, x307); var x321: u64 = undefined; var x322: u1 = undefined; addcarryxU64(&x321, &x322, x320, x285, x309); var x323: u64 = undefined; var x324: u1 = undefined; addcarryxU64(&x323, &x324, x322, (cast(u64, x286) + cast(u64, x258)), (cast(u64, x310) + x290)); var x325: u64 = undefined; var x326: u64 = undefined; mulxU64(&x325, &x326, x5, 0x200000000); var x327: u64 = undefined; var x328: u64 = undefined; mulxU64(&x327, &x328, x5, 0xfffffffe00000000); var x329: u64 = undefined; var x330: u64 = undefined; mulxU64(&x329, &x330, x5, 0x200000000); var x331: u64 = undefined; var x332: u64 = undefined; mulxU64(&x331, &x332, x5, 0xfffffffe00000001); var x333: u64 = undefined; var x334: u1 = undefined; addcarryxU64(&x333, &x334, 0x0, x332, x329); var x335: u64 = undefined; var x336: u1 = undefined; addcarryxU64(&x335, &x336, x334, x330, x327); var x337: u64 = undefined; var x338: u1 = undefined; addcarryxU64(&x337, &x338, x336, x328, x325); var x339: u64 = undefined; var x340: u1 = undefined; addcarryxU64(&x339, &x340, x338, x326, x5); var x341: u64 = undefined; var x342: u1 = undefined; addcarryxU64(&x341, &x342, 0x0, x313, x331); var x343: u64 = undefined; var x344: u1 = undefined; addcarryxU64(&x343, &x344, x342, x315, x333); var x345: u64 = undefined; var x346: u1 = undefined; addcarryxU64(&x345, &x346, x344, x317, x335); var x347: u64 = undefined; var x348: u1 = undefined; addcarryxU64(&x347, &x348, x346, x319, x337); var x349: u64 = undefined; var x350: u1 = undefined; addcarryxU64(&x349, &x350, x348, x321, x339); var x351: u64 = undefined; var x352: u1 = undefined; addcarryxU64(&x351, &x352, x350, x323, cast(u64, x340)); var x353: u64 = undefined; var x354: u64 = undefined; mulxU64(&x353, &x354, x341, 0x100000001); var x355: u64 = undefined; var x356: u64 = undefined; mulxU64(&x355, &x356, x353, 0xffffffffffffffff); var x357: u64 = undefined; var x358: u64 = undefined; mulxU64(&x357, &x358, x353, 0xffffffffffffffff); var x359: u64 = undefined; var x360: u64 = undefined; mulxU64(&x359, &x360, x353, 0xffffffffffffffff); var x361: u64 = undefined; var x362: u64 = undefined; mulxU64(&x361, &x362, x353, 0xfffffffffffffffe); var x363: u64 = undefined; var x364: u64 = undefined; mulxU64(&x363, &x364, x353, 0xffffffff00000000); var x365: u64 = undefined; var x366: u64 = undefined; mulxU64(&x365, &x366, x353, 0xffffffff); var x367: u64 = undefined; var x368: u1 = undefined; addcarryxU64(&x367, &x368, 0x0, x366, x363); var x369: u64 = undefined; var x370: u1 = undefined; addcarryxU64(&x369, &x370, x368, x364, x361); var x371: u64 = undefined; var x372: u1 = undefined; addcarryxU64(&x371, &x372, x370, x362, x359); var x373: u64 = undefined; var x374: u1 = undefined; addcarryxU64(&x373, &x374, x372, x360, x357); var x375: u64 = undefined; var x376: u1 = undefined; addcarryxU64(&x375, &x376, x374, x358, x355); var x377: u64 = undefined; var x378: u1 = undefined; addcarryxU64(&x377, &x378, 0x0, x341, x365); var x379: u64 = undefined; var x380: u1 = undefined; addcarryxU64(&x379, &x380, x378, x343, x367); var x381: u64 = undefined; var x382: u1 = undefined; addcarryxU64(&x381, &x382, x380, x345, x369); var x383: u64 = undefined; var x384: u1 = undefined; addcarryxU64(&x383, &x384, x382, x347, x371); var x385: u64 = undefined; var x386: u1 = undefined; addcarryxU64(&x385, &x386, x384, x349, x373); var x387: u64 = undefined; var x388: u1 = undefined; addcarryxU64(&x387, &x388, x386, x351, x375); var x389: u64 = undefined; var x390: u1 = undefined; addcarryxU64(&x389, &x390, x388, (cast(u64, x352) + cast(u64, x324)), (cast(u64, x376) + x356)); var x391: u64 = undefined; var x392: u1 = undefined; subborrowxU64(&x391, &x392, 0x0, x379, 0xffffffff); var x393: u64 = undefined; var x394: u1 = undefined; subborrowxU64(&x393, &x394, x392, x381, 0xffffffff00000000); var x395: u64 = undefined; var x396: u1 = undefined; subborrowxU64(&x395, &x396, x394, x383, 0xfffffffffffffffe); var x397: u64 = undefined; var x398: u1 = undefined; subborrowxU64(&x397, &x398, x396, x385, 0xffffffffffffffff); var x399: u64 = undefined; var x400: u1 = undefined; subborrowxU64(&x399, &x400, x398, x387, 0xffffffffffffffff); var x401: u64 = undefined; var x402: u1 = undefined; subborrowxU64(&x401, &x402, x400, x389, 0xffffffffffffffff); var x403: u64 = undefined; var x404: u1 = undefined; subborrowxU64(&x403, &x404, x402, cast(u64, x390), cast(u64, 0x0)); var x405: u64 = undefined; cmovznzU64(&x405, x404, x391, x379); var x406: u64 = undefined; cmovznzU64(&x406, x404, x393, x381); var x407: u64 = undefined; cmovznzU64(&x407, x404, x395, x383); var x408: u64 = undefined; cmovznzU64(&x408, x404, x397, x385); var x409: u64 = undefined; cmovznzU64(&x409, x404, x399, x387); var x410: u64 = undefined; cmovznzU64(&x410, x404, x401, x389); out1[0] = x405; out1[1] = x406; out1[2] = x407; out1[3] = x408; out1[4] = x409; out1[5] = x410; } /// The function nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn nonzero(out1: *u64, arg1: [6]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | ((arg1[4]) | (arg1[5])))))); out1.* = x1; } /// The function selectznz is a multi-limb conditional select. /// /// Postconditions: /// out1 = (if arg1 = 0 then arg2 else arg3) /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [[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]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn selectznz(out1: *[6]u64, arg1: u1, arg2: [6]u64, arg3: [6]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); var x2: u64 = undefined; cmovznzU64(&x2, arg1, (arg2[1]), (arg3[1])); var x3: u64 = undefined; cmovznzU64(&x3, arg1, (arg2[2]), (arg3[2])); var x4: u64 = undefined; cmovznzU64(&x4, arg1, (arg2[3]), (arg3[3])); var x5: u64 = undefined; cmovznzU64(&x5, arg1, (arg2[4]), (arg3[4])); var x6: u64 = undefined; cmovznzU64(&x6, arg1, (arg2[5]), (arg3[5])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; out1[4] = x5; out1[5] = x6; } /// The function toBytes serializes a field element NOT in the Montgomery domain to bytes in little-endian order. /// /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..47] /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] pub fn toBytes(out1: *[48]u8, arg1: [6]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[5]); const x2 = (arg1[4]); const x3 = (arg1[3]); const x4 = (arg1[2]); const x5 = (arg1[1]); const x6 = (arg1[0]); const x7 = cast(u8, (x6 & cast(u64, 0xff))); const x8 = (x6 >> 8); const x9 = cast(u8, (x8 & cast(u64, 0xff))); const x10 = (x8 >> 8); const x11 = cast(u8, (x10 & cast(u64, 0xff))); const x12 = (x10 >> 8); const x13 = cast(u8, (x12 & cast(u64, 0xff))); const x14 = (x12 >> 8); const x15 = cast(u8, (x14 & cast(u64, 0xff))); const x16 = (x14 >> 8); const x17 = cast(u8, (x16 & cast(u64, 0xff))); const x18 = (x16 >> 8); const x19 = cast(u8, (x18 & cast(u64, 0xff))); const x20 = cast(u8, (x18 >> 8)); const x21 = cast(u8, (x5 & cast(u64, 0xff))); const x22 = (x5 >> 8); const x23 = cast(u8, (x22 & cast(u64, 0xff))); const x24 = (x22 >> 8); const x25 = cast(u8, (x24 & cast(u64, 0xff))); const x26 = (x24 >> 8); const x27 = cast(u8, (x26 & cast(u64, 0xff))); const x28 = (x26 >> 8); const x29 = cast(u8, (x28 & cast(u64, 0xff))); const x30 = (x28 >> 8); const x31 = cast(u8, (x30 & cast(u64, 0xff))); const x32 = (x30 >> 8); const x33 = cast(u8, (x32 & cast(u64, 0xff))); const x34 = cast(u8, (x32 >> 8)); const x35 = cast(u8, (x4 & cast(u64, 0xff))); const x36 = (x4 >> 8); const x37 = cast(u8, (x36 & cast(u64, 0xff))); const x38 = (x36 >> 8); const x39 = cast(u8, (x38 & cast(u64, 0xff))); const x40 = (x38 >> 8); const x41 = cast(u8, (x40 & cast(u64, 0xff))); const x42 = (x40 >> 8); const x43 = cast(u8, (x42 & cast(u64, 0xff))); const x44 = (x42 >> 8); const x45 = cast(u8, (x44 & cast(u64, 0xff))); const x46 = (x44 >> 8); const x47 = cast(u8, (x46 & cast(u64, 0xff))); const x48 = cast(u8, (x46 >> 8)); const x49 = cast(u8, (x3 & cast(u64, 0xff))); const x50 = (x3 >> 8); const x51 = cast(u8, (x50 & cast(u64, 0xff))); const x52 = (x50 >> 8); const x53 = cast(u8, (x52 & cast(u64, 0xff))); const x54 = (x52 >> 8); const x55 = cast(u8, (x54 & cast(u64, 0xff))); const x56 = (x54 >> 8); const x57 = cast(u8, (x56 & cast(u64, 0xff))); const x58 = (x56 >> 8); const x59 = cast(u8, (x58 & cast(u64, 0xff))); const x60 = (x58 >> 8); const x61 = cast(u8, (x60 & cast(u64, 0xff))); const x62 = cast(u8, (x60 >> 8)); const x63 = cast(u8, (x2 & cast(u64, 0xff))); const x64 = (x2 >> 8); const x65 = cast(u8, (x64 & cast(u64, 0xff))); const x66 = (x64 >> 8); const x67 = cast(u8, (x66 & cast(u64, 0xff))); const x68 = (x66 >> 8); const x69 = cast(u8, (x68 & cast(u64, 0xff))); const x70 = (x68 >> 8); const x71 = cast(u8, (x70 & cast(u64, 0xff))); const x72 = (x70 >> 8); const x73 = cast(u8, (x72 & cast(u64, 0xff))); const x74 = (x72 >> 8); const x75 = cast(u8, (x74 & cast(u64, 0xff))); const x76 = cast(u8, (x74 >> 8)); const x77 = cast(u8, (x1 & cast(u64, 0xff))); const x78 = (x1 >> 8); const x79 = cast(u8, (x78 & cast(u64, 0xff))); const x80 = (x78 >> 8); const x81 = cast(u8, (x80 & cast(u64, 0xff))); const x82 = (x80 >> 8); const x83 = cast(u8, (x82 & cast(u64, 0xff))); const x84 = (x82 >> 8); const x85 = cast(u8, (x84 & cast(u64, 0xff))); const x86 = (x84 >> 8); const x87 = cast(u8, (x86 & cast(u64, 0xff))); const x88 = (x86 >> 8); const x89 = cast(u8, (x88 & cast(u64, 0xff))); const x90 = cast(u8, (x88 >> 8)); out1[0] = x7; out1[1] = x9; out1[2] = x11; out1[3] = x13; out1[4] = x15; out1[5] = x17; out1[6] = x19; out1[7] = x20; out1[8] = x21; out1[9] = x23; out1[10] = x25; out1[11] = x27; out1[12] = x29; out1[13] = x31; out1[14] = x33; out1[15] = x34; out1[16] = x35; out1[17] = x37; out1[18] = x39; out1[19] = x41; out1[20] = x43; out1[21] = x45; out1[22] = x47; out1[23] = x48; out1[24] = x49; out1[25] = x51; out1[26] = x53; out1[27] = x55; out1[28] = x57; out1[29] = x59; out1[30] = x61; out1[31] = x62; out1[32] = x63; out1[33] = x65; out1[34] = x67; out1[35] = x69; out1[36] = x71; out1[37] = x73; out1[38] = x75; out1[39] = x76; out1[40] = x77; out1[41] = x79; out1[42] = x81; out1[43] = x83; out1[44] = x85; out1[45] = x87; out1[46] = x89; out1[47] = x90; } /// The function fromBytes deserializes a field element NOT in the Montgomery domain from bytes in little-endian order. /// /// Preconditions: /// 0 ≤ bytes_eval arg1 < m /// Postconditions: /// eval out1 mod m = bytes_eval arg1 mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromBytes(out1: *[6]u64, arg1: [48]u8) void { @setRuntimeSafety(mode == .Debug); const x1 = (cast(u64, (arg1[47])) << 56); const x2 = (cast(u64, (arg1[46])) << 48); const x3 = (cast(u64, (arg1[45])) << 40); const x4 = (cast(u64, (arg1[44])) << 32); const x5 = (cast(u64, (arg1[43])) << 24); const x6 = (cast(u64, (arg1[42])) << 16); const x7 = (cast(u64, (arg1[41])) << 8); const x8 = (arg1[40]); const x9 = (cast(u64, (arg1[39])) << 56); const x10 = (cast(u64, (arg1[38])) << 48); const x11 = (cast(u64, (arg1[37])) << 40); const x12 = (cast(u64, (arg1[36])) << 32); const x13 = (cast(u64, (arg1[35])) << 24); const x14 = (cast(u64, (arg1[34])) << 16); const x15 = (cast(u64, (arg1[33])) << 8); const x16 = (arg1[32]); const x17 = (cast(u64, (arg1[31])) << 56); const x18 = (cast(u64, (arg1[30])) << 48); const x19 = (cast(u64, (arg1[29])) << 40); const x20 = (cast(u64, (arg1[28])) << 32); const x21 = (cast(u64, (arg1[27])) << 24); const x22 = (cast(u64, (arg1[26])) << 16); const x23 = (cast(u64, (arg1[25])) << 8); const x24 = (arg1[24]); const x25 = (cast(u64, (arg1[23])) << 56); const x26 = (cast(u64, (arg1[22])) << 48); const x27 = (cast(u64, (arg1[21])) << 40); const x28 = (cast(u64, (arg1[20])) << 32); const x29 = (cast(u64, (arg1[19])) << 24); const x30 = (cast(u64, (arg1[18])) << 16); const x31 = (cast(u64, (arg1[17])) << 8); const x32 = (arg1[16]); const x33 = (cast(u64, (arg1[15])) << 56); const x34 = (cast(u64, (arg1[14])) << 48); const x35 = (cast(u64, (arg1[13])) << 40); const x36 = (cast(u64, (arg1[12])) << 32); const x37 = (cast(u64, (arg1[11])) << 24); const x38 = (cast(u64, (arg1[10])) << 16); const x39 = (cast(u64, (arg1[9])) << 8); const x40 = (arg1[8]); const x41 = (cast(u64, (arg1[7])) << 56); const x42 = (cast(u64, (arg1[6])) << 48); const x43 = (cast(u64, (arg1[5])) << 40); const x44 = (cast(u64, (arg1[4])) << 32); const x45 = (cast(u64, (arg1[3])) << 24); const x46 = (cast(u64, (arg1[2])) << 16); const x47 = (cast(u64, (arg1[1])) << 8); const x48 = (arg1[0]); const x49 = (x47 + cast(u64, x48)); const x50 = (x46 + x49); const x51 = (x45 + x50); const x52 = (x44 + x51); const x53 = (x43 + x52); const x54 = (x42 + x53); const x55 = (x41 + x54); const x56 = (x39 + cast(u64, x40)); const x57 = (x38 + x56); const x58 = (x37 + x57); const x59 = (x36 + x58); const x60 = (x35 + x59); const x61 = (x34 + x60); const x62 = (x33 + x61); const x63 = (x31 + cast(u64, x32)); const x64 = (x30 + x63); const x65 = (x29 + x64); const x66 = (x28 + x65); const x67 = (x27 + x66); const x68 = (x26 + x67); const x69 = (x25 + x68); const x70 = (x23 + cast(u64, x24)); const x71 = (x22 + x70); const x72 = (x21 + x71); const x73 = (x20 + x72); const x74 = (x19 + x73); const x75 = (x18 + x74); const x76 = (x17 + x75); const x77 = (x15 + cast(u64, x16)); const x78 = (x14 + x77); const x79 = (x13 + x78); const x80 = (x12 + x79); const x81 = (x11 + x80); const x82 = (x10 + x81); const x83 = (x9 + x82); const x84 = (x7 + cast(u64, x8)); const x85 = (x6 + x84); const x86 = (x5 + x85); const x87 = (x4 + x86); const x88 = (x3 + x87); const x89 = (x2 + x88); const x90 = (x1 + x89); out1[0] = x55; out1[1] = x62; out1[2] = x69; out1[3] = x76; out1[4] = x83; out1[5] = x90; } /// The function setOne returns the field element one in the Montgomery domain. /// /// Postconditions: /// eval (from_montgomery out1) mod m = 1 mod m /// 0 ≤ eval out1 < m /// pub fn setOne(out1: *MontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); out1[0] = 0xffffffff00000001; out1[1] = 0xffffffff; out1[2] = cast(u64, 0x1); out1[3] = cast(u64, 0x0); out1[4] = cast(u64, 0x0); out1[5] = cast(u64, 0x0); } /// The function msat returns the saturated representation of the prime modulus. /// /// Postconditions: /// twos_complement_eval out1 = m /// 0 ≤ eval out1 < m /// /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn msat(out1: *[7]u64) void { @setRuntimeSafety(mode == .Debug); out1[0] = 0xffffffff; out1[1] = 0xffffffff00000000; out1[2] = 0xfffffffffffffffe; out1[3] = 0xffffffffffffffff; out1[4] = 0xffffffffffffffff; out1[5] = 0xffffffffffffffff; out1[6] = cast(u64, 0x0); } /// The function divstep computes a divstep. /// /// Preconditions: /// 0 ≤ eval arg4 < m /// 0 ≤ eval arg5 < m /// Postconditions: /// out1 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then 1 - arg1 else 1 + arg1) /// twos_complement_eval out2 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then twos_complement_eval arg3 else twos_complement_eval arg2) /// twos_complement_eval out3 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then ⌊(twos_complement_eval arg3 - twos_complement_eval arg2) / 2⌋ else ⌊(twos_complement_eval arg3 + (twos_complement_eval arg3 mod 2) * twos_complement_eval arg2) / 2⌋) /// eval (from_montgomery out4) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (2 * eval (from_montgomery arg5)) mod m else (2 * eval (from_montgomery arg4)) mod m) /// eval (from_montgomery out5) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (eval (from_montgomery arg4) - eval (from_montgomery arg4)) mod m else (eval (from_montgomery arg5) + (twos_complement_eval arg3 mod 2) * eval (from_montgomery arg4)) mod m) /// 0 ≤ eval out5 < m /// 0 ≤ eval out5 < m /// 0 ≤ eval out2 < m /// 0 ≤ eval out3 < m /// /// Input Bounds: /// arg1: [0x0 ~> 0xffffffffffffffff] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstep(out1: *u64, out2: *[7]u64, out3: *[7]u64, out4: *[6]u64, out5: *[6]u64, arg1: u64, arg2: [7]u64, arg3: [7]u64, arg4: [6]u64, arg5: [6]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; addcarryxU64(&x1, &x2, 0x0, (~arg1), cast(u64, 0x1)); const x3 = (cast(u1, (x1 >> 63)) & cast(u1, ((arg3[0]) & cast(u64, 0x1)))); var x4: u64 = undefined; var x5: u1 = undefined; addcarryxU64(&x4, &x5, 0x0, (~arg1), cast(u64, 0x1)); var x6: u64 = undefined; cmovznzU64(&x6, x3, arg1, x4); var x7: u64 = undefined; cmovznzU64(&x7, x3, (arg2[0]), (arg3[0])); var x8: u64 = undefined; cmovznzU64(&x8, x3, (arg2[1]), (arg3[1])); var x9: u64 = undefined; cmovznzU64(&x9, x3, (arg2[2]), (arg3[2])); var x10: u64 = undefined; cmovznzU64(&x10, x3, (arg2[3]), (arg3[3])); var x11: u64 = undefined; cmovznzU64(&x11, x3, (arg2[4]), (arg3[4])); var x12: u64 = undefined; cmovznzU64(&x12, x3, (arg2[5]), (arg3[5])); var x13: u64 = undefined; cmovznzU64(&x13, x3, (arg2[6]), (arg3[6])); var x14: u64 = undefined; var x15: u1 = undefined; addcarryxU64(&x14, &x15, 0x0, cast(u64, 0x1), (~(arg2[0]))); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, x15, cast(u64, 0x0), (~(arg2[1]))); var x18: u64 = undefined; var x19: u1 = undefined; addcarryxU64(&x18, &x19, x17, cast(u64, 0x0), (~(arg2[2]))); var x20: u64 = undefined; var x21: u1 = undefined; addcarryxU64(&x20, &x21, x19, cast(u64, 0x0), (~(arg2[3]))); var x22: u64 = undefined; var x23: u1 = undefined; addcarryxU64(&x22, &x23, x21, cast(u64, 0x0), (~(arg2[4]))); var x24: u64 = undefined; var x25: u1 = undefined; addcarryxU64(&x24, &x25, x23, cast(u64, 0x0), (~(arg2[5]))); var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU64(&x26, &x27, x25, cast(u64, 0x0), (~(arg2[6]))); var x28: u64 = undefined; cmovznzU64(&x28, x3, (arg3[0]), x14); var x29: u64 = undefined; cmovznzU64(&x29, x3, (arg3[1]), x16); var x30: u64 = undefined; cmovznzU64(&x30, x3, (arg3[2]), x18); var x31: u64 = undefined; cmovznzU64(&x31, x3, (arg3[3]), x20); var x32: u64 = undefined; cmovznzU64(&x32, x3, (arg3[4]), x22); var x33: u64 = undefined; cmovznzU64(&x33, x3, (arg3[5]), x24); var x34: u64 = undefined; cmovznzU64(&x34, x3, (arg3[6]), x26); var x35: u64 = undefined; cmovznzU64(&x35, x3, (arg4[0]), (arg5[0])); var x36: u64 = undefined; cmovznzU64(&x36, x3, (arg4[1]), (arg5[1])); var x37: u64 = undefined; cmovznzU64(&x37, x3, (arg4[2]), (arg5[2])); var x38: u64 = undefined; cmovznzU64(&x38, x3, (arg4[3]), (arg5[3])); var x39: u64 = undefined; cmovznzU64(&x39, x3, (arg4[4]), (arg5[4])); var x40: u64 = undefined; cmovznzU64(&x40, x3, (arg4[5]), (arg5[5])); var x41: u64 = undefined; var x42: u1 = undefined; addcarryxU64(&x41, &x42, 0x0, x35, x35); var x43: u64 = undefined; var x44: u1 = undefined; addcarryxU64(&x43, &x44, x42, x36, x36); var x45: u64 = undefined; var x46: u1 = undefined; addcarryxU64(&x45, &x46, x44, x37, x37); var x47: u64 = undefined; var x48: u1 = undefined; addcarryxU64(&x47, &x48, x46, x38, x38); var x49: u64 = undefined; var x50: u1 = undefined; addcarryxU64(&x49, &x50, x48, x39, x39); var x51: u64 = undefined; var x52: u1 = undefined; addcarryxU64(&x51, &x52, x50, x40, x40); var x53: u64 = undefined; var x54: u1 = undefined; subborrowxU64(&x53, &x54, 0x0, x41, 0xffffffff); var x55: u64 = undefined; var x56: u1 = undefined; subborrowxU64(&x55, &x56, x54, x43, 0xffffffff00000000); var x57: u64 = undefined; var x58: u1 = undefined; subborrowxU64(&x57, &x58, x56, x45, 0xfffffffffffffffe); var x59: u64 = undefined; var x60: u1 = undefined; subborrowxU64(&x59, &x60, x58, x47, 0xffffffffffffffff); var x61: u64 = undefined; var x62: u1 = undefined; subborrowxU64(&x61, &x62, x60, x49, 0xffffffffffffffff); var x63: u64 = undefined; var x64: u1 = undefined; subborrowxU64(&x63, &x64, x62, x51, 0xffffffffffffffff); var x65: u64 = undefined; var x66: u1 = undefined; subborrowxU64(&x65, &x66, x64, cast(u64, x52), cast(u64, 0x0)); const x67 = (arg4[5]); const x68 = (arg4[4]); const x69 = (arg4[3]); const x70 = (arg4[2]); const x71 = (arg4[1]); const x72 = (arg4[0]); var x73: u64 = undefined; var x74: u1 = undefined; subborrowxU64(&x73, &x74, 0x0, cast(u64, 0x0), x72); var x75: u64 = undefined; var x76: u1 = undefined; subborrowxU64(&x75, &x76, x74, cast(u64, 0x0), x71); var x77: u64 = undefined; var x78: u1 = undefined; subborrowxU64(&x77, &x78, x76, cast(u64, 0x0), x70); var x79: u64 = undefined; var x80: u1 = undefined; subborrowxU64(&x79, &x80, x78, cast(u64, 0x0), x69); var x81: u64 = undefined; var x82: u1 = undefined; subborrowxU64(&x81, &x82, x80, cast(u64, 0x0), x68); var x83: u64 = undefined; var x84: u1 = undefined; subborrowxU64(&x83, &x84, x82, cast(u64, 0x0), x67); var x85: u64 = undefined; cmovznzU64(&x85, x84, cast(u64, 0x0), 0xffffffffffffffff); var x86: u64 = undefined; var x87: u1 = undefined; addcarryxU64(&x86, &x87, 0x0, x73, (x85 & 0xffffffff)); var x88: u64 = undefined; var x89: u1 = undefined; addcarryxU64(&x88, &x89, x87, x75, (x85 & 0xffffffff00000000)); var x90: u64 = undefined; var x91: u1 = undefined; addcarryxU64(&x90, &x91, x89, x77, (x85 & 0xfffffffffffffffe)); var x92: u64 = undefined; var x93: u1 = undefined; addcarryxU64(&x92, &x93, x91, x79, x85); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, x93, x81, x85); var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x83, x85); var x98: u64 = undefined; cmovznzU64(&x98, x3, (arg5[0]), x86); var x99: u64 = undefined; cmovznzU64(&x99, x3, (arg5[1]), x88); var x100: u64 = undefined; cmovznzU64(&x100, x3, (arg5[2]), x90); var x101: u64 = undefined; cmovznzU64(&x101, x3, (arg5[3]), x92); var x102: u64 = undefined; cmovznzU64(&x102, x3, (arg5[4]), x94); var x103: u64 = undefined; cmovznzU64(&x103, x3, (arg5[5]), x96); const x104 = cast(u1, (x28 & cast(u64, 0x1))); var x105: u64 = undefined; cmovznzU64(&x105, x104, cast(u64, 0x0), x7); var x106: u64 = undefined; cmovznzU64(&x106, x104, cast(u64, 0x0), x8); var x107: u64 = undefined; cmovznzU64(&x107, x104, cast(u64, 0x0), x9); var x108: u64 = undefined; cmovznzU64(&x108, x104, cast(u64, 0x0), x10); var x109: u64 = undefined; cmovznzU64(&x109, x104, cast(u64, 0x0), x11); var x110: u64 = undefined; cmovznzU64(&x110, x104, cast(u64, 0x0), x12); var x111: u64 = undefined; cmovznzU64(&x111, x104, cast(u64, 0x0), x13); var x112: u64 = undefined; var x113: u1 = undefined; addcarryxU64(&x112, &x113, 0x0, x28, x105); var x114: u64 = undefined; var x115: u1 = undefined; addcarryxU64(&x114, &x115, x113, x29, x106); var x116: u64 = undefined; var x117: u1 = undefined; addcarryxU64(&x116, &x117, x115, x30, x107); var x118: u64 = undefined; var x119: u1 = undefined; addcarryxU64(&x118, &x119, x117, x31, x108); var x120: u64 = undefined; var x121: u1 = undefined; addcarryxU64(&x120, &x121, x119, x32, x109); var x122: u64 = undefined; var x123: u1 = undefined; addcarryxU64(&x122, &x123, x121, x33, x110); var x124: u64 = undefined; var x125: u1 = undefined; addcarryxU64(&x124, &x125, x123, x34, x111); var x126: u64 = undefined; cmovznzU64(&x126, x104, cast(u64, 0x0), x35); var x127: u64 = undefined; cmovznzU64(&x127, x104, cast(u64, 0x0), x36); var x128: u64 = undefined; cmovznzU64(&x128, x104, cast(u64, 0x0), x37); var x129: u64 = undefined; cmovznzU64(&x129, x104, cast(u64, 0x0), x38); var x130: u64 = undefined; cmovznzU64(&x130, x104, cast(u64, 0x0), x39); var x131: u64 = undefined; cmovznzU64(&x131, x104, cast(u64, 0x0), x40); var x132: u64 = undefined; var x133: u1 = undefined; addcarryxU64(&x132, &x133, 0x0, x98, x126); var x134: u64 = undefined; var x135: u1 = undefined; addcarryxU64(&x134, &x135, x133, x99, x127); var x136: u64 = undefined; var x137: u1 = undefined; addcarryxU64(&x136, &x137, x135, x100, x128); var x138: u64 = undefined; var x139: u1 = undefined; addcarryxU64(&x138, &x139, x137, x101, x129); var x140: u64 = undefined; var x141: u1 = undefined; addcarryxU64(&x140, &x141, x139, x102, x130); var x142: u64 = undefined; var x143: u1 = undefined; addcarryxU64(&x142, &x143, x141, x103, x131); var x144: u64 = undefined; var x145: u1 = undefined; subborrowxU64(&x144, &x145, 0x0, x132, 0xffffffff); var x146: u64 = undefined; var x147: u1 = undefined; subborrowxU64(&x146, &x147, x145, x134, 0xffffffff00000000); var x148: u64 = undefined; var x149: u1 = undefined; subborrowxU64(&x148, &x149, x147, x136, 0xfffffffffffffffe); var x150: u64 = undefined; var x151: u1 = undefined; subborrowxU64(&x150, &x151, x149, x138, 0xffffffffffffffff); var x152: u64 = undefined; var x153: u1 = undefined; subborrowxU64(&x152, &x153, x151, x140, 0xffffffffffffffff); var x154: u64 = undefined; var x155: u1 = undefined; subborrowxU64(&x154, &x155, x153, x142, 0xffffffffffffffff); var x156: u64 = undefined; var x157: u1 = undefined; subborrowxU64(&x156, &x157, x155, cast(u64, x143), cast(u64, 0x0)); var x158: u64 = undefined; var x159: u1 = undefined; addcarryxU64(&x158, &x159, 0x0, x6, cast(u64, 0x1)); const x160 = ((x112 >> 1) | ((x114 << 63) & 0xffffffffffffffff)); const x161 = ((x114 >> 1) | ((x116 << 63) & 0xffffffffffffffff)); const x162 = ((x116 >> 1) | ((x118 << 63) & 0xffffffffffffffff)); const x163 = ((x118 >> 1) | ((x120 << 63) & 0xffffffffffffffff)); const x164 = ((x120 >> 1) | ((x122 << 63) & 0xffffffffffffffff)); const x165 = ((x122 >> 1) | ((x124 << 63) & 0xffffffffffffffff)); const x166 = ((x124 & 0x8000000000000000) | (x124 >> 1)); var x167: u64 = undefined; cmovznzU64(&x167, x66, x53, x41); var x168: u64 = undefined; cmovznzU64(&x168, x66, x55, x43); var x169: u64 = undefined; cmovznzU64(&x169, x66, x57, x45); var x170: u64 = undefined; cmovznzU64(&x170, x66, x59, x47); var x171: u64 = undefined; cmovznzU64(&x171, x66, x61, x49); var x172: u64 = undefined; cmovznzU64(&x172, x66, x63, x51); var x173: u64 = undefined; cmovznzU64(&x173, x157, x144, x132); var x174: u64 = undefined; cmovznzU64(&x174, x157, x146, x134); var x175: u64 = undefined; cmovznzU64(&x175, x157, x148, x136); var x176: u64 = undefined; cmovznzU64(&x176, x157, x150, x138); var x177: u64 = undefined; cmovznzU64(&x177, x157, x152, x140); var x178: u64 = undefined; cmovznzU64(&x178, x157, x154, x142); out1.* = x158; out2[0] = x7; out2[1] = x8; out2[2] = x9; out2[3] = x10; out2[4] = x11; out2[5] = x12; out2[6] = x13; out3[0] = x160; out3[1] = x161; out3[2] = x162; out3[3] = x163; out3[4] = x164; out3[5] = x165; out3[6] = x166; out4[0] = x167; out4[1] = x168; out4[2] = x169; out4[3] = x170; out4[4] = x171; out4[5] = x172; out5[0] = x173; out5[1] = x174; out5[2] = x175; out5[3] = x176; out5[4] = x177; out5[5] = x178; } /// The function divstepPrecomp returns the precomputed value for Bernstein-Yang-inversion (in montgomery form). /// /// Postconditions: /// eval (from_montgomery out1) = ⌊(m - 1) / 2⌋^(if ⌊log2 m⌋ + 1 < 46 then ⌊(49 * (⌊log2 m⌋ + 1) + 80) / 17⌋ else ⌊(49 * (⌊log2 m⌋ + 1) + 57) / 17⌋) /// 0 ≤ eval out1 < m /// /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstepPrecomp(out1: *[6]u64) void { @setRuntimeSafety(mode == .Debug); out1[0] = 0xfff69400fff18fff; out1[1] = 0x2b7feffffd3ff; out1[2] = 0xfffedbfffffe97ff; out1[3] = 0x2840000002fff; out1[4] = 0x6040000050400; out1[5] = 0xfffc480000038000; }
fiat-zig/src/p384_64.zig
const windows = std.os.windows; const builtin = @import("builtin"); const native_os = builtin.os.tag; const c = @cImport({ if (native_os == .windows) { @cInclude("SDL.h"); } else { @cInclude("SDL2/SDL.h"); } }); const std = @import("std"); const math = @import("std").math; const rand = @import("std").rand; const WINDOW_WIDTH: i32 = 1024; const WINDOW_HEIGHT: i32 = 768; const RndGen = rand.DefaultPrng; const Star = struct { x: f32, y: f32, delta: f32, m: f32, age: u8, r: u8, g: u8, b: u8, pub fn init3(x: f32, y: f32, delta: f32) Star { return Star{ .x = x, .y = y, .delta = delta, .m = y - delta * x, .r = 0xff, .g = 0xff, .b = 0xff, .age = 0xf0, }; } pub fn init2(x: f32, y: f32) Star { var delta: f32 = (@intToFloat(f32, WINDOW_HEIGHT / 2) - y) / (@intToFloat(f32, WINDOW_WIDTH / 2) - x); return Star{ .x = x, .y = y, .delta = delta, .m = y - x * delta, .r = 0xff, .g = 0xff, .b = 0xff, .age = 0xf0, }; } }; pub fn main() anyerror!void { var prnd = rand.DefaultPrng.init(42); const random = prnd.random(); std.log.info("A small sdl test.", .{}); if (c.SDL_Init(c.SDL_INIT_VIDEO) != 0) { c.SDL_Log("Unable to initialize SDL: %s", c.SDL_GetError()); return error.SDLInitializationFailed; } defer c.SDL_Quit(); const screen = c.SDL_CreateWindow("My Game Window", c.SDL_WINDOWPOS_UNDEFINED, c.SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, c.SDL_RENDERER_PRESENTVSYNC | c.SDL_RENDERER_ACCELERATED) orelse { c.SDL_Log("Unable to create window: %s", c.SDL_GetError()); return error.SDLInitializationFailed; }; defer c.SDL_DestroyWindow(screen); const renderer = c.SDL_CreateRenderer(screen, -1, 0) orelse { c.SDL_Log("Unable to create renderer: %s", c.SDL_GetError()); return error.SDLInitializationFailed; }; defer c.SDL_DestroyRenderer(renderer); _ = c.SDL_RenderClear(renderer); _ = c.SDL_RenderPresent(renderer); var quit = false; // var _pos_x: i32 = 0; // var _pos_y: i32 = WINDOW_HEIGHT / 2; //var star = Star.init2(@intToFloat(f32, WINDOW_WIDTH / 2) + 10.0, @intToFloat(f32, WINDOW_HEIGHT / 2) + 10.0); var stars: [500]Star = undefined; for (stars) |*st| { st.* = Star.init2(random.float(f32) * @intToFloat(f32, WINDOW_WIDTH), random.float(f32) * @intToFloat(f32, WINDOW_HEIGHT)); } //std.debug.print("-> {d}\n", .{star}); while (!quit) { _ = c.SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00); _ = c.SDL_RenderClear(renderer); var event: c.SDL_Event = undefined; while (c.SDL_PollEvent(&event) != 0) { switch (event.@"type") { c.SDL_QUIT => { quit = true; }, else => {}, } } for (stars) |*star| { _ = c.SDL_SetRenderDrawColor(renderer, star.r - star.age, star.g - star.age, star.b - star.age, 0x00); if (star.age > 0x2) { star.age -= 0x2; } if (star.x < WINDOW_WIDTH / 2) { star.x -= math.clamp(1 / math.fabs(star.delta), 0.1, 1); //1.0; } else { star.x += math.clamp(1 / math.fabs(star.delta), 0.1, 1); //1.0; } star.y = star.x * star.delta + star.m; _ = c.SDL_RenderDrawPoint(renderer, @floatToInt(i32, star.x), @floatToInt(i32, star.y)); if (star.x < 0 or star.x > WINDOW_WIDTH) { star.* = Star.init2(random.float(f32) * @intToFloat(f32, WINDOW_WIDTH), random.float(f32) * @intToFloat(f32, WINDOW_HEIGHT)); } else if (star.y < 0 or star.y > WINDOW_HEIGHT) { star.* = Star.init2(random.float(f32) * @intToFloat(f32, WINDOW_WIDTH), random.float(f32) * @intToFloat(f32, WINDOW_HEIGHT)); } } //_ = c.SDL_RenderCopy(renderer, zig_texture, null, null); c.SDL_RenderPresent(renderer); c.SDL_Delay(17); } }
src/main.zig
const std = @import("std"); const mem = std.mem; const print = std.debug.print; const render_utils = @import("render_utils.zig"); pub fn highlightZigCode(raw_src: [:0]const u8, allocator: *std.mem.Allocator, out: anytype) !void { // TODO: who should be doing this cleanup? // We are doing this to preserve the null termination of the string. // It Tokenizer ever stops needing that, we can get rid of this copy! const src = try allocator.dupeZ(u8, mem.trim(u8, raw_src, " \n")); defer allocator.free(src); try out.writeAll("<pre><code class=\"zig\">"); var tokenizer = std.zig.Tokenizer.init(src); var index: usize = 0; var next_tok_is_fn = false; while (true) { const prev_tok_was_fn = next_tok_is_fn; next_tok_is_fn = false; const token = tokenizer.next(); try render_utils.writeEscaped(out, src[index..token.loc.start]); switch (token.tag) { .eof => break, .keyword_addrspace, .keyword_align, .keyword_and, .keyword_asm, .keyword_async, .keyword_await, .keyword_break, .keyword_catch, .keyword_comptime, .keyword_const, .keyword_continue, .keyword_defer, .keyword_else, .keyword_enum, .keyword_errdefer, .keyword_error, .keyword_export, .keyword_extern, .keyword_for, .keyword_if, .keyword_inline, .keyword_noalias, .keyword_noinline, .keyword_nosuspend, .keyword_opaque, .keyword_or, .keyword_orelse, .keyword_packed, .keyword_anyframe, .keyword_pub, .keyword_resume, .keyword_return, .keyword_linksection, .keyword_callconv, .keyword_struct, .keyword_suspend, .keyword_switch, .keyword_test, .keyword_threadlocal, .keyword_try, .keyword_union, .keyword_unreachable, .keyword_usingnamespace, .keyword_var, .keyword_volatile, .keyword_allowzero, .keyword_while, .keyword_anytype, => { try out.writeAll("<span class=\"tok tok-kw\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); }, .keyword_fn => { try out.writeAll("<span class=\"tok tok-kw\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); next_tok_is_fn = true; }, .string_literal, .multiline_string_literal_line, .char_literal, => { try out.writeAll("<span class=\"tok tok-str\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); }, .builtin => { try out.writeAll("<span class=\"tok tok-builtin\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); }, .doc_comment, .container_doc_comment, => { try out.writeAll("<span class=\"tok tok-comment\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); }, .identifier => { if (prev_tok_was_fn) { try out.writeAll("<span class=\"tok tok-fn\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); } else { const is_int = blk: { if (src[token.loc.start] != 'i' and src[token.loc.start] != 'u') break :blk false; var i = token.loc.start + 1; if (i == token.loc.end) break :blk false; while (i != token.loc.end) : (i += 1) { if (src[i] < '0' or src[i] > '9') break :blk false; } break :blk true; }; if (is_int or isType(src[token.loc.start..token.loc.end])) { try out.writeAll("<span class=\"tok tok-type\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); } else { try out.writeAll("<span class=\"tok\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); } } }, .integer_literal, .float_literal, => { try out.writeAll("<span class=\"tok tok-number\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); }, .bang, .pipe, .pipe_pipe, .pipe_equal, .equal, .equal_equal, .equal_angle_bracket_right, .bang_equal, .l_paren, .r_paren, .semicolon, .percent, .percent_equal, .l_brace, .r_brace, .l_bracket, .r_bracket, .period, .period_asterisk, .ellipsis2, .ellipsis3, .caret, .caret_equal, .plus, .plus_plus, .plus_equal, .plus_percent, .plus_percent_equal, .minus, .minus_equal, .minus_percent, .minus_percent_equal, .asterisk, .asterisk_equal, .asterisk_asterisk, .asterisk_percent, .asterisk_percent_equal, .arrow, .colon, .slash, .slash_equal, .comma, .ampersand, .ampersand_equal, .question_mark, .angle_bracket_left, .angle_bracket_left_equal, .angle_bracket_angle_bracket_left, .angle_bracket_angle_bracket_left_equal, .angle_bracket_right, .angle_bracket_right_equal, .angle_bracket_angle_bracket_right, .angle_bracket_angle_bracket_right_equal, .tilde, .plus_pipe, .plus_pipe_equal, .minus_pipe, .minus_pipe_equal, .asterisk_pipe, .asterisk_pipe_equal, .angle_bracket_angle_bracket_left_pipe, .angle_bracket_angle_bracket_left_pipe_equal, => { try out.writeAll("<span class=\"tok tok-symbol\">"); try render_utils.writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll("</span>"); }, .invalid, .invalid_periodasterisks => return parseError( src, token, "syntax error", .{}, ), } index = token.loc.end; } try out.writeAll("</code></pre>"); } // TODO: this function returns anyerror, interesting fn parseError(src: []const u8, token: std.zig.Token, comptime fmt: []const u8, args: anytype) anyerror { const loc = getTokenLocation(src, token); // const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 }; // print("{s}:{d}:{d}: error: " ++ fmt ++ "\n", args_prefix ++ args); const args_prefix = .{ loc.line + 1, loc.column + 1 }; print("{d}:{d}: error: " ++ fmt ++ "\n", args_prefix ++ args); if (loc.line_start <= loc.line_end) { print("{s}\n", .{src[loc.line_start..loc.line_end]}); { var i: usize = 0; while (i < loc.column) : (i += 1) { print(" ", .{}); } } { const caret_count = token.loc.end - token.loc.start; var i: usize = 0; while (i < caret_count) : (i += 1) { print("~", .{}); } } print("\n", .{}); } return error.ParseError; } const builtin_types = [_][]const u8{ "f16", "f32", "f64", "f128", "c_longdouble", "c_short", "c_ushort", "c_int", "c_uint", "c_long", "c_ulong", "c_longlong", "c_ulonglong", "c_char", "c_void", "void", "bool", "isize", "usize", "noreturn", "type", "anyerror", "comptime_int", "comptime_float", }; fn isType(name: []const u8) bool { for (builtin_types) |t| { if (mem.eql(u8, t, name)) return true; } return false; } const Location = struct { line: usize, column: usize, line_start: usize, line_end: usize, }; fn getTokenLocation(src: []const u8, token: std.zig.Token) Location { var loc = Location{ .line = 0, .column = 0, .line_start = 0, .line_end = 0, }; for (src) |c, i| { if (i == token.loc.start) { loc.line_end = i; while (loc.line_end < src.len and src[loc.line_end] != '\n') : (loc.line_end += 1) {} return loc; } if (c == '\n') { loc.line += 1; loc.column = 0; loc.line_start = i + 1; } else { loc.column += 1; } } return loc; }
src/doctest/syntax.zig
const std = @import("std"); const helper = @import("helper.zig"); const Allocator = std.mem.Allocator; const Grid = helper.Grid; const input = @embedFile("../inputs/day25.txt"); pub fn run(alloc: Allocator, stdout_: anytype) !void { var grid = try parseInitial(alloc, input); var buffer = try Grid(Tile).init(alloc, grid.m, grid.n); defer grid.deinit(); defer buffer.deinit(); const res1 = advanceUntilStopped(&grid, &buffer); if (stdout_) |stdout| { try stdout.print("Part 1: {}\n", .{res1}); } } const Tile = enum { empty, south, east }; fn print(grid: Grid(Tile)) void { for (grid.data) |tile, i| { if (i > 0 and i % grid.n == 0) std.debug.print("\n", .{}); const ch: u8 = switch (tile) { .empty => '.', .east => '>', .south => 'v', }; std.debug.print("{c}", .{ch}); } std.debug.print("\n\n", .{}); } fn parseInitial(alloc: Allocator, inp: []const u8) !Grid(Tile) { const m = count(u8, inp, "\n"); var lines = helper.getlines(inp); const n = lines.next().?.len; var grid = try Grid(Tile).init(alloc, m, n); var i: usize = 0; for (inp) |ch| { const tile: Tile = switch (ch) { '.' => .empty, '>' => .east, 'v' => .south, else => continue, }; grid.data[i] = tile; i += 1; } return grid; } fn advanceUntilStopped(grid: *Grid(Tile), buffer: *Grid(Tile)) i32 { var i: i32 = 1; while (advance(grid, buffer)) i += 1; return i; } fn advance(grid: *Grid(Tile), buffer: *Grid(Tile)) bool { const east = advanceEast(grid, buffer); const south = advanceSouth(grid, buffer); return east or south; // to stop short-circuiting } fn advanceEast(grid: *Grid(Tile), buffer: *Grid(Tile)) bool { std.mem.set(Tile, buffer.data, .empty); var modified: bool = false; var i: usize = 0; while (i < grid.m) : (i += 1) { var j: usize = 0; while (j < grid.n) : (j += 1) { switch (grid.get(i, j)) { .east => { if (grid.get(i, (j + 1) % grid.n) == .empty) { buffer.set(i, (j + 1) % grid.n, .east); modified = true; } else { buffer.set(i, j, .east); } }, .south => buffer.set(i, j, .south), .empty => {}, } } } std.mem.swap(Grid(Tile), grid, buffer); return modified; } fn advanceSouth(grid: *Grid(Tile), buffer: *Grid(Tile)) bool { std.mem.set(Tile, buffer.data, .empty); var modified: bool = false; var i: usize = 0; while (i < grid.m) : (i += 1) { var j: usize = 0; while (j < grid.n) : (j += 1) { switch (grid.get(i, j)) { .south => { if (grid.get((i + 1) % grid.m, j) == .empty) { buffer.set((i + 1) % grid.m, j, .south); modified = true; } else { buffer.set(i, j, .south); } }, .east => buffer.set(i, j, .east), .empty => {}, } } } std.mem.swap(Grid(Tile), grid, buffer); return modified; } const eql = std.mem.eql; const tokenize = std.mem.tokenize; const split = std.mem.split; const count = std.mem.count; const parseUnsigned = std.fmt.parseUnsigned; const parseInt = std.fmt.parseInt; const sort = std.sort.sort;
src/day25.zig
const std = @import("std"); const georgios = @import("georgios"); const utils = @import("utils"); const kernel = @import("root").kernel; const kthreading = kernel.threading; const Thread = kthreading.Thread; const Process = kthreading.Process; const kmemory = kernel.memory; const Range = kmemory.Range; const print = kernel.print; const platform = @import("platform.zig"); const pmemory = @import("memory.zig"); const interrupts = @import("interrupts.zig"); const InterruptStack = interrupts.InterruptStack; const segments = @import("segments.zig"); pub const Error = georgios.threading.Error; const pmem = &kernel.memory_mgr.impl; fn v86(ss: u32, esp: u32, cs: u32, eip: u32) noreturn { asm volatile ("push %[ss]" :: [ss] "{ax}" (ss)); asm volatile ("push %[esp]" :: [esp] "{ax}" (esp)); asm volatile ( \\pushf \\orl $0x20000, (%%esp) ); asm volatile ("push %[cs]" :: [cs] "{ax}" (cs)); asm volatile ("push %[eip]" :: [eip] "{ax}" (eip)); asm volatile ("iret"); unreachable; // asm volatile ( // \\push // :: // [old_context_ptr] "{ax}" (@ptrToInt(&last.impl.context)), // [new_context] "{bx}" (self.context)); // ); } fn usermode(ip: u32, sp: u32, v8086: bool) noreturn { asm volatile ( \\// Load User Data Selector into Data Segment Registers \\movw %[user_data_selector], %%ds \\movw %[user_data_selector], %%es \\movw %[user_data_selector], %%fs \\movw %[user_data_selector], %%gs \\ \\// Push arguments for iret \\pushl %[user_data_selector] // ss \\pushl %[sp] // sp \\// Push Flags with Interrupts Enabled \\pushf \\movl (%%esp), %%edx \\orl $0x0200, %%edx \\cmpl $0, %[v8086] \\jz no_v8086 \\orl $0x20000, %%edx \\no_v8086: \\movl %%edx, (%%esp) \\pushl %[user_code_selector] \\pushl %[ip] // ip \\ \\.global usermode_iret // Breakpoint for Debugging \\usermode_iret: \\iret // jump to ip as ring 3 : : [user_code_selector] "{cx}" (@as(u32, segments.user_code_selector)), [user_data_selector] "{dx}" (@as(u32, segments.user_data_selector)), [sp] "{bx}" (sp), [ip] "{ax}" (ip), [v8086] "{si}" (@as(u32, @boolToInt(v8086))), ); unreachable; } pub const ThreadImpl = struct { thread: *Thread, context: usize, context_is_setup: bool, usermode_stack: Range, usermode_stack_ptr: usize, kernelmode_stack: Range, v8086: bool, pub fn init(self: *ThreadImpl, thread: *Thread, boot_thread: bool) Error!void { self.thread = thread; self.context_is_setup = boot_thread; if (!boot_thread) { const stack_size = utils.Ki(8); const guard_size = utils.Ki(4); self.kernelmode_stack = try kernel.memory_mgr.big_alloc.alloc_range(guard_size + stack_size); try kernel.memory_mgr.impl.make_guard_page(null, self.kernelmode_stack.start, true); self.kernelmode_stack.start += guard_size; self.kernelmode_stack.size -= guard_size; // print.format("3/4 point on stack: .{:a}\n", // .{self.kernelmode_stack.start + stack_size / 4}); } self.v8086 = if (thread.process) |process| process.impl.v8086 else false; } fn push_to_context(self: *ThreadImpl, value: anytype) void { const Type = @TypeOf(value); const size = @sizeOf(Type); self.context -= size; _ = utils.memory_copy_truncate( @intToPtr([*]u8, self.context)[0..size], std.mem.asBytes(&value)); } fn pop_from_context(self: *ThreadImpl, comptime Type: type) Type { const size = @sizeOf(Type); var value: Type = undefined; _ = utils.memory_copy_truncate( std.mem.asBytes(&value), @intToPtr([*]const u8, self.context)[0..size]); self.context += size; return value; } /// Initial Kernel Mode Stack/Context in switch_to() for New Threads const SwitchToFrame = packed struct { // pusha edi: u32, esi: u32, ebp: u32, esp: u32, ebx: u32, edx: u32, ecx: u32, eax: u32, // pushf eflags: u32, // switch_to() Base Frame func_eax: u32, func_ebx: u32, func_ebp: u32, func_return: u32, // run() Frame run_return: u32, run_arg: u32, }; /// Setup Initial Kernel Mode Stack/Context in switch_to() for New Threads fn setup_context(self: *ThreadImpl) void { // Setup Usermode Stack if (!self.thread.kernel_mode) { if (self.thread.process) |process| { process.impl.setup(self); } } // Setup Initial Kernel Mode Stack/Context const sp = self.kernelmode_stack.end() - 1; self.context = sp; var frame = utils.zero_init(SwitchToFrame); frame.esp = sp; // TODO: Zig Bug? @ptrToInt(&run) results in weird address frame.func_return = @ptrToInt(run); frame.func_ebp = sp; frame.run_arg = @ptrToInt(self); self.push_to_context(frame); } pub fn before_switch(self: *ThreadImpl) void { if (!self.context_is_setup) { self.setup_context(); self.context_is_setup = true; } if (self.thread.process) |process| { process.impl.switch_to() catch @panic("before_switch: ProcessImpl.switch_to"); } if (!self.thread.kernel_mode) { platform.segments.set_interrupt_handler_stack(self.kernelmode_stack.end() - 1); } kernel.threading_mgr.current_process = self.thread.process; kernel.threading_mgr.current_thread = self.thread; } pub fn switch_to(self: *ThreadImpl) callconv(.C) void { // WARNING: A FRAME FOR THIS FUNCTION NEEDS TO BE SETUP IN setup_context! const last = kernel.threading_mgr.current_thread.?; self.before_switch(); asm volatile ( \\pushf \\pusha \\movl %%esp, (%[old_context_ptr]) \\movl %[new_context], %%esp \\popa \\popf : : [old_context_ptr] "{ax}" (@ptrToInt(&last.impl.context)), [new_context] "{bx}" (self.context)); after_switch(); } pub fn after_switch() void { if (interrupts.in_tick) { if (kthreading.debug) print.char('#'); interrupts.pic.end_of_interrupt(0, false); interrupts.in_tick = false; platform.enable_interrupts(); } } pub fn run_impl(self: *ThreadImpl) void { self.before_switch(); if (self.thread.kernel_mode) { platform.enable_interrupts(); asm volatile ("call *%[entry]" : : [entry] "{ax}" (self.thread.entry)); kernel.threading_mgr.remove_current_thread(); } else { usermode(self.thread.entry, self.usermode_stack_ptr, self.v8086); } } // WARNING: THIS FUNCTION'S ARGUMENTS NEED TO BE SETUP IN setup_context! pub fn run(self: *ThreadImpl) callconv(.C) void { if (kthreading.debug) print.format("Thread {} has Started\n", .{self.thread.id}); self.run_impl(); } }; pub const ProcessImpl = struct { const main_bios_memory = Range{.start = 0x00080000, .size = 0x00080000}; process: *Process = undefined, page_directory: []u32 = undefined, v8086: bool = false, pub fn init(self: *ProcessImpl, process: *Process) Error!void { self.process = process; self.page_directory = try pmem.new_page_directory(); } // TODO: Cleanup fn copy_string_to_user_stack(self: *ProcessImpl, thread: *ThreadImpl, s: []const u8) []const u8 { thread.usermode_stack_ptr -= s.len; const usermode_slice = @intToPtr([*]const u8, thread.usermode_stack_ptr)[0..s.len]; pmem.page_directory_memory_copy( self.page_directory, thread.usermode_stack_ptr, s) catch unreachable; return usermode_slice; } pub fn setup(self: *ProcessImpl, thread: *ThreadImpl) void { const main_thread = &self.process.main_thread == thread.thread; if (!main_thread) { // TODO: This code won't work if we want to call multiple threads per process. // We need to allocate a different stack for each thread. @panic("TODO: Support multiple threads per process"); } const stack_bottom: usize = if (self.v8086) main_bios_memory.start else platform.kernel_to_virtual(0); thread.usermode_stack = .{ .start = stack_bottom - platform.frame_size, .size = platform.frame_size}; pmem.mark_virtual_memory_present( self.page_directory, thread.usermode_stack, true) catch @panic("setup_context: mark_virtual_memory_present"); thread.usermode_stack_ptr = thread.usermode_stack.end(); if (self.v8086) { // Map Real-Mode Interrupt Vector Table (IVT) and BIOS Data Area (BDA) pmem.map(.{.start = 0, .size = platform.frame_size}, 0, true) catch @panic("ProcessImpl.setup: v8086 map IVT and BDA"); // Map the Main BIOS Region of Memory pmem.map(main_bios_memory, main_bios_memory.start, true) catch @panic("ProcessImpl.setup: v8086 map main bios memory"); } else if (main_thread) { thread.usermode_stack_ptr -= @sizeOf(u32); const stack_end: u32 = 0xc000dead; pmem.page_directory_memory_copy( self.page_directory, thread.usermode_stack_ptr, utils.to_const_bytes(&stack_end)) catch unreachable; var info = self.process.info.?; // ProcessInfo path and name info.path = self.copy_string_to_user_stack(thread, info.path); info.name = self.copy_string_to_user_stack(thread, info.name); // ProcessInfo.args thread.usermode_stack_ptr = utils.align_down(thread.usermode_stack_ptr - @sizeOf([]const u8) * info.args.len, @sizeOf([]const u8)); const args_array = thread.usermode_stack_ptr; var arg_slice_ptr = args_array; for (info.args) |arg| { const arg_slice = self.copy_string_to_user_stack(thread, arg); pmem.page_directory_memory_copy( self.page_directory, arg_slice_ptr, utils.to_const_bytes(&arg_slice)) catch unreachable; arg_slice_ptr += @sizeOf([]const u8); } info.args = @intToPtr([*]const []const u8, args_array)[0..info.args.len]; // ProcessInfo thread.usermode_stack_ptr -= utils.align_up( @sizeOf(georgios.ProcessInfo), @alignOf(georgios.ProcessInfo)); pmem.page_directory_memory_copy( self.page_directory, thread.usermode_stack_ptr, utils.to_const_bytes(&info)) catch unreachable; } } pub fn switch_to(self: *ProcessImpl) Error!void { var current_page_directory: ?[]u32 = null; if (kernel.threading_mgr.current_process) |current| { if (current == self.process) { return; } else { current_page_directory = current.impl.page_directory; } } try pmemory.load_page_directory(self.page_directory, current_page_directory); // TODO: Try to undo the effects if there is an error. } pub fn start(self: *ProcessImpl) Error!void { self.process.main_thread.impl.switch_to(); } pub fn address_space_copy(self: *ProcessImpl, address: usize, data: []const u8) kmemory.AllocError!void { try pmem.page_directory_memory_copy( self.page_directory, address, data); } pub fn address_space_set(self: *ProcessImpl, address: usize, byte: u8, len: usize) kmemory.AllocError!void { try pmem.page_directory_memory_set( self.page_directory, address, byte, len); } }; pub fn new_v8086_process() !*Process { const p = try kernel.threading_mgr.new_process_i(); p.info = null; p.impl.v8086 = true; p.entry = platform.frame_size; try p.init(null); return p; } // const process = try platform.impl.threading.new_v8086_process(); // try process.address_space_copy(process.entry, // @intToPtr([*]const u8, @ptrToInt(exc))[0..@ptrToInt(&exc_end) - @ptrToInt(exc)]); // try threading_mgr.start_process(process); // threading_mgr.wait_for_process(process.id);
kernel/platform/threading.zig
const semver = @import("pkg/semver"); const unicode = @import("unicode"); const utf8 = unicode.utf8; pub const Version = struct { path: []const u8, version: ?[]const u8, pub fn check(path: []const u8, version: ?[]const u8) !void { try checkPath(path); if (version) |ver| { if (!semver.isValid(ver)) { return error.MailFormedSemanticVersion; } } } pub fn checkPath(path: []const u8) !void { try validatePath(path, true); var i: usize = 0; if (mem.indexOfScalar(u8, path, '/')) |idx| { i = idx; } else { i = path.len; } if (i == 0) { return error.MailFormedModulePath; } if (mem.indexOfScalar(u8, path[0..i], '.')) { return error.MailFormedModulePath; } if (path[0] == '-') { return error.MailFormedModulePath; } var it = &utf8.Interator.init(path[0..i]); while (try it.next()) |rune| { if (!firstPathOK(rune.value)) { return error.MailFormedModulePath; } } } fn validatePath(path: []const u8, filaname: bool) !void { if (!utf8.valid(path)) { return error.INvalidUTF8; } if (path.len == 0) { return error.EmptyPath; } if (path[0] == '-') { return error.LeadingDash; } if (mem.indexOf(u8, path, "..")) |_| { return error.DoubleDot; } if (mem.indexOf(u8, path, "//")) |_| { return error.DoubleSlash; } if (path[path.len - 1] == '/') { return error.TrailingSlash; } var i: usize = 0; var element_start: usize = 0; var it = &utf8.Interator.init(path); while (try it.next()) |rune| { if (rune.value == '/') { try checkElem(path[element_start..i], filaname); element_start = i + 1; } i += rune.size; } return checkElem(path[element_start..], filaname); } fn checkElem(elem: []const u8, filaname: bool) !void {} fn firstPathOk(r: i32) bool { return r == '-' or r == '.' or '0' <= r and r <= '9' or 'a' <= r and r <= 'z'; } fn pathOk(r: i32) bool { if (r < utf8.rune_self) { return r == '+' or r == '-' or r == '.' or r == '_' or r == '~' or '0' <= r and r <= '9' or 'A' <= r and r <= 'Z' or 'a' <= r and r <= 'z'; } return false; } fn fileNameOK(r: i32) bool { if (r < utf8.rune_self) { const allowed = "!#$%&()+,-.=@[]^_{}~ "; if ('0' <= r and r <= '9' or 'A' <= r and r <= 'Z' or 'a' <= r and r <= 'z') { return true; } var i: usize = 0; while (i < allowed.len) : (i += 1) { if (@intCast(i32, allowed[i]) == r) { return true; } } return false; } return unicode.isLetter(r); } };
src/pkg/module.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const Reader = std.fs.File.Reader; const ArrayList = std.ArrayList; const builtin = @import("builtin"); const mat = @import("zalgebra"); const mat4 = mat.mat4; const vec = mat.vec3; const ParseError = error{ FormatInvalid, FormatNotSupported, } || Reader.Error || Allocator.Error; fn errors(comptime f: anytype) type { return @typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?).ErrorUnion.error_set; } pub const Vertex = struct { Position: vec, Normal: vec, }; var format: Format = undefined; const Format = enum { Ascii, BinaryLittleEndian, BinaryBigEndian, }; const Element = struct { name: []const u8, count: usize, properties: ArrayList(Property), fn parseDefinition(allocator: *Allocator, reader: *Reader) !@This() { var name = try readWord(allocator, reader); errdefer allocator.free(name); var count_str = try readWord(allocator, reader); defer allocator.free(count_str); var count = std.fmt.parseUnsigned(usize, count_str, 10) catch |err| return error.FormatInvalid; var properties = ArrayList(Property).init(allocator); return @This(){ .name = name, .count = count, .properties = properties, }; } fn deinit(allocator: *Allocator) void { allocator.free(name); properties.deinit(); } const Value = struct { properties: []Property.Value, fn deinit(self: @This(), allocator: *Allocator) void { for (self.properties) |prop| { prop.deinit(allocator); } allocator.free(self.properties); } }; fn read(self: @This(), allocator: *Allocator, reader: *Reader) !Value { var res = try allocator.alloc(Property.Value, self.properties.items.len); errdefer allocator.free(res); for (self.properties.items) |p, i| { res[i] = try p.read(allocator, reader); } return @This().Value{ .properties = res }; } fn ignore(self: @This(), reader: *Reader) !void { for (self.properties.items) |p, i| { try p.ignore(reader); } } }; const Property = union(enum) { const Self = @This(); const Type = enum { Char, Uchar, Short, Ushort, Int, Uint, Float, Double, fn parse(name: []const u8) ?@This() { if (eql(name, "char")) { return .Char; } else if (eql(name, "uchar")) { return .Uchar; } else if (eql(name, "short")) { return .Short; } else if (eql(name, "ushort")) { return .Ushort; } else if (eql(name, "int")) { return .Int; } else if (eql(name, "uint")) { return .Uint; } else if (eql(name, "float")) { return .Float; } else if (eql(name, "double")) { return .Double; } else { return null; } } fn read(self: @This(), reader: *Reader) !Value { return switch (self) { .Char => .{ .Char = try readVal(reader, i8) }, .Uchar => .{ .Uchar = try readVal(reader, u8) }, .Short => .{ .Short = try readVal(reader, i16) }, .Ushort => .{ .Ushort = try readVal(reader, u16) }, .Int => .{ .Int = try readVal(reader, i32) }, .Uint => .{ .Uint = try readVal(reader, u32) }, .Float => .{ .Float = try readVal(reader, f32) }, .Double => .{ .Double = try readVal(reader, f64) }, }; } fn size(self: @This()) usize { return switch (self) { .Char, .Uchar => 1, .Short, .Ushort => 2, .Int, .Uint, .Float => 4, .Double => 8, }; } }; const List = struct { const CountType = enum { Uchar, Ushort, Uint, }; count: CountType, content: Type, fn parseDefinition(allocator: *Allocator, reader: *Reader) !@This() { var self: @This() = undefined; var count = try readWord(allocator, reader); defer allocator.free(count); if (eql(count, "uchar")) { self.count = .Uchar; } else if (eql(count, "ushort")) { self.count = .Ushort; } else if (eql(count, "uint")) { self.count = .Uint; } else { return error.FormatInvalid; } var content = try readWord(allocator, reader); defer allocator.free(content); self.content = Type.parse(content) orelse return error.FormatInvalid; var name = try readWord(allocator, reader); defer allocator.free(name); return self; } fn read(self: @This(), allocator: *Allocator, reader: *Reader) !Value { var count: usize = switch (self.count) { .Uchar => @intCast(usize, try readVal(reader, u8)), .Ushort => @intCast(usize, try readVal(reader, u16)), .Uint => @intCast(usize, try readVal(reader, u32)), }; var val: Value = undefined; switch (self.content) { .Char => val.CharList = try readList(allocator, reader, i8, count), .Uchar => val.UcharList = try readList(allocator, reader, u8, count), .Short => val.ShortList = try readList(allocator, reader, i16, count), .Ushort => val.UshortList = try readList(allocator, reader, u16, count), .Int => val.IntList = try readList(allocator, reader, i32, count), .Uint => val.UintList = try readList(allocator, reader, u32, count), .Float => val.FloatList = try readList(allocator, reader, f32, count), .Double => val.DoubleList = try readList(allocator, reader, f64, count), } return val; } fn readList(allocator: *Allocator, reader: *Reader, comptime T: type, size: usize) ![]T { var content = try allocator.alloc(T, size); errdefer allocator.free(content); for (content) |*item| { item.* = try readVal(reader, T); } return content; } }; basic: Type, list: List, fn parseDefinition(allocator: *Allocator, reader: *Reader) !Self { var kind = try readWord(allocator, reader); var self: Self = undefined; if (Type.parse(kind)) |t| { var name = try readWord(allocator, reader); defer allocator.free(name); return Self{ .basic = t }; } else if (eql(kind, "list")) { return Self{ .list = try List.parseDefinition(allocator, reader) }; } else { return error.FormatInvalid; } } fn read(self: @This(), allocator: *Allocator, reader: *Reader) (errors(Type.read) || errors(List.read))!Value { //@typeInfo(@typeInfo(@TypeOf(Type.read)).Fn.return_type.?).ErrorUnion.error_set return switch (self) { .basic => |t| t.read(reader), .list => |l| l.read(allocator, reader), }; } fn ignore(self: @This(), reader: *Reader) !void { switch (self) { .list => |l| { const count: usize = switch (l.count) { .Uchar => @intCast(usize, try readVal(reader, u8)), .Ushort => @intCast(usize, try readVal(reader, u16)), .Uint => @intCast(usize, try readVal(reader, u32)), }; try reader.skipBytes(l.content.size() * count, Reader.SkipBytesOptions{}); }, .basic => |b| try reader.skipBytes(b.size(), Reader.SkipBytesOptions{}), } } const Value = union(enum) { Char: i8, Uchar: u8, Short: i16, Ushort: u16, Int: i32, Uint: u32, Float: f32, Double: f64, CharList: []i8, UcharList: []u8, ShortList: []i16, UshortList: []u16, IntList: []i32, UintList: []u32, FloatList: []f32, DoubleList: []f64, fn deinit(self: @This(), allocator: *Allocator) void { switch (self) { .CharList => |val| allocator.free(val), .UcharList => |val| allocator.free(val), .ShortList => |val| allocator.free(val), .UshortList => |val| allocator.free(val), .IntList => |val| allocator.free(val), .UintList => |val| allocator.free(val), .FloatList => |val| allocator.free(val), .DoubleList => |val| allocator.free(val), else => {}, } } }; }; fn readVal(read: *Reader, comptime T: type) ParseError!T { return switch (format) { .Ascii => readAscii(read, T), .BinaryBigEndian, .BinaryLittleEndian => switch (T) { u8, i8, u16, i16, u32, i32 => read.readInt(T, if (format == .BinaryLittleEndian) builtin.Endian.Little else builtin.Endian.Big) catch |err| switch (err) { error.EndOfStream => error.FormatInvalid, else => |e| e, }, f32 => @bitCast(f32, try readVal(read, u32)), f64 => @bitCast(f64, try readVal(read, u64)), else => @compileError("type not supported"), }, }; } fn readAscii(read: *Reader, comptime T: type) !T { var buf = [1]u8{0} ** 32; var count: usize = 0; while (true) { if (count >= buf.len) { return error.FormatInvalid; } const r = read.readByte() catch |err| switch (err) { error.EndOfStream => if (count > 0) { break; } else { return error.FormatInvalid; }, else => |e| return e, }; if (std.ascii.isSpace(r)) { if (count > 0) break; } else { buf[count] = r; count += 1; } } return switch (T) { u8, i8, u16, i16, u32, i32 => std.fmt.parseInt(T, buf[0..count], 10) catch |err| return error.FormatInvalid, f32, f64 => std.fmt.parseFloat(T, buf[0..count]) catch |err| { return error.FormatInvalid; }, else => @compileError("type not supported"), }; } fn eql(a: []const u8, b: []const u8) bool { return std.mem.eql(u8, a, b); } /// caller owns returned memory pub fn load(allocator: *Allocator, path: []const u8) ![]Vertex { var file = try std.fs.cwd().openFile(path, .{ .read = true, .write = false, .lock = .None }); defer file.close(); var reader = file.reader(); if (!expect(&reader, "ply\nformat ")) { return error.FormatInvalid; } var formatString = try readWord(allocator, &reader); defer allocator.free(formatString); format = if (eql(formatString, "ascii")) Format.Ascii else if (eql(formatString, "binary_little_endian")) Format.BinaryLittleEndian else if (eql(formatString, "binary_big_endian")) Format.BinaryBigEndian else return error.FormatNotSupported; if (!expect(&reader, "1.0\n")) { return error.FormatNotSupported; } var elements = try readHeader(allocator, &reader); defer allocator.free(elements); for (elements) |elem| { if (eql(elem.name, "vertex")) { if (elem.properties.items.len != 6) { return error.FormatNotSupported; } for (elem.properties.items) |p| { // TODO: property names switch (p) { .basic => |b| if (b != Property.Type.Float) return error.FormatNotSupported, else => return error.FormatNotSupported, } } const vertices = try allocator.alloc(Vertex, elem.count); errdefer allocator.free(vertices); var i: usize = 0; while (i < elem.count) : (i += 1) { // const e = try elem.read(allocator, &reader); // defer e.deinit(allocator); vertices[i] = Vertex{ .Position = .{ .x = try readVal(&reader, f32), .y = try readVal(&reader, f32), .z = try readVal(&reader, f32), }, .Normal = .{ .x = try readVal(&reader, f32), .y = try readVal(&reader, f32), .z = try readVal(&reader, f32), }, }; } return vertices; } else { var i: usize = 0; while (i < elem.count) : (i += 1) { try elem.ignore(&reader); } } } return error.FormatNotSupported; } fn expect(read: *Reader, expected: []const u8) bool { return read.isBytes(expected) catch |err| false; } /// caller owns returned memory fn readWord(allocator: *Allocator, read: *Reader) ![]u8 { var l = std.ArrayList(u8).init(allocator); defer l.deinit(); while (true) { const r = read.readByte() catch |err| switch (err) { error.EndOfStream => if (l.items.len > 0) { break; } else { return error.FormatInvalid; }, else => return err, }; if (std.ascii.isSpace(r)) { if (l.items.len > 0) break; } else { try l.append(r); } } return l.toOwnedSlice(); } /// caller owns returned memory fn readHeader(allocator: *Allocator, read: *Reader) ![]Element { var elems = std.ArrayList(Element).init(allocator); defer elems.deinit(); while (true) { var word = readWord(allocator, read) catch |err| switch (err) { error.EndOfStream => return error.FormatInvalid, else => |e| return e, }; defer allocator.free(word); if (eql(word, "end_header")) { return elems.toOwnedSlice(); } else if (eql(word, "comment")) { while (true) { var b = read.readByte() catch |err| switch (err) { error.EndOfStream => return error.FormatInvalid, else => |e| return e, }; if (b == '\n') { break; } } } else if (eql(word, "element")) { try elems.append(try Element.parseDefinition(allocator, read)); } else if (eql(word, "property")) { const last_properties = &elems.items[elems.items.len - 1].properties; try last_properties.append(try Property.parseDefinition(allocator, read)); } else { return error.FormatInvalid; } } }
src/load_ply.zig
const std = @import("std"); const fun = @import("fun"); const testing = std.testing; const heap = std.heap; const io = std.io; const math = std.math; const mem = std.mem; const os = std.os; const scan = fun.scan.scan; pub fn main() !void { const stdin = &(try io.getStdIn()).inStream().stream; const stdout = &(try io.getStdOut()).outStream().stream; var ps = io.PeekStream(1, os.File.InStream.Error).init(stdin); var direct_allocator = heap.DirectAllocator.init(); const allocator = &direct_allocator.allocator; defer direct_allocator.deinit(); const dependencies = try readDependencies(allocator, &ps); const build_order = try buildOrder(allocator, dependencies); try stdout.print("{}\n", build_order); try stdout.print("{}\n", try buildSpeed(allocator, 5, 61 - 'A', dependencies)); } fn readDependencies(allocator: *mem.Allocator, ps: var) ![]Dependency { var dependencies = std.ArrayList(Dependency).init(allocator); defer dependencies.deinit(); while (readDependency(ps)) |dp| { try dependencies.append(dp); } else |err| switch (err) { error.EndOfStream => {}, else => return err, } return dependencies.toOwnedSlice(); } fn readDependency(ps: var) !Dependency { _ = try scan(ps, "Step ", struct {}); const depends_on = try ps.stream.readByte(); _ = try scan(ps, " must be finished before step ", struct {}); const step = try ps.stream.readByte(); _ = try scan(ps, " can begin.\n", struct {}); return Dependency{ .step = step, .depends_on = depends_on, }; } const Dependency = struct { step: u8, depends_on: u8, }; fn buildOrder(allocator: *mem.Allocator, dependencies: []const Dependency) ![]u8 { var arena_state = heap.ArenaAllocator.init(allocator); const arena = &arena_state.allocator; defer arena_state.deinit(); var res = std.ArrayList(u8).init(allocator); defer res.deinit(); const Deps = std.AutoHashMap(u8, void); var dep_map = std.AutoHashMap(u8, Deps).init(allocator); for (dependencies) |dep| { const kv = try dep_map.getOrPutValue(dep.step, Deps.init(allocator)); _ = try dep_map.getOrPutValue(dep.depends_on, Deps.init(allocator)); _ = try kv.value.put(dep.depends_on, {}); } while (dep_map.count() != 0) { var iter = dep_map.iterator(); var build = loop: while (iter.next()) |kv| { if (kv.value.count() == 0) break :loop kv.key; } else { return error.CouldNotBuild; }; while (iter.next()) |kv| { if (kv.value.count() == 0 and kv.key < build) build = kv.key; } _ = dep_map.remove(build) orelse unreachable; try res.append(build); iter = dep_map.iterator(); while (iter.next()) |kv| { _ = kv.value.remove(build); } } return res.toOwnedSlice(); } test "buildSpeed" { var direct_allocator = heap.DirectAllocator.init(); const allocator = &direct_allocator.allocator; defer direct_allocator.deinit(); const speed = try buildSpeed(allocator, 2, 1 - 'A', []Dependency{ Dependency{ .step = 'A', .depends_on = 'C' }, Dependency{ .step = 'F', .depends_on = 'C' }, Dependency{ .step = 'B', .depends_on = 'A' }, Dependency{ .step = 'D', .depends_on = 'A' }, Dependency{ .step = 'E', .depends_on = 'B' }, Dependency{ .step = 'E', .depends_on = 'D' }, Dependency{ .step = 'E', .depends_on = 'F' }, }); testing.expectEqual(isize(15), speed); } fn buildSpeed(allocator: *mem.Allocator, workers: usize, duration: isize, dependencies: []const Dependency) !isize { var arena_state = heap.ArenaAllocator.init(allocator); const arena = &arena_state.allocator; defer arena_state.deinit(); const Work = struct { work: u8, done: isize, fn lessThan(a: @This(), b: @This()) bool { return a.done < b.done; } }; var work_stack = std.ArrayList(Work).init(arena); try work_stack.ensureCapacity(workers + 1); var next_work = std.ArrayList(u8).init(arena); try next_work.ensureCapacity(workers + 1); const Deps = std.AutoHashMap(u8, void); var dep_map = std.AutoHashMap(u8, Deps).init(allocator); for (dependencies) |dep| { const kv = try dep_map.getOrPutValue(dep.step, Deps.init(allocator)); _ = try dep_map.getOrPutValue(dep.depends_on, Deps.init(allocator)); _ = try kv.value.put(dep.depends_on, {}); } var res: isize = 0; while (dep_map.count() != 0 or work_stack.len != 0) { var iter = dep_map.iterator(); while (iter.next()) |kv| { if (kv.value.count() != 0) continue; next_work.append(kv.key) catch unreachable; if (next_work.len > (workers - work_stack.len)) { std.sort.sort(u8, next_work.toSlice(), lessThan(u8)); _ = next_work.pop(); } } for (next_work.toSlice()) |work| { _ = dep_map.remove(work) orelse unreachable; work_stack.append(Work{ .work = work, .done = res + duration + @intCast(isize, work), }) catch unreachable; } next_work.resize(0) catch unreachable; const time = min(Work, work_stack.toSlice(), Work.lessThan) orelse return error.CouldNotBuild; res += (time.done - res); var i: usize = 0; while (i < work_stack.len) { const work = &work_stack.toSlice()[i]; if (work.done == res) { iter = dep_map.iterator(); while (iter.next()) |kv| { _ = kv.value.remove(work.work); } work.* = work_stack.pop(); } else { i += 1; } } } return res; } fn min(comptime T: type, slice: []const T, lt: fn (T, T) bool) ?T { if (slice.len == 0) return null; var res = slice[0]; for (slice[0..]) |item| { if (lt(item, res)) res = item; } return res; } fn lessThan(comptime T: type) fn (T, T) bool { return struct { fn lessThan(a: T, b: T) bool { return a < b; } }.lessThan; }
src/day7.zig
const Inputs = @This(); const SDL = @import("sdl2"); const ButtonEntry = struct { keycode: SDL.Keycode, port: u1, bitmask: u8 }; const BUTTON_MAP = [_]ButtonEntry{ .{ .keycode = .up, .port = 0, .bitmask = UP }, .{ .keycode = .left, .port = 0, .bitmask = LEFT }, .{ .keycode = .right, .port = 0, .bitmask = RIGHT }, .{ .keycode = .down, .port = 0, .bitmask = DOWN }, .{ .keycode = .c, .port = 0, .bitmask = COIN_1 }, .{ .keycode = .w, .port = 1, .bitmask = UP }, .{ .keycode = .a, .port = 1, .bitmask = LEFT }, .{ .keycode = .d, .port = 1, .bitmask = RIGHT }, .{ .keycode = .s, .port = 1, .bitmask = DOWN }, .{ .keycode = .@"1", .port = 1, .bitmask = START_1 }, .{ .keycode = .@"2", .port = 1, .bitmask = START_2 }, }; fn getButtonMapping(keycode: SDL.Keycode) ?*const ButtonEntry { for (BUTTON_MAP) |*entry| { if (entry.keycode == keycode) return entry; } return null; } const UP: u8 = 1 << 0; const LEFT: u8 = 1 << 1; const RIGHT: u8 = 1 << 2; const DOWN: u8 = 1 << 3; const RACK_TEST: u8 = 1 << 4; const COIN_1: u8 = 1 << 5; const COIN_2: u8 = 1 << 6; const COIN_3: u8 = 1 << 7; const SERVICE: u8 = 1 << 4; const START_1: u8 = 1 << 5; const START_2: u8 = 1 << 6; const CABINET: u8 = 1 << 7; in0: u8 = 0xff, in1: u8 = 0xff, pause: bool = false, pub fn cocktailMode(self: *Inputs) void { self.in1 &= ~CABINET; } pub fn onKeyDown(self: *Inputs, keycode: SDL.Keycode) void { switch (keycode) { .f1 => self.in0 ^= RACK_TEST, .f2 => self.in1 ^= SERVICE, .p => self.pause = !self.pause, else => if (getButtonMapping(keycode)) |entry| { switch (entry.port) { 0 => self.in0 &= ~entry.bitmask, 1 => self.in1 &= ~entry.bitmask, } }, } } pub fn onKeyUp(self: *Inputs, keycode: SDL.Keycode) void { if (getButtonMapping(keycode)) |entry| { switch (entry.port) { 0 => self.in0 |= entry.bitmask, 1 => self.in1 |= entry.bitmask, } } }
src/Inputs.zig
const debug = @import("std").debug; const parse = @import("parse.zig"); const compile = @import("compile.zig"); const Expr = parse.Expr; const Instruction = compile.Instruction; const InstructionData = compile.InstructionData; const Program = compile.Program; pub fn printCharEscaped(ch: u8) void { switch (ch) { '\t' => { debug.print("\\t", .{}); }, '\r' => { debug.print("\\r", .{}); }, '\n' => { debug.print("\\n", .{}); }, // printable characters 32...126 => { debug.print("{c}", .{ch}); }, else => { debug.print("0x{x}", .{ch}); }, } } pub fn dumpExpr(e: Expr) void { dumpExprIndent(e, 0); } fn dumpExprIndent(e: Expr, indent: usize) void { var i: usize = 0; while (i < indent) : (i += 1) { debug.print(" ", .{}); } switch (e) { Expr.AnyCharNotNL => { debug.print("{s}\n", .{@tagName(e)}); }, Expr.EmptyMatch => |assertion| { debug.print("{s}({s})\n", .{ @tagName(e), @tagName(assertion) }); }, Expr.Literal => |lit| { debug.print("{s}(", .{@tagName(e)}); printCharEscaped(lit); debug.print(")\n", .{}); }, Expr.Capture => |subexpr| { debug.print("{s}\n", .{@tagName(e)}); dumpExprIndent(subexpr.*, indent + 1); }, Expr.Repeat => |repeat| { debug.print("{s}(min={d}, max={d}, greedy={d})\n", .{ @tagName(e), repeat.min, repeat.max, repeat.greedy }); dumpExprIndent(repeat.subexpr.*, indent + 1); }, Expr.ByteClass => |class| { debug.print("{s}(", .{@tagName(e)}); for (class.ranges.items) |r| { debug.print("[", .{}); printCharEscaped(r.min); debug.print("-", .{}); printCharEscaped(r.max); debug.print("]", .{}); } debug.print(")\n", .{}); }, // TODO: Can we get better type unification on enum variants with the same type? Expr.Concat => |subexprs| { debug.print("{s}\n", .{@tagName(e)}); for (subexprs.items) |s| dumpExprIndent(s.*, indent + 1); }, Expr.Alternate => |subexprs| { debug.print("{s}\n", .{@tagName(e)}); for (subexprs.items) |s| dumpExprIndent(s.*, indent + 1); }, // NOTE: Shouldn't occur ever in returned output. Expr.PseudoLeftParen => { debug.print("{s}\n", .{@tagName(e)}); }, } } pub fn dumpInstruction(s: Instruction) void { switch (s.data) { InstructionData.Char => |ch| { debug.print("char({}) '{c}'\n", .{ s.out, ch }); }, InstructionData.EmptyMatch => |assertion| { debug.print("empty({}) {s}\n", .{ s.out, @tagName(assertion) }); }, InstructionData.ByteClass => |class| { debug.print("range({}) ", .{s.out}); for (class.ranges.items) |r| debug.print("[{d}-{d}]", .{ r.min, r.max }); debug.print("\n", .{}); }, InstructionData.AnyCharNotNL => { debug.print("any({})\n", .{s.out}); }, InstructionData.Match => { debug.print("match\n", .{}); }, InstructionData.Jump => { debug.print("jump({})\n", .{s.out}); }, InstructionData.Split => |branch| { debug.print("split({}) {}\n", .{ s.out, branch }); }, InstructionData.Save => |slot| { debug.print("save({}), {}\n", .{ s.out, slot }); }, } } pub fn dumpProgram(s: Program) void { debug.print("start: {}\n\n", .{s.start}); for (s.insts) |inst, i| { debug.print("L{}: ", .{i}); dumpInstruction(inst); } }
src/debug.zig
const std = @import("std"); const subcommands = @import("../subcommands.zig"); const shared = @import("../shared.zig"); const zsw = @import("zsw"); const log = std.log.scoped(.yes); pub const name = "yes"; pub const usage = \\Usage: {0s} [STRING]... \\ or: {0s} OPTION \\ \\Repeatedly output a line with all specified STRING(s), or 'y'. \\ \\ -h, --help display this help and exit \\ --version output version information and exit \\ ; // io // .{ // .stderr: std.io.Writer, // .stdin: std.io.Reader, // .stdout: std.io.Writer, // }, // args // struct { // fn next(self: *Self) ?shared.Arg, // // // intended to only be called for the first argument // fn nextWithHelpOrVersion(self: *Self) !?shared.Arg, // // fn nextRaw(self: *Self) ?[]const u8, // } pub fn execute( allocator: std.mem.Allocator, io: anytype, args: anytype, system: zsw.System, exe_path: []const u8, ) subcommands.Error!u8 { const z = shared.tracy.traceNamed(@src(), name); defer z.end(); _ = exe_path; _ = system; const string = try getString(allocator, args); defer if (shared.free_on_close) string.deinit(allocator); while (true) { io.stdout.writeAll(string.value) catch |err| shared.unableToWriteTo("stdout", io, err); } return 0; } fn getString(allocator: std.mem.Allocator, args: anytype) !MaybeAllocatedString { const z = shared.tracy.traceNamed(@src(), name); defer z.end(); var buffer = std.ArrayList(u8).init(allocator); errdefer if (shared.free_on_close) buffer.deinit(); if (try args.nextWithHelpOrVersion()) |arg| { try buffer.appendSlice(arg.raw); } else return MaybeAllocatedString.not_allocated("y\n"); while (args.nextRaw()) |arg| { try buffer.append(' '); try buffer.appendSlice(arg); } try buffer.append('\n'); return MaybeAllocatedString.allocated(buffer.toOwnedSlice()); } const MaybeAllocatedString = MaybeAllocated([]const u8, freeSlice); fn freeSlice(self: []const u8, allocator: std.mem.Allocator) void { allocator.free(self); } fn MaybeAllocated(comptime T: type, comptime dealloc: fn (self: T, allocator: std.mem.Allocator) void) type { return struct { is_allocated: bool, value: T, pub fn allocated(value: T) @This() { return .{ .is_allocated = true, .value = value, }; } pub fn not_allocated(value: T) @This() { return .{ .is_allocated = false, .value = value, }; } pub fn deinit(self: @This(), allocator: std.mem.Allocator) void { if (self.is_allocated) { dealloc(self.value, allocator); } } comptime { std.testing.refAllDecls(@This()); } }; } test "yes help" { try subcommands.testHelp(@This()); } test "yes version" { try subcommands.testVersion(@This()); } comptime { std.testing.refAllDecls(@This()); }
src/subcommands/yes.zig
pub const DosQVariant = c_void; pub const DosQModelIndex = c_void; pub const DosQAbstractItemModel = c_void; pub const DosQAbstractListModel = c_void; pub const DosQAbstractTableModel = c_void; pub const DosQQmlApplicationEngine = c_void; pub const DosQQuickView = c_void; pub const DosQQmlContext = c_void; pub const DosQHashIntQByteArray = c_void; pub const DosQUrl = c_void; pub const DosQMetaObject = c_void; pub const DosQObject = c_void; pub const DosQQuickImageProvider = c_void; pub const DosPixmap = c_void; pub const DosQPointer = c_void; pub const RequestPixmapCallback = ?fn ([*c]const u8, [*c]c_int, [*c]c_int, c_int, c_int, ?*DosPixmap) callconv(.C) void; pub const DObjectCallback = ?fn (?*c_void, ?*DosQVariant, c_int, [*c]?*DosQVariant) callconv(.C) void; pub const RowCountCallback = ?fn (?*c_void, ?*const DosQModelIndex, [*c]c_int) callconv(.C) void; pub const ColumnCountCallback = ?fn (?*c_void, ?*const DosQModelIndex, [*c]c_int) callconv(.C) void; pub const DataCallback = ?fn (?*c_void, ?*const DosQModelIndex, c_int, ?*DosQVariant) callconv(.C) void; pub const SetDataCallback = ?fn (?*c_void, ?*const DosQModelIndex, ?*const DosQVariant, c_int, [*c]bool) callconv(.C) void; pub const RoleNamesCallback = ?fn (?*c_void, ?*DosQHashIntQByteArray) callconv(.C) void; pub const FlagsCallback = ?fn (?*c_void, ?*const DosQModelIndex, [*c]c_int) callconv(.C) void; pub const HeaderDataCallback = ?fn (?*c_void, c_int, c_int, c_int, ?*DosQVariant) callconv(.C) void; pub const IndexCallback = ?fn (?*c_void, c_int, c_int, ?*const DosQModelIndex, ?*DosQModelIndex) callconv(.C) void; pub const ParentCallback = ?fn (?*c_void, ?*const DosQModelIndex, ?*DosQModelIndex) callconv(.C) void; pub const HasChildrenCallback = ?fn (?*c_void, ?*const DosQModelIndex, [*c]bool) callconv(.C) void; pub const CanFetchMoreCallback = ?fn (?*c_void, ?*const DosQModelIndex, [*c]bool) callconv(.C) void; pub const FetchMoreCallback = ?fn (?*c_void, ?*const DosQModelIndex) callconv(.C) void; pub const CreateDObject = ?fn (c_int, ?*c_void, [*c]?*c_void, [*c]?*c_void) callconv(.C) void; pub const DeleteDObject = ?fn (c_int, ?*c_void) callconv(.C) void; pub const struct_DosQVariantArray = extern struct { size: c_int, data: [*c]?*DosQVariant, }; pub const DosQVariantArray = struct_DosQVariantArray; pub const struct_QmlRegisterType = extern struct { major: c_int, minor: c_int, uri: [*c]const u8, qml: [*c]const u8, staticMetaObject: ?*DosQMetaObject, createDObject: CreateDObject, deleteDObject: DeleteDObject, }; pub const QmlRegisterType = struct_QmlRegisterType; pub const struct_ParameterDefinition = extern struct { name: [*c]const u8, metaType: c_int, }; pub const ParameterDefinition = struct_ParameterDefinition; pub const struct_SignalDefinition = extern struct { name: [*c]const u8, parametersCount: c_int, parameters: [*c]ParameterDefinition, }; pub const SignalDefinition = struct_SignalDefinition; pub const struct_SignalDefinitions = extern struct { count: c_int, definitions: [*c]SignalDefinition, }; pub const SignalDefinitions = struct_SignalDefinitions; pub const struct_SlotDefinition = extern struct { name: [*c]const u8, returnMetaType: c_int, parametersCount: c_int, parameters: [*c]ParameterDefinition, }; pub const SlotDefinition = struct_SlotDefinition; pub const struct_SlotDefinitions = extern struct { count: c_int, definitions: [*c]SlotDefinition, }; pub const SlotDefinitions = struct_SlotDefinitions; pub const struct_PropertyDefinition = extern struct { name: [*c]const u8, propertyMetaType: c_int, readSlot: [*c]const u8, writeSlot: [*c]const u8, notifySignal: [*c]const u8, }; pub const PropertyDefinition = struct_PropertyDefinition; pub const struct_PropertyDefinitions = extern struct { count: c_int, definitions: [*c]PropertyDefinition, }; pub const PropertyDefinitions = struct_PropertyDefinitions; pub const struct_DosQAbstractItemModelCallbacks = extern struct { rowCount: RowCountCallback, columnCount: ColumnCountCallback, data: DataCallback, setData: SetDataCallback, roleNames: RoleNamesCallback, flags: FlagsCallback, headerData: HeaderDataCallback, index: IndexCallback, parent: ParentCallback, hasChildren: HasChildrenCallback, canFetchMore: CanFetchMoreCallback, fetchMore: FetchMoreCallback, }; pub const DosQAbstractItemModelCallbacks = struct_DosQAbstractItemModelCallbacks; pub const DosQEventLoopProcessEventFlagProcessAllEvents = @enumToInt(enum_DosQEventLoopProcessEventFlag.ProcessAllEvents); pub const DosQEventLoopProcessEventFlagExcludeUserInputEvents = @enumToInt(enum_DosQEventLoopProcessEventFlag.ExcludeUserInputEvents); pub const DosQEventLoopProcessEventFlagProcessExcludeSocketNotifiers = @enumToInt(enum_DosQEventLoopProcessEventFlag.ProcessExcludeSocketNotifiers); pub const DosQEventLoopProcessEventFlagProcessAllEventsWaitForMoreEvents = @enumToInt(enum_DosQEventLoopProcessEventFlag.ProcessAllEventsWaitForMoreEvents); pub const enum_DosQEventLoopProcessEventFlag = extern enum(c_int) { ProcessAllEvents = 0, ExcludeUserInputEvents = 1, ProcessExcludeSocketNotifiers = 2, ProcessAllEventsWaitForMoreEvents = 3, _, }; pub const DosQtConnectionTypeAutoConnection = @enumToInt(enum_DosQtConnectionType.AutoConnection); pub const DosQtConnectionTypeDirectConnection = @enumToInt(enum_DosQtConnectionType.DirectConnection); pub const DosQtConnectionTypeQueuedConnection = @enumToInt(enum_DosQtConnectionType.QueuedConnection); pub const DosQtConnectionTypeBlockingConnection = @enumToInt(enum_DosQtConnectionType.BlockingConnection); pub const DosQtCOnnectionTypeUniqueConnection = @enumToInt(enum_DosQtConnectionType.DosQtCOnnectionTypeUniqueConnection); pub const enum_DosQtConnectionType = extern enum(c_int) { AutoConnection = 0, DirectConnection = 1, QueuedConnection = 2, BlockingConnection = 3, DosQtCOnnectionTypeUniqueConnection = 128, _, };
src/DOtherSideTypes.zig
const std = @import("std"); const c = @import("c.zig"); const shaderc = @import("shaderc.zig"); // This struct runs a raytracing kernel which uses a compiled scene. // Compiling the scene shader is slower to generate initially, but runs faster. pub const Optimized = struct { const Self = @This(); device: c.WGPUDeviceId, bind_group: c.WGPUBindGroupId, bind_group_layout: c.WGPUBindGroupLayoutId, compute_pipeline: c.WGPURenderPipelineId, initialized: bool = false, pub fn init( alloc: *std.mem.Allocator, comp_shader: c.WGPUShaderModuleId, device: c.WGPUDeviceId, uniform_buf: c.WGPUBufferId, image_buf: c.WGPUTextureViewId, image_buf_size: u32, ) !Self { //////////////////////////////////////////////////////////////////////////// // Bind groups const bind_group_layout_entries = [_]c.WGPUBindGroupLayoutEntry{ (c.WGPUBindGroupLayoutEntry){ // Uniforms buffer .binding = 0, .visibility = c.WGPUShaderStage_COMPUTE, .ty = c.WGPUBindingType_UniformBuffer, .has_dynamic_offset = false, .min_buffer_binding_size = 0, .multisampled = undefined, .filtering = undefined, .view_dimension = undefined, .texture_component_type = undefined, .storage_texture_format = undefined, .count = undefined, }, (c.WGPUBindGroupLayoutEntry){ // Image buffer .binding = 1, .visibility = c.WGPUShaderStage_COMPUTE, .ty = c.WGPUBindingType_StorageBuffer, .has_dynamic_offset = false, .min_buffer_binding_size = 0, .multisampled = undefined, .filtering = undefined, .view_dimension = undefined, .texture_component_type = undefined, .storage_texture_format = undefined, .count = undefined, }, }; const bind_group_layout = c.wgpu_device_create_bind_group_layout( device, &(c.WGPUBindGroupLayoutDescriptor){ .label = "bind group layout", .entries = &bind_group_layout_entries, .entries_length = bind_group_layout_entries.len, }, ); //////////////////////////////////////////////////////////////////////// // Render pipelines const bind_group_layouts = [_]c.WGPUBindGroupId{bind_group_layout}; const pipeline_layout = c.wgpu_device_create_pipeline_layout( device, &(c.WGPUPipelineLayoutDescriptor){ .label = "", .bind_group_layouts = &bind_group_layouts, .bind_group_layouts_length = bind_group_layouts.len, }, ); defer c.wgpu_pipeline_layout_destroy(pipeline_layout); const compute_pipeline = c.wgpu_device_create_compute_pipeline( device, &(c.WGPUComputePipelineDescriptor){ .label = "preview pipeline", .layout = pipeline_layout, .compute_stage = (c.WGPUProgrammableStageDescriptor){ .module = comp_shader, .entry_point = "main", }, }, ); //////////////////////////////////////////////////////////////////////// var out = Self{ .device = device, .bind_group = undefined, // populated in rebuilds_bind_group .bind_group_layout = bind_group_layout, .compute_pipeline = compute_pipeline, }; out.rebuild_bind_group(uniform_buf, image_buf, image_buf_size); out.initialized = true; return out; } pub fn rebuild_bind_group( self: *Self, uniform_buf: c.WGPUBufferId, image_buf: c.WGPUBufferId, image_buf_size: u32, ) void { if (self.initialized) { c.wgpu_bind_group_destroy(self.bind_group); } // Rebuild the bind group as well const bind_group_entries = [_]c.WGPUBindGroupEntry{ (c.WGPUBindGroupEntry){ .binding = 0, .buffer = uniform_buf, .offset = 0, .size = @sizeOf(c.rayUniforms), .sampler = 0, // None .texture_view = 0, // None }, (c.WGPUBindGroupEntry){ .binding = 1, .buffer = image_buf, .offset = 0, .size = image_buf_size, .sampler = 0, // None .texture_view = 0, // None }, }; self.bind_group = c.wgpu_device_create_bind_group( self.device, &(c.WGPUBindGroupDescriptor){ .label = "bind group", .layout = self.bind_group_layout, .entries = &bind_group_entries, .entries_length = bind_group_entries.len, }, ); } pub fn deinit(self: *Self) void { c.wgpu_bind_group_layout_destroy(self.bind_group_layout); c.wgpu_bind_group_destroy(self.bind_group); c.wgpu_compute_pipeline_destroy(self.compute_pipeline); } pub fn render( self: *Self, first: bool, nt: u32, cmd_encoder: c.WGPUCommandEncoderId, ) !void { const cpass = c.wgpu_command_encoder_begin_compute_pass( cmd_encoder, &(c.WGPUComputePassDescriptor){ .label = "" }, ); c.wgpu_compute_pass_set_pipeline(cpass, self.compute_pipeline); c.wgpu_compute_pass_set_bind_group(cpass, 0, self.bind_group, null, 0); c.wgpu_compute_pass_dispatch(cpass, nt, 1, 1); c.wgpu_compute_pass_end_pass(cpass); } };
src/optimized.zig
test "format string" { try testTransform( \\f"foo {{1:2}:32} bar { 2 \\* \\3:4} baz \t" \\ \\ , \\f"foo {{1:2}:32} bar {2 * \\ 3:4} baz \t" \\ ); } test "try-catch" { try testCanonical( \\try \\ assert(x == y) \\ assert(x != z) \\catch ("assertion failure") \\ print("assertion failure") \\catch (1) \\ print("got one") \\catch (let err) \\ print(err) \\ \\ \\ ); try testCanonical( \\try assert(x == y) catch ("assertion failure") print("assertion failure") \\ ); try testCanonical( \\try foo() catch (1) print("1") catch (2) print("2") \\ ); } test "numbers" { try testTransform( \\[0,0] \\[0.0] \\[0,0,0] , \\[0,0] \\[0.0] \\[0,0, 0] \\ ); } test "ranges" { try testCanonical( \\1:2:3 \\:2:3 \\::3 \\1:2: \\1:: \\1::3 \\1:2 \\1: \\:2 \\: \\ ); } test "ignore comments in indent blocks" { try testTransform( \\const foo = fn() \\ #quux \\#foo bar \\ #quux \\#foo bar \\ #quux \\ return 2 , // TODO improve comment rendering \\const foo = fn() \\#quux \\#foo bar \\#quux \\#foo bar \\#quux \\ return 2 \\ \\ \\ ); } test "tag" { try testCanonical( \\@foo \\@bar(foo) \\@baz(2.4, "foo") \\@qux[1, 2] \\@quux{foo: bar} \\ ); } test "different error initializations" { try testCanonical( \\error \\error(foo) \\error(2.4, "foo") \\error[1, 2] \\error{foo: bar} \\ ); } test "nested blocks and matches" { try testCanonical( \\if (false) \\ if (true) \\ match (2) \\ true => a \\ false => b \\ \\ \\ else \\ 2 \\ \\ \\ ); } test "comments after expression" { try testCanonical( \\a \\#foo \\#bar \\ ); } test "two empty lines after block" { try testTransform( \\const foo = fn(a) \\ a * 4 \\const bar = 2 , \\const foo = fn(a) \\ a * 4 \\ \\ \\const bar = 2 \\ ); } test "respect new lines" { try testCanonical( \\const foo = 1 \\ \\const bar = 2 \\ ); try testTransform( \\const foo = 1 \\ \\ \\const bar = 2 , \\const foo = 1 \\ \\const bar = 2 \\ ); } test "nested blocks" { try testCanonical( \\if (false) \\ if (false) \\ 3 \\ else if (true) \\ 4 \\ else \\ 5 \\ \\ \\ ); } test "preserve comment after comma" { try testTransform( \\(1, #hello world \\ 2) \\ , \\( \\ 1, #hello world \\ 2, \\) \\ ); try testTransform( \\(1#hello world \\ , 2) \\ , \\( \\ 1, #hello world \\ 2, \\) \\ ); } test "preserve comments" { try testCanonical( \\#some comment \\123 + \\ #another comment \\ #third comment \\ 2 \\#fourth comment \\#fifth comment \\ ); } test "match" { try testCanonical( \\match (2) \\ let (x, 2) => x + 4 \\ 2, 3 => 1 \\ _ => () \\ \\ \\ ); } test "if" { try testCanonical( \\if (foo) bar else baz \\if (const foo = bar()) baz \\ ); } test "tuples, lists, maps" { try testCanonical( \\(a, b) \\[a, b] \\{a: b, c: d} \\ ); try testTransform( \\(a,b,c,) , \\( \\ a, \\ b, \\ c, \\) \\ ); } test "functions" { try testCanonical( \\const foo = fn(arg1, arg2, _, arg3) (arg1, arg2, arg3) \\const bar = fn(val) \\ val * 45 \\ \\ \\ ); } test "unicode identifiers" { try testTransform( \\öäöäö;öö , \\öäöäö \\öö \\ ); } test "trailing comma in call" { try testCanonical( \\foo(2, 3) \\bar( \\ 2, \\ 3, \\) \\ ); try testTransform( \\foo(2, 3,) \\bar( \\ 2, \\ 3 \\) \\ , \\foo( \\ 2, \\ 3, \\) \\bar( \\ 2, \\ 3, \\) \\ ); } test "loops" { try testCanonical( \\while (true) break \\return 123 // 4 \\for (let foo in arr) foo + 2 \\for (1:3) continue \\ ); } test "declarations" { try testCanonical( \\let bar = import("args") \\const foo = bar + 2 \\let err = error(foo) \\ ); } test "suffix ops" { try testCanonical( \\foo[2].bar(2).baz[5 + 5] \\ ); } test "prefix ops" { try testCanonical( \\not true \\-2 \\ ); } test "infix ops" { try testCanonical( \\123 + 2 * 3 / (4 as num) + () \\ ); } const std = @import("std"); const mem = std.mem; const warn = std.debug.warn; const bog = @import("bog"); fn testTransform(source: []const u8, expected: []const u8) !void { _ = bog.Vm; // avoid false dependency loop var errors = bog.Errors.init(std.testing.allocator); defer errors.deinit(); var tree = bog.parse(std.testing.allocator, source, &errors) catch |e| switch (e) { else => @panic("test failure"), error.TokenizeError, error.ParseError => { errors.render(source, std.io.getStdErr().writer()) catch {}; @panic("test failure"); }, }; defer tree.deinit(); var out_buf = std.ArrayList(u8).init(std.testing.allocator); defer out_buf.deinit(); _ = tree.render(out_buf.writer()) catch @panic("test failure"); try std.testing.expectEqualStrings(expected, out_buf.items); } fn testCanonical(source: []const u8) !void { try testTransform(source, source); }
tests/fmt.zig
const cmp = @import("cmp.zig"); const testing = @import("std").testing; fn test__ucmpti2(a: u128, b: u128, expected: i32) !void { var result = cmp.__ucmpti2(a, b); try testing.expectEqual(expected, result); } test "ucmpti2" { // minInt == 0 // maxInt == 340282366920938463463374607431768211455 // minInt/2 == 0 // maxInt/2 == 170141183460469231731687303715884105727 // 1. equality minInt, minInt+1, maxInt/2, maxInt-1, maxInt try test__ucmpti2(0, 0, 1); try test__ucmpti2(1, 1, 1); try test__ucmpti2(170141183460469231731687303715884105727, 170141183460469231731687303715884105727, 1); try test__ucmpti2(340282366920938463463374607431768211454, 340282366920938463463374607431768211454, 1); try test__ucmpti2(340282366920938463463374607431768211455, 340282366920938463463374607431768211455, 1); // 2. cmp minInt, {minInt + 1, maxInt/2, maxInt-1, maxInt} try test__ucmpti2(0, 1, 0); try test__ucmpti2(0, 170141183460469231731687303715884105727, 0); try test__ucmpti2(0, 340282366920938463463374607431768211454, 0); try test__ucmpti2(0, 340282366920938463463374607431768211455, 0); // 3. cmp minInt+1, {minInt, maxInt/2, maxInt-1, maxInt} try test__ucmpti2(1, 0, 2); try test__ucmpti2(1, 170141183460469231731687303715884105727, 0); try test__ucmpti2(1, 340282366920938463463374607431768211454, 0); try test__ucmpti2(1, 340282366920938463463374607431768211455, 0); // 4. cmp minInt/2, {} // 5. cmp -1, {} // 6. cmp 0, {} // 7. cmp 1, {} // 8. cmp maxInt/2, {} try test__ucmpti2(170141183460469231731687303715884105727, 0, 2); try test__ucmpti2(170141183460469231731687303715884105727, 1, 2); try test__ucmpti2(170141183460469231731687303715884105727, 340282366920938463463374607431768211454, 0); try test__ucmpti2(170141183460469231731687303715884105727, 340282366920938463463374607431768211455, 0); // 9. cmp maxInt-1, {minInt, minInt + 1, maxInt/2, maxInt} try test__ucmpti2(340282366920938463463374607431768211454, 0, 2); try test__ucmpti2(340282366920938463463374607431768211454, 1, 2); try test__ucmpti2(340282366920938463463374607431768211454, 170141183460469231731687303715884105727, 2); try test__ucmpti2(340282366920938463463374607431768211454, 340282366920938463463374607431768211455, 0); // 10.cmp maxInt, {minInt, minInt + 1, minInt/2, -2,-1,0,1,2, maxInt/2, maxInt-1, } try test__ucmpti2(340282366920938463463374607431768211455, 0, 2); try test__ucmpti2(340282366920938463463374607431768211455, 1, 2); try test__ucmpti2(340282366920938463463374607431768211455, 170141183460469231731687303715884105727, 2); try test__ucmpti2(340282366920938463463374607431768211455, 340282366920938463463374607431768211454, 2); }
lib/std/special/compiler_rt/ucmpti2_test.zig
const Builder = @import("std").build.Builder; const builtin = @import("builtin"); const std = @import("std"); const CheckFileStep = std.build.CheckFileStep; pub fn build(b: *Builder) void { const target = .{ .cpu_arch = .thumb, .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m4 }, .os_tag = .freestanding, .abi = .gnueabihf, }; const mode = b.standardReleaseOptions(); const elf = b.addExecutable("zig-nrf52-blink.elf", "main.zig"); elf.setTarget(target); elf.setBuildMode(mode); const test_step = b.step("test", "Test the program"); b.default_step.dependOn(test_step); const hex_step = b.addInstallRaw(elf, "hello.hex", .{}); test_step.dependOn(&hex_step.step); const explicit_format_hex_step = b.addInstallRaw(elf, "hello.foo", .{ .format = .hex }); test_step.dependOn(&explicit_format_hex_step.step); const expected_hex = &[_][]const u8{ ":020000021000EC", ":1000D400A401010001000000A601010001000000CC", ":1000E400FC01010001000000F80101000100000012", ":1000F4000E02010001000000B60201000100000030", ":10010400E00201000100000079020200000000008A", ":1001140000000000000000000000000000000000DB", ":1001240000000000000000000000000000000000CB", ":1001340000000000000000000000000000000000BB", ":1001440083020200F401010009000000FE01010025", ":100154000900000001000000000000000000000091", ":1001640000080002008001010004000010000000EB", ":100174000000000000000000000000001F0000005C", ":1001840048010100000040888000FF01142800524B", ":100194000080610100040020110000000000000044", ":1001A40000000000000000001F000000000000002C", ":1001B400000000000000000000000000000000003B", ":1001C400000000000000000000000000000000002B", ":1001D4000802010010000000190201002C000000B8", ":1001E400460201001B00000062020100130000002F", ":1001F400636F727465785F6D3400636F72746578D1", ":100204002D6D34006469766973696F6E206279209C", ":100214007A65726F0072656D61696E6465722064DF", ":1002240069766973696F6E206279207A65726F20CE", ":100234006F72206E656761746976652076616C758E", ":100244006500696E746567657220636173742074F8", ":1002540072756E6361746564206269747300696E9B", ":10026400646578206F7574206F6620626F756E64A4", ":100274007300000081B00091FFE700BEFDE7D0B538", ":1002840002AF90B00391029007A800F029F80399F7", ":100294000020069048680490FFE7049906980190AE", ":1002A40088420FD2FFE7019903980068405C07F881", ":1002B400310C17F8311C07A800F021F8019801301F", ":1002C4000690EAE7029807A9B1E80C50A0E80C50A0", ":1002D40091E81C5080E81C5010B0D0BDFFE7FEE749", ":1002E400D0B502AF40F2B011C0F20101B1E80C5038", ":1002F400A0E80C5091E81C5080E81C50D0BD80B59B", ":100304006F4688B006906FF35F2127F80A1C37F810", ":100314000A0C0490012038B9FFE740F2D410C0F26F", ":1003240001000021FFF7A6FF0498C0F3431027F84B", ":10033400020C37F80A0C0390002038B9FFE7039841", ":1003440000F01F000290012038B914E040F2DC10E4", ":10035400C0F201000021FFF78DFF029800F01F009A", ":1003640007F8030C0698009037F8020C0146019137", ":1003740009280ED306E040F2E410C0F20100002187", ":10038400FFF778FF40F2EC10C0F201000021FFF704", ":1003940071FF0099019A51F8220017F803CC012348", ":1003A40003FA0CF3184341F8220008B080BD81B071", ":1003B40000F03F008DF802009DF802000F3000F0BD", ":1003C4003F00022804D3FFE700208DF8030003E078", ":1003D40001208DF80300FFE79DF8030001B070478A", ":1003E4000A00000012000000020071001200000068", ":1003F4006600000003007D0C060000000000000001", ":1004040000011101250E1305030E10171B0EB44233", ":0A0414001911011206000002340065", ":020000021000EC", ":1000D400A401010001000000A601010001000000CC", ":1000E400FC01010001000000F80101000100000012", ":1000F4000E02010001000000B60201000100000030", ":10010400E00201000100000079020200000000008A", ":1001140000000000000000000000000000000000DB", ":1001240000000000000000000000000000000000CB", ":1001340000000000000000000000000000000000BB", ":1001440083020200F401010009000000FE01010025", ":100154000900000001000000000000000000000091", ":1001640000080002008001010004000010000000EB", ":100174000000000000000000000000001F0000005C", ":1001840048010100000040888000FF01142800524B", ":100194000080610100040020110000000000000044", ":1001A40000000000000000001F000000000000002C", ":1001B400000000000000000000000000000000003B", ":1001C400000000000000000000000000000000002B", ":1001D4000802010010000000190201002C000000B8", ":1001E400460201001B00000062020100130000002F", ":1001F400636F727465785F6D3400636F72746578D1", ":100204002D6D34006469766973696F6E206279209C", ":100214007A65726F0072656D61696E6465722064DF", ":1002240069766973696F6E206279207A65726F20CE", ":100234006F72206E656761746976652076616C758E", ":100244006500696E746567657220636173742074F8", ":1002540072756E6361746564206269747300696E9B", ":10026400646578206F7574206F6620626F756E64A4", ":100274007300000081B00091FFE700BEFDE7D0B538", ":1002840002AF90B00391029007A800F029F80399F7", ":100294000020069048680490FFE7049906980190AE", ":1002A40088420FD2FFE7019903980068405C07F881", ":1002B400310C17F8311C07A800F021F8019801301F", ":1002C4000690EAE7029807A9B1E80C50A0E80C50A0", ":1002D40091E81C5080E81C5010B0D0BDFFE7FEE749", ":1002E400D0B502AF40F2B011C0F20101B1E80C5038", ":1002F400A0E80C5091E81C5080E81C50D0BD80B59B", ":100304006F4688B006906FF35F2127F80A1C37F810", ":100314000A0C0490012038B9FFE740F2D410C0F26F", ":1003240001000021FFF7A6FF0498C0F3431027F84B", ":10033400020C37F80A0C0390002038B9FFE7039841", ":1003440000F01F000290012038B914E040F2DC10E4", ":10035400C0F201000021FFF78DFF029800F01F009A", ":1003640007F8030C0698009037F8020C0146019137", ":1003740009280ED306E040F2E410C0F20100002187", ":10038400FFF778FF40F2EC10C0F201000021FFF704", ":1003940071FF0099019A51F8220017F803CC012348", ":1003A40003FA0CF3184341F8220008B080BD81B071", ":1003B40000F03F008DF802009DF802000F3000F0BD", ":1003C4003F00022804D3FFE700208DF8030003E078", ":1003D40001208DF80300FFE79DF8030001B070478A", ":1003E4000A00000012000000020071001200000068", ":1003F4006600000003007D0C060000000000000001", ":1004040000011101250E1305030E10171B0EB44233", ":0A0414001911011206000002340065", ":020000022000DC", ":1002780081B00091FFE700BEFDE7D0B502AF90B0B6", ":100288000391029007A800F029F80399002006902E", ":1002980048680490FFE704990698019088420FD2B5", ":1002A800FFE7019903980068405C07F8310C17F8DC", ":1002B800311C07A800F021F8019801300690EAE700", ":1002C800029807A9B1E80C50A0E80C5091E81C501E", ":1002D80080E81C5010B0D0BDFFE7FEE7D0B502AFF4", ":1002E80040F2B011C0F20101B1E80C50A0E80C5086", ":1002F80091E81C5080E81C50D0BD80B56F4688B08E", ":1003080006906FF35F2127F80A1C37F80A0C04904F", ":10031800012038B9FFE740F2D410C0F201000021F3", ":10032800FFF7A6FF0498C0F3431027F8020C37F82C", ":100338000A0C0390002038B9FFE7039800F01F006B", ":100348000290012038B914E040F2DC10C0F201003C", ":100358000021FFF78DFF029800F01F0007F8030C3B", ":100368000698009037F8020C0146019109280ED32F", ":1003780006E040F2E410C0F201000021FFF778FF28", ":1003880040F2EC10C0F201000021FFF771FF009964", ":10039800019A51F8220017F803CC012303FA0CF351", ":1003A800184341F8220008B080BD81B000F03F003A", ":1003B8008DF802009DF802000F3000F03F0002287F", ":1003C80004D3FFE700208DF8030003E001208DF837", ":0C03D8000300FFE79DF8030001B0704730", ":00000001FF", }; test_step.dependOn(&CheckFileStep.create(b, hex_step.getOutputSource(), expected_hex).step); test_step.dependOn(&CheckFileStep.create(b, explicit_format_hex_step.getOutputSource(), expected_hex).step); }
test/standalone/install_raw_hex/build.zig
const std = @import("std"); const TestContext = @import("../../src/test.zig").TestContext; const linux_arm = std.zig.CrossTarget{ .cpu_arch = .arm, .os_tag = .linux, }; pub fn addCases(ctx: *TestContext) !void { { var case = ctx.exe("hello world", linux_arm); // Regular old hello world case.addCompareOutput( \\export fn _start() noreturn { \\ print(); \\ exit(); \\} \\ \\fn print() void { \\ asm volatile ("svc #0" \\ : \\ : [number] "{r7}" (4), \\ [arg1] "{r0}" (1), \\ [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), \\ [arg3] "{r2}" (14) \\ : "memory" \\ ); \\ return; \\} \\ \\fn exit() noreturn { \\ asm volatile ("svc #0" \\ : \\ : [number] "{r7}" (1), \\ [arg1] "{r0}" (0) \\ : "memory" \\ ); \\ unreachable; \\} , "Hello, World!\n", ); } { var case = ctx.exe("parameters and return values", linux_arm); // Testing simple parameters and return values // // TODO: The parameters to the asm statement in print() had to // be in a specific order because otherwise the write to r0 // would overwrite the len parameter which resides in r0 case.addCompareOutput( \\export fn _start() noreturn { \\ print(id(14)); \\ exit(); \\} \\ \\fn id(x: u32) u32 { \\ return x; \\} \\ \\fn print(len: u32) void { \\ asm volatile ("svc #0" \\ : \\ : [number] "{r7}" (4), \\ [arg3] "{r2}" (len), \\ [arg1] "{r0}" (1), \\ [arg2] "{r1}" (@ptrToInt("Hello, World!\n")) \\ : "memory" \\ ); \\ return; \\} \\ \\fn exit() noreturn { \\ asm volatile ("svc #0" \\ : \\ : [number] "{r7}" (1), \\ [arg1] "{r0}" (0) \\ : "memory" \\ ); \\ unreachable; \\} , "Hello, World!\n", ); } { var case = ctx.exe("non-leaf functions", linux_arm); // Testing non-leaf functions case.addCompareOutput( \\export fn _start() noreturn { \\ foo(); \\ exit(); \\} \\ \\fn foo() void { \\ bar(); \\} \\ \\fn bar() void {} \\ \\fn exit() noreturn { \\ asm volatile ("svc #0" \\ : \\ : [number] "{r7}" (1), \\ [arg1] "{r0}" (0) \\ : "memory" \\ ); \\ unreachable; \\} , "", ); } }
test/stage2/arm.zig
// Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. const std = @import("std"); const StackTrace = @import("builtin").StackTrace; const page_allocator = std.heap.page_allocator; const win32 = std.os.windows; // TYPE DEFS pub const BOOL = win32.BOOL; pub const DWORD = win32.DWORD; pub const COLORREF = win32.DWORD; pub const HBRUSH = win32.HBRUSH; pub const HCURSOR = win32.HCURSOR; pub const HICON = win32.HICON; pub const HDC = win32.HDC; pub const HMODULE = win32.HMODULE; pub const HRGN = *@Type(.Opaque); pub const HGDIOBJ = *@Type(.Opaque); pub const HFONT = HGDIOBJ; pub const HBITMAP = HGDIOBJ; pub const HPEN = HGDIOBJ; pub const HPALETTE = HGDIOBJ; pub const HINSTANCE = win32.HINSTANCE; pub const HMENU = win32.HMENU; pub const HWND = win32.HWND; pub const INT = win32.INT; pub const LONG = win32.LONG; pub const LARGE_INTEGER = i64; pub const LPARAM = i64; pub const LPCSTR = win32.LPCSTR; pub const LPVOID = win32.LPVOID; pub const LRESULT = win32.LRESULT; pub const PWSTR = win32.PWSTR; pub const UINT = win32.UINT; pub const WORD = win32.WORD; pub const WPARAM = win32.WPARAM; pub const SIZE_T = win32.SIZE_Tk; pub const FARPROC = c_longlong; pub const BI_RGB = 0; pub const BI_RLE8 = 1; pub const BI_RLE4 = 2; pub const BI_BITFIELDS = 3; pub const BI_JPEG = 4; pub const BI_PNG = 5; pub const POINT = extern struct { x: u32, y: u32, }; pub const RECT = extern struct { left: LONG, top: LONG, right: LONG, bottom: LONG, }; pub const MSG = extern struct { hWnd: ?HWND, message: UINT, wParam: WPARAM, lParam: LPARAM, time: DWORD, pt: POINT, lPrivate: DWORD, }; const WNDCLASSEXA = extern struct { cbSize: UINT = @sizeOf(WNDCLASSEXA), style: UINT = 0, lpfnWndProc: WNDPROC, cbClsExtra: i32 = 0, cbWndExtra: i32 = 0, hInstance: ?HINSTANCE = null, hIcon: ?HICON = null, hCursor: ?HCURSOR = null, hbrBackground: ?HBRUSH = null, lpszMenuName: ?LPCSTR = null, lpszClassName: ?LPCSTR = null, hIconSm: ?HICON = null, }; pub const RGBQUAD = extern struct { rgbBlue: u8 = 0, rgbGreen: u8 = 0, rgbRed: u8 = 0, rgbReserved: u8 = 0, }; pub const BITMAPINFOHEADER = extern struct { biSize: DWORD = @sizeOf(BITMAPINFOHEADER), biWidth: LONG, biHeight: LONG, biPlanes: WORD = 1, biBitCount: WORD = 32, biCompression: DWORD = BI_RGB, biSizeImage: DWORD = 0, biXPelsPerMeter: LONG = 0, biYPelsPerMeter: LONG = 0, biClrUsed: DWORD = 0, biClrImportant: DWORD = 0, }; pub const BITMAPINFO = extern struct { bmiHeader: BITMAPINFOHEADER, bmiColors: [1]RGBQUAD, }; // Enum Definitions /// Based On the Win32 Styles /// https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles pub const WS_BORDER = 0x00800000; pub const WS_CAPTION = 0x00C00000; pub const WS_CHILD = 0x40000000; pub const WS_CHILDWINDOW = 0x40000000; pub const WS_CLIPCHILDREN = 0x02000000; pub const WS_CLIPSIBLINGS = 0x04000000; pub const WS_DISABLED = 0x08000000; pub const WS_DLGFRAME = 0x00400000; pub const WS_GROUP = 0x00020000; pub const WS_HSCROLL = 0x00100000; pub const WS_ICONIC = 0x20000000; pub const WS_MAXIMIZE = 0x01000000; pub const WS_MAXIMIZEBOX = 0x00010000; pub const WS_MINIMIZE = 0x20000000; pub const WS_MINIMIZEBOX = 0x00020000; pub const WS_OVERLAPPED = 0x00000000; pub const WS_POPUP = 0x80000000; pub const WS_SIZEBOX = 0x00040000; pub const WS_SYSMENU = 0x00080000; pub const WS_TABSTOP = 0x00010000; pub const WS_THICKFRAME = 0x00040000; pub const WS_TILED = 0x00000000; pub const WS_VISIBLE = 0x10000000; pub const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX); pub const WS_TILEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX); pub const WS_POPUPWINDOW = (WS_POPUP | WS_BORDER | WS_SYSMENU); /// Based on the Win32 PeekMessage /// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-peekmessagea pub const PM_NOREMOVE = 0x0000; pub const PM_REMOVE = 0x0001; pub const PM_NOYIELD = 0x0002; /// Window Messages pub const WM_NULL = 0x0000; pub const WM_CREATE = 0x0001; pub const WM_DESTROY = 0x0002; pub const WM_MOVE = 0x0003; pub const WM_SIZE = 0x0005; pub const WM_SETFOCUS = 0x0007; pub const WM_KILLFOCUS = 0x0008; pub const WM_ENABLE = 0x000A; pub const WM_SETREDRAW = 0x000B; pub const WM_SETTEXT = 0x000C; pub const WM_GETTEXT = 0x000D; pub const WM_GETTEXTLENGTH = 0x000E; pub const WM_PAINT = 0x000F; pub const WM_CLOSE = 0x0010; pub const WM_QUIT = 0x0012; pub const WM_ERASEBKGND = 0x0014; pub const WM_SYSCOLORCHANGE = 0x0015; pub const WM_SHOWWINDOW = 0x0018; pub const WM_WININICHANGE = 0x001A; pub const WM_NCDESTROY = 0x0082; pub const WM_KEYDOWN = 0x0100; pub const WM_KEYUP = 0x0101; pub const WM_SYSKEYDOWN = 0x0104; pub const WM_SYSKEYUP = 0x0105; pub const WM_SYSCOMMAND = 0x0112; pub const WM_ENTERSIZEMOVE = 0x0231; pub const WM_EXITSIZEMOVE = 0x0232; pub const CW_USEDEFAULT: i32 = -0x80000000; pub const CS_HREDRAW = 0x0002; pub const CS_VREDRAW = 0x0001; pub const CS_OWNDC = 0x0020; pub const MEM_COMMIT = 0x00001000; pub const MEM_RESERVE = 0x00002000; pub const MEM_REPLACE_PLACEHOLDER = 0x00004000; pub const MEM_RESERVE_PLACEHOLDER = 0x00040000; pub const MEM_RESET = 0x00080000; pub const MEM_TOP_DOWN = 0x00100000; pub const MEM_WRITE_WATCH = 0x00200000; pub const MEM_PHYSICAL = 0x00400000; pub const MEM_ROTATE = 0x00800000; pub const MEM_DIFFERENT_IMAGE_BASE_OK = 0x00800000; pub const MEM_RESET_UNDO = 0x01000000; pub const MEM_LARGE_PAGES = 0x20000000; pub const MEM_4MB_PAGES = 0x80000000; pub const MEM_64K_PAGES = (MEM_LARGE_PAGES | MEM_PHYSICAL); pub const MEM_UNMAP_WITH_TRANSIENT_BOOST = 0x00000001; pub const MEM_COALESCE_PLACEHOLDERS = 0x00000001; pub const MEM_PRESERVE_PLACEHOLDER = 0x00000002; pub const MEM_DECOMMIT = 0x00004000; pub const MEM_RELEASE = 0x00008000; pub const MEM_FREE = 0x00010000; pub const PAGE_NOACCESS = 0x01; pub const PAGE_READONLY = 0x02; pub const PAGE_READWRITE = 0x04; pub const PAGE_WRITECOPY = 0x08; pub const PAGE_EXECUTE = 0x10; pub const PAGE_EXECUTE_READ = 0x20; pub const PAGE_EXECUTE_READWRITE = 0x40; pub const PAGE_EXECUTE_WRITECOPY = 0x80; pub const PAGE_GUARD = 0x100; pub const PAGE_NOCACHE = 0x200; pub const PAGE_WRITECOMBINE = 0x400; pub const PAGE_GRAPHICS_NOACCESS = 0x0800; pub const PAGE_GRAPHICS_READONLY = 0x1000; pub const PAGE_GRAPHICS_READWRITE = 0x2000; pub const PAGE_GRAPHICS_EXECUTE = 0x4000; pub const PAGE_GRAPHICS_EXECUTE_READ = 0x8000; pub const PAGE_GRAPHICS_EXECUTE_READWRITE = 0x10000; pub const PAGE_GRAPHICS_COHERENT = 0x20000; pub const PAGE_ENCLAVE_THREAD_CONTROL = 0x80000000; pub const PAGE_REVERT_TO_FILE_MAP = 0x80000000; pub const PAGE_TARGETS_NO_UPDATE = 0x40000000; pub const PAGE_TARGETS_INVALID = 0x40000000; pub const PAGE_ENCLAVE_UNVALIDATED = 0x20000000; pub const PAGE_ENCLAVE_DECOMMIT = 0x10000000; // /* // * Virtual Keys, Standard Set // */ pub const VK_LBUTTON = 0x01; pub const VK_RBUTTON = 0x02; pub const VK_CANCEL = 0x03; pub const VK_MBUTTON = 0x04; pub const VK_XBUTTON1 = 0x05; pub const VK_XBUTTON2 = 0x06; pub const VK_BACK = 0x08; pub const VK_TAB = 0x09; pub const VK_CLEAR = 0x0C; pub const VK_RETURN = 0x0D; pub const VK_SHIFT = 0x10; pub const VK_CONTROL = 0x11; pub const VK_MENU = 0x12; pub const VK_PAUSE = 0x13; pub const VK_CAPITAL = 0x14; pub const VK_KANA = 0x15; pub const VK_HANGEUL = 0x15; pub const VK_HANGUL = 0x15; pub const VK_JUNJA = 0x17; pub const VK_FINAL = 0x18; pub const VK_HANJA = 0x19; pub const VK_KANJI = 0x19; pub const VK_ESCAPE = 0x1B; pub const VK_CONVERT = 0x1C; pub const VK_NONCONVERT = 0x1D; pub const VK_ACCEPT = 0x1E; pub const VK_MODECHANGE = 0x1F; pub const VK_SPACE = 0x20; pub const VK_PRIOR = 0x21; pub const VK_NEXT = 0x22; pub const VK_END = 0x23; pub const VK_HOME = 0x24; pub const VK_LEFT = 0x25; pub const VK_UP = 0x26; pub const VK_RIGHT = 0x27; pub const VK_DOWN = 0x28; pub const VK_SELECT = 0x29; pub const VK_PRINT = 0x2A; pub const VK_EXECUTE = 0x2B; pub const VK_SNAPSHOT = 0x2C; pub const VK_INSERT = 0x2D; pub const VK_DELETE = 0x2E; pub const VK_HELP = 0x2F; pub const VK_NUMPAD0 = 0x60; pub const VK_NUMPAD1 = 0x61; pub const VK_NUMPAD2 = 0x62; pub const VK_NUMPAD3 = 0x63; pub const VK_NUMPAD4 = 0x64; pub const VK_NUMPAD5 = 0x65; pub const VK_NUMPAD6 = 0x66; pub const VK_NUMPAD7 = 0x67; pub const VK_NUMPAD8 = 0x68; pub const VK_NUMPAD9 = 0x69; pub const VK_MULTIPLY = 0x6A; pub const VK_ADD = 0x6B; pub const VK_SEPARATOR = 0x6C; pub const VK_SUBTRACT = 0x6D; pub const VK_DECIMAL = 0x6E; pub const VK_DIVIDE = 0x6F; pub const VK_F1 = 0x70; pub const VK_F2 = 0x71; pub const VK_F3 = 0x72; pub const VK_F4 = 0x73; pub const VK_F5 = 0x74; pub const VK_F6 = 0x75; pub const VK_F7 = 0x76; pub const VK_F8 = 0x77; pub const VK_F9 = 0x78; pub const VK_F10 = 0x79; pub const VK_F11 = 0x7A; pub const VK_F12 = 0x7B; pub const VK_F13 = 0x7C; pub const VK_F14 = 0x7D; pub const VK_F15 = 0x7E; pub const VK_F16 = 0x7F; pub const VK_F17 = 0x80; pub const VK_F18 = 0x81; pub const VK_F19 = 0x82; pub const VK_F20 = 0x83; pub const VK_F21 = 0x84; pub const VK_F22 = 0x85; pub const VK_F23 = 0x86; pub const VK_F24 = 0x87; pub const VK_NAVIGATION_VIEW = 0x88; // reserved pub const VK_NAVIGATION_MENU = 0x89; // reserved pub const VK_NAVIGATION_UP = 0x8A; // reserved pub const VK_NAVIGATION_DOWN = 0x8B; // reserved pub const VK_NAVIGATION_LEFT = 0x8C; // reserved pub const VK_NAVIGATION_RIGHT = 0x8D; // reserved pub const VK_NAVIGATION_ACCEPT = 0x8E; // reserved pub const VK_NAVIGATION_CANCEL = 0x8F; // reserved pub const VK_NUMLOCK = 0x90; pub const VK_SCROLL = 0x91; pub const VK_OEM_FJ_JISHO = 0x92; // 'Dictionary' key pub const VK_OEM_FJ_MASSHOU = 0x93; // 'Unregister word' key pub const VK_OEM_FJ_TOUROKU = 0x94; // 'Register word' key pub const VK_OEM_FJ_LOYA = 0x95; // 'Left OYAYUBI' key pub const VK_OEM_FJ_ROYA = 0x96; // 'Right OYAYUBI' key pub const VK_LSHIFT = 0xA0; pub const VK_RSHIFT = 0xA1; pub const VK_LCONTROL = 0xA2; pub const VK_RCONTROL = 0xA3; pub const VK_LMENU = 0xA4; pub const VK_RMENU = 0xA5; pub const VK_BROWSER_BACK = 0xA6; pub const VK_BROWSER_FORWARD = 0xA7; pub const VK_BROWSER_REFRESH = 0xA8; pub const VK_BROWSER_STOP = 0xA9; pub const VK_BROWSER_SEARCH = 0xAA; pub const VK_BROWSER_FAVORITES = 0xAB; pub const VK_BROWSER_HOME = 0xAC; pub const VK_VOLUME_MUTE = 0xAD; pub const VK_VOLUME_DOWN = 0xAE; pub const VK_VOLUME_UP = 0xAF; pub const VK_MEDIA_NEXT_TRACK = 0xB0; pub const VK_MEDIA_PREV_TRACK = 0xB1; pub const VK_MEDIA_STOP = 0xB2; pub const VK_MEDIA_PLAY_PAUSE = 0xB3; pub const VK_LAUNCH_MAIL = 0xB4; pub const VK_LAUNCH_MEDIA_SELECT = 0xB5; pub const VK_LAUNCH_APP1 = 0xB6; pub const VK_LAUNCH_APP2 = 0xB7; pub const VK_OEM_1 = 0xBA; // ';:' for US pub const VK_OEM_PLUS = 0xBB; // '+' any country pub const VK_OEM_COMMA = 0xBC; // ',' any country pub const VK_OEM_MINUS = 0xBD; // '-' any country pub const VK_OEM_PERIOD = 0xBE; // '.' any country pub const VK_OEM_2 = 0xBF; // '/?' for US pub const VK_OEM_3 = 0xC0; // '`~' for US pub const VK_OEM_4 = 0xDB; // '[{' for US pub const VK_OEM_5 = 0xDC; // '\|' for US pub const VK_OEM_6 = 0xDD; // ']}' for US pub const VK_OEM_7 = 0xDE; // ''"' for US pub const VK_OEM_8 = 0xDF; pub const VK_OEM_AX = 0xE1; // 'AX' key on Japanese AX kbd pub const VK_OEM_102 = 0xE2; // "<>" or "\|" on RT 102-key kbd. pub const VK_ICO_HELP = 0xE3; // Help key on ICO pub const VK_ICO_00 = 0xE4; // 00 key on ICO pub const VK_PROCESSKEY = 0xE5; pub const VK_ICO_CLEAR = 0xE6; pub const VK_PACKET = 0xE7; pub const VK_OEM_RESET = 0xE9; pub const VK_OEM_JUMP = 0xEA; pub const VK_OEM_PA1 = 0xEB; pub const VK_OEM_PA2 = 0xEC; pub const VK_OEM_PA3 = 0xED; pub const VK_OEM_WSCTRL = 0xEE; pub const VK_OEM_CUSEL = 0xEF; pub const VK_OEM_ATTN = 0xF0; pub const VK_OEM_FINISH = 0xF1; pub const VK_OEM_COPY = 0xF2; pub const VK_OEM_AUTO = 0xF3; pub const VK_OEM_ENLW = 0xF4; pub const VK_OEM_BACKTAB = 0xF5; pub const VK_ATTN = 0xF6; pub const VK_CRSEL = 0xF7; pub const VK_EXSEL = 0xF8; pub const VK_EREOF = 0xF9; pub const VK_PLAY = 0xFA; pub const VK_ZOOM = 0xFB; pub const VK_NONAME = 0xFC; pub const VK_PA1 = 0xFD; pub const VK_OEM_CLEAR = 0xFE; // GDI Bits pub const DIB_RGB_COLORS = 0; pub const DIB_PAL_COLORS = 1; pub const SRCCOPY: DWORD = 0x00CC0020; pub const SRCPAINT: DWORD = 0x00EE0086; pub const SRCAND: DWORD = 0x008800C6; pub const SRCINVERT: DWORD = 0x00660046; pub const SRCERASE: DWORD = 0x00440328; pub const NOTSRCCOPY: DWORD = 0x00330008; pub const NOTSRCERASE: DWORD = 0x001100A6; pub const MERGECOPY: DWORD = 0x00C000CA; pub const MERGEPAINT: DWORD = 0x00BB0226; pub const PATCOPY: DWORD = 0x00F00021; pub const PATPAINT: DWORD = 0x00FB0A09; pub const PATINVERT: DWORD = 0x005A0049; pub const DSTINVERT: DWORD = 0x00550009; pub const BLACKNESS: DWORD = 0x00000042; pub const WHITENESS: DWORD = 0x00FF0062; pub const ETO_OPAQUE = 0x0002; pub const ETO_CLIPPED = 0x0004; pub const ETO_GLYPH_INDEX = 0x0010; pub const ETO_RTLREADING = 0x0080; pub const ETO_NUMERICSLOCAL = 0x0400; pub const ETO_NUMERICSLATIN = 0x0800; pub const ETO_IGNORELANGUAGE = 0x1000; pub const ETO_PDY = 0x2000; pub const ETO_REVERSE_INDEX_MAP = 0x10000; // /* Stock Logical Objects */ pub const WHITE_BRUSH = 0; pub const LTGRAY_BRUSH = 1; pub const GRAY_BRUSH = 2; pub const DKGRAY_BRUSH = 3; pub const BLACK_BRUSH = 4; pub const NULL_BRUSH = 5; pub const HOLLOW_BRUSH = NULL_BRUSH; pub const WHITE_PEN = 6; pub const BLACK_PEN = 7; pub const NULL_PEN = 8; pub const OEM_FIXED_FONT = 10; pub const ANSI_FIXED_FONT = 11; pub const ANSI_VAR_FONT = 12; pub const SYSTEM_FONT = 13; pub const DEVICE_DEFAULT_FONT = 14; pub const DEFAULT_PALETTE = 15; pub const SYSTEM_FIXED_FONT = 16; pub const DEFAULT_GUI_FONT = 17; pub const DC_BRUSH = 18; pub const DC_PEN = 19; pub const STOCK_LAST = 19; pub const CLR_INVALID = 0xFFFFFFFF; pub const BS_SOLID = 0; pub const BS_NULL = 1; pub const BS_HOLLOW = BS_NULL; pub const BS_HATCHED = 2; pub const BS_PATTERN = 3; pub const BS_INDEXED = 4; pub const BS_DIBPATTERN = 5; pub const BS_DIBPATTERNPT = 6; pub const BS_PATTERN8X8 = 7; pub const BS_DIBPATTERN8X8 = 8; pub const BS_MONOPATTERN = 9; // ----- pub const HS_HORIZONTAL = 0; // ||||| pub const HS_VERTICAL = 1; // \\\\\ pub const HS_FDIAGONAL = 2; // ///// pub const HS_BDIAGONAL = 3; // +++++ pub const HS_CROSS = 4; // xxxxx pub const HS_DIAGCROSS = 5; pub const HS_API_MAX = 12; pub const PS_SOLID = 0; // ------- pub const PS_DASH = 1; // ....... pub const PS_DOT = 2; // _._._._ pub const PS_DASHDOT = 3; // _.._.._ pub const PS_DASHDOTDOT = 4; pub const PS_NULL = 5; pub const PS_INSIDEFRAME = 6; pub const PS_USERSTYLE = 7; pub const PS_ALTERNATE = 8; pub const PS_STYLE_MASK = 0x0000000F; pub const PS_ENDCAP_ROUND = 0x00000000; pub const PS_ENDCAP_SQUARE = 0x00000100; pub const PS_ENDCAP_FLAT = 0x00000200; pub const PS_ENDCAP_MASK = 0x00000F00; pub const PS_JOIN_ROUND = 0x00000000; pub const PS_JOIN_BEVEL = 0x00001000; pub const PS_JOIN_MITER = 0x00002000; pub const PS_JOIN_MASK = 0x0000F000; pub const PS_COSMETIC = 0x00000000; pub const PS_GEOMETRIC = 0x00010000; pub const PS_TYPE_MASK = 0x000F0000; // Function Definitions pub const WNDPROC = fn (HWND, UINT, WPARAM, LPARAM) callconv(.Stdcall) LRESULT; pub extern "user32" fn RegisterClassExA(*const WNDCLASSEXA) callconv(.Stdcall) c_ushort; pub extern "user32" fn CreateWindowExA(DWORD, LPCSTR, LPCSTR, DWORD, i32, i32, i32, i32, ?HWND, ?HMENU, HINSTANCE, ?LPVOID) callconv(.Stdcall) ?HWND; pub extern "user32" fn PeekMessageA(*MSG, HWND, u32, u32, u32) callconv(.Stdcall) bool; pub extern "user32" fn DefWindowProcA(HWND, UINT, WPARAM, LPARAM) callconv(.Stdcall) LRESULT; pub extern "user32" fn TranslateMessage(*MSG) callconv(.Stdcall) bool; pub extern "user32" fn DispatchMessageA(*MSG) callconv(.Stdcall) LRESULT; pub extern "user32" fn GetDC(hWnd: HWND) HDC; pub extern "user32" fn GetClientRect(hWnd: HWND, lpRect: *RECT) BOOL; pub extern "kernel32" fn VirtualAlloc(lpAddress: ?LPVOID, dwSize: usize, flAllocationType: DWORD, flProtect: DWORD) ?LPVOID; pub extern "kernel32" fn VirtualFree(lpAddress: LPVOID, dwSize: usize, dwFreeType: DWORD) BOOL; pub extern "kernel32" fn OutputDebugStringA([*:0]const u8) void; pub extern "kernel32" fn QueryPerformanceCounter(*LARGE_INTEGER) bool; pub extern "kernel32" fn QueryPerformanceFrequency(*LARGE_INTEGER) bool; pub extern "kernel32" fn LoadLibraryA([*:0]const u8) ?HMODULE; pub extern "gdi32" fn StretchDIBits(hdc: HDC, xDest: i32, yDest: i32, DestWidth: i32, DestHeight: i32, xSrc: i32, ySrc: i32, SrcWidth: i32, SrcHeight: i32, lpBits: *c_void, lpbmi: *BITMAPINFO, iUsage: UINT, rop: DWORD) i32; pub extern "gdi32" fn PatBlt(hdc: HDC, x: c_int, y: c_int, w: c_int, h: c_int, rop: DWORD) BOOL; pub extern "gdi32" fn BitBlt(hdc: HDC, x: c_int, y: c_int, cx: c_int, cy: c_int, src: HDC, x1: c_int, y1: c_int, rop: DWORD) BOOL; pub extern "gdi32" fn CreateCompatibleDC(hdc: ?HDC) ?HDC; pub extern "gdi32" fn CreateCompatibleBitmap(hdc: ?HDC, x: c_int, y: c_int) ?HBITMAP; pub extern "gdi32" fn SetBkColor(hdc: HDC, color: COLORREF) COLORREF; pub extern "gdi32" fn ExtTextOutA(hdc: HDC, x: c_int, y: c_int, options: c_uint, rect: *const RECT, lpString: ?LPCSTR, c: c_uint, dx: ?*const c_int) COLORREF; pub extern "gdi32" fn SetDCPenColor(hdc: HDC, color: COLORREF) COLORREF; pub extern "gdi32" fn SetDCBrushColor(hdc: HDC, color: COLORREF) COLORREF; pub extern "gdi32" fn RoundRect(hdc: HDC, left: c_int, top: c_int, right: c_int, bottom: c_int, width: c_int, height: c_int) bool; pub extern "gdi32" fn Rectangle(hdc: HDC, left: c_int, top: c_int, right: c_int, bottom: c_int) bool; pub extern "gdi32" fn SelectObject(hdc: HDC, obj: HGDIOBJ) ?HGDIOBJ; pub extern "gdi32" fn CreatePen(style: c_int, width: c_int, color: COLORREF) HPEN; pub extern "gdi32" fn DeleteObject(obj: HGDIOBJ) bool; pub extern "gdi32" fn GetStockObject(index: c_int) callconv(.C) ?HGDIOBJ; pub extern "gdi32" fn MoveToEx(hdc: HDC, x: c_int, y: c_int, point: ?*POINT) bool; pub extern "gdi32" fn LineTo(hdc: HDC, x: c_int, y: c_int) bool; pub extern "gdi32" fn Polygon(hdc: HDC, apt: *const POINT, cpt: c_int) bool; pub extern "gdi32" fn SelectClipRgn(dc: HDC, region: ?HRGN) c_int; pub extern "gdi32" fn IntersectClipRect(dc: HDC, left: c_int, top: c_int, right: c_int, bottom: c_int) c_int; pub extern "gdi32" fn Ellipse(dc: HDC, left: c_int, top: c_int, right: c_int, bottom: c_int) bool; pub extern "gdi32" fn PolyBezier(dc: HDC, points: *const POINT, point_count: DWORD) bool; // Minimum timer resolution, in milliseconds, for the application or device driver. A lower value specifies a higher (more accurate) resolution. pub extern "Winmm" fn timeBeginPeriod(u32) u32; // Minimum timer resolution specified in the previous call to the timeBeginPeriod function. pub extern "Winmm" fn timeEndPeriod(u32) u32; /// Extern Function Definitions /// /// ACTUAL CODE /// pub const WindowError = error{ FailedToCreateWindow, FailedToAllocateMemory, FailedToUnallocateMemory, LibraryLoadError, TimerNoCanDo, }; pub const Win32Message = MSG; pub const Win32Config = struct { wnd_proc: WNDPROC, style: DWORD = CS_HREDRAW | CS_VREDRAW | CS_OWNDC, window_name: LPCSTR, window_class_name: LPCSTR, display_style: DWORD = WS_OVERLAPPEDWINDOW | WS_VISIBLE, x: i32 = CW_USEDEFAULT, y: i32 = CW_USEDEFAULT, width: i32 = CW_USEDEFAULT, height: i32 = CW_USEDEFAULT, h_instance: HINSTANCE, }; pub const Window = struct { const Self = @This(); window: HWND, msg: Win32Message = undefined, pub fn init(config: Win32Config) !Window { const window_class = WNDCLASSEXA{ .style = config.style, .lpfnWndProc = config.wnd_proc, .hInstance = config.h_instance, .lpszClassName = config.window_class_name, }; _ = RegisterClassExA(&window_class); if (CreateWindowExA( 0, config.window_class_name, config.window_name, config.display_style, config.x, config.y, config.width, config.height, null, null, config.h_instance, null, )) |window| { return Window{ .window = window, }; } else { return WindowError.FailedToCreateWindow; } } pub fn peek_message(self: *Self) ?*Win32Message { if (PeekMessageA(&self.msg, self.window, 0, 0, PM_REMOVE)) { return &self.msg; } else { return null; } } pub fn dispatch_message(self: *Self, message: *Win32Message) void { _ = TranslateMessage(message); _ = DispatchMessageA(message); } }; pub fn debug(comptime fmt: []const u8, args: var) void { const output = std.fmt.allocPrint0(page_allocator, fmt, args) catch unreachable; OutputDebugStringA(@ptrCast([*:0]const u8, output.ptr)); page_allocator.free(output); } pub inline fn GetWallClock() i64 { var result: i64 = 0; _ = QueryPerformanceCounter(&result); return result; } pub inline fn GetFreq() i64 { var result: i64 = 0; _ = QueryPerformanceFrequency(&result); return result; } pub fn win32_panic(message: []const u8, stack_trace: ?*StackTrace) noreturn { debug("Panic: {}\n{}\n", .{ message, stack_trace }); std.os.abort(); } pub fn time_begin_period(period: u32) !void { if (timeBeginPeriod(period) != 0) { return WindowError.TimerNoCanDo; } } pub fn time_end_period(period: u32) !void { if (timeEndPeriod(period) != 0) { return WindowError.TimerNoCanDo; } }
win32.zig
const std = @import("std"); const builtin = @import("builtin"); const mem = std.mem; const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; test "@maximum" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { var x: i32 = 10; var y: f32 = 0.68; try expect(@as(i32, 10) == @maximum(@as(i32, -3), x)); try expect(@as(f32, 3.2) == @maximum(@as(f32, 3.2), y)); } }; try S.doTheTest(); comptime try S.doTheTest(); } test "@maximum on vectors" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { var a: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; var b: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; var x = @maximum(a, b); try expect(mem.eql(i32, &@as([4]i32, x), &[4]i32{ 2147483647, 2147483647, 30, 40 })); var c: @Vector(4, f32) = [4]f32{ 0, 0.4, -2.4, 7.8 }; var d: @Vector(4, f32) = [4]f32{ -0.23, 0.42, -0.64, 0.9 }; var y = @maximum(c, d); try expect(mem.eql(f32, &@as([4]f32, y), &[4]f32{ 0, 0.42, -0.64, 7.8 })); var e: @Vector(2, f32) = [2]f32{ 0, std.math.qnan_f32 }; var f: @Vector(2, f32) = [2]f32{ std.math.qnan_f32, 0 }; var z = @maximum(e, f); try expect(mem.eql(f32, &@as([2]f32, z), &[2]f32{ 0, 0 })); } }; try S.doTheTest(); comptime try S.doTheTest(); } test "@minimum" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { var x: i32 = 10; var y: f32 = 0.68; try expect(@as(i32, -3) == @minimum(@as(i32, -3), x)); try expect(@as(f32, 0.68) == @minimum(@as(f32, 3.2), y)); } }; try S.doTheTest(); comptime try S.doTheTest(); } test "@minimum for vectors" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { var a: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; var b: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; var x = @minimum(a, b); try expect(mem.eql(i32, &@as([4]i32, x), &[4]i32{ 1, -2, 3, 4 })); var c: @Vector(4, f32) = [4]f32{ 0, 0.4, -2.4, 7.8 }; var d: @Vector(4, f32) = [4]f32{ -0.23, 0.42, -0.64, 0.9 }; var y = @minimum(c, d); try expect(mem.eql(f32, &@as([4]f32, y), &[4]f32{ -0.23, 0.4, -2.4, 0.9 })); var e: @Vector(2, f32) = [2]f32{ 0, std.math.qnan_f32 }; var f: @Vector(2, f32) = [2]f32{ std.math.qnan_f32, 0 }; var z = @maximum(e, f); try expect(mem.eql(f32, &@as([2]f32, z), &[2]f32{ 0, 0 })); } }; try S.doTheTest(); comptime try S.doTheTest(); }
test/behavior/maximum_minimum.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); const ally = &arena.allocator; const Deck = std.ArrayList(u8); const p1_init = [_]u8 { 26, 16, 33, 8, 5, 46, 12, 47, 39, 27, 50, 10, 34, 20, 23, 11, 43, 14, 18, 1, 48, 28, 31, 38, 41, }; const p2_init = [_]u8 { 45, 7, 9, 4, 15, 19, 49, 3, 36, 25, 24, 2, 21, 37, 35, 44, 29, 13, 32, 22, 17, 30, 42, 40, 6, }; const HistoryState = struct { p1: []const u8, p2: []const u8, fn eql(self: HistoryState, p1: []const u8, p2: []const u8) bool { return std.mem.eql(u8, self.p1, p1) and std.mem.eql(u8, self.p2, p2); } }; pub fn recursiveCombat(p1v: []const u8, p2v: []const u8) bool { var history = std.ArrayList(HistoryState).init(ally); defer history.deinit(); var p1 = Deck.init(ally); defer p1.deinit(); var p2 = Deck.init(ally); defer p2.deinit(); p1.appendSlice(p1v) catch unreachable; p2.appendSlice(p2v) catch unreachable; while (p1.items.len > 0 and p2.items.len > 0) { for (history.items) |hist| { if (hist.eql(p1.items, p2.items)) { return false; // p1 wins } } history.append(.{ .p1 = ally.dupe(u8, p1.items) catch unreachable, .p2 = ally.dupe(u8, p2.items) catch unreachable, }) catch unreachable; const a = p1.pop(); const b = p2.pop(); var winner = false; if (a <= p1.items.len and b <= p2.items.len) { winner = recursiveCombat( p1.items[p1.items.len - a..], p2.items[p2.items.len - b..], ); } else { winner = b > a; } if (winner) { p2.insertSlice(0, &[_]u8{a, b}) catch unreachable; } else { p1.insertSlice(0, &[_]u8{b, a}) catch unreachable; } } return p2.items.len > 0; } pub fn main() !void { var p1 = Deck.init(ally); var p2 = Deck.init(ally); for (p1_init) |c| { try p1.insert(0, c); } for (p2_init) |c| { try p2.insert(0, c); } var history = std.ArrayList(HistoryState).init(ally); var round: usize = 0; var overall = foo: while (p1.items.len > 0 and p2.items.len > 0) : (round += 1) { for (history.items) |hist| { if (hist.eql(p1.items, p2.items)) { break :foo false; // p1 wins } } const a = p1.pop(); const b = p2.pop(); var winner = false; if (a <= p1.items.len and b <= p2.items.len) { winner = recursiveCombat( p1.items[p1.items.len - a..], p2.items[p2.items.len - b..], ); } else { winner = b > a; } if (winner) { try p2.insertSlice(0, &[_]u8{a, b}); } else { try p1.insertSlice(0, &[_]u8{b, a}); } } else p2.items.len > 0; var result: usize = 0; if (overall) { for (p2.items) |c, i| { result += c * (i+1); } } else { for (p1.items) |c, i| { result += c * (i+1); } } print("Finished after {} rounds, Result: {}\n", .{round, result}); }
src/day22.zig
pub const Token = struct { id: Id, start: usize, end: usize, line: ?*@This() = null, }; pub const Id = enum(u8) { Invalid = 0, Eof = 1, MinusEqual = 30, Slash = 63, Keyword_continue = 75, EqualAngleBracketRight = 114, Keyword_suspend = 22, RBracket = 83, Keyword_null = 95, Keyword_switch = 105, EqualEqual = 46, Tilde = 68, BangEqual = 47, LParen = 16, MinusPercent = 61, Asterisk = 62, Comma = 4, Keyword_fn = 15, Keyword_const = 20, AngleBracketAngleBracketRightEqual = 32, AsteriskAsterisk = 65, Keyword_cancel = 73, Keyword_or = 43, CaretEqual = 34, DocComment = 2, QuestionMark = 79, FloatLiteral = 89, Keyword_error = 92, Keyword_defer = 23, RBrace = 78, Keyword_true = 94, Keyword_await = 71, Ellipsis2 = 99, PeriodAsterisk = 100, Keyword_if = 111, LCurly = 77, Keyword_unreachable = 97, Keyword_noalias = 120, Bang = 18, Identifier = 21, LineString = 121, Keyword_try = 70, Ellipsis3 = 110, StringLiteral = 6, Keyword_export = 10, AngleBracketAngleBracketLeftEqual = 31, MinusAngleBracketRight = 81, Keyword_stdcallcc = 109, Keyword_while = 113, Semicolon = 8, Keyword_comptime = 7, AsteriskEqual = 26, Recovery = 40, AngleBracketLeftEqual = 50, Keyword_orelse = 41, LBrace = 86, BracketStarBracket = 84, PipeEqual = 35, IntegerLiteral = 90, Keyword_enum = 102, PlusEqual = 29, Builtin = 98, Keyword_union = 103, Caret = 53, Keyword_asm = 106, Keyword_inline = 11, Keyword_struct = 117, Colon = 87, PlusPercent = 60, Keyword_else = 25, PlusPercentEqual = 37, AngleBracketRight = 49, Minus = 58, CharLiteral = 88, Keyword_extern = 9, Keyword_test = 5, AngleBracketLeft = 48, Pipe = 52, Keyword_use = 13, Keyword_false = 93, Keyword_packed = 104, MinusPercentEqual = 38, RParen = 17, Keyword_var = 19, AsteriskPercentEqual = 36, Keyword_return = 76, LBracket = 82, PeriodQuestionMark = 101, Plus = 57, Keyword_volatile = 115, Period = 91, Keyword_allowzero = 116, PercentEqual = 28, Keyword_linksection = 107, RootDocComment = 3, Keyword_and = 45, Keyword_pub = 119, Keyword_nakedcc = 108, Percent = 64, Keyword_align = 118, Keyword_usingnamespace = 12, AngleBracketAngleBracketRight = 56, AsteriskPercent = 66, Keyword_undefined = 96, Equal = 39, SlashEqual = 27, Keyword_for = 112, PipePipe = 67, BracketStarCBracket = 85, Keyword_threadlocal = 14, LineCString = 122, Keyword_resume = 72, AngleBracketRightEqual = 51, Keyword_errdefer = 24, Keyword_catch = 42, AmpersandEqual = 33, AmpersandAmpersand = 44, Ampersand = 54, AngleBracketAngleBracketLeft = 55, PlusPlus = 59, Keyword_async = 69, Keyword_break = 74, Keyword_promise = 80, ShebangLine = 123, LineComment = 124, Newline = 125, Ignore = 126, }; pub const TerminalId = enum(u8) { Accept = 0, Expr = 28, ContainerDeclOp = 61, MaybeExpr = 76, AsmOutputItem = 38, IfPrefix = 47, DocCommentLines = 3, MaybeContainerMembers = 6, SwitchProng = 53, MaybeAlign = 63, MaybeConst = 81, MultilineStringLiteral = 82, ContainerField = 15, Statement = 18, ParamType = 46, BlockLabel = 31, TopLevelComptime = 10, ContainerMembers = 7, MaybeNoalias = 77, ContainerDecl = 32, MaybeLinkSection = 43, TestDecl = 9, BreakLabel = 42, SwitchCase = 54, MaybeExprList = 71, FnCC = 44, MultilineCStringLiteral = 83, BlockExpr = 29, AsmExpr = 36, BlockExprStatement = 25, WhilePrefix = 49, MaybeByteAlign = 62, ParamDeclList = 70, ErrorTagList = 64, FnProto = 13, SwitchItems = 55, Block = 30, AsmOutputList = 66, ContainerMember = 8, SwitchExpr = 34, ContainerDeclTypeEnum = 59, MaybeIdentifier = 79, Statements = 17, MaybePtrPayload = 51, ContainerDeclTypeType = 60, MaybeColonTypeExpr = 75, SwitchProngList = 65, MaybeVolatile = 57, MaybeAllowzero = 58, MaybeEqualExpr = 27, ForPrefix = 48, PtrIndexPayload = 52, MaybePub = 74, MaybeDocComment = 2, LabeledStatement = 21, RootDocCommentLines = 5, IfStatement = 19, MaybePayload = 50, MaybeThreadlocal = 12, ForStatement = 22, AsmInputList = 67, ElseNoPayloadStatement = 23, ExternPacked = 33, MaybeInline = 78, WhileStatement = 24, MaybeRootDocComment = 4, ElseStatement = 20, TopLevelDecl = 11, AsmInput = 39, VarDecl = 14, MaybeStatements = 16, Root = 1, AssignExpr = 26, String = 35, InitList = 73, AsmClobber = 41, StringList = 68, ExprList = 72, AsmInputItem = 40, MaybeComma = 80, ParamDecl = 45, SwitchItem = 56, AsmOutput = 37, MaybeParamDeclList = 69, }; pub fn terminalIdToString(id: TerminalId) []const u8 { switch(id) { .Accept => return "$accept", .Expr => return "Expr", .ContainerDeclOp => return "ContainerDeclOp", .MaybeExpr => return "Expr?", .AsmOutputItem => return "AsmOutputItem", .IfPrefix => return "IfPrefix", .DocCommentLines => return "DocCommentLines", .MaybeContainerMembers => return "ContainerMembers?", .SwitchProng => return "SwitchProng", .MaybeAlign => return "Align?", .MaybeConst => return "Const?", .MultilineStringLiteral => return "MultilineStringLiteral", .ContainerField => return "ContainerField", .Statement => return "Statement", .ParamType => return "ParamType", .BlockLabel => return "BlockLabel", .TopLevelComptime => return "TopLevelComptime", .ContainerMembers => return "ContainerMembers", .MaybeNoalias => return "Noalias?", .ContainerDecl => return "ContainerDecl", .MaybeLinkSection => return "LinkSection?", .TestDecl => return "TestDecl", .BreakLabel => return "BreakLabel", .SwitchCase => return "SwitchCase", .MaybeExprList => return "ExprList?", .FnCC => return "FnCC", .MultilineCStringLiteral => return "MultilineCStringLiteral", .BlockExpr => return "BlockExpr", .AsmExpr => return "AsmExpr", .BlockExprStatement => return "BlockExprStatement", .WhilePrefix => return "WhilePrefix", .MaybeByteAlign => return "ByteAlign?", .ParamDeclList => return "ParamDeclList", .ErrorTagList => return "ErrorTagList", .FnProto => return "FnProto", .SwitchItems => return "SwitchItems", .Block => return "Block", .AsmOutputList => return "AsmOutputList", .ContainerMember => return "ContainerMember", .SwitchExpr => return "SwitchExpr", .ContainerDeclTypeEnum => return "ContainerDeclTypeEnum", .MaybeIdentifier => return "Identifier?", .Statements => return "Statements", .MaybePtrPayload => return "PtrPayload?", .ContainerDeclTypeType => return "ContainerDeclTypeType", .MaybeColonTypeExpr => return "ColonTypeExpr?", .SwitchProngList => return "SwitchProngList", .MaybeVolatile => return "Volatile?", .MaybeAllowzero => return "Allowzero?", .MaybeEqualExpr => return "EqualExpr?", .ForPrefix => return "ForPrefix", .PtrIndexPayload => return "PtrIndexPayload", .MaybePub => return "Pub?", .MaybeDocComment => return "DocComment?", .LabeledStatement => return "LabeledStatement", .RootDocCommentLines => return "RootDocCommentLines", .IfStatement => return "IfStatement", .MaybePayload => return "Payload?", .MaybeThreadlocal => return "Threadlocal?", .ForStatement => return "ForStatement", .AsmInputList => return "AsmInputList", .ElseNoPayloadStatement => return "ElseNoPayloadStatement", .ExternPacked => return "ExternPacked", .MaybeInline => return "Inline?", .WhileStatement => return "WhileStatement", .MaybeRootDocComment => return "RootDocComment?", .ElseStatement => return "ElseStatement", .TopLevelDecl => return "TopLevelDecl", .AsmInput => return "AsmInput", .VarDecl => return "VarDecl", .MaybeStatements => return "Statements?", .Root => return "Root", .AssignExpr => return "AssignExpr", .String => return "String", .InitList => return "InitList", .AsmClobber => return "AsmClobber", .StringList => return "StringList", .ExprList => return "ExprList", .AsmInputItem => return "AsmInputItem", .MaybeComma => return "Comma?", .ParamDecl => return "ParamDecl", .SwitchItem => return "SwitchItem", .AsmOutput => return "AsmOutput", .MaybeParamDeclList => return "ParamDeclList?", } }
zig/zig_grammar.tokens.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; test "@sizeOf(T) == 0 doesn't force resolving struct size" { const S = struct { const Foo = struct { y: if (@sizeOf(Foo) == 0) u64 else u32, }; const Bar = struct { x: i32, y: if (0 == @sizeOf(Bar)) u64 else u32, }; }; try expect(@sizeOf(S.Foo) == 4); try expect(@sizeOf(S.Bar) == 8); } test "@TypeOf() has no runtime side effects" { const S = struct { fn foo(comptime T: type, ptr: *T) T { ptr.* += 1; return ptr.*; } }; var data: i32 = 0; const T = @TypeOf(S.foo(i32, &data)); comptime try expect(T == i32); try expect(data == 0); } test "branching logic inside @TypeOf" { const S = struct { var data: i32 = 0; fn foo() anyerror!i32 { data += 1; return undefined; } }; const T = @TypeOf(S.foo() catch undefined); comptime try expect(T == i32); try expect(S.data == 0); } test "@bitSizeOf" { try expect(@bitSizeOf(u2) == 2); try expect(@bitSizeOf(u8) == @sizeOf(u8) * 8); try expect(@bitSizeOf(struct { a: u2, }) == 8); try expect(@bitSizeOf(packed struct { a: u2, }) == 2); } test "@sizeOf comparison against zero" { const S0 = struct { f: *@This(), }; const U0 = union { f: *@This(), }; const S1 = struct { fn H(comptime T: type) type { return struct { x: T, }; } f0: H(*@This()), f1: H(**@This()), f2: H(***@This()), }; const U1 = union { fn H(comptime T: type) type { return struct { x: T, }; } f0: H(*@This()), f1: H(**@This()), f2: H(***@This()), }; const S = struct { fn doTheTest(comptime T: type, comptime result: bool) !void { try expectEqual(result, @sizeOf(T) > 0); } }; // Zero-sized type try S.doTheTest(u0, false); try S.doTheTest(*u0, false); // Non byte-sized type try S.doTheTest(u1, true); try S.doTheTest(*u1, true); // Regular type try S.doTheTest(u8, true); try S.doTheTest(*u8, true); try S.doTheTest(f32, true); try S.doTheTest(*f32, true); // Container with ptr pointing to themselves try S.doTheTest(S0, true); try S.doTheTest(U0, true); try S.doTheTest(S1, true); try S.doTheTest(U1, true); }
test/behavior/sizeof_and_typeof_stage1.zig
// To lay down that the true shape of truth is scientific- // or, what is the same thing, to maintain that truth has only the // Notion as the element of its existence - seems, I know, to contradict // a view which is in our time as prevalent as it is pretentious, // and to go against what that view implies. const std = @import("std"); const R_Instruction = @import("instruction.zig").R_Instruction; const I_Instruction = @import("instruction.zig").I_Instruction; const C_Instruction = @import("instruction.zig").C_Instruction; const PseudoInstruction = @import("instruction.zig").PseudoInstruction; const Register = @import("register.zig").Register; const vm = @import("vm.zig"); const string_to_enum = @import("util.zig").string_to_enum; const build_instruction = @import("util.zig").build_instruction; const register_to_address = @import("util.zig").register_to_address; const build_I_Instruction = @import("util.zig").build_I_Instruction; const build_C_Instruction = @import("util.zig").build_C_Instruction; const build_R_Instruction = @import("util.zig").build_R_Instruction; pub const Assembler = struct { const TagLocation = struct { location: u64, tag_name: []const u8, }; tokens: std.ArrayList([][]const u8), allocator: std.mem.Allocator, unresolved_tags_table: std.ArrayList(TagLocation), tag_locations_table: std.StringHashMap(u64), instruction_buffer: []u32, /// Split line into array of tokens by a space fn tokenize_line(allocator: std.mem.Allocator, line: []const u8) !std.ArrayList([]const u8) { var tokens = std.ArrayList([]const u8).init(allocator); var token_iterator = std.mem.tokenize(u8, line, " "); while (token_iterator.next()) |token| { try tokens.append(token); } return tokens; } /// Split a string into tokens fn tokenize_string(allocator: std.mem.Allocator, input: []const u8) !std.ArrayList([][]const u8) { var lines = std.ArrayList([][]const u8).init(allocator); var line_iterator = std.mem.tokenize(u8, input, "\n"); while (line_iterator.next()) |line| { try lines.append((try tokenize_line(allocator, line)).toOwnedSlice()); } // This leaves the slice allocated in memory and must be freed with deinit() return lines; } pub fn init(allocator: std.mem.Allocator, input: []const u8) !Assembler { var unresolved_tags_table = std.ArrayList(TagLocation).init(allocator); var tag_locations_table = std.StringHashMap(u64).init(allocator); const lines = try tokenize_string(allocator, input); return Assembler{ // This also leaves the slice allocated in memory and must be freed .tokens = lines, .allocator = allocator, .unresolved_tags_table = unresolved_tags_table, .tag_locations_table = tag_locations_table, .instruction_buffer = &[_]u32{}, }; } /// Parse line of tokens /// Returns a slcie of instructions fn parse_line(self: *Assembler, line: [][]const u8, location: u64) !?[]const u32 { var buffer = std.ArrayList(u32).init(self.allocator); const ins = line[0]; if (ins[0] == ";"[0]) { return null; } else if (ins[ins.len - 1] == ":"[0]) { try self.tag_locations_table.put(ins[0 .. ins.len - 1], location); return null; } else { var upper_ins: []const u8 = std.ascii.allocUpperString(self.allocator, ins) catch |e| blk: { std.log.err("Cannot upperate the string {s}", .{e}); break :blk "IGL"; }; defer self.allocator.free(upper_ins); if (string_to_enum(R_Instruction, upper_ins)) |r_ins| { if (line.len < 4) { std.log.err("Line: {s}\nR-Instruction must have at least 3 operands", .{line}); } const rd = register_to_address(line[1]).?; const rs1 = register_to_address(line[2]).?; const rs2 = register_to_address(line[3]).?; try buffer.append(build_R_Instruction(r_ins, rd, rs1, rs2)); } else if (string_to_enum(I_Instruction, upper_ins)) |i_ins| { if (line.len < 4) { std.log.err("Line: {s}\nR-Instruction must have at least 2 operands and a offset", .{line}); } const rd = register_to_address(line[1]).?; const rs1 = register_to_address(line[2]).?; //TODO: Check how int cast handles too big numbers const imm12 = @bitCast(u12, @intCast(i12, try self.label_to_offset(line[3], location))); try buffer.append(build_I_Instruction(i_ins, rd, rs1, imm12)); } else if (string_to_enum(C_Instruction, upper_ins)) |c_ins| { if (line.len < 3) { std.log.err("Line: {s}\nR-Instruction must have at least 1 operand and a offset", .{line}); } const rd = register_to_address(line[1]).?; const imm20 = @bitCast(u20, @intCast(i20, try self.label_to_offset(line[2], location))); try buffer.append(build_C_Instruction(c_ins, rd, imm20)); } else { if (string_to_enum(PseudoInstruction, upper_ins)) |pseudo_ins| { switch (pseudo_ins) { PseudoInstruction.NOP => { try buffer.append(build_instruction(I_Instruction.ADDI, "zero", "zero", null, 0)); }, PseudoInstruction.J => { if (line.len < 2) { std.log.err("Line: {s}\n J-pseudoinstruction must have atleast an offset", .{line}); } const offset = try self.label_to_offset(line[1], location); try buffer.append(build_instruction(C_Instruction.JR, "zero", null, null, @bitCast(u32, offset))); }, PseudoInstruction.JAL => { if (line.len < 3) { std.log.err("Line: {s}\n JAL-pseudoinstruction must have atleast rd and offset", .{line}); } const offset = try self.label_to_offset(line[2], location); try buffer.append(build_instruction(I_Instruction.JALR, line[1], "zero", null, @bitCast(u32, offset))); }, PseudoInstruction.CALL => { if (line.len < 2) { std.log.err("Line: {s}\n CALL-pseudoinstruction must have atleast an offset", .{line}); } const offset = try self.label_to_offset(line[2], location); const imm20 = @truncate(u20, @bitCast(u32, offset) >> 12); const imm12 = @truncate(u12, @bitCast(u32, offset)); try buffer.append(build_instruction(C_Instruction.AUIPC, "ra", null, null, imm20)); try buffer.append(build_instruction(I_Instruction.JALR, "ra", "ra", null, imm12)); }, PseudoInstruction.TAIL => { if (line.len < 2) { std.log.err("Line: {s}\n TAIL-pseudoinstruction must have atleast an offset", .{line}); } const offset = try self.label_to_offset(line[2], location); const imm20 = @truncate(u20, @bitCast(u32, offset) >> 12); const imm12 = @truncate(u12, @bitCast(u32, offset)); try buffer.append(build_instruction(C_Instruction.AUIPC, "t0", null, null, imm20)); try buffer.append(build_instruction(C_Instruction.JR, "t0", null, null, @as(u20, imm12))); }, PseudoInstruction.MV => { if (line.len < 3) { std.log.err("Line: {s}\n MV-pseudoinstruction must have atleast rd and rs", .{line}); } try buffer.append(build_instruction(I_Instruction.ADDI, line[1], line[2], null, 0)); }, PseudoInstruction.RET => { try buffer.append(build_instruction(C_Instruction.JR, "ra", null, null, 0)); }, PseudoInstruction.NOT => { try buffer.append(build_instruction(I_Instruction.XORI, line[1], line[2], null, @bitCast(u32, @as(i32, -1)))); }, PseudoInstruction.NEG => { try buffer.append(build_instruction(R_Instruction.SUB, line[1], "zero", line[2], null)); }, PseudoInstruction.GT => { try buffer.append(build_instruction(R_Instruction.LT, line[1], line[3], line[2], null)); }, PseudoInstruction.LE => { try buffer.append(build_instruction(R_Instruction.GE, line[1], line[3], line[2], null)); }, PseudoInstruction.LI => { // This pseudoinstruction expands either to one or two // instructions depending on the size of the immediate const imm = try self.label_to_offset(line[2], location); if (imm <= 2047 and imm >= -2048) { try buffer.append(build_instruction(I_Instruction.ADDI, line[1], "zero", null, @bitCast(u12, @intCast(i12, imm)))); } else { const imm20 = @truncate(u20, @bitCast(u32, imm) >> 12); const imm12 = @truncate(u12, @bitCast(u32, imm)); try buffer.append(build_instruction(C_Instruction.LUI, line[1], null, null, imm20)); try buffer.append(build_instruction(I_Instruction.ADDI, line[1], line[1], null, imm12)); } }, } } } return buffer.toOwnedSlice(); } } /// Converts immediate to number, either a label or a immediate /// Should support binary, hex and decadic numbers in '0xFFFF', '0b1111' or '9999' /// And label in the ':label' format fn label_to_offset(self: *Assembler, token: []const u8, call_location: u64) !i32 { if (token[0] == ':') { if (self.tag_locations_table.get(token[1..])) |location| { return @intCast(i32, @intCast(i65, location) - @intCast(i65, (call_location + 1))); } else { std.log.err("Label {s} not found! {s} item", .{ token, self.tag_locations_table.keyIterator().next().?.* }); return 0; } } else { return try std.fmt.parseInt(i32, token, 0); } } /// Convert instructions into bytecode and scan for labels pub fn assembly_pass(self: *Assembler) !void { var buffer = std.ArrayList(u32).init(self.allocator); for (self.tokens.items) |line| { if (try self.parse_line(line, buffer.items.len)) |parsed| { try buffer.appendSlice(parsed); self.allocator.free(parsed); } } self.instruction_buffer = buffer.toOwnedSlice(); } pub fn deinit(self: *Assembler) void { // deinit arrays self.tag_locations_table.deinit(); self.unresolved_tags_table.deinit(); // free slices // Free all the inner slices for (self.tokens.items) |token| { self.allocator.free(token); } // Free the outer slice self.tokens.deinit(); self.allocator.free(self.instruction_buffer); } }; test "ASM: Test tokenization" { const assembly = "add a0 a1 a2"; var assm = try Assembler.init(std.testing.allocator, assembly); defer assm.deinit(); const test_data: []const []const []const u8 = ([_][]const []const u8{([_]([]const u8){ "add", "a0", "a1", "a2" })[0..]})[0..]; for (assm.tokens.items) |line, line_index| { for (line) |_, index| { try std.testing.expectEqualStrings(test_data[line_index][index], line[index]); } } } test "ASM: simple program translation" { const assembly = "add a0 a1 a2\nhlt zero zero zero"; var assembler = try Assembler.init(std.testing.allocator, assembly); defer assembler.deinit(); const test_data: []const u32 = &[_]u32{ build_R_Instruction(R_Instruction.ADD, @enumToInt(Register.a0), @enumToInt(Register.a1), @enumToInt(Register.a2)), build_R_Instruction(R_Instruction.HLT, @enumToInt(Register.zero), @enumToInt(Register.zero), @enumToInt(Register.zero)), }; try assembler.assembly_pass(); try std.testing.expectEqualSlices(u32, test_data, assembler.instruction_buffer); } test "ASM: tag resolution" { const assembly = "add a0 a1 zero\ntag:\nj :tag"; const test_data: []const u32 = &[_]u32{ build_instruction(R_Instruction.ADD, "a0", "a1", "zero", 0), build_instruction(C_Instruction.JR, "zero", null, null, @bitCast(u32, @as(i32, -1))), }; var assembler = try Assembler.init(std.testing.allocator, assembly); defer assembler.deinit(); try assembler.assembly_pass(); try std.testing.expectEqualSlices(u32, test_data, assembler.instruction_buffer); }
src/asm.zig
const std = @import("std"); const mem = std.mem; const page_size = std.mem.page_size; const warn = std.debug.warn; const testing = std.testing; const adma = @import("adma"); test "Use adma" { var a = adma.AdmaAllocator.init(); defer a.deinit(); var aa = &a.allocator; var tmp: [50][]u8 = undefined; for (tmp) |_, i| { tmp[i] = try aa.alloc(u8, 2000); } for (tmp) |_, i| { aa.free(tmp[i]); } } test "Resize too large external buffer into adma chunk" { var a = adma.AdmaAllocator.init(); defer a.deinit(); var aa = &a.allocator; var buf = try aa.alloc(u8, 10000); // dont free var buf2 = try aa.realloc(buf, 1000); testing.expect(buf2.len == adma.AdmaAllocator.largest_alloc + 1); aa.free(buf2); } test "Resize adma chunk to another adma chunk" { var a = adma.AdmaAllocator.init(); defer a.deinit(); var aa = &a.allocator; var buf = try aa.alloc(u8, 1000); // dont free buf = try aa.realloc(buf, 2048); testing.expect(buf.len == adma.AdmaAllocator.largest_alloc); aa.free(buf); } test "Allocate chunk then resize into external buffer" { var a = adma.AdmaAllocator.init(); defer a.deinit(); var aa = &a.allocator; var buf = try aa.alloc(u8, 1000); // dont free var buf2 = try aa.alloc(u8, 1000); defer aa.free(buf2); std.mem.set(u8, buf, 1); std.mem.set(u8, buf2, 1); var buf3 = try aa.realloc(buf, 10000); defer aa.free(buf3); testing.expectEqualSlices(u8, buf3[0..1000], buf2); } test "Wrapping adma with an arena allocator" { var a = adma.AdmaAllocator.init(); defer a.deinit(); var arena = std.heap.ArenaAllocator.init(&a.allocator); defer arena.deinit(); var arenaal = &arena.allocator; var buf = try arenaal.alloc(u8, 50); defer arenaal.free(buf); } test "arraylist" { var a = adma.AdmaAllocator.init(); defer a.deinit(); var aa = &a.allocator; var list = std.ArrayList(usize).init(aa); defer list.deinit(); try list.ensureCapacity(5000); var x: usize = 0; while (x != 10000) : (x += 1) { _ = try list.append(x); } } fn threadFree(buf: []u8) !void { var a = adma.AdmaAllocator.init(); defer a.deinit(); var aa = &a.allocator; aa.free(buf); } test "free remote chunk" { if (std.builtin.single_threaded == true) return; var a = adma.AdmaAllocator.init(); defer a.deinit(); var aa = &a.allocator; var buf = try aa.alloc(u8, 1000); var buf2 = try aa.alloc(u8, 1000); var thd = try std.Thread.spawn(buf, threadFree); thd.wait(); var buf3 = try aa.alloc(u8, 1000); aa.free(buf2); // should also free buf1 aa.free(buf3); } test "small allocations - free in same order" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var list = std.ArrayList(*u64).init(std.testing.allocator); defer list.deinit(); var i: usize = 0; while (i < 513) : (i += 1) { const ptr = try allocator.create(u64); try list.append(ptr); } for (list.items) |ptr| { allocator.destroy(ptr); } } test "small allocations - free in reverse order" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var list = std.ArrayList(*u64).init(std.testing.allocator); defer list.deinit(); var i: usize = 0; while (i < 513) : (i += 1) { const ptr = try allocator.create(u64); try list.append(ptr); } while (list.popOrNull()) |ptr| { allocator.destroy(ptr); } } test "large allocations" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; const ptr1 = try allocator.alloc(u64, 42768); const ptr2 = try allocator.alloc(u64, 52768); allocator.free(ptr1); const ptr3 = try allocator.alloc(u64, 62768); allocator.free(ptr3); allocator.free(ptr2); } test "realloc" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var slice = try allocator.alignedAlloc(u8, @alignOf(u32), 1); defer allocator.free(slice); slice[0] = 0x12; // This reallocation should keep its pointer address. const old_slice = slice; slice = try allocator.realloc(slice, 2); std.testing.expect(old_slice.ptr == slice.ptr); std.testing.expect(slice[0] == 0x12); slice[1] = 0x34; // This requires upgrading to a larger size class slice = try allocator.realloc(slice, 17); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[1] == 0x34); } test "shrink" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var slice = try allocator.alloc(u8, 20); defer allocator.free(slice); mem.set(u8, slice, 0x11); slice = allocator.shrink(slice, 17); for (slice) |b| { std.testing.expect(b == 0x11); } slice = allocator.shrink(slice, 16); for (slice) |b| { std.testing.expect(b == 0x11); } } test "large object - grow" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var slice1 = try allocator.alloc(u8, page_size * 2 - 20); defer allocator.free(slice1); const old = slice1; slice1 = try allocator.realloc(slice1, page_size * 2 - 10); std.testing.expect(slice1.ptr == old.ptr); slice1 = try allocator.realloc(slice1, page_size * 2); std.testing.expect(slice1.ptr == old.ptr); slice1 = try allocator.realloc(slice1, page_size * 2 + 1); } test "realloc small object to large object" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var slice = try allocator.alloc(u8, 70); defer allocator.free(slice); slice[0] = 0x12; slice[60] = 0x34; // This requires upgrading to a large object const large_object_size = page_size * 2 + 50; slice = try allocator.realloc(slice, large_object_size); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[60] == 0x34); } test "shrink large object to large object" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var slice = try allocator.alloc(u8, page_size * 2 + 50); defer allocator.free(slice); slice[0] = 0x12; slice[60] = 0x34; slice = try allocator.resize(slice, page_size * 2 + 1); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[60] == 0x34); slice = allocator.shrink(slice, page_size * 2 + 1); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[60] == 0x34); slice = try allocator.realloc(slice, page_size * 2); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[60] == 0x34); } test "shrink large object to large object with larger alignment" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var debug_buffer: [1000]u8 = undefined; const debug_allocator = &std.heap.FixedBufferAllocator.init(&debug_buffer).allocator; const alloc_size = page_size * 2 + 50; var slice = try allocator.alignedAlloc(u8, 16, alloc_size); defer allocator.free(slice); const big_alignment: usize = switch (std.Target.current.os.tag) { .windows => page_size * 32, // Windows aligns to 64K. else => page_size * 2, }; // This loop allocates until we find a page that is not aligned to the big // alignment. Then we shrink the allocation after the loop, but increase the // alignment to the higher one, that we know will force it to realloc. var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); while (mem.isAligned(@ptrToInt(slice.ptr), big_alignment)) { try stuff_to_free.append(slice); slice = try allocator.alignedAlloc(u8, 16, alloc_size); } while (stuff_to_free.popOrNull()) |item| { allocator.free(item); } slice[0] = 0x12; slice[60] = 0x34; slice = try allocator.reallocAdvanced(slice, big_alignment, alloc_size / 2, .exact); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[60] == 0x34); } test "realloc large object to small object" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var slice = try allocator.alloc(u8, page_size * 2 + 50); defer allocator.free(slice); slice[0] = 0x12; slice[16] = 0x34; slice = try allocator.realloc(slice, 19); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[16] == 0x34); } test "non-page-allocator backing allocator" { var adm = try adma.AdmaAllocator.initWith(std.testing.allocator, 0); defer adm.deinit(); const allocator = &adm.allocator; const ptr = try allocator.create(i32); defer allocator.destroy(ptr); } test "realloc large object to larger alignment" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; var debug_buffer: [1000]u8 = undefined; const debug_allocator = &std.heap.FixedBufferAllocator.init(&debug_buffer).allocator; var slice = try allocator.alignedAlloc(u8, 16, page_size * 2 + 50); defer allocator.free(slice); const big_alignment: usize = switch (std.Target.current.os.tag) { .windows => page_size * 32, // Windows aligns to 64K. else => page_size * 2, }; // This loop allocates until we find a page that is not aligned to the big alignment. var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); while (mem.isAligned(@ptrToInt(slice.ptr), big_alignment)) { try stuff_to_free.append(slice); slice = try allocator.alignedAlloc(u8, 16, page_size * 2 + 50); } while (stuff_to_free.popOrNull()) |item| { allocator.free(item); } slice[0] = 0x12; slice[16] = 0x34; slice = try allocator.reallocAdvanced(slice, 32, page_size * 2 + 100, .exact); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[16] == 0x34); slice = try allocator.reallocAdvanced(slice, 32, page_size * 2 + 25, .exact); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[16] == 0x34); slice = try allocator.reallocAdvanced(slice, big_alignment, page_size * 2 + 100, .exact); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[16] == 0x34); } test "large object shrinks to small but allocation fails during shrink" { var failing_allocator = std.testing.FailingAllocator.init(std.heap.page_allocator, 3); var adm = try adma.AdmaAllocator.initWith(&failing_allocator.allocator, 0); defer adm.deinit(); const allocator = &adm.allocator; var slice = try allocator.alloc(u8, page_size * 2 + 50); defer allocator.free(slice); slice[0] = 0x12; slice[3] = 0x34; // Next allocation will fail in the backing allocator of the GeneralPurposeAllocator slice = allocator.shrink(slice, 4); std.testing.expect(slice[0] == 0x12); std.testing.expect(slice[3] == 0x34); } test "objects of size 1024 and 2048" { var adm = adma.AdmaAllocator.init(); defer adm.deinit(); const allocator = &adm.allocator; const slice = try allocator.alloc(u8, 1025); const slice2 = try allocator.alloc(u8, 3000); allocator.free(slice); allocator.free(slice2); }
tests/adma_tests.zig
usingnamespace @import("psptypes.zig"); test "" { @import("std").meta.refAllDecls(@This()); } pub const AtracError = enum(u32) { ParamFail = (0x80630001), ApiFail = (0x80630002), NoAtracid = (0x80630003), BadCodectype = (0x80630004), BadAtracid = (0x80630005), UnknownFormat = (0x80630006), UnmatchFormat = (0x80630007), BadData = (0x80630008), AlldataIsOnmemory = (0x80630009), UnsetData = (0x80630010), ReadsizeIsTooSmall = (0x80630011), NeedSecondBuffer = (0x80630012), ReadsizeOverBuffer = (0x80630013), Not4byteAlignment = (0x80630014), BadSample = (0x80630015), WritebyteFirstBuffer = (0x80630016), WritebyteSecondBuffer = (0x80630017), AddDataIsTooBig = (0x80630018), UnsetParam = (0x80630021), NoneedSecondBuffer = (0x80630022), NodataInBuffer = (0x80630023), AlldataWasDecoded = (0x80630024), }; fn intToError(res: c_int) !void { @setRuntimeSafety(false); if (res < 0) { var translated = @bitCast(u32, res); switch (@intToEnum(AtracError, res)) { ParamFail => { return error.ParamFail; }, ApiFail => { return error.ApiFail; }, NoAtracid => { return error.NoAtracid; }, BadCodectype => { return error.BadCodectype; }, BadAtracid => { return error.BadAtracid; }, UnknownFormat => { return error.UnknownFormat; }, UnmatchFormat => { return error.UnmatchFormat; }, BadData => { return error.BadData; }, AlldataIsOnmemory => { return error.AlldataIsOnmemory; }, UnsetData => { return error.UnsetData; }, ReadSizeIsTooSmall => { return error.ReadSizeIsTooSmall; }, NeedSecondBuffer => { return error.NeedSecondBuffer; }, ReadSizeOverBuffer => { return error.ReadSizeOverBuffer; }, Not4byteAlignment => { return error.Not4byteAlignment; }, BadSample => { return error.BadSample; }, WriteByteFirstBuffer => { return error.WriteByteFirstBuffer; }, WriteByteSecondBuffer => { return error.WriteByteSecondBuffer; }, AddDataIsTooBig => { return error.AddDataIsTooBig; }, UnsetParam => { return error.UnsetParam; }, NoNeedSecondBuffer => { return error.NoNeedSecondBuffer; }, NoDataInBuffer => { return error.NoDataInBuffer; }, AllDataWasDecoded => { return error.AllDataWasDecoded; }, } } } //Buffer information pub const PspBufferInfo = extern struct { pucWritePositionFirstBuf: [*c]u8, uiWritableByteFirstBuf: u32, uiMinWriteByteFirstBuf: u32, uiReadPositionFirstBuf: u32, pucWritePositionSecondBuf: [*c]u8, uiWritableByteSecondBuf: u32, uiMinWriteByteSecondBuf: u32, uiReadPositionSecondBuf: u32, }; pub extern fn sceAtracGetAtracID(uiCodecType: u32) c_int; // Codec ID Enumeration pub const AtracCodecType = enum(u32) { At3Plus = 0x1000, At3 = 0x1001, }; // Gets the ID for a certain codec. // Can return error for invalid ID. pub fn atracGetAtracID(uiCodecType: AtracCodecType) !i32 { var res = sceAtracGetAtracID(@enumToInt(uiCodecType)); try intToError(res); return res; } // Creates a new Atrac ID from the specified data // // @param buf - the buffer holding the atrac3 data, including the RIFF/WAVE header. // @param bufsize - the size of the buffer pointed by buf // // @return the new atrac ID, or < 0 on error pub extern fn sceAtracSetDataAndGetID(buf: ?*c_void, bufsize: SceSize) c_int; pub fn atracSetDataAndGetID(buf: *c_void, bufSize: usize) !u32 { var res = sceAtracSetDataAndGetID(buf, bufSize); try intToError(res); return res; } // Decode a frame of data. // // @param atracID - the atrac ID // @param outSamples - pointer to a buffer that receives the decoded data of the current frame // @param outN - pointer to a integer that receives the number of audio samples of the decoded frame // @param outEnd - pointer to a integer that receives a boolean value indicating if the decoded frame is the last one // @param outRemainFrame - pointer to a integer that receives either -1 if all at3 data is already on memory, // or the remaining (not decoded yet) frames at memory if not all at3 data is on memory // // // @return < 0 on error, otherwise 0 pub extern fn sceAtracDecodeData(atracID: u32, outSamples: [*c]u16, outN: [*c]c_int, outEnd: [*c]c_int, outRemainFrame: [*c]c_int) c_int; pub fn atracDecodeData(atracID: u32, outSamples: []u16, outN: []i32, outEnd: []i32, outRemainFrame: []i32) !void { var res = sceAtracDecodeData(atracID, outSamples, outN, outEnd, outRemainFrame); try intToError(res); } // Gets the remaining (not decoded) number of frames // // @param atracID - the atrac ID // @param outRemainFrame - pointer to a integer that receives either -1 if all at3 data is already on memory, // or the remaining (not decoded yet) frames at memory if not all at3 data is on memory // // @return < 0 on error, otherwise 0 pub extern fn sceAtracGetRemainFrame(atracID: u32, outRemainFrame: [*c]c_int) c_int; pub fn atracGetRemainFrame(atracID: u32, outRemainFrame: []i32) !void { var res = sceAtracDecodeData(atracID, outSamples, outN, outEnd, outRemainFrame); try intToError(res); } // Gets the info of stream data // @param atracID - the atrac ID // @param writePointer - Pointer to where to read the atrac data // @param availableBytes - Number of bytes available at the writePointer location // @param readOffset - Offset where to seek into the atrac file before reading // // @return < 0 on error, otherwise 0 pub extern fn sceAtracGetStreamDataInfo(atracID: u32, writePointer: [*c][*c]u8, availableBytes: [*c]u32, readOffset: [*c]u32) c_int; pub fn atracGetStreamDataInfo(atracID: u32, writePointer: [*c][*c]u8, availableBytes: [*c]u32, readOffset: [*c]u32) !void { var res = sceAtracGetStreamDataInfo(atracID, writePointer, availableBytes, readOffset); try intToError(res); } // Adds to stream data // @param atracID - the atrac ID // @param bytesToAdd - Number of bytes read into location given by sceAtracGetStreamDataInfo(). // // @return < 0 on error, otherwise 0 pub extern fn sceAtracAddStreamData(atracID: u32, bytesToAdd: c_uint) c_int; pub fn atracAddStreamData(atracID: u32, bytesToAdd: u32) !void { var res = sceAtracAddStreamData(atracID, bytesToAdd); try intToError(res); } // Gets the bitrate. // // @param atracID - the atracID // @param outBitrate - pointer to a integer that receives the bitrate in kbps // // @return < 0 on error, otherwise 0 pub extern fn sceAtracGetBitrate(atracID: u32, outBitrate: [*c]c_int) c_int; pub fn atracGetBitrate(atracID: u32, outBitrate: [*c]c_int) !void { var res = sceAtracGetBitrate(atracID, outBitrate); try intToError(res); } // Sets the number of loops for this atrac ID // // @param atracID - the atracID // @param nloops - the number of loops to set // // @return < 0 on error, otherwise 0 pub extern fn sceAtracSetLoopNum(atracID: u32, nloops: c_int) c_int; pub fn atracSetLoopNum(atracID: u32, nloops: c_int) !void { var res = atracSetLoopNum(atracID, nloops); try intToError(res); } // Releases an atrac ID // // @param atracID - the atrac ID to release // // @return < 0 on error pub extern fn sceAtracReleaseAtracID(atracID: u32) c_int; pub fn atracReleaseAtracID(atracID: u32) !i32 { var res = sceAtracReleaseAtracID(atracID); try intToError(res); return res; } //Gets the number of samples of the next frame to be decoded. // //@param atracID - the atrac ID //@param outN - pointer to receives the number of samples of the next frame. // //@return < 0 on error, otherwise 0 pub extern fn sceAtracGetNextSample(atracID: u32, outN: [*c]c_int) c_int; pub fn atracGetNextSample(atracID: u32, outN: [*c]c_int) !void { var res = sceAtracGetNextSample(atracID, outN); try intToError(res); } //These are undocumented - thus I cannot wrap them pub extern fn sceAtracGetMaxSample(atracID: c_int, outMax: [*c]c_int) c_int; pub extern fn sceAtracGetBufferInfoForReseting(atracID: c_int, uiSample: u32, pBufferInfo: [*c]PspBufferInfo) c_int; pub extern fn sceAtracGetChannel(atracID: c_int, puiChannel: [*c]u32) c_int; pub extern fn sceAtracGetInternalErrorInfo(atracID: c_int, piResult: [*c]c_int) c_int; pub extern fn sceAtracGetLoopStatus(atracID: c_int, piLoopNum: [*c]c_int, puiLoopStatus: [*c]u32) c_int; pub extern fn sceAtracGetNextDecodePosition(atracID: c_int, puiSamplePosition: [*c]u32) c_int; pub extern fn sceAtracGetSecondBufferInfo(atracID: c_int, puiPosition: [*c]u32, puiDataByte: [*c]u32) c_int; pub extern fn sceAtracGetSoundSample(atracID: c_int, piEndSample: [*c]c_int, piLoopStartSample: [*c]c_int, piLoopEndSample: [*c]c_int) c_int; pub extern fn sceAtracResetPlayPosition(atracID: c_int, uiSample: u32, uiWriteByteFirstBuf: u32, uiWriteByteSecondBuf: u32) c_int; pub extern fn sceAtracSetData(atracID: c_int, pucBufferAddr: [*c]u8, uiBufferByte: u32) c_int; pub extern fn sceAtracSetHalfwayBuffer(atracID: c_int, pucBufferAddr: [*c]u8, uiReadByte: u32, uiBufferByte: u32) c_int; pub extern fn sceAtracSetHalfwayBufferAndGetID(pucBufferAddr: [*c]u8, uiReadByte: u32, uiBufferByte: u32) c_int; pub extern fn sceAtracSetSecondBuffer(atracID: c_int, pucSecondBufferAddr: [*c]u8, uiSecondBufferByte: u32) c_int;
src/psp/sdk/pspatrac3.zig
const getty = @import("getty"); const std = @import("std"); const eql = std.mem.eql; const testing = std.testing; const expect = testing.expect; const expectEqual = testing.expectEqual; const expectEqualSlices = testing.expectEqualSlices; const expectError = testing.expectError; pub const de = struct { pub fn free(allocator: std.mem.Allocator, value: anytype) void { return getty.de.free(allocator, value); } }; pub const Deserializer = @import("de/deserializer.zig").Deserializer; pub fn fromDeserializer(comptime T: type, d: *Deserializer) !T { const value = try getty.deserialize(d.allocator, T, d.deserializer()); errdefer if (d.allocator) |alloc| de.free(alloc, value); try d.end(); return value; } pub fn fromDeserializerWith(comptime T: type, d: *Deserializer, _de: anytype) !T { const value = try getty.deserializeWith(d.allocator, T, d.deserializer(), _de); errdefer if (d.allocator) |alloc| de.free(alloc, value); try d.end(); return value; } pub fn fromSlice(allocator: ?std.mem.Allocator, comptime T: type, slice: []const u8) !T { var d = if (allocator) |alloc| Deserializer.withAllocator(alloc, slice) else Deserializer.init(slice); return fromDeserializer(T, &d); } pub fn fromSliceWith(allocator: ?std.mem.Allocator, comptime T: type, slice: []const u8, _de: anytype) !T { var d = if (allocator) |alloc| Deserializer.withAllocator(alloc, slice) else Deserializer.init(slice); return fromDeserializerWith(T, &d, _de); } test "array" { try expectEqual([0]bool{}, try fromSlice(null, [0]bool, "[]")); try expectEqual([1]bool{true}, try fromSlice(null, [1]bool, "[true]")); try expectEqual([2]bool{ true, false }, try fromSlice(null, [2]bool, "[true,false]")); try expectEqual([5]i32{ 1, 2, 3, 4, 5 }, try fromSlice(null, [5]i32, "[1,2,3,4,5]")); try expectEqual([2][1]i32{ .{1}, .{2} }, try fromSlice(null, [2][1]i32, "[[1],[2]]")); try expectEqual([2][1][3]i32{ .{.{ 1, 2, 3 }}, .{.{ 4, 5, 6 }} }, try fromSlice(null, [2][1][3]i32, "[[[1,2,3]],[[4,5,6]]]")); } test "array list" { // scalar child { const got = try fromSlice(testing.allocator, std.ArrayList(u8), "[1,2,3,4,5]"); defer got.deinit(); try expectEqual(std.ArrayList(u8), @TypeOf(got)); try expect(eql(u8, &[_]u8{ 1, 2, 3, 4, 5 }, got.items)); } // array list child { const got = try fromSlice(testing.allocator, std.ArrayList(std.ArrayList(u8)), "[[1, 2],[3,4]]"); defer de.free(testing.allocator, got); try expectEqual(std.ArrayList(std.ArrayList(u8)), @TypeOf(got)); try expectEqual(std.ArrayList(u8), @TypeOf(got.items[0])); try expectEqual(std.ArrayList(u8), @TypeOf(got.items[1])); try expect(eql(u8, &[_]u8{ 1, 2 }, got.items[0].items)); try expect(eql(u8, &[_]u8{ 3, 4 }, got.items[1].items)); } } test "bool" { try expectEqual(true, try fromSlice(null, bool, "true")); try expectEqual(false, try fromSlice(null, bool, "false")); } test "enum" { const Enum = enum { foo, bar }; try expectEqual(Enum.foo, try fromSlice(null, Enum, "0")); try expectEqual(Enum.bar, try fromSlice(null, Enum, "1")); try expectEqual(Enum.foo, try fromSlice(testing.allocator, Enum, "\"foo\"")); try expectEqual(Enum.bar, try fromSlice(testing.allocator, Enum, "\"bar\"")); } test "float" { try expectEqual(@as(f32, std.math.f32_min), try fromSlice(null, f32, "1.17549435082228750797e-38")); try expectEqual(@as(f32, std.math.f32_max), try fromSlice(null, f32, "3.40282346638528859812e+38")); try expectEqual(@as(f64, std.math.f64_min), try fromSlice(null, f64, "2.2250738585072014e-308")); try expectEqual(@as(f64, std.math.f64_max), try fromSlice(null, f64, "1.79769313486231570815e+308")); try expectEqual(@as(f32, 1.0), try fromSlice(null, f32, "1")); try expectEqual(@as(f64, 2.0), try fromSlice(null, f64, "2")); } test "int" { try expectEqual(@as(u8, std.math.maxInt(u8)), try fromSlice(null, u8, "255")); try expectEqual(@as(u32, std.math.maxInt(u32)), try fromSlice(null, u32, "4294967295")); try expectEqual(@as(u64, std.math.maxInt(u64)), try fromSlice(null, u64, "18446744073709551615")); try expectEqual(@as(i8, std.math.maxInt(i8)), try fromSlice(null, i8, "127")); try expectEqual(@as(i32, std.math.maxInt(i32)), try fromSlice(null, i32, "2147483647")); try expectEqual(@as(i64, std.math.maxInt(i64)), try fromSlice(null, i64, "9223372036854775807")); try expectEqual(@as(i8, std.math.minInt(i8)), try fromSlice(null, i8, "-128")); try expectEqual(@as(i32, std.math.minInt(i32)), try fromSlice(null, i32, "-2147483648")); try expectEqual(@as(i64, std.math.minInt(i64)), try fromSlice(null, i64, "-9223372036854775808")); // TODO: higher-bit conversions from float don't seem to work. } test "optional" { try expectEqual(@as(?bool, null), try fromSlice(null, ?bool, "null")); try expectEqual(@as(?bool, true), try fromSlice(null, ?bool, "true")); } test "pointer" { // one level of indirection { const value = try fromSlice(testing.allocator, *bool, "true"); defer de.free(testing.allocator, value); try expectEqual(true, value.*); } // two levels of indirection { const value = try fromSlice(testing.allocator, **[]const u8, "\"Hello, World!\""); defer de.free(testing.allocator, value); try expectEqualSlices(u8, "Hello, World!", value.*.*); } // enum { const T = enum { foo, bar }; // Tag value { const value = try fromSlice(testing.allocator, *T, "0"); defer de.free(testing.allocator, value); try expectEqual(T.foo, value.*); } // Tag name { const value = try fromSlice(testing.allocator, *T, "\"bar\""); defer de.free(testing.allocator, value); try expectEqual(T.bar, value.*); } } // optional { // some { const value = try fromSlice(testing.allocator, *?bool, "true"); defer de.free(testing.allocator, value); try expectEqual(true, value.*.?); } // none { const value = try fromSlice(testing.allocator, *?bool, "null"); defer de.free(testing.allocator, value); try expectEqual(false, value.* orelse false); } } // sequence { const value = try fromSlice(testing.allocator, *[3]i8, "[1,2,3]"); defer de.free(testing.allocator, value); try expectEqual([_]i8{ 1, 2, 3 }, value.*); } // struct { const T = struct { x: i32, y: []const u8, z: *[]const u8 }; const value = try fromSlice(testing.allocator, *T, \\{"x":1,"y":"hello","z":"world"} ); defer de.free(testing.allocator, value); try expectEqual(@as(i32, 1), value.*.x); try expectEqualSlices(u8, "hello", value.*.y); try expectEqualSlices(u8, "world", value.*.z.*); } // void { const value = try fromSlice(testing.allocator, *void, "null"); defer de.free(testing.allocator, value); try expectEqual({}, value.*); } } test "slice (string)" { // Zig string const got = try fromSlice(testing.allocator, []const u8, "\"Hello, World!\""); defer de.free(testing.allocator, got); try expect(eql(u8, "Hello, World!", got)); // Non-zig string try expectError(error.InvalidType, fromSlice(testing.allocator, []i8, "\"Hello, World!\"")); } test "slice (non-string)" { // scalar child { const got = try fromSlice(testing.allocator, []i32, "[1,2,3,4,5]"); defer de.free(testing.allocator, got); try expectEqual([]i32, @TypeOf(got)); try expect(eql(i32, &[_]i32{ 1, 2, 3, 4, 5 }, got)); } // array child { const wants = .{ [3]u32{ 1, 2, 3 }, [3]u32{ 4, 5, 6 }, [3]u32{ 7, 8, 9 }, }; const got = try fromSlice(testing.allocator, [][3]u32, \\[[1,2,3],[4,5,6],[7,8,9]] ); defer de.free(testing.allocator, got); try expectEqual([][3]u32, @TypeOf(got)); inline for (wants) |want, i| try expect(eql(u32, &want, &got[i])); } // slice child { const wants = .{ [_]i8{ 1, 2, 3 }, [_]i8{ 4, 5 }, [_]i8{6}, [_]i8{ 7, 8, 9, 10 }, }; const got = try fromSlice(testing.allocator, [][]i8, \\[[1,2,3],[4,5],[6],[7,8,9,10]] ); defer de.free(testing.allocator, got); try expectEqual([][]i8, @TypeOf(got)); inline for (wants) |want, i| try expect(eql(i8, &want, got[i])); } // string child { const wants = .{ "Foo", "Bar", "Foobar", }; const got = try fromSlice(testing.allocator, [][]const u8, \\["Foo","Bar","Foobar"] ); defer de.free(testing.allocator, got); try expectEqual([][]const u8, @TypeOf(got)); inline for (wants) |want, i| { try expect(eql(u8, want, got[i])); } } } test "struct" { const got = try fromSlice(testing.allocator, struct { x: i32, y: []const u8 }, \\{"x":1,"y":"Hello"} ); defer de.free(testing.allocator, got); try expectEqual(@as(i32, 1), got.x); try expect(eql(u8, "Hello", got.y)); } test "void" { try expectEqual({}, try fromSlice(null, void, "null")); try testing.expectError(error.InvalidType, fromSlice(null, void, "true")); try testing.expectError(error.InvalidType, fromSlice(null, void, "1")); } test { testing.refAllDecls(@This()); }
src/de.zig
const std = @import("std"); const Mutex = std.Thread.Mutex; pub fn init(alloc: std.mem.Allocator) void { std.debug.assert(allocator == null and allocations == null); allocator = alloc; allocations = std.AutoHashMap(usize, usize).init(allocator.?); allocations.?.ensureTotalCapacity(32) catch unreachable; zmesh_setAllocator(zmeshAlloc, zmeshClearAlloc, zmeshReAlloc, zmeshFree); meshopt_setAllocator(zmeshAlloc, zmeshFree); } pub fn deinit() void { allocations.?.deinit(); allocations = null; allocator = null; } extern fn zmesh_setAllocator( malloc: fn (size: usize) callconv(.C) ?*anyopaque, calloc: fn (num: usize, size: usize) callconv(.C) ?*anyopaque, realloc: fn (ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque, free: fn (ptr: ?*anyopaque) callconv(.C) void, ) void; extern fn meshopt_setAllocator( allocate: fn (size: usize) callconv(.C) ?*anyopaque, deallocate: fn (ptr: ?*anyopaque) callconv(.C) void, ) void; var allocator: ?std.mem.Allocator = null; var allocations: ?std.AutoHashMap(usize, usize) = null; var mutex: Mutex = .{}; export fn zmeshAlloc(size: usize) callconv(.C) ?*anyopaque { mutex.lock(); defer mutex.unlock(); var slice = allocator.?.allocBytes( @sizeOf(usize), size, 0, @returnAddress(), ) catch @panic("zmesh: out of memory"); allocations.?.put(@ptrToInt(slice.ptr), size) catch @panic("zmesh: out of memory"); return slice.ptr; } export fn zmeshClearAlloc(num: usize, size: usize) callconv(.C) ?*anyopaque { const ptr = zmeshAlloc(num * size); if (ptr != null) { @memset(@ptrCast([*]u8, ptr), 0, num * size); return ptr; } return null; } pub export fn zmeshAllocUser(user: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque { _ = user; return zmeshAlloc(size); } export fn zmeshReAlloc(ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque { mutex.lock(); defer mutex.unlock(); const old_len = if (ptr != null) allocations.?.get(@ptrToInt(ptr.?)).? else 0; var old_mem = if (old_len > 0) @ptrCast([*]u8, ptr)[0..old_len] else @as([*]u8, undefined)[0..0]; var slice = allocator.?.reallocBytes( old_mem, @sizeOf(usize), size, @sizeOf(usize), 0, @returnAddress(), ) catch @panic("zmesh: out of memory"); if (ptr != null) { const removed = allocations.?.remove(@ptrToInt(ptr.?)); std.debug.assert(removed); } allocations.?.put(@ptrToInt(slice.ptr), size) catch @panic("zmesh: out of memory"); return slice.ptr; } export fn zmeshFree(ptr: ?*anyopaque) callconv(.C) void { if (ptr != null) { mutex.lock(); defer mutex.unlock(); const size = allocations.?.fetchRemove(@ptrToInt(ptr.?)).?.value; const slice = @ptrCast([*]u8, ptr.?)[0..size]; allocator.?.free(slice); } } pub export fn zmeshFreeUser(user: ?*anyopaque, ptr: ?*anyopaque) callconv(.C) void { _ = user; zmeshFree(ptr); }
libs/zmesh/src/memory.zig
const std = @import("std"); const rec = @import("./record.zig"); const Op = @import("./ops.zig").Op; const Record = rec.Record; const RecordError = rec.RecordError; const expect = std.testing.expect; const lsmtree = @import("main.zig"); pub const WalError = error{ MaxSizeReached, } || RecordError || std.mem.Allocator.Error; pub fn Wal(comptime size_in_bytes: usize) type { return struct { const Self = @This(); current_size: usize, max_size: usize, total_records: usize, mem: []*Record, allocator: *std.mem.Allocator, // Start a new in memory WAL using the provided allocator // REMEMBER to call `deinit()` once you are done with the iterator, // for example after persisting it to disk. // CALL `deinitCascade()` if you want also to free all the records // stored in it. pub fn init(allocator: *std.mem.Allocator) !*Self { var wal = try allocator.create(Wal(size_in_bytes)); wal.current_size = 0; wal.total_records = 0; wal.max_size = size_in_bytes; wal.allocator = allocator; wal.mem = try allocator.alloc(*Record, size_in_bytes / Record.minimum_size()); return wal; } // Add a new record in order to the in memory WAL pub fn add_record(self: *Self, r: *Record) WalError!void { const record_size: usize = r.bytesLen(); // Check if there's available space in the WAL if ((self.current_size + record_size > size_in_bytes) or (self.total_records >= self.mem.len)) { return WalError.MaxSizeReached; } self.mem[self.total_records] = r; self.total_records += 1; self.current_size += record_size; } // Compare the provided keys with the ones in memory and // returns the last record that is found (or none if none is found) pub fn find(self: *Self, key_to_find: []const u8) ?*Record { var iter = self.backwards_iterator(); while (iter.next()) |r| { if (std.mem.eql(u8, r.key, key_to_find)) { return r; } } return null; } // Sort the list of records in lexicographical order pub fn sort(self: *Self) void { std.sort.sort(*Record, self.mem[0..self.total_records], {}, lexicographical_compare); } // Creates a forward iterator to go through the wal. pub fn iterator(self: *Self) RecordIterator { const iter = RecordIterator.init(self.mem[0..self.total_records]); return iter; } // Creates a forward iterator to go through the wal. pub fn backwards_iterator(self: *Self) RecordBackwardIterator { const iter = RecordBackwardIterator.init(self.mem[0..self.total_records]); return iter; } // Frees the array that contains the Records but leaving them untouched pub fn deinit(self: *Self) void { self.allocator.free(self.mem); self.allocator.destroy(self); } // Frees the array that contains the Records and the Records themselves. pub fn deinit_cascade(self: *Self) void { var iter = self.iterator(); while (iter.next()) |r| { r.deinit(); } self.deinit(); } fn lexicographical_compare(_: void, lhs: *Record, rhs: *Record) bool { const smaller_size: usize = if (lhs.key.len > rhs.key.len) rhs.key.len else lhs.key.len; var i: usize = 0; while (i < smaller_size) { if (lhs.key[i] == rhs.key[i]) { i += 1; continue; } else if (lhs.key[i] > rhs.key[i]) { return false; } else { return true; } } // if all chars were equal, return shortest as true return (lhs.key.len < rhs.key.len); } const RecordIterator = struct { pos: usize = 0, records: []*Record, pub fn init(records: []*Record) RecordIterator { return RecordIterator{ .records = records, }; } pub fn next(self: *RecordIterator) ?*Record { if (self.pos == self.records.len) { return null; } const r = self.records[self.pos]; self.pos += 1; return r; } }; const RecordBackwardIterator = struct { pos: usize = 0, records: []*Record, finished: bool = false, pub fn init(records: []*Record) RecordBackwardIterator { return RecordBackwardIterator{ .records = records, .pos = records.len - 1, }; } pub fn next(self: *RecordBackwardIterator) ?*Record { if (self.pos == 0 and self.finished) { return null; } const r = self.records[self.pos]; if (self.pos != 0) { self.pos -= 1; } else { self.finished = true; } return r; } }; }; } test "wal.iterator backwards" { var alloc = std.testing.allocator; var wal = try Wal(100).init(&alloc); defer wal.deinit_cascade(); try wal.add_record(try Record.init("hell0", "world", Op.Create, &alloc)); try wal.add_record(try Record.init("hell1", "world", Op.Create, &alloc)); try wal.add_record(try Record.init("hell2", "world", Op.Create, &alloc)); try wal.add_record(try Record.init("hell0", "world0", Op.Create, &alloc)); var iter = wal.backwards_iterator(); var next = iter.next().?; try std.testing.expectEqualStrings("world0", next.value); } test "wal.iterator" { var alloc = std.testing.allocator; var wal = try Wal(100).init(&alloc); defer wal.deinit_cascade(); try wal.add_record(try Record.init("hell0", "world", Op.Create, &alloc)); try wal.add_record(try Record.init("hell1", "world", Op.Create, &alloc)); try wal.add_record(try Record.init("hell2", "world", Op.Create, &alloc)); try wal.add_record(try Record.init("hell0", "world0", Op.Create, &alloc)); var iter = wal.iterator(); _ = iter.next().?; _ = iter.next().?; _ = iter.next().?; var record = iter.next().?; try std.testing.expectEqualStrings("world0", record.value); } test "wal.lexicographical_compare" { var alloc = std.testing.allocator; var r1 = try Record.init("hello", "world", Op.Create, &alloc); var r2 = try Record.init("hellos", "world", Op.Create, &alloc); defer r1.deinit(); defer r2.deinit(); try std.testing.expect(!Wal(100).lexicographical_compare({}, r2, r1)); } test "wal.sort a wal" { var alloc = std.testing.allocator; var wal = try Wal(100).init(&alloc); defer wal.deinit_cascade(); var r1 = try Record.init("hellos", "world", Op.Create, &alloc); var r2 = try Record.init("hello", "world", Op.Create, &alloc); try wal.add_record(r1); try wal.add_record(r2); try std.testing.expectEqualSlices(u8, wal.mem[0].key, r1.key); try std.testing.expectEqualSlices(u8, wal.mem[1].key, r2.key); wal.sort(); try std.testing.expectEqualSlices(u8, wal.mem[1].key, r1.key); try std.testing.expectEqualSlices(u8, wal.mem[0].key, r2.key); } test "wal.add record" { var alloc = std.testing.allocator; var wal = try Wal(100).init(&alloc); defer wal.deinit_cascade(); var r = try Record.init("hello", "world", Op.Create, &alloc); try wal.add_record(r); try std.testing.expect(wal.total_records == 1); try std.testing.expect(wal.current_size == r.bytesLen()); } test "wal.max size reached" { var alloc = std.testing.allocator; var wal = try Wal(23).init(&alloc); defer wal.deinit_cascade(); try std.testing.expectEqual(@as(usize, 1), wal.mem.len); var r = try Record.init("hello", "world", Op.Create, &alloc); try std.testing.expectEqual(@as(usize, 21), r.bytesLen()); wal.add_record(r) catch unreachable; var buf: [24]u8 = undefined; _ = try lsmtree.serialize.record.toBytes(r, buf[0..]); if (wal.add_record(r)) |_| unreachable else |err| { try std.testing.expect(err == WalError.MaxSizeReached); } } test "wal.find a key" { var alloc = std.testing.allocator; var wal = try Wal(100).init(&alloc); defer wal.deinit_cascade(); var r1 = try Record.init("hello", "world", Op.Create, &alloc); var r2 = try Record.init("hello", "world1", Op.Create, &alloc); var r3 = try Record.init("hello", "world3", Op.Create, &alloc); var r4 = try Record.init("hello1", "world", Op.Create, &alloc); try wal.add_record(r1); try wal.add_record(r2); try wal.add_record(r3); try wal.add_record(r4); try std.testing.expect(wal.total_records == 4); const maybe_record = wal.find(r1.key[0..]); //we expect value of r3 as it's the last inserted using key `hello` try std.testing.expect(std.mem.eql(u8, maybe_record.?.value, r3.value[0..])); const unkonwn_record = wal.find("unknokwn"); try std.testing.expect(unkonwn_record == null); } test "wal.size on memory" { try std.testing.expectEqual(48, @sizeOf(Wal(100))); }
src/wal.zig
pub const NET_IF_OPER_STATUS_DOWN_NOT_AUTHENTICATED = @as(u32, 1); pub const NET_IF_OPER_STATUS_DOWN_NOT_MEDIA_CONNECTED = @as(u32, 2); pub const NET_IF_OPER_STATUS_DORMANT_PAUSED = @as(u32, 4); pub const NET_IF_OPER_STATUS_DORMANT_LOW_POWER = @as(u32, 8); pub const NET_IF_OID_IF_ALIAS = @as(u32, 1); pub const NET_IF_OID_COMPARTMENT_ID = @as(u32, 2); pub const NET_IF_OID_NETWORK_GUID = @as(u32, 3); pub const NET_IF_OID_IF_ENTRY = @as(u32, 4); pub const NET_SITEID_UNSPECIFIED = @as(u32, 0); pub const NET_SITEID_MAXUSER = @as(u32, 134217727); pub const NET_SITEID_MAXSYSTEM = @as(u32, 268435455); pub const NET_IFLUID_UNSPECIFIED = @as(u32, 0); pub const NIIF_HARDWARE_INTERFACE = @as(u32, 1); pub const NIIF_FILTER_INTERFACE = @as(u32, 2); pub const NIIF_NDIS_RESERVED1 = @as(u32, 4); pub const NIIF_NDIS_RESERVED2 = @as(u32, 8); pub const NIIF_NDIS_RESERVED3 = @as(u32, 16); pub const NIIF_NDIS_WDM_INTERFACE = @as(u32, 32); pub const NIIF_NDIS_ENDPOINT_INTERFACE = @as(u32, 64); pub const NIIF_NDIS_ISCSI_INTERFACE = @as(u32, 128); pub const NIIF_NDIS_RESERVED4 = @as(u32, 256); pub const IF_MAX_STRING_SIZE = @as(u32, 256); pub const IF_MAX_PHYS_ADDRESS_LENGTH = @as(u32, 32); pub const ANY_SIZE = @as(u32, 1); pub const MAXLEN_PHYSADDR = @as(u32, 8); pub const MAXLEN_IFDESCR = @as(u32, 256); pub const MAX_INTERFACE_NAME_LEN = @as(u32, 256); pub const MIN_IF_TYPE = @as(u32, 1); pub const IF_TYPE_OTHER = @as(u32, 1); pub const IF_TYPE_REGULAR_1822 = @as(u32, 2); pub const IF_TYPE_HDH_1822 = @as(u32, 3); pub const IF_TYPE_DDN_X25 = @as(u32, 4); pub const IF_TYPE_RFC877_X25 = @as(u32, 5); pub const IF_TYPE_ETHERNET_CSMACD = @as(u32, 6); pub const IF_TYPE_IS088023_CSMACD = @as(u32, 7); pub const IF_TYPE_ISO88024_TOKENBUS = @as(u32, 8); pub const IF_TYPE_ISO88025_TOKENRING = @as(u32, 9); pub const IF_TYPE_ISO88026_MAN = @as(u32, 10); pub const IF_TYPE_STARLAN = @as(u32, 11); pub const IF_TYPE_PROTEON_10MBIT = @as(u32, 12); pub const IF_TYPE_PROTEON_80MBIT = @as(u32, 13); pub const IF_TYPE_HYPERCHANNEL = @as(u32, 14); pub const IF_TYPE_FDDI = @as(u32, 15); pub const IF_TYPE_LAP_B = @as(u32, 16); pub const IF_TYPE_SDLC = @as(u32, 17); pub const IF_TYPE_DS1 = @as(u32, 18); pub const IF_TYPE_E1 = @as(u32, 19); pub const IF_TYPE_BASIC_ISDN = @as(u32, 20); pub const IF_TYPE_PRIMARY_ISDN = @as(u32, 21); pub const IF_TYPE_PROP_POINT2POINT_SERIAL = @as(u32, 22); pub const IF_TYPE_PPP = @as(u32, 23); pub const IF_TYPE_SOFTWARE_LOOPBACK = @as(u32, 24); pub const IF_TYPE_EON = @as(u32, 25); pub const IF_TYPE_ETHERNET_3MBIT = @as(u32, 26); pub const IF_TYPE_NSIP = @as(u32, 27); pub const IF_TYPE_SLIP = @as(u32, 28); pub const IF_TYPE_ULTRA = @as(u32, 29); pub const IF_TYPE_DS3 = @as(u32, 30); pub const IF_TYPE_SIP = @as(u32, 31); pub const IF_TYPE_FRAMERELAY = @as(u32, 32); pub const IF_TYPE_RS232 = @as(u32, 33); pub const IF_TYPE_PARA = @as(u32, 34); pub const IF_TYPE_ARCNET = @as(u32, 35); pub const IF_TYPE_ARCNET_PLUS = @as(u32, 36); pub const IF_TYPE_ATM = @as(u32, 37); pub const IF_TYPE_MIO_X25 = @as(u32, 38); pub const IF_TYPE_SONET = @as(u32, 39); pub const IF_TYPE_X25_PLE = @as(u32, 40); pub const IF_TYPE_ISO88022_LLC = @as(u32, 41); pub const IF_TYPE_LOCALTALK = @as(u32, 42); pub const IF_TYPE_SMDS_DXI = @as(u32, 43); pub const IF_TYPE_FRAMERELAY_SERVICE = @as(u32, 44); pub const IF_TYPE_V35 = @as(u32, 45); pub const IF_TYPE_HSSI = @as(u32, 46); pub const IF_TYPE_HIPPI = @as(u32, 47); pub const IF_TYPE_MODEM = @as(u32, 48); pub const IF_TYPE_AAL5 = @as(u32, 49); pub const IF_TYPE_SONET_PATH = @as(u32, 50); pub const IF_TYPE_SONET_VT = @as(u32, 51); pub const IF_TYPE_SMDS_ICIP = @as(u32, 52); pub const IF_TYPE_PROP_VIRTUAL = @as(u32, 53); pub const IF_TYPE_PROP_MULTIPLEXOR = @as(u32, 54); pub const IF_TYPE_IEEE80212 = @as(u32, 55); pub const IF_TYPE_FIBRECHANNEL = @as(u32, 56); pub const IF_TYPE_HIPPIINTERFACE = @as(u32, 57); pub const IF_TYPE_FRAMERELAY_INTERCONNECT = @as(u32, 58); pub const IF_TYPE_AFLANE_8023 = @as(u32, 59); pub const IF_TYPE_AFLANE_8025 = @as(u32, 60); pub const IF_TYPE_CCTEMUL = @as(u32, 61); pub const IF_TYPE_FASTETHER = @as(u32, 62); pub const IF_TYPE_ISDN = @as(u32, 63); pub const IF_TYPE_V11 = @as(u32, 64); pub const IF_TYPE_V36 = @as(u32, 65); pub const IF_TYPE_G703_64K = @as(u32, 66); pub const IF_TYPE_G703_2MB = @as(u32, 67); pub const IF_TYPE_QLLC = @as(u32, 68); pub const IF_TYPE_FASTETHER_FX = @as(u32, 69); pub const IF_TYPE_CHANNEL = @as(u32, 70); pub const IF_TYPE_IEEE80211 = @as(u32, 71); pub const IF_TYPE_IBM370PARCHAN = @as(u32, 72); pub const IF_TYPE_ESCON = @as(u32, 73); pub const IF_TYPE_DLSW = @as(u32, 74); pub const IF_TYPE_ISDN_S = @as(u32, 75); pub const IF_TYPE_ISDN_U = @as(u32, 76); pub const IF_TYPE_LAP_D = @as(u32, 77); pub const IF_TYPE_IPSWITCH = @as(u32, 78); pub const IF_TYPE_RSRB = @as(u32, 79); pub const IF_TYPE_ATM_LOGICAL = @as(u32, 80); pub const IF_TYPE_DS0 = @as(u32, 81); pub const IF_TYPE_DS0_BUNDLE = @as(u32, 82); pub const IF_TYPE_BSC = @as(u32, 83); pub const IF_TYPE_ASYNC = @as(u32, 84); pub const IF_TYPE_CNR = @as(u32, 85); pub const IF_TYPE_ISO88025R_DTR = @as(u32, 86); pub const IF_TYPE_EPLRS = @as(u32, 87); pub const IF_TYPE_ARAP = @as(u32, 88); pub const IF_TYPE_PROP_CNLS = @as(u32, 89); pub const IF_TYPE_HOSTPAD = @as(u32, 90); pub const IF_TYPE_TERMPAD = @as(u32, 91); pub const IF_TYPE_FRAMERELAY_MPI = @as(u32, 92); pub const IF_TYPE_X213 = @as(u32, 93); pub const IF_TYPE_ADSL = @as(u32, 94); pub const IF_TYPE_RADSL = @as(u32, 95); pub const IF_TYPE_SDSL = @as(u32, 96); pub const IF_TYPE_VDSL = @as(u32, 97); pub const IF_TYPE_ISO88025_CRFPRINT = @as(u32, 98); pub const IF_TYPE_MYRINET = @as(u32, 99); pub const IF_TYPE_VOICE_EM = @as(u32, 100); pub const IF_TYPE_VOICE_FXO = @as(u32, 101); pub const IF_TYPE_VOICE_FXS = @as(u32, 102); pub const IF_TYPE_VOICE_ENCAP = @as(u32, 103); pub const IF_TYPE_VOICE_OVERIP = @as(u32, 104); pub const IF_TYPE_ATM_DXI = @as(u32, 105); pub const IF_TYPE_ATM_FUNI = @as(u32, 106); pub const IF_TYPE_ATM_IMA = @as(u32, 107); pub const IF_TYPE_PPPMULTILINKBUNDLE = @as(u32, 108); pub const IF_TYPE_IPOVER_CDLC = @as(u32, 109); pub const IF_TYPE_IPOVER_CLAW = @as(u32, 110); pub const IF_TYPE_STACKTOSTACK = @as(u32, 111); pub const IF_TYPE_VIRTUALIPADDRESS = @as(u32, 112); pub const IF_TYPE_MPC = @as(u32, 113); pub const IF_TYPE_IPOVER_ATM = @as(u32, 114); pub const IF_TYPE_ISO88025_FIBER = @as(u32, 115); pub const IF_TYPE_TDLC = @as(u32, 116); pub const IF_TYPE_GIGABITETHERNET = @as(u32, 117); pub const IF_TYPE_HDLC = @as(u32, 118); pub const IF_TYPE_LAP_F = @as(u32, 119); pub const IF_TYPE_V37 = @as(u32, 120); pub const IF_TYPE_X25_MLP = @as(u32, 121); pub const IF_TYPE_X25_HUNTGROUP = @as(u32, 122); pub const IF_TYPE_TRANSPHDLC = @as(u32, 123); pub const IF_TYPE_INTERLEAVE = @as(u32, 124); pub const IF_TYPE_FAST = @as(u32, 125); pub const IF_TYPE_IP = @as(u32, 126); pub const IF_TYPE_DOCSCABLE_MACLAYER = @as(u32, 127); pub const IF_TYPE_DOCSCABLE_DOWNSTREAM = @as(u32, 128); pub const IF_TYPE_DOCSCABLE_UPSTREAM = @as(u32, 129); pub const IF_TYPE_A12MPPSWITCH = @as(u32, 130); pub const IF_TYPE_TUNNEL = @as(u32, 131); pub const IF_TYPE_COFFEE = @as(u32, 132); pub const IF_TYPE_CES = @as(u32, 133); pub const IF_TYPE_ATM_SUBINTERFACE = @as(u32, 134); pub const IF_TYPE_L2_VLAN = @as(u32, 135); pub const IF_TYPE_L3_IPVLAN = @as(u32, 136); pub const IF_TYPE_L3_IPXVLAN = @as(u32, 137); pub const IF_TYPE_DIGITALPOWERLINE = @as(u32, 138); pub const IF_TYPE_MEDIAMAILOVERIP = @as(u32, 139); pub const IF_TYPE_DTM = @as(u32, 140); pub const IF_TYPE_DCN = @as(u32, 141); pub const IF_TYPE_IPFORWARD = @as(u32, 142); pub const IF_TYPE_MSDSL = @as(u32, 143); pub const IF_TYPE_IEEE1394 = @as(u32, 144); pub const IF_TYPE_IF_GSN = @as(u32, 145); pub const IF_TYPE_DVBRCC_MACLAYER = @as(u32, 146); pub const IF_TYPE_DVBRCC_DOWNSTREAM = @as(u32, 147); pub const IF_TYPE_DVBRCC_UPSTREAM = @as(u32, 148); pub const IF_TYPE_ATM_VIRTUAL = @as(u32, 149); pub const IF_TYPE_MPLS_TUNNEL = @as(u32, 150); pub const IF_TYPE_SRP = @as(u32, 151); pub const IF_TYPE_VOICEOVERATM = @as(u32, 152); pub const IF_TYPE_VOICEOVERFRAMERELAY = @as(u32, 153); pub const IF_TYPE_IDSL = @as(u32, 154); pub const IF_TYPE_COMPOSITELINK = @as(u32, 155); pub const IF_TYPE_SS7_SIGLINK = @as(u32, 156); pub const IF_TYPE_PROP_WIRELESS_P2P = @as(u32, 157); pub const IF_TYPE_FR_FORWARD = @as(u32, 158); pub const IF_TYPE_RFC1483 = @as(u32, 159); pub const IF_TYPE_USB = @as(u32, 160); pub const IF_TYPE_IEEE8023AD_LAG = @as(u32, 161); pub const IF_TYPE_BGP_POLICY_ACCOUNTING = @as(u32, 162); pub const IF_TYPE_FRF16_MFR_BUNDLE = @as(u32, 163); pub const IF_TYPE_H323_GATEKEEPER = @as(u32, 164); pub const IF_TYPE_H323_PROXY = @as(u32, 165); pub const IF_TYPE_MPLS = @as(u32, 166); pub const IF_TYPE_MF_SIGLINK = @as(u32, 167); pub const IF_TYPE_HDSL2 = @as(u32, 168); pub const IF_TYPE_SHDSL = @as(u32, 169); pub const IF_TYPE_DS1_FDL = @as(u32, 170); pub const IF_TYPE_POS = @as(u32, 171); pub const IF_TYPE_DVB_ASI_IN = @as(u32, 172); pub const IF_TYPE_DVB_ASI_OUT = @as(u32, 173); pub const IF_TYPE_PLC = @as(u32, 174); pub const IF_TYPE_NFAS = @as(u32, 175); pub const IF_TYPE_TR008 = @as(u32, 176); pub const IF_TYPE_GR303_RDT = @as(u32, 177); pub const IF_TYPE_GR303_IDT = @as(u32, 178); pub const IF_TYPE_ISUP = @as(u32, 179); pub const IF_TYPE_PROP_DOCS_WIRELESS_MACLAYER = @as(u32, 180); pub const IF_TYPE_PROP_DOCS_WIRELESS_DOWNSTREAM = @as(u32, 181); pub const IF_TYPE_PROP_DOCS_WIRELESS_UPSTREAM = @as(u32, 182); pub const IF_TYPE_HIPERLAN2 = @as(u32, 183); pub const IF_TYPE_PROP_BWA_P2MP = @as(u32, 184); pub const IF_TYPE_SONET_OVERHEAD_CHANNEL = @as(u32, 185); pub const IF_TYPE_DIGITAL_WRAPPER_OVERHEAD_CHANNEL = @as(u32, 186); pub const IF_TYPE_AAL2 = @as(u32, 187); pub const IF_TYPE_RADIO_MAC = @as(u32, 188); pub const IF_TYPE_ATM_RADIO = @as(u32, 189); pub const IF_TYPE_IMT = @as(u32, 190); pub const IF_TYPE_MVL = @as(u32, 191); pub const IF_TYPE_REACH_DSL = @as(u32, 192); pub const IF_TYPE_FR_DLCI_ENDPT = @as(u32, 193); pub const IF_TYPE_ATM_VCI_ENDPT = @as(u32, 194); pub const IF_TYPE_OPTICAL_CHANNEL = @as(u32, 195); pub const IF_TYPE_OPTICAL_TRANSPORT = @as(u32, 196); pub const IF_TYPE_IEEE80216_WMAN = @as(u32, 237); pub const IF_TYPE_WWANPP = @as(u32, 243); pub const IF_TYPE_WWANPP2 = @as(u32, 244); pub const IF_TYPE_IEEE802154 = @as(u32, 259); pub const IF_TYPE_XBOX_WIRELESS = @as(u32, 281); pub const MAX_IF_TYPE = @as(u32, 281); pub const IF_CHECK_NONE = @as(u32, 0); pub const IF_CHECK_MCAST = @as(u32, 1); pub const IF_CHECK_SEND = @as(u32, 2); pub const IF_CONNECTION_DEDICATED = @as(u32, 1); pub const IF_CONNECTION_PASSIVE = @as(u32, 2); pub const IF_CONNECTION_DEMAND = @as(u32, 3); pub const IF_ADMIN_STATUS_UP = @as(u32, 1); pub const IF_ADMIN_STATUS_DOWN = @as(u32, 2); pub const IF_ADMIN_STATUS_TESTING = @as(u32, 3); pub const MIB_IF_TYPE_OTHER = @as(u32, 1); pub const MIB_IF_TYPE_ETHERNET = @as(u32, 6); pub const MIB_IF_TYPE_TOKENRING = @as(u32, 9); pub const MIB_IF_TYPE_FDDI = @as(u32, 15); pub const MIB_IF_TYPE_PPP = @as(u32, 23); pub const MIB_IF_TYPE_LOOPBACK = @as(u32, 24); pub const MIB_IF_TYPE_SLIP = @as(u32, 28); pub const MIB_IF_ADMIN_STATUS_UP = @as(u32, 1); pub const MIB_IF_ADMIN_STATUS_DOWN = @as(u32, 2); pub const MIB_IF_ADMIN_STATUS_TESTING = @as(u32, 3); pub const MIB_IPADDR_PRIMARY = @as(u32, 1); pub const MIB_IPADDR_DYNAMIC = @as(u32, 4); pub const MIB_IPADDR_DISCONNECTED = @as(u32, 8); pub const MIB_IPADDR_DELETED = @as(u32, 64); pub const MIB_IPADDR_TRANSIENT = @as(u32, 128); pub const MIB_IPADDR_DNS_ELIGIBLE = @as(u32, 256); pub const MIB_IPROUTE_METRIC_UNUSED = @as(u32, 4294967295); pub const MIB_USE_CURRENT_TTL = @as(u32, 4294967295); pub const MIB_USE_CURRENT_FORWARDING = @as(u32, 4294967295); pub const ICMP6_INFOMSG_MASK = @as(u32, 128); pub const IPRTRMGR_PID = @as(u32, 10000); pub const IF_NUMBER = @as(u32, 0); pub const IF_TABLE = @as(u32, 1); pub const IF_ROW = @as(u32, 2); pub const IP_STATS = @as(u32, 3); pub const IP_ADDRTABLE = @as(u32, 4); pub const IP_ADDRROW = @as(u32, 5); pub const IP_FORWARDNUMBER = @as(u32, 6); pub const IP_FORWARDTABLE = @as(u32, 7); pub const IP_FORWARDROW = @as(u32, 8); pub const IP_NETTABLE = @as(u32, 9); pub const IP_NETROW = @as(u32, 10); pub const ICMP_STATS = @as(u32, 11); pub const TCP_STATS = @as(u32, 12); pub const TCP_TABLE = @as(u32, 13); pub const TCP_ROW = @as(u32, 14); pub const UDP_STATS = @as(u32, 15); pub const UDP_TABLE = @as(u32, 16); pub const UDP_ROW = @as(u32, 17); pub const MCAST_MFE = @as(u32, 18); pub const MCAST_MFE_STATS = @as(u32, 19); pub const BEST_IF = @as(u32, 20); pub const BEST_ROUTE = @as(u32, 21); pub const PROXY_ARP = @as(u32, 22); pub const MCAST_IF_ENTRY = @as(u32, 23); pub const MCAST_GLOBAL = @as(u32, 24); pub const IF_STATUS = @as(u32, 25); pub const MCAST_BOUNDARY = @as(u32, 26); pub const MCAST_SCOPE = @as(u32, 27); pub const DEST_MATCHING = @as(u32, 28); pub const DEST_LONGER = @as(u32, 29); pub const DEST_SHORTER = @as(u32, 30); pub const ROUTE_MATCHING = @as(u32, 31); pub const ROUTE_LONGER = @as(u32, 32); pub const ROUTE_SHORTER = @as(u32, 33); pub const ROUTE_STATE = @as(u32, 34); pub const MCAST_MFE_STATS_EX = @as(u32, 35); pub const IP6_STATS = @as(u32, 36); pub const UDP6_STATS = @as(u32, 37); pub const TCP6_STATS = @as(u32, 38); pub const NUMBER_OF_EXPORTED_VARIABLES = @as(u32, 39); pub const MAX_SCOPE_NAME_LEN = @as(u32, 255); pub const MAX_MIB_OFFSET = @as(u32, 8); pub const MIB_INVALID_TEREDO_PORT_NUMBER = @as(u32, 0); pub const DNS_SETTINGS_VERSION1 = @as(u32, 1); pub const DNS_SETTINGS_VERSION2 = @as(u32, 2); pub const DNS_INTERFACE_SETTINGS_VERSION1 = @as(u32, 1); pub const DNS_INTERFACE_SETTINGS_VERSION2 = @as(u32, 2); pub const DNS_INTERFACE_SETTINGS_VERSION3 = @as(u32, 3); pub const DNS_SETTING_IPV6 = @as(u32, 1); pub const DNS_SETTING_NAMESERVER = @as(u32, 2); pub const DNS_SETTING_SEARCHLIST = @as(u32, 4); pub const DNS_SETTING_REGISTRATION_ENABLED = @as(u32, 8); pub const DNS_SETTING_REGISTER_ADAPTER_NAME = @as(u32, 16); pub const DNS_SETTING_DOMAIN = @as(u32, 32); pub const DNS_SETTING_HOSTNAME = @as(u32, 64); pub const DNS_SETTINGS_ENABLE_LLMNR = @as(u32, 128); pub const DNS_SETTINGS_QUERY_ADAPTER_NAME = @as(u32, 256); pub const DNS_SETTING_PROFILE_NAMESERVER = @as(u32, 512); pub const DNS_SETTING_DISABLE_UNCONSTRAINED_QUERIES = @as(u32, 1024); pub const DNS_SETTING_SUPPLEMENTAL_SEARCH_LIST = @as(u32, 2048); pub const DNS_SETTING_DOH = @as(u32, 4096); pub const DNS_SETTING_DOH_PROFILE = @as(u32, 8192); pub const DNS_ENABLE_DOH = @as(u32, 1); pub const DNS_DOH_POLICY_NOT_CONFIGURED = @as(u32, 4); pub const DNS_DOH_POLICY_DISABLE = @as(u32, 8); pub const DNS_DOH_POLICY_AUTO = @as(u32, 16); pub const DNS_DOH_POLICY_REQUIRED = @as(u32, 32); pub const DNS_SERVER_PROPERTY_VERSION1 = @as(u32, 1); pub const DNS_DOH_SERVER_SETTINGS_ENABLE_AUTO = @as(u32, 1); pub const DNS_DOH_SERVER_SETTINGS_ENABLE = @as(u32, 2); pub const DNS_DOH_SERVER_SETTINGS_FALLBACK_TO_UDP = @as(u32, 4); pub const DNS_DOH_AUTO_UPGRADE_SERVER = @as(u32, 8); pub const TCPIP_OWNING_MODULE_SIZE = @as(u32, 16); pub const FD_FLAGS_NOSYN = @as(u32, 1); pub const FD_FLAGS_ALLFLAGS = @as(u32, 1); pub const LB_SRC_ADDR_USE_SRCADDR_FLAG = @as(u32, 1); pub const LB_SRC_ADDR_USE_DSTADDR_FLAG = @as(u32, 2); pub const LB_DST_ADDR_USE_SRCADDR_FLAG = @as(u32, 4); pub const LB_DST_ADDR_USE_DSTADDR_FLAG = @as(u32, 8); pub const LB_SRC_MASK_LATE_FLAG = @as(u32, 16); pub const LB_DST_MASK_LATE_FLAG = @as(u32, 32); pub const ERROR_BASE = @as(u32, 23000); pub const PFERROR_NO_PF_INTERFACE = @as(u32, 23000); pub const PFERROR_NO_FILTERS_GIVEN = @as(u32, 23001); pub const PFERROR_BUFFER_TOO_SMALL = @as(u32, 23002); pub const ERROR_IPV6_NOT_IMPLEMENTED = @as(u32, 23003); pub const IP_EXPORT_INCLUDED = @as(u32, 1); pub const MAX_ADAPTER_NAME = @as(u32, 128); pub const IP_STATUS_BASE = @as(u32, 11000); pub const IP_SUCCESS = @as(u32, 0); pub const IP_BUF_TOO_SMALL = @as(u32, 11001); pub const IP_DEST_NET_UNREACHABLE = @as(u32, 11002); pub const IP_DEST_HOST_UNREACHABLE = @as(u32, 11003); pub const IP_DEST_PROT_UNREACHABLE = @as(u32, 11004); pub const IP_DEST_PORT_UNREACHABLE = @as(u32, 11005); pub const IP_NO_RESOURCES = @as(u32, 11006); pub const IP_BAD_OPTION = @as(u32, 11007); pub const IP_HW_ERROR = @as(u32, 11008); pub const IP_PACKET_TOO_BIG = @as(u32, 11009); pub const IP_REQ_TIMED_OUT = @as(u32, 11010); pub const IP_BAD_REQ = @as(u32, 11011); pub const IP_BAD_ROUTE = @as(u32, 11012); pub const IP_TTL_EXPIRED_TRANSIT = @as(u32, 11013); pub const IP_TTL_EXPIRED_REASSEM = @as(u32, 11014); pub const IP_PARAM_PROBLEM = @as(u32, 11015); pub const IP_SOURCE_QUENCH = @as(u32, 11016); pub const IP_OPTION_TOO_BIG = @as(u32, 11017); pub const IP_BAD_DESTINATION = @as(u32, 11018); pub const IP_DEST_NO_ROUTE = @as(u32, 11002); pub const IP_DEST_ADDR_UNREACHABLE = @as(u32, 11003); pub const IP_DEST_PROHIBITED = @as(u32, 11004); pub const IP_HOP_LIMIT_EXCEEDED = @as(u32, 11013); pub const IP_REASSEMBLY_TIME_EXCEEDED = @as(u32, 11014); pub const IP_PARAMETER_PROBLEM = @as(u32, 11015); pub const IP_DEST_UNREACHABLE = @as(u32, 11040); pub const IP_TIME_EXCEEDED = @as(u32, 11041); pub const IP_BAD_HEADER = @as(u32, 11042); pub const IP_UNRECOGNIZED_NEXT_HEADER = @as(u32, 11043); pub const IP_ICMP_ERROR = @as(u32, 11044); pub const IP_DEST_SCOPE_MISMATCH = @as(u32, 11045); pub const IP_ADDR_DELETED = @as(u32, 11019); pub const IP_SPEC_MTU_CHANGE = @as(u32, 11020); pub const IP_MTU_CHANGE = @as(u32, 11021); pub const IP_UNLOAD = @as(u32, 11022); pub const IP_ADDR_ADDED = @as(u32, 11023); pub const IP_MEDIA_CONNECT = @as(u32, 11024); pub const IP_MEDIA_DISCONNECT = @as(u32, 11025); pub const IP_BIND_ADAPTER = @as(u32, 11026); pub const IP_UNBIND_ADAPTER = @as(u32, 11027); pub const IP_DEVICE_DOES_NOT_EXIST = @as(u32, 11028); pub const IP_DUPLICATE_ADDRESS = @as(u32, 11029); pub const IP_INTERFACE_METRIC_CHANGE = @as(u32, 11030); pub const IP_RECONFIG_SECFLTR = @as(u32, 11031); pub const IP_NEGOTIATING_IPSEC = @as(u32, 11032); pub const IP_INTERFACE_WOL_CAPABILITY_CHANGE = @as(u32, 11033); pub const IP_DUPLICATE_IPADD = @as(u32, 11034); pub const IP_GENERAL_FAILURE = @as(u32, 11050); pub const MAX_IP_STATUS = @as(u32, 11050); pub const IP_PENDING = @as(u32, 11255); pub const IP_FLAG_REVERSE = @as(u32, 1); pub const IP_FLAG_DF = @as(u32, 2); pub const MAX_OPT_SIZE = @as(u32, 40); pub const IOCTL_IP_RTCHANGE_NOTIFY_REQUEST = @as(u32, 101); pub const IOCTL_IP_ADDCHANGE_NOTIFY_REQUEST = @as(u32, 102); pub const IOCTL_ARP_SEND_REQUEST = @as(u32, 103); pub const IOCTL_IP_INTERFACE_INFO = @as(u32, 104); pub const IOCTL_IP_GET_BEST_INTERFACE = @as(u32, 105); pub const IOCTL_IP_UNIDIRECTIONAL_ADAPTER_ADDRESS = @as(u32, 106); pub const NET_STRING_IPV4_ADDRESS = @as(u32, 1); pub const NET_STRING_IPV4_SERVICE = @as(u32, 2); pub const NET_STRING_IPV4_NETWORK = @as(u32, 4); pub const NET_STRING_IPV6_ADDRESS = @as(u32, 8); pub const NET_STRING_IPV6_ADDRESS_NO_SCOPE = @as(u32, 16); pub const NET_STRING_IPV6_SERVICE = @as(u32, 32); pub const NET_STRING_IPV6_SERVICE_NO_SCOPE = @as(u32, 64); pub const NET_STRING_IPV6_NETWORK = @as(u32, 128); pub const NET_STRING_NAMED_ADDRESS = @as(u32, 256); pub const NET_STRING_NAMED_SERVICE = @as(u32, 512); pub const MAX_ADAPTER_DESCRIPTION_LENGTH = @as(u32, 128); pub const MAX_ADAPTER_NAME_LENGTH = @as(u32, 256); pub const MAX_ADAPTER_ADDRESS_LENGTH = @as(u32, 8); pub const DEFAULT_MINIMUM_ENTITIES = @as(u32, 32); pub const MAX_HOSTNAME_LEN = @as(u32, 128); pub const MAX_DOMAIN_NAME_LEN = @as(u32, 128); pub const MAX_SCOPE_ID_LEN = @as(u32, 256); pub const MAX_DHCPV6_DUID_LENGTH = @as(u32, 130); pub const MAX_DNS_SUFFIX_STRING_LENGTH = @as(u32, 256); pub const BROADCAST_NODETYPE = @as(u32, 1); pub const PEER_TO_PEER_NODETYPE = @as(u32, 2); pub const MIXED_NODETYPE = @as(u32, 4); pub const HYBRID_NODETYPE = @as(u32, 8); pub const IP_ADAPTER_ADDRESS_DNS_ELIGIBLE = @as(u32, 1); pub const IP_ADAPTER_ADDRESS_TRANSIENT = @as(u32, 2); pub const IP_ADAPTER_DDNS_ENABLED = @as(u32, 1); pub const IP_ADAPTER_REGISTER_ADAPTER_SUFFIX = @as(u32, 2); pub const IP_ADAPTER_DHCP_ENABLED = @as(u32, 4); pub const IP_ADAPTER_RECEIVE_ONLY = @as(u32, 8); pub const IP_ADAPTER_NO_MULTICAST = @as(u32, 16); pub const IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG = @as(u32, 32); pub const IP_ADAPTER_NETBIOS_OVER_TCPIP_ENABLED = @as(u32, 64); pub const IP_ADAPTER_IPV4_ENABLED = @as(u32, 128); pub const IP_ADAPTER_IPV6_ENABLED = @as(u32, 256); pub const IP_ADAPTER_IPV6_MANAGE_ADDRESS_CONFIG = @as(u32, 512); pub const GAA_FLAG_SKIP_DNS_INFO = @as(u32, 2048); pub const IP_ROUTER_MANAGER_VERSION = @as(u32, 1); pub const IP_GENERAL_INFO_BASE = @as(u32, 4294901760); pub const IP_IN_FILTER_INFO = @as(u32, 4294901761); pub const IP_OUT_FILTER_INFO = @as(u32, 4294901762); pub const IP_GLOBAL_INFO = @as(u32, 4294901763); pub const IP_INTERFACE_STATUS_INFO = @as(u32, 4294901764); pub const IP_ROUTE_INFO = @as(u32, 4294901765); pub const IP_PROT_PRIORITY_INFO = @as(u32, 4294901766); pub const IP_ROUTER_DISC_INFO = @as(u32, 4294901767); pub const IP_DEMAND_DIAL_FILTER_INFO = @as(u32, 4294901769); pub const IP_MCAST_HEARBEAT_INFO = @as(u32, 4294901770); pub const IP_MCAST_BOUNDARY_INFO = @as(u32, 4294901771); pub const IP_IPINIP_CFG_INFO = @as(u32, 4294901772); pub const IP_IFFILTER_INFO = @as(u32, 4294901773); pub const IP_MCAST_LIMIT_INFO = @as(u32, 4294901774); pub const IPV6_GLOBAL_INFO = @as(u32, 4294901775); pub const IPV6_ROUTE_INFO = @as(u32, 4294901776); pub const IP_IN_FILTER_INFO_V6 = @as(u32, 4294901777); pub const IP_OUT_FILTER_INFO_V6 = @as(u32, 4294901778); pub const IP_DEMAND_DIAL_FILTER_INFO_V6 = @as(u32, 4294901779); pub const IP_IFFILTER_INFO_V6 = @as(u32, 4294901780); pub const IP_FILTER_ENABLE_INFO = @as(u32, 4294901781); pub const IP_FILTER_ENABLE_INFO_V6 = @as(u32, 4294901782); pub const IP_PROT_PRIORITY_INFO_EX = @as(u32, 4294901783); //-------------------------------------------------------------------------------- // Section: Types (225) //-------------------------------------------------------------------------------- pub const ADDRESS_FAMILY = enum(u32) { INET = 2, INET6 = 23, UNSPEC = 0, }; pub const AF_INET = ADDRESS_FAMILY.INET; pub const AF_INET6 = ADDRESS_FAMILY.INET6; pub const AF_UNSPEC = ADDRESS_FAMILY.UNSPEC; pub const GET_ADAPTERS_ADDRESSES_FLAGS = enum(u32) { SKIP_UNICAST = 1, SKIP_ANYCAST = 2, SKIP_MULTICAST = 4, SKIP_DNS_SERVER = 8, INCLUDE_PREFIX = 16, SKIP_FRIENDLY_NAME = 32, INCLUDE_WINS_INFO = 64, INCLUDE_GATEWAYS = 128, INCLUDE_ALL_INTERFACES = 256, INCLUDE_ALL_COMPARTMENTS = 512, INCLUDE_TUNNEL_BINDINGORDER = 1024, _, pub fn initFlags(o: struct { SKIP_UNICAST: u1 = 0, SKIP_ANYCAST: u1 = 0, SKIP_MULTICAST: u1 = 0, SKIP_DNS_SERVER: u1 = 0, INCLUDE_PREFIX: u1 = 0, SKIP_FRIENDLY_NAME: u1 = 0, INCLUDE_WINS_INFO: u1 = 0, INCLUDE_GATEWAYS: u1 = 0, INCLUDE_ALL_INTERFACES: u1 = 0, INCLUDE_ALL_COMPARTMENTS: u1 = 0, INCLUDE_TUNNEL_BINDINGORDER: u1 = 0, }) GET_ADAPTERS_ADDRESSES_FLAGS { return @intToEnum(GET_ADAPTERS_ADDRESSES_FLAGS, (if (o.SKIP_UNICAST == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_UNICAST) else 0) | (if (o.SKIP_ANYCAST == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_ANYCAST) else 0) | (if (o.SKIP_MULTICAST == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_MULTICAST) else 0) | (if (o.SKIP_DNS_SERVER == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_DNS_SERVER) else 0) | (if (o.INCLUDE_PREFIX == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_PREFIX) else 0) | (if (o.SKIP_FRIENDLY_NAME == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_FRIENDLY_NAME) else 0) | (if (o.INCLUDE_WINS_INFO == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_WINS_INFO) else 0) | (if (o.INCLUDE_GATEWAYS == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_GATEWAYS) else 0) | (if (o.INCLUDE_ALL_INTERFACES == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_ALL_INTERFACES) else 0) | (if (o.INCLUDE_ALL_COMPARTMENTS == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_ALL_COMPARTMENTS) else 0) | (if (o.INCLUDE_TUNNEL_BINDINGORDER == 1) @enumToInt(GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_TUNNEL_BINDINGORDER) else 0) ); } }; pub const GAA_FLAG_SKIP_UNICAST = GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_UNICAST; pub const GAA_FLAG_SKIP_ANYCAST = GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_ANYCAST; pub const GAA_FLAG_SKIP_MULTICAST = GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_MULTICAST; pub const GAA_FLAG_SKIP_DNS_SERVER = GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_DNS_SERVER; pub const GAA_FLAG_INCLUDE_PREFIX = GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_PREFIX; pub const GAA_FLAG_SKIP_FRIENDLY_NAME = GET_ADAPTERS_ADDRESSES_FLAGS.SKIP_FRIENDLY_NAME; pub const GAA_FLAG_INCLUDE_WINS_INFO = GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_WINS_INFO; pub const GAA_FLAG_INCLUDE_GATEWAYS = GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_GATEWAYS; pub const GAA_FLAG_INCLUDE_ALL_INTERFACES = GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_ALL_INTERFACES; pub const GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_ALL_COMPARTMENTS; pub const GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = GET_ADAPTERS_ADDRESSES_FLAGS.INCLUDE_TUNNEL_BINDINGORDER; // TODO: this type has a FreeFunc 'IcmpCloseHandle', what can Zig do with this information? pub const IcmpHandle = isize; pub const HIFTIMESTAMPCHANGE = *opaque{}; pub const ip_option_information = extern struct { Ttl: u8, Tos: u8, Flags: u8, OptionsSize: u8, OptionsData: ?*u8, }; pub const icmp_echo_reply = extern struct { Address: u32, Status: u32, RoundTripTime: u32, DataSize: u16, Reserved: u16, Data: ?*anyopaque, Options: ip_option_information, }; pub const IPV6_ADDRESS_EX = packed struct { sin6_port: u16, sin6_flowinfo: u32, sin6_addr: [8]u16, sin6_scope_id: u32, }; pub const icmpv6_echo_reply_lh = extern struct { Address: IPV6_ADDRESS_EX, Status: u32, RoundTripTime: u32, }; pub const arp_send_reply = extern struct { DestAddress: u32, SrcAddress: u32, }; pub const tcp_reserve_port_range = extern struct { UpperRange: u16, LowerRange: u16, }; pub const IP_ADAPTER_INDEX_MAP = extern struct { Index: u32, Name: [128]u16, }; pub const IP_INTERFACE_INFO = extern struct { NumAdapters: i32, Adapter: [1]IP_ADAPTER_INDEX_MAP, }; pub const IP_UNIDIRECTIONAL_ADAPTER_ADDRESS = extern struct { NumAdapters: u32, Address: [1]u32, }; pub const IP_ADAPTER_ORDER_MAP = extern struct { NumAdapters: u32, AdapterOrder: [1]u32, }; pub const IP_MCAST_COUNTER_INFO = extern struct { InMcastOctets: u64, OutMcastOctets: u64, InMcastPkts: u64, OutMcastPkts: u64, }; pub const IF_ACCESS_TYPE = enum(i32) { LOOPBACK = 1, BROADCAST = 2, POINT_TO_POINT = 3, // POINTTOPOINT = 3, this enum value conflicts with POINT_TO_POINT POINT_TO_MULTI_POINT = 4, // POINTTOMULTIPOINT = 4, this enum value conflicts with POINT_TO_MULTI_POINT }; pub const IF_ACCESS_LOOPBACK = IF_ACCESS_TYPE.LOOPBACK; pub const IF_ACCESS_BROADCAST = IF_ACCESS_TYPE.BROADCAST; pub const IF_ACCESS_POINT_TO_POINT = IF_ACCESS_TYPE.POINT_TO_POINT; pub const IF_ACCESS_POINTTOPOINT = IF_ACCESS_TYPE.POINT_TO_POINT; pub const IF_ACCESS_POINT_TO_MULTI_POINT = IF_ACCESS_TYPE.POINT_TO_MULTI_POINT; pub const IF_ACCESS_POINTTOMULTIPOINT = IF_ACCESS_TYPE.POINT_TO_MULTI_POINT; pub const INTERNAL_IF_OPER_STATUS = enum(i32) { NON_OPERATIONAL = 0, UNREACHABLE = 1, DISCONNECTED = 2, CONNECTING = 3, CONNECTED = 4, OPERATIONAL = 5, }; pub const IF_OPER_STATUS_NON_OPERATIONAL = INTERNAL_IF_OPER_STATUS.NON_OPERATIONAL; pub const IF_OPER_STATUS_UNREACHABLE = INTERNAL_IF_OPER_STATUS.UNREACHABLE; pub const IF_OPER_STATUS_DISCONNECTED = INTERNAL_IF_OPER_STATUS.DISCONNECTED; pub const IF_OPER_STATUS_CONNECTING = INTERNAL_IF_OPER_STATUS.CONNECTING; pub const IF_OPER_STATUS_CONNECTED = INTERNAL_IF_OPER_STATUS.CONNECTED; pub const IF_OPER_STATUS_OPERATIONAL = INTERNAL_IF_OPER_STATUS.OPERATIONAL; pub const NET_IF_OPER_STATUS = enum(i32) { UP = 1, DOWN = 2, TESTING = 3, UNKNOWN = 4, DORMANT = 5, NOT_PRESENT = 6, LOWER_LAYER_DOWN = 7, }; pub const NET_IF_OPER_STATUS_UP = NET_IF_OPER_STATUS.UP; pub const NET_IF_OPER_STATUS_DOWN = NET_IF_OPER_STATUS.DOWN; pub const NET_IF_OPER_STATUS_TESTING = NET_IF_OPER_STATUS.TESTING; pub const NET_IF_OPER_STATUS_UNKNOWN = NET_IF_OPER_STATUS.UNKNOWN; pub const NET_IF_OPER_STATUS_DORMANT = NET_IF_OPER_STATUS.DORMANT; pub const NET_IF_OPER_STATUS_NOT_PRESENT = NET_IF_OPER_STATUS.NOT_PRESENT; pub const NET_IF_OPER_STATUS_LOWER_LAYER_DOWN = NET_IF_OPER_STATUS.LOWER_LAYER_DOWN; pub const NET_IF_ADMIN_STATUS = enum(i32) { UP = 1, DOWN = 2, TESTING = 3, }; pub const NET_IF_ADMIN_STATUS_UP = NET_IF_ADMIN_STATUS.UP; pub const NET_IF_ADMIN_STATUS_DOWN = NET_IF_ADMIN_STATUS.DOWN; pub const NET_IF_ADMIN_STATUS_TESTING = NET_IF_ADMIN_STATUS.TESTING; pub const NET_IF_RCV_ADDRESS_TYPE = enum(i32) { OTHER = 1, VOLATILE = 2, NON_VOLATILE = 3, }; pub const NET_IF_RCV_ADDRESS_TYPE_OTHER = NET_IF_RCV_ADDRESS_TYPE.OTHER; pub const NET_IF_RCV_ADDRESS_TYPE_VOLATILE = NET_IF_RCV_ADDRESS_TYPE.VOLATILE; pub const NET_IF_RCV_ADDRESS_TYPE_NON_VOLATILE = NET_IF_RCV_ADDRESS_TYPE.NON_VOLATILE; pub const NET_IF_RCV_ADDRESS_LH = extern struct { ifRcvAddressType: NET_IF_RCV_ADDRESS_TYPE, ifRcvAddressLength: u16, ifRcvAddressOffset: u16, }; pub const NET_IF_ALIAS_LH = extern struct { ifAliasLength: u16, ifAliasOffset: u16, }; pub const NET_LUID_LH = extern union { Value: u64, Info: extern struct { _bitfield: u64, }, }; pub const NET_IF_CONNECTION_TYPE = enum(i32) { DEDICATED = 1, PASSIVE = 2, DEMAND = 3, MAXIMUM = 4, }; pub const NET_IF_CONNECTION_DEDICATED = NET_IF_CONNECTION_TYPE.DEDICATED; pub const NET_IF_CONNECTION_PASSIVE = NET_IF_CONNECTION_TYPE.PASSIVE; pub const NET_IF_CONNECTION_DEMAND = NET_IF_CONNECTION_TYPE.DEMAND; pub const NET_IF_CONNECTION_MAXIMUM = NET_IF_CONNECTION_TYPE.MAXIMUM; pub const TUNNEL_TYPE = enum(i32) { NONE = 0, OTHER = 1, DIRECT = 2, @"6TO4" = 11, ISATAP = 13, TEREDO = 14, IPHTTPS = 15, }; pub const TUNNEL_TYPE_NONE = TUNNEL_TYPE.NONE; pub const TUNNEL_TYPE_OTHER = TUNNEL_TYPE.OTHER; pub const TUNNEL_TYPE_DIRECT = TUNNEL_TYPE.DIRECT; pub const TUNNEL_TYPE_6TO4 = TUNNEL_TYPE.@"6TO4"; pub const TUNNEL_TYPE_ISATAP = TUNNEL_TYPE.ISATAP; pub const TUNNEL_TYPE_TEREDO = TUNNEL_TYPE.TEREDO; pub const TUNNEL_TYPE_IPHTTPS = TUNNEL_TYPE.IPHTTPS; pub const NET_IF_ACCESS_TYPE = enum(i32) { LOOPBACK = 1, BROADCAST = 2, POINT_TO_POINT = 3, POINT_TO_MULTI_POINT = 4, MAXIMUM = 5, }; pub const NET_IF_ACCESS_LOOPBACK = NET_IF_ACCESS_TYPE.LOOPBACK; pub const NET_IF_ACCESS_BROADCAST = NET_IF_ACCESS_TYPE.BROADCAST; pub const NET_IF_ACCESS_POINT_TO_POINT = NET_IF_ACCESS_TYPE.POINT_TO_POINT; pub const NET_IF_ACCESS_POINT_TO_MULTI_POINT = NET_IF_ACCESS_TYPE.POINT_TO_MULTI_POINT; pub const NET_IF_ACCESS_MAXIMUM = NET_IF_ACCESS_TYPE.MAXIMUM; pub const NET_IF_DIRECTION_TYPE = enum(i32) { SENDRECEIVE = 0, SENDONLY = 1, RECEIVEONLY = 2, MAXIMUM = 3, }; pub const NET_IF_DIRECTION_SENDRECEIVE = NET_IF_DIRECTION_TYPE.SENDRECEIVE; pub const NET_IF_DIRECTION_SENDONLY = NET_IF_DIRECTION_TYPE.SENDONLY; pub const NET_IF_DIRECTION_RECEIVEONLY = NET_IF_DIRECTION_TYPE.RECEIVEONLY; pub const NET_IF_DIRECTION_MAXIMUM = NET_IF_DIRECTION_TYPE.MAXIMUM; pub const NET_IF_MEDIA_CONNECT_STATE = enum(i32) { Unknown = 0, Connected = 1, Disconnected = 2, }; pub const MediaConnectStateUnknown = NET_IF_MEDIA_CONNECT_STATE.Unknown; pub const MediaConnectStateConnected = NET_IF_MEDIA_CONNECT_STATE.Connected; pub const MediaConnectStateDisconnected = NET_IF_MEDIA_CONNECT_STATE.Disconnected; pub const NET_IF_MEDIA_DUPLEX_STATE = enum(i32) { Unknown = 0, Half = 1, Full = 2, }; pub const MediaDuplexStateUnknown = NET_IF_MEDIA_DUPLEX_STATE.Unknown; pub const MediaDuplexStateHalf = NET_IF_MEDIA_DUPLEX_STATE.Half; pub const MediaDuplexStateFull = NET_IF_MEDIA_DUPLEX_STATE.Full; pub const NET_PHYSICAL_LOCATION_LH = extern struct { BusNumber: u32, SlotNumber: u32, FunctionNumber: u32, }; pub const IF_COUNTED_STRING_LH = extern struct { Length: u16, String: [257]u16, }; pub const IF_PHYSICAL_ADDRESS_LH = extern struct { Length: u16, Address: [32]u8, }; pub const IF_ADMINISTRATIVE_STATE = enum(i32) { DISABLED = 0, ENABLED = 1, DEMANDDIAL = 2, }; pub const IF_ADMINISTRATIVE_DISABLED = IF_ADMINISTRATIVE_STATE.DISABLED; pub const IF_ADMINISTRATIVE_ENABLED = IF_ADMINISTRATIVE_STATE.ENABLED; pub const IF_ADMINISTRATIVE_DEMANDDIAL = IF_ADMINISTRATIVE_STATE.DEMANDDIAL; pub const IF_OPER_STATUS = enum(i32) { Up = 1, Down = 2, Testing = 3, Unknown = 4, Dormant = 5, NotPresent = 6, LowerLayerDown = 7, }; pub const IfOperStatusUp = IF_OPER_STATUS.Up; pub const IfOperStatusDown = IF_OPER_STATUS.Down; pub const IfOperStatusTesting = IF_OPER_STATUS.Testing; pub const IfOperStatusUnknown = IF_OPER_STATUS.Unknown; pub const IfOperStatusDormant = IF_OPER_STATUS.Dormant; pub const IfOperStatusNotPresent = IF_OPER_STATUS.NotPresent; pub const IfOperStatusLowerLayerDown = IF_OPER_STATUS.LowerLayerDown; pub const NDIS_INTERFACE_INFORMATION = extern struct { ifOperStatus: NET_IF_OPER_STATUS, ifOperStatusFlags: u32, MediaConnectState: NET_IF_MEDIA_CONNECT_STATE, MediaDuplexState: NET_IF_MEDIA_DUPLEX_STATE, ifMtu: u32, ifPromiscuousMode: BOOLEAN, ifDeviceWakeUpEnable: BOOLEAN, XmitLinkSpeed: u64, RcvLinkSpeed: u64, ifLastChange: u64, ifCounterDiscontinuityTime: u64, ifInUnknownProtos: u64, ifInDiscards: u64, ifInErrors: u64, ifHCInOctets: u64, ifHCInUcastPkts: u64, ifHCInMulticastPkts: u64, ifHCInBroadcastPkts: u64, ifHCOutOctets: u64, ifHCOutUcastPkts: u64, ifHCOutMulticastPkts: u64, ifHCOutBroadcastPkts: u64, ifOutErrors: u64, ifOutDiscards: u64, ifHCInUcastOctets: u64, ifHCInMulticastOctets: u64, ifHCInBroadcastOctets: u64, ifHCOutUcastOctets: u64, ifHCOutMulticastOctets: u64, ifHCOutBroadcastOctets: u64, CompartmentId: u32, SupportedStatistics: u32, }; pub const MIB_NOTIFICATION_TYPE = enum(i32) { ParameterNotification = 0, AddInstance = 1, DeleteInstance = 2, InitialNotification = 3, }; pub const MibParameterNotification = MIB_NOTIFICATION_TYPE.ParameterNotification; pub const MibAddInstance = MIB_NOTIFICATION_TYPE.AddInstance; pub const MibDeleteInstance = MIB_NOTIFICATION_TYPE.DeleteInstance; pub const MibInitialNotification = MIB_NOTIFICATION_TYPE.InitialNotification; pub const MIB_IF_ROW2 = extern struct { InterfaceLuid: NET_LUID_LH, InterfaceIndex: u32, InterfaceGuid: Guid, Alias: [257]u16, Description: [257]u16, PhysicalAddressLength: u32, PhysicalAddress: [32]u8, PermanentPhysicalAddress: [32]u8, Mtu: u32, Type: u32, TunnelType: TUNNEL_TYPE, MediaType: NDIS_MEDIUM, PhysicalMediumType: NDIS_PHYSICAL_MEDIUM, AccessType: NET_IF_ACCESS_TYPE, DirectionType: NET_IF_DIRECTION_TYPE, InterfaceAndOperStatusFlags: extern struct { _bitfield: u8, }, OperStatus: IF_OPER_STATUS, AdminStatus: NET_IF_ADMIN_STATUS, MediaConnectState: NET_IF_MEDIA_CONNECT_STATE, NetworkGuid: Guid, ConnectionType: NET_IF_CONNECTION_TYPE, TransmitLinkSpeed: u64, ReceiveLinkSpeed: u64, InOctets: u64, InUcastPkts: u64, InNUcastPkts: u64, InDiscards: u64, InErrors: u64, InUnknownProtos: u64, InUcastOctets: u64, InMulticastOctets: u64, InBroadcastOctets: u64, OutOctets: u64, OutUcastPkts: u64, OutNUcastPkts: u64, OutDiscards: u64, OutErrors: u64, OutUcastOctets: u64, OutMulticastOctets: u64, OutBroadcastOctets: u64, OutQLen: u64, }; pub const MIB_IF_TABLE2 = extern struct { NumEntries: u32, Table: [1]MIB_IF_ROW2, }; pub const MIB_IF_ENTRY_LEVEL = enum(i32) { l = 0, WithoutStatistics = 2, }; pub const MibIfEntryNormal = MIB_IF_ENTRY_LEVEL.l; pub const MibIfEntryNormalWithoutStatistics = MIB_IF_ENTRY_LEVEL.WithoutStatistics; pub const MIB_IF_TABLE_LEVEL = enum(i32) { Normal = 0, Raw = 1, NormalWithoutStatistics = 2, }; pub const MibIfTableNormal = MIB_IF_TABLE_LEVEL.Normal; pub const MibIfTableRaw = MIB_IF_TABLE_LEVEL.Raw; pub const MibIfTableNormalWithoutStatistics = MIB_IF_TABLE_LEVEL.NormalWithoutStatistics; pub const MIB_IPINTERFACE_ROW = extern struct { Family: u16, InterfaceLuid: NET_LUID_LH, InterfaceIndex: u32, MaxReassemblySize: u32, InterfaceIdentifier: u64, MinRouterAdvertisementInterval: u32, MaxRouterAdvertisementInterval: u32, AdvertisingEnabled: BOOLEAN, ForwardingEnabled: BOOLEAN, WeakHostSend: BOOLEAN, WeakHostReceive: BOOLEAN, UseAutomaticMetric: BOOLEAN, UseNeighborUnreachabilityDetection: BOOLEAN, ManagedAddressConfigurationSupported: BOOLEAN, OtherStatefulConfigurationSupported: BOOLEAN, AdvertiseDefaultRoute: BOOLEAN, RouterDiscoveryBehavior: NL_ROUTER_DISCOVERY_BEHAVIOR, DadTransmits: u32, BaseReachableTime: u32, RetransmitTime: u32, PathMtuDiscoveryTimeout: u32, LinkLocalAddressBehavior: NL_LINK_LOCAL_ADDRESS_BEHAVIOR, LinkLocalAddressTimeout: u32, ZoneIndices: [16]u32, SitePrefixLength: u32, Metric: u32, NlMtu: u32, Connected: BOOLEAN, SupportsWakeUpPatterns: BOOLEAN, SupportsNeighborDiscovery: BOOLEAN, SupportsRouterDiscovery: BOOLEAN, ReachableTime: u32, TransmitOffload: NL_INTERFACE_OFFLOAD_ROD, ReceiveOffload: NL_INTERFACE_OFFLOAD_ROD, DisableDefaultRoutes: BOOLEAN, }; pub const MIB_IPINTERFACE_TABLE = extern struct { NumEntries: u32, Table: [1]MIB_IPINTERFACE_ROW, }; pub const MIB_IFSTACK_ROW = extern struct { HigherLayerInterfaceIndex: u32, LowerLayerInterfaceIndex: u32, }; pub const MIB_INVERTEDIFSTACK_ROW = extern struct { LowerLayerInterfaceIndex: u32, HigherLayerInterfaceIndex: u32, }; pub const MIB_IFSTACK_TABLE = extern struct { NumEntries: u32, Table: [1]MIB_IFSTACK_ROW, }; pub const MIB_INVERTEDIFSTACK_TABLE = extern struct { NumEntries: u32, Table: [1]MIB_INVERTEDIFSTACK_ROW, }; pub const PIPINTERFACE_CHANGE_CALLBACK = fn( CallerContext: ?*anyopaque, Row: ?*MIB_IPINTERFACE_ROW, NotificationType: MIB_NOTIFICATION_TYPE, ) callconv(@import("std").os.windows.WINAPI) void; pub const MIB_IP_NETWORK_CONNECTION_BANDWIDTH_ESTIMATES = extern struct { InboundBandwidthInformation: NL_BANDWIDTH_INFORMATION, OutboundBandwidthInformation: NL_BANDWIDTH_INFORMATION, }; pub const MIB_UNICASTIPADDRESS_ROW = extern struct { Address: SOCKADDR_INET, InterfaceLuid: NET_LUID_LH, InterfaceIndex: u32, PrefixOrigin: NL_PREFIX_ORIGIN, SuffixOrigin: NL_SUFFIX_ORIGIN, ValidLifetime: u32, PreferredLifetime: u32, OnLinkPrefixLength: u8, SkipAsSource: BOOLEAN, DadState: NL_DAD_STATE, ScopeId: SCOPE_ID, CreationTimeStamp: LARGE_INTEGER, }; pub const MIB_UNICASTIPADDRESS_TABLE = extern struct { NumEntries: u32, Table: [1]MIB_UNICASTIPADDRESS_ROW, }; pub const PUNICAST_IPADDRESS_CHANGE_CALLBACK = fn( CallerContext: ?*anyopaque, Row: ?*MIB_UNICASTIPADDRESS_ROW, NotificationType: MIB_NOTIFICATION_TYPE, ) callconv(@import("std").os.windows.WINAPI) void; pub const PSTABLE_UNICAST_IPADDRESS_TABLE_CALLBACK = fn( CallerContext: ?*anyopaque, AddressTable: ?*MIB_UNICASTIPADDRESS_TABLE, ) callconv(@import("std").os.windows.WINAPI) void; pub const MIB_ANYCASTIPADDRESS_ROW = extern struct { Address: SOCKADDR_INET, InterfaceLuid: NET_LUID_LH, InterfaceIndex: u32, ScopeId: SCOPE_ID, }; pub const MIB_ANYCASTIPADDRESS_TABLE = extern struct { NumEntries: u32, Table: [1]MIB_ANYCASTIPADDRESS_ROW, }; pub const MIB_MULTICASTIPADDRESS_ROW = extern struct { Address: SOCKADDR_INET, InterfaceIndex: u32, InterfaceLuid: NET_LUID_LH, ScopeId: SCOPE_ID, }; pub const MIB_MULTICASTIPADDRESS_TABLE = extern struct { NumEntries: u32, Table: [1]MIB_MULTICASTIPADDRESS_ROW, }; pub const IP_ADDRESS_PREFIX = extern struct { Prefix: SOCKADDR_INET, PrefixLength: u8, }; pub const MIB_IPFORWARD_ROW2 = extern struct { InterfaceLuid: NET_LUID_LH, InterfaceIndex: u32, DestinationPrefix: IP_ADDRESS_PREFIX, NextHop: SOCKADDR_INET, SitePrefixLength: u8, ValidLifetime: u32, PreferredLifetime: u32, Metric: u32, Protocol: NL_ROUTE_PROTOCOL, Loopback: BOOLEAN, AutoconfigureAddress: BOOLEAN, Publish: BOOLEAN, Immortal: BOOLEAN, Age: u32, Origin: NL_ROUTE_ORIGIN, }; pub const MIB_IPFORWARD_TABLE2 = extern struct { NumEntries: u32, Table: [1]MIB_IPFORWARD_ROW2, }; pub const PIPFORWARD_CHANGE_CALLBACK = fn( CallerContext: ?*anyopaque, Row: ?*MIB_IPFORWARD_ROW2, NotificationType: MIB_NOTIFICATION_TYPE, ) callconv(@import("std").os.windows.WINAPI) void; pub const MIB_IPPATH_ROW = extern struct { Source: SOCKADDR_INET, Destination: SOCKADDR_INET, InterfaceLuid: NET_LUID_LH, InterfaceIndex: u32, CurrentNextHop: SOCKADDR_INET, PathMtu: u32, RttMean: u32, RttDeviation: u32, Anonymous: extern union { LastReachable: u32, LastUnreachable: u32, }, IsReachable: BOOLEAN, LinkTransmitSpeed: u64, LinkReceiveSpeed: u64, }; pub const MIB_IPPATH_TABLE = extern struct { NumEntries: u32, Table: [1]MIB_IPPATH_ROW, }; pub const MIB_IPNET_ROW2 = extern struct { Address: SOCKADDR_INET, InterfaceIndex: u32, InterfaceLuid: NET_LUID_LH, PhysicalAddress: [32]u8, PhysicalAddressLength: u32, State: NL_NEIGHBOR_STATE, Anonymous: extern union { Anonymous: extern struct { _bitfield: u8, }, Flags: u8, }, ReachabilityTime: extern union { LastReachable: u32, LastUnreachable: u32, }, }; pub const MIB_IPNET_TABLE2 = extern struct { NumEntries: u32, Table: [1]MIB_IPNET_ROW2, }; pub const PTEREDO_PORT_CHANGE_CALLBACK = fn( CallerContext: ?*anyopaque, Port: u16, NotificationType: MIB_NOTIFICATION_TYPE, ) callconv(@import("std").os.windows.WINAPI) void; pub const DNS_SETTINGS = extern struct { Version: u32, Flags: u64, Hostname: ?PWSTR, Domain: ?PWSTR, SearchList: ?PWSTR, }; pub const DNS_SETTINGS2 = extern struct { Version: u32, Flags: u64, Hostname: ?PWSTR, Domain: ?PWSTR, SearchList: ?PWSTR, SettingFlags: u64, }; pub const DNS_DOH_SERVER_SETTINGS = extern struct { Template: ?PWSTR, Flags: u64, }; pub const DNS_SERVER_PROPERTY_TYPE = enum(i32) { InvalidProperty = 0, DohProperty = 1, }; pub const DnsServerInvalidProperty = DNS_SERVER_PROPERTY_TYPE.InvalidProperty; pub const DnsServerDohProperty = DNS_SERVER_PROPERTY_TYPE.DohProperty; pub const DNS_SERVER_PROPERTY_TYPES = extern union { DohSettings: ?*DNS_DOH_SERVER_SETTINGS, }; pub const DNS_SERVER_PROPERTY = extern struct { Version: u32, ServerIndex: u32, Type: DNS_SERVER_PROPERTY_TYPE, Property: DNS_SERVER_PROPERTY_TYPES, }; pub const DNS_INTERFACE_SETTINGS = extern struct { Version: u32, Flags: u64, Domain: ?PWSTR, NameServer: ?PWSTR, SearchList: ?PWSTR, RegistrationEnabled: u32, RegisterAdapterName: u32, EnableLLMNR: u32, QueryAdapterName: u32, ProfileNameServer: ?PWSTR, }; pub const DNS_INTERFACE_SETTINGS_EX = extern struct { SettingsV1: DNS_INTERFACE_SETTINGS, DisableUnconstrainedQueries: u32, SupplementalSearchList: ?PWSTR, }; pub const DNS_INTERFACE_SETTINGS3 = extern struct { Version: u32, Flags: u64, Domain: ?PWSTR, NameServer: ?PWSTR, SearchList: ?PWSTR, RegistrationEnabled: u32, RegisterAdapterName: u32, EnableLLMNR: u32, QueryAdapterName: u32, ProfileNameServer: ?PWSTR, DisableUnconstrainedQueries: u32, SupplementalSearchList: ?PWSTR, cServerProperties: u32, ServerProperties: ?*DNS_SERVER_PROPERTY, cProfileServerProperties: u32, ProfileServerProperties: ?*DNS_SERVER_PROPERTY, }; pub const PNETWORK_CONNECTIVITY_HINT_CHANGE_CALLBACK = fn( CallerContext: ?*anyopaque, ConnectivityHint: NL_NETWORK_CONNECTIVITY_HINT, ) callconv(@import("std").os.windows.WINAPI) void; pub const MIB_OPAQUE_QUERY = extern struct { dwVarId: u32, rgdwVarIndex: [1]u32, }; pub const MIB_IFNUMBER = extern struct { dwValue: u32, }; pub const MIB_IFROW = extern struct { wszName: [256]u16, dwIndex: u32, dwType: u32, dwMtu: u32, dwSpeed: u32, dwPhysAddrLen: u32, bPhysAddr: [8]u8, dwAdminStatus: u32, dwOperStatus: INTERNAL_IF_OPER_STATUS, dwLastChange: u32, dwInOctets: u32, dwInUcastPkts: u32, dwInNUcastPkts: u32, dwInDiscards: u32, dwInErrors: u32, dwInUnknownProtos: u32, dwOutOctets: u32, dwOutUcastPkts: u32, dwOutNUcastPkts: u32, dwOutDiscards: u32, dwOutErrors: u32, dwOutQLen: u32, dwDescrLen: u32, bDescr: [256]u8, }; pub const MIB_IFTABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IFROW, }; pub const MIB_IPADDRROW_XP = extern struct { dwAddr: u32, dwIndex: u32, dwMask: u32, dwBCastAddr: u32, dwReasmSize: u32, unused1: u16, wType: u16, }; pub const MIB_IPADDRROW_W2K = extern struct { dwAddr: u32, dwIndex: u32, dwMask: u32, dwBCastAddr: u32, dwReasmSize: u32, unused1: u16, unused2: u16, }; pub const MIB_IPADDRTABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IPADDRROW_XP, }; pub const MIB_IPFORWARDNUMBER = extern struct { dwValue: u32, }; pub const MIB_IPFORWARD_TYPE = enum(i32) { OTHER = 1, INVALID = 2, DIRECT = 3, INDIRECT = 4, }; // TODO: enum 'MIB_IPFORWARD_TYPE' has known issues with its value aliases pub const MIB_IPFORWARDROW = extern struct { dwForwardDest: u32, dwForwardMask: u32, dwForwardPolicy: u32, dwForwardNextHop: u32, dwForwardIfIndex: u32, Anonymous1: extern union { dwForwardType: u32, ForwardType: MIB_IPFORWARD_TYPE, }, Anonymous2: extern union { dwForwardProto: u32, ForwardProto: NL_ROUTE_PROTOCOL, }, dwForwardAge: u32, dwForwardNextHopAS: u32, dwForwardMetric1: u32, dwForwardMetric2: u32, dwForwardMetric3: u32, dwForwardMetric4: u32, dwForwardMetric5: u32, }; pub const MIB_IPFORWARDTABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IPFORWARDROW, }; pub const MIB_IPNET_TYPE = enum(i32) { OTHER = 1, INVALID = 2, DYNAMIC = 3, STATIC = 4, }; pub const MIB_IPNET_TYPE_OTHER = MIB_IPNET_TYPE.OTHER; pub const MIB_IPNET_TYPE_INVALID = MIB_IPNET_TYPE.INVALID; pub const MIB_IPNET_TYPE_DYNAMIC = MIB_IPNET_TYPE.DYNAMIC; pub const MIB_IPNET_TYPE_STATIC = MIB_IPNET_TYPE.STATIC; pub const MIB_IPNETROW_LH = extern struct { dwIndex: u32, dwPhysAddrLen: u32, bPhysAddr: [8]u8, dwAddr: u32, Anonymous: extern union { dwType: u32, Type: MIB_IPNET_TYPE, }, }; pub const MIB_IPNETROW_W2K = extern struct { dwIndex: u32, dwPhysAddrLen: u32, bPhysAddr: [8]u8, dwAddr: u32, dwType: u32, }; pub const MIB_IPNETTABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IPNETROW_LH, }; pub const MIB_IPSTATS_FORWARDING = enum(i32) { FORWARDING = 1, NOT_FORWARDING = 2, }; pub const MIB_IP_FORWARDING = MIB_IPSTATS_FORWARDING.FORWARDING; pub const MIB_IP_NOT_FORWARDING = MIB_IPSTATS_FORWARDING.NOT_FORWARDING; pub const MIB_IPSTATS_LH = extern struct { Anonymous: extern union { dwForwarding: u32, Forwarding: MIB_IPSTATS_FORWARDING, }, dwDefaultTTL: u32, dwInReceives: u32, dwInHdrErrors: u32, dwInAddrErrors: u32, dwForwDatagrams: u32, dwInUnknownProtos: u32, dwInDiscards: u32, dwInDelivers: u32, dwOutRequests: u32, dwRoutingDiscards: u32, dwOutDiscards: u32, dwOutNoRoutes: u32, dwReasmTimeout: u32, dwReasmReqds: u32, dwReasmOks: u32, dwReasmFails: u32, dwFragOks: u32, dwFragFails: u32, dwFragCreates: u32, dwNumIf: u32, dwNumAddr: u32, dwNumRoutes: u32, }; pub const MIB_IPSTATS_W2K = extern struct { dwForwarding: u32, dwDefaultTTL: u32, dwInReceives: u32, dwInHdrErrors: u32, dwInAddrErrors: u32, dwForwDatagrams: u32, dwInUnknownProtos: u32, dwInDiscards: u32, dwInDelivers: u32, dwOutRequests: u32, dwRoutingDiscards: u32, dwOutDiscards: u32, dwOutNoRoutes: u32, dwReasmTimeout: u32, dwReasmReqds: u32, dwReasmOks: u32, dwReasmFails: u32, dwFragOks: u32, dwFragFails: u32, dwFragCreates: u32, dwNumIf: u32, dwNumAddr: u32, dwNumRoutes: u32, }; pub const MIBICMPSTATS = extern struct { dwMsgs: u32, dwErrors: u32, dwDestUnreachs: u32, dwTimeExcds: u32, dwParmProbs: u32, dwSrcQuenchs: u32, dwRedirects: u32, dwEchos: u32, dwEchoReps: u32, dwTimestamps: u32, dwTimestampReps: u32, dwAddrMasks: u32, dwAddrMaskReps: u32, }; pub const MIBICMPINFO = extern struct { icmpInStats: MIBICMPSTATS, icmpOutStats: MIBICMPSTATS, }; pub const MIB_ICMP = extern struct { stats: MIBICMPINFO, }; pub const MIBICMPSTATS_EX_XPSP1 = extern struct { dwMsgs: u32, dwErrors: u32, rgdwTypeCount: [256]u32, }; pub const MIB_ICMP_EX_XPSP1 = extern struct { icmpInStats: MIBICMPSTATS_EX_XPSP1, icmpOutStats: MIBICMPSTATS_EX_XPSP1, }; pub const ICMP6_TYPE = enum(i32) { ICMP6_DST_UNREACH = 1, ICMP6_PACKET_TOO_BIG = 2, ICMP6_TIME_EXCEEDED = 3, ICMP6_PARAM_PROB = 4, ICMP6_ECHO_REQUEST = 128, ICMP6_ECHO_REPLY = 129, ICMP6_MEMBERSHIP_QUERY = 130, ICMP6_MEMBERSHIP_REPORT = 131, ICMP6_MEMBERSHIP_REDUCTION = 132, ND_ROUTER_SOLICIT = 133, ND_ROUTER_ADVERT = 134, ND_NEIGHBOR_SOLICIT = 135, ND_NEIGHBOR_ADVERT = 136, ND_REDIRECT = 137, ICMP6_V2_MEMBERSHIP_REPORT = 143, }; pub const ICMP6_DST_UNREACH = ICMP6_TYPE.ICMP6_DST_UNREACH; pub const ICMP6_PACKET_TOO_BIG = ICMP6_TYPE.ICMP6_PACKET_TOO_BIG; pub const ICMP6_TIME_EXCEEDED = ICMP6_TYPE.ICMP6_TIME_EXCEEDED; pub const ICMP6_PARAM_PROB = ICMP6_TYPE.ICMP6_PARAM_PROB; pub const ICMP6_ECHO_REQUEST = ICMP6_TYPE.ICMP6_ECHO_REQUEST; pub const ICMP6_ECHO_REPLY = ICMP6_TYPE.ICMP6_ECHO_REPLY; pub const ICMP6_MEMBERSHIP_QUERY = ICMP6_TYPE.ICMP6_MEMBERSHIP_QUERY; pub const ICMP6_MEMBERSHIP_REPORT = ICMP6_TYPE.ICMP6_MEMBERSHIP_REPORT; pub const ICMP6_MEMBERSHIP_REDUCTION = ICMP6_TYPE.ICMP6_MEMBERSHIP_REDUCTION; pub const ND_ROUTER_SOLICIT = ICMP6_TYPE.ND_ROUTER_SOLICIT; pub const ND_ROUTER_ADVERT = ICMP6_TYPE.ND_ROUTER_ADVERT; pub const ND_NEIGHBOR_SOLICIT = ICMP6_TYPE.ND_NEIGHBOR_SOLICIT; pub const ND_NEIGHBOR_ADVERT = ICMP6_TYPE.ND_NEIGHBOR_ADVERT; pub const ND_REDIRECT = ICMP6_TYPE.ND_REDIRECT; pub const ICMP6_V2_MEMBERSHIP_REPORT = ICMP6_TYPE.ICMP6_V2_MEMBERSHIP_REPORT; pub const ICMP4_TYPE = enum(i32) { ECHO_REPLY = 0, DST_UNREACH = 3, SOURCE_QUENCH = 4, REDIRECT = 5, ECHO_REQUEST = 8, ROUTER_ADVERT = 9, ROUTER_SOLICIT = 10, TIME_EXCEEDED = 11, PARAM_PROB = 12, TIMESTAMP_REQUEST = 13, TIMESTAMP_REPLY = 14, MASK_REQUEST = 17, MASK_REPLY = 18, }; pub const ICMP4_ECHO_REPLY = ICMP4_TYPE.ECHO_REPLY; pub const ICMP4_DST_UNREACH = ICMP4_TYPE.DST_UNREACH; pub const ICMP4_SOURCE_QUENCH = ICMP4_TYPE.SOURCE_QUENCH; pub const ICMP4_REDIRECT = ICMP4_TYPE.REDIRECT; pub const ICMP4_ECHO_REQUEST = ICMP4_TYPE.ECHO_REQUEST; pub const ICMP4_ROUTER_ADVERT = ICMP4_TYPE.ROUTER_ADVERT; pub const ICMP4_ROUTER_SOLICIT = ICMP4_TYPE.ROUTER_SOLICIT; pub const ICMP4_TIME_EXCEEDED = ICMP4_TYPE.TIME_EXCEEDED; pub const ICMP4_PARAM_PROB = ICMP4_TYPE.PARAM_PROB; pub const ICMP4_TIMESTAMP_REQUEST = ICMP4_TYPE.TIMESTAMP_REQUEST; pub const ICMP4_TIMESTAMP_REPLY = ICMP4_TYPE.TIMESTAMP_REPLY; pub const ICMP4_MASK_REQUEST = ICMP4_TYPE.MASK_REQUEST; pub const ICMP4_MASK_REPLY = ICMP4_TYPE.MASK_REPLY; pub const MIB_IPMCAST_OIF_XP = extern struct { dwOutIfIndex: u32, dwNextHopAddr: u32, dwReserved: u32, dwReserved1: u32, }; pub const MIB_IPMCAST_OIF_W2K = extern struct { dwOutIfIndex: u32, dwNextHopAddr: u32, pvReserved: ?*anyopaque, dwReserved: u32, }; pub const MIB_IPMCAST_MFE = extern struct { dwGroup: u32, dwSource: u32, dwSrcMask: u32, dwUpStrmNgbr: u32, dwInIfIndex: u32, dwInIfProtocol: u32, dwRouteProtocol: u32, dwRouteNetwork: u32, dwRouteMask: u32, ulUpTime: u32, ulExpiryTime: u32, ulTimeOut: u32, ulNumOutIf: u32, fFlags: u32, dwReserved: u32, rgmioOutInfo: [1]MIB_IPMCAST_OIF_XP, }; pub const MIB_MFE_TABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IPMCAST_MFE, }; pub const MIB_IPMCAST_OIF_STATS_LH = extern struct { dwOutIfIndex: u32, dwNextHopAddr: u32, dwDialContext: u32, ulTtlTooLow: u32, ulFragNeeded: u32, ulOutPackets: u32, ulOutDiscards: u32, }; pub const MIB_IPMCAST_OIF_STATS_W2K = extern struct { dwOutIfIndex: u32, dwNextHopAddr: u32, pvDialContext: ?*anyopaque, ulTtlTooLow: u32, ulFragNeeded: u32, ulOutPackets: u32, ulOutDiscards: u32, }; pub const MIB_IPMCAST_MFE_STATS = extern struct { dwGroup: u32, dwSource: u32, dwSrcMask: u32, dwUpStrmNgbr: u32, dwInIfIndex: u32, dwInIfProtocol: u32, dwRouteProtocol: u32, dwRouteNetwork: u32, dwRouteMask: u32, ulUpTime: u32, ulExpiryTime: u32, ulNumOutIf: u32, ulInPkts: u32, ulInOctets: u32, ulPktsDifferentIf: u32, ulQueueOverflow: u32, rgmiosOutStats: [1]MIB_IPMCAST_OIF_STATS_LH, }; pub const MIB_MFE_STATS_TABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IPMCAST_MFE_STATS, }; pub const MIB_IPMCAST_MFE_STATS_EX_XP = extern struct { dwGroup: u32, dwSource: u32, dwSrcMask: u32, dwUpStrmNgbr: u32, dwInIfIndex: u32, dwInIfProtocol: u32, dwRouteProtocol: u32, dwRouteNetwork: u32, dwRouteMask: u32, ulUpTime: u32, ulExpiryTime: u32, ulNumOutIf: u32, ulInPkts: u32, ulInOctets: u32, ulPktsDifferentIf: u32, ulQueueOverflow: u32, ulUninitMfe: u32, ulNegativeMfe: u32, ulInDiscards: u32, ulInHdrErrors: u32, ulTotalOutPackets: u32, rgmiosOutStats: [1]MIB_IPMCAST_OIF_STATS_LH, }; pub const MIB_MFE_STATS_TABLE_EX_XP = extern struct { dwNumEntries: u32, table: [1]?*MIB_IPMCAST_MFE_STATS_EX_XP, }; pub const MIB_IPMCAST_GLOBAL = extern struct { dwEnable: u32, }; pub const MIB_IPMCAST_IF_ENTRY = extern struct { dwIfIndex: u32, dwTtl: u32, dwProtocol: u32, dwRateLimit: u32, ulInMcastOctets: u32, ulOutMcastOctets: u32, }; pub const MIB_IPMCAST_IF_TABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IPMCAST_IF_ENTRY, }; pub const MIB_TCP_STATE = enum(i32) { CLOSED = 1, LISTEN = 2, SYN_SENT = 3, SYN_RCVD = 4, ESTAB = 5, FIN_WAIT1 = 6, FIN_WAIT2 = 7, CLOSE_WAIT = 8, CLOSING = 9, LAST_ACK = 10, TIME_WAIT = 11, DELETE_TCB = 12, RESERVED = 100, }; pub const MIB_TCP_STATE_CLOSED = MIB_TCP_STATE.CLOSED; pub const MIB_TCP_STATE_LISTEN = MIB_TCP_STATE.LISTEN; pub const MIB_TCP_STATE_SYN_SENT = MIB_TCP_STATE.SYN_SENT; pub const MIB_TCP_STATE_SYN_RCVD = MIB_TCP_STATE.SYN_RCVD; pub const MIB_TCP_STATE_ESTAB = MIB_TCP_STATE.ESTAB; pub const MIB_TCP_STATE_FIN_WAIT1 = MIB_TCP_STATE.FIN_WAIT1; pub const MIB_TCP_STATE_FIN_WAIT2 = MIB_TCP_STATE.FIN_WAIT2; pub const MIB_TCP_STATE_CLOSE_WAIT = MIB_TCP_STATE.CLOSE_WAIT; pub const MIB_TCP_STATE_CLOSING = MIB_TCP_STATE.CLOSING; pub const MIB_TCP_STATE_LAST_ACK = MIB_TCP_STATE.LAST_ACK; pub const MIB_TCP_STATE_TIME_WAIT = MIB_TCP_STATE.TIME_WAIT; pub const MIB_TCP_STATE_DELETE_TCB = MIB_TCP_STATE.DELETE_TCB; pub const MIB_TCP_STATE_RESERVED = MIB_TCP_STATE.RESERVED; pub const TCP_CONNECTION_OFFLOAD_STATE = enum(i32) { InHost = 0, Offloading = 1, Offloaded = 2, Uploading = 3, Max = 4, }; pub const TcpConnectionOffloadStateInHost = TCP_CONNECTION_OFFLOAD_STATE.InHost; pub const TcpConnectionOffloadStateOffloading = TCP_CONNECTION_OFFLOAD_STATE.Offloading; pub const TcpConnectionOffloadStateOffloaded = TCP_CONNECTION_OFFLOAD_STATE.Offloaded; pub const TcpConnectionOffloadStateUploading = TCP_CONNECTION_OFFLOAD_STATE.Uploading; pub const TcpConnectionOffloadStateMax = TCP_CONNECTION_OFFLOAD_STATE.Max; pub const MIB_TCPROW_LH = extern struct { Anonymous: extern union { dwState: u32, State: MIB_TCP_STATE, }, dwLocalAddr: u32, dwLocalPort: u32, dwRemoteAddr: u32, dwRemotePort: u32, }; pub const MIB_TCPROW_W2K = extern struct { dwState: u32, dwLocalAddr: u32, dwLocalPort: u32, dwRemoteAddr: u32, dwRemotePort: u32, }; pub const MIB_TCPTABLE = extern struct { dwNumEntries: u32, table: [1]MIB_TCPROW_LH, }; pub const MIB_TCPROW2 = extern struct { dwState: u32, dwLocalAddr: u32, dwLocalPort: u32, dwRemoteAddr: u32, dwRemotePort: u32, dwOwningPid: u32, dwOffloadState: TCP_CONNECTION_OFFLOAD_STATE, }; pub const MIB_TCPTABLE2 = extern struct { dwNumEntries: u32, table: [1]MIB_TCPROW2, }; pub const MIB_TCPROW_OWNER_PID = extern struct { dwState: u32, dwLocalAddr: u32, dwLocalPort: u32, dwRemoteAddr: u32, dwRemotePort: u32, dwOwningPid: u32, }; pub const MIB_TCPTABLE_OWNER_PID = extern struct { dwNumEntries: u32, table: [1]MIB_TCPROW_OWNER_PID, }; pub const MIB_TCPROW_OWNER_MODULE = extern struct { dwState: u32, dwLocalAddr: u32, dwLocalPort: u32, dwRemoteAddr: u32, dwRemotePort: u32, dwOwningPid: u32, liCreateTimestamp: LARGE_INTEGER, OwningModuleInfo: [16]u64, }; pub const MIB_TCPTABLE_OWNER_MODULE = extern struct { dwNumEntries: u32, table: [1]MIB_TCPROW_OWNER_MODULE, }; pub const MIB_TCP6ROW = extern struct { State: MIB_TCP_STATE, LocalAddr: IN6_ADDR, dwLocalScopeId: u32, dwLocalPort: u32, RemoteAddr: IN6_ADDR, dwRemoteScopeId: u32, dwRemotePort: u32, }; pub const MIB_TCP6TABLE = extern struct { dwNumEntries: u32, table: [1]MIB_TCP6ROW, }; pub const MIB_TCP6ROW2 = extern struct { LocalAddr: IN6_ADDR, dwLocalScopeId: u32, dwLocalPort: u32, RemoteAddr: IN6_ADDR, dwRemoteScopeId: u32, dwRemotePort: u32, State: MIB_TCP_STATE, dwOwningPid: u32, dwOffloadState: TCP_CONNECTION_OFFLOAD_STATE, }; pub const MIB_TCP6TABLE2 = extern struct { dwNumEntries: u32, table: [1]MIB_TCP6ROW2, }; pub const MIB_TCP6ROW_OWNER_PID = extern struct { ucLocalAddr: [16]u8, dwLocalScopeId: u32, dwLocalPort: u32, ucRemoteAddr: [16]u8, dwRemoteScopeId: u32, dwRemotePort: u32, dwState: u32, dwOwningPid: u32, }; pub const MIB_TCP6TABLE_OWNER_PID = extern struct { dwNumEntries: u32, table: [1]MIB_TCP6ROW_OWNER_PID, }; pub const MIB_TCP6ROW_OWNER_MODULE = extern struct { ucLocalAddr: [16]u8, dwLocalScopeId: u32, dwLocalPort: u32, ucRemoteAddr: [16]u8, dwRemoteScopeId: u32, dwRemotePort: u32, dwState: u32, dwOwningPid: u32, liCreateTimestamp: LARGE_INTEGER, OwningModuleInfo: [16]u64, }; pub const MIB_TCP6TABLE_OWNER_MODULE = extern struct { dwNumEntries: u32, table: [1]MIB_TCP6ROW_OWNER_MODULE, }; pub const TCP_RTO_ALGORITHM = enum(i32) { TcpRtoAlgorithmOther = 1, TcpRtoAlgorithmConstant = 2, TcpRtoAlgorithmRsre = 3, TcpRtoAlgorithmVanj = 4, // MIB_TCP_RTO_OTHER = 1, this enum value conflicts with TcpRtoAlgorithmOther // MIB_TCP_RTO_CONSTANT = 2, this enum value conflicts with TcpRtoAlgorithmConstant // MIB_TCP_RTO_RSRE = 3, this enum value conflicts with TcpRtoAlgorithmRsre // MIB_TCP_RTO_VANJ = 4, this enum value conflicts with TcpRtoAlgorithmVanj }; pub const TcpRtoAlgorithmOther = TCP_RTO_ALGORITHM.TcpRtoAlgorithmOther; pub const TcpRtoAlgorithmConstant = TCP_RTO_ALGORITHM.TcpRtoAlgorithmConstant; pub const TcpRtoAlgorithmRsre = TCP_RTO_ALGORITHM.TcpRtoAlgorithmRsre; pub const TcpRtoAlgorithmVanj = TCP_RTO_ALGORITHM.TcpRtoAlgorithmVanj; pub const MIB_TCP_RTO_OTHER = TCP_RTO_ALGORITHM.TcpRtoAlgorithmOther; pub const MIB_TCP_RTO_CONSTANT = TCP_RTO_ALGORITHM.TcpRtoAlgorithmConstant; pub const MIB_TCP_RTO_RSRE = TCP_RTO_ALGORITHM.TcpRtoAlgorithmRsre; pub const MIB_TCP_RTO_VANJ = TCP_RTO_ALGORITHM.TcpRtoAlgorithmVanj; pub const MIB_TCPSTATS_LH = extern struct { Anonymous: extern union { dwRtoAlgorithm: u32, RtoAlgorithm: TCP_RTO_ALGORITHM, }, dwRtoMin: u32, dwRtoMax: u32, dwMaxConn: u32, dwActiveOpens: u32, dwPassiveOpens: u32, dwAttemptFails: u32, dwEstabResets: u32, dwCurrEstab: u32, dwInSegs: u32, dwOutSegs: u32, dwRetransSegs: u32, dwInErrs: u32, dwOutRsts: u32, dwNumConns: u32, }; pub const MIB_TCPSTATS_W2K = extern struct { dwRtoAlgorithm: u32, dwRtoMin: u32, dwRtoMax: u32, dwMaxConn: u32, dwActiveOpens: u32, dwPassiveOpens: u32, dwAttemptFails: u32, dwEstabResets: u32, dwCurrEstab: u32, dwInSegs: u32, dwOutSegs: u32, dwRetransSegs: u32, dwInErrs: u32, dwOutRsts: u32, dwNumConns: u32, }; pub const MIB_TCPSTATS2 = extern struct { RtoAlgorithm: TCP_RTO_ALGORITHM, dwRtoMin: u32, dwRtoMax: u32, dwMaxConn: u32, dwActiveOpens: u32, dwPassiveOpens: u32, dwAttemptFails: u32, dwEstabResets: u32, dwCurrEstab: u32, dw64InSegs: u64, dw64OutSegs: u64, dwRetransSegs: u32, dwInErrs: u32, dwOutRsts: u32, dwNumConns: u32, }; pub const MIB_UDPROW = extern struct { dwLocalAddr: u32, dwLocalPort: u32, }; pub const MIB_UDPTABLE = extern struct { dwNumEntries: u32, table: [1]MIB_UDPROW, }; pub const MIB_UDPROW_OWNER_PID = extern struct { dwLocalAddr: u32, dwLocalPort: u32, dwOwningPid: u32, }; pub const MIB_UDPTABLE_OWNER_PID = extern struct { dwNumEntries: u32, table: [1]MIB_UDPROW_OWNER_PID, }; pub const MIB_UDPROW_OWNER_MODULE = extern struct { dwLocalAddr: u32, dwLocalPort: u32, dwOwningPid: u32, liCreateTimestamp: LARGE_INTEGER, Anonymous: extern union { Anonymous: extern struct { _bitfield: i32, }, dwFlags: i32, }, OwningModuleInfo: [16]u64, }; pub const MIB_UDPTABLE_OWNER_MODULE = extern struct { dwNumEntries: u32, table: [1]MIB_UDPROW_OWNER_MODULE, }; pub const MIB_UDPROW2 = extern struct { dwLocalAddr: u32, dwLocalPort: u32, dwOwningPid: u32, liCreateTimestamp: LARGE_INTEGER, Anonymous: extern union { Anonymous: extern struct { _bitfield: i32, }, dwFlags: i32, }, OwningModuleInfo: [16]u64, dwRemoteAddr: u32, dwRemotePort: u32, }; pub const MIB_UDPTABLE2 = extern struct { dwNumEntries: u32, table: [1]MIB_UDPROW2, }; pub const MIB_UDP6ROW = extern struct { dwLocalAddr: IN6_ADDR, dwLocalScopeId: u32, dwLocalPort: u32, }; pub const MIB_UDP6TABLE = extern struct { dwNumEntries: u32, table: [1]MIB_UDP6ROW, }; pub const MIB_UDP6ROW_OWNER_PID = extern struct { ucLocalAddr: [16]u8, dwLocalScopeId: u32, dwLocalPort: u32, dwOwningPid: u32, }; pub const MIB_UDP6TABLE_OWNER_PID = extern struct { dwNumEntries: u32, table: [1]MIB_UDP6ROW_OWNER_PID, }; pub const MIB_UDP6ROW_OWNER_MODULE = extern struct { ucLocalAddr: [16]u8, dwLocalScopeId: u32, dwLocalPort: u32, dwOwningPid: u32, liCreateTimestamp: LARGE_INTEGER, Anonymous: extern union { Anonymous: extern struct { _bitfield: i32, }, dwFlags: i32, }, OwningModuleInfo: [16]u64, }; pub const MIB_UDP6TABLE_OWNER_MODULE = extern struct { dwNumEntries: u32, table: [1]MIB_UDP6ROW_OWNER_MODULE, }; pub const MIB_UDP6ROW2 = extern struct { ucLocalAddr: [16]u8, dwLocalScopeId: u32, dwLocalPort: u32, dwOwningPid: u32, liCreateTimestamp: LARGE_INTEGER, Anonymous: extern union { Anonymous: extern struct { _bitfield: i32, }, dwFlags: i32, }, OwningModuleInfo: [16]u64, ucRemoteAddr: [16]u8, dwRemoteScopeId: u32, dwRemotePort: u32, }; pub const MIB_UDP6TABLE2 = extern struct { dwNumEntries: u32, table: [1]MIB_UDP6ROW2, }; pub const MIB_UDPSTATS = extern struct { dwInDatagrams: u32, dwNoPorts: u32, dwInErrors: u32, dwOutDatagrams: u32, dwNumAddrs: u32, }; pub const MIB_UDPSTATS2 = extern struct { dw64InDatagrams: u64, dwNoPorts: u32, dwInErrors: u32, dw64OutDatagrams: u64, dwNumAddrs: u32, }; pub const TCP_TABLE_CLASS = enum(i32) { BASIC_LISTENER = 0, BASIC_CONNECTIONS = 1, BASIC_ALL = 2, OWNER_PID_LISTENER = 3, OWNER_PID_CONNECTIONS = 4, OWNER_PID_ALL = 5, OWNER_MODULE_LISTENER = 6, OWNER_MODULE_CONNECTIONS = 7, OWNER_MODULE_ALL = 8, }; pub const TCP_TABLE_BASIC_LISTENER = TCP_TABLE_CLASS.BASIC_LISTENER; pub const TCP_TABLE_BASIC_CONNECTIONS = TCP_TABLE_CLASS.BASIC_CONNECTIONS; pub const TCP_TABLE_BASIC_ALL = TCP_TABLE_CLASS.BASIC_ALL; pub const TCP_TABLE_OWNER_PID_LISTENER = TCP_TABLE_CLASS.OWNER_PID_LISTENER; pub const TCP_TABLE_OWNER_PID_CONNECTIONS = TCP_TABLE_CLASS.OWNER_PID_CONNECTIONS; pub const TCP_TABLE_OWNER_PID_ALL = TCP_TABLE_CLASS.OWNER_PID_ALL; pub const TCP_TABLE_OWNER_MODULE_LISTENER = TCP_TABLE_CLASS.OWNER_MODULE_LISTENER; pub const TCP_TABLE_OWNER_MODULE_CONNECTIONS = TCP_TABLE_CLASS.OWNER_MODULE_CONNECTIONS; pub const TCP_TABLE_OWNER_MODULE_ALL = TCP_TABLE_CLASS.OWNER_MODULE_ALL; pub const UDP_TABLE_CLASS = enum(i32) { BASIC = 0, OWNER_PID = 1, OWNER_MODULE = 2, }; pub const UDP_TABLE_BASIC = UDP_TABLE_CLASS.BASIC; pub const UDP_TABLE_OWNER_PID = UDP_TABLE_CLASS.OWNER_PID; pub const UDP_TABLE_OWNER_MODULE = UDP_TABLE_CLASS.OWNER_MODULE; pub const TCPIP_OWNER_MODULE_INFO_CLASS = enum(i32) { C = 0, }; pub const TCPIP_OWNER_MODULE_INFO_BASIC = TCPIP_OWNER_MODULE_INFO_CLASS.C; pub const TCPIP_OWNER_MODULE_BASIC_INFO = extern struct { pModuleName: ?[*]u16, pModulePath: ?[*]u16, }; pub const MIB_IPMCAST_BOUNDARY = extern struct { dwIfIndex: u32, dwGroupAddress: u32, dwGroupMask: u32, dwStatus: u32, }; pub const MIB_IPMCAST_BOUNDARY_TABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IPMCAST_BOUNDARY, }; pub const MIB_BOUNDARYROW = extern struct { dwGroupAddress: u32, dwGroupMask: u32, }; pub const MIB_MCAST_LIMIT_ROW = extern struct { dwTtl: u32, dwRateLimit: u32, }; pub const MIB_IPMCAST_SCOPE = extern struct { dwGroupAddress: u32, dwGroupMask: u32, snNameBuffer: [256]u16, dwStatus: u32, }; pub const MIB_IPDESTROW = extern struct { ForwardRow: MIB_IPFORWARDROW, dwForwardPreference: u32, dwForwardViewSet: u32, }; pub const MIB_IPDESTTABLE = extern struct { dwNumEntries: u32, table: [1]MIB_IPDESTROW, }; pub const MIB_BEST_IF = extern struct { dwDestAddr: u32, dwIfIndex: u32, }; pub const MIB_PROXYARP = extern struct { dwAddress: u32, dwMask: u32, dwIfIndex: u32, }; pub const MIB_IFSTATUS = extern struct { dwIfIndex: u32, dwAdminStatus: u32, dwOperationalStatus: u32, bMHbeatActive: BOOL, bMHbeatAlive: BOOL, }; pub const MIB_ROUTESTATE = extern struct { bRoutesSetToStack: BOOL, }; pub const MIB_OPAQUE_INFO = extern struct { dwId: u32, Anonymous: extern union { ullAlign: u64, rgbyData: [1]u8, }, }; pub const IP_ADDRESS_STRING = extern struct { String: [16]CHAR, }; pub const IP_ADDR_STRING = extern struct { Next: ?*IP_ADDR_STRING, IpAddress: IP_ADDRESS_STRING, IpMask: IP_ADDRESS_STRING, Context: u32, }; pub const IP_ADAPTER_INFO = extern struct { Next: ?*IP_ADAPTER_INFO, ComboIndex: u32, AdapterName: [260]CHAR, Description: [132]CHAR, AddressLength: u32, Address: [8]u8, Index: u32, Type: u32, DhcpEnabled: u32, CurrentIpAddress: ?*IP_ADDR_STRING, IpAddressList: IP_ADDR_STRING, GatewayList: IP_ADDR_STRING, DhcpServer: IP_ADDR_STRING, HaveWins: BOOL, PrimaryWinsServer: IP_ADDR_STRING, SecondaryWinsServer: IP_ADDR_STRING, LeaseObtained: i64, LeaseExpires: i64, }; pub const IP_ADAPTER_UNICAST_ADDRESS_LH = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, Flags: u32, }, }, Next: ?*IP_ADAPTER_UNICAST_ADDRESS_LH, Address: SOCKET_ADDRESS, PrefixOrigin: NL_PREFIX_ORIGIN, SuffixOrigin: NL_SUFFIX_ORIGIN, DadState: NL_DAD_STATE, ValidLifetime: u32, PreferredLifetime: u32, LeaseLifetime: u32, OnLinkPrefixLength: u8, }; pub const IP_ADAPTER_UNICAST_ADDRESS_XP = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, Flags: u32, }, }, Next: ?*IP_ADAPTER_UNICAST_ADDRESS_XP, Address: SOCKET_ADDRESS, PrefixOrigin: NL_PREFIX_ORIGIN, SuffixOrigin: NL_SUFFIX_ORIGIN, DadState: NL_DAD_STATE, ValidLifetime: u32, PreferredLifetime: u32, LeaseLifetime: u32, }; pub const IP_ADAPTER_ANYCAST_ADDRESS_XP = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, Flags: u32, }, }, Next: ?*IP_ADAPTER_ANYCAST_ADDRESS_XP, Address: SOCKET_ADDRESS, }; pub const IP_ADAPTER_MULTICAST_ADDRESS_XP = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, Flags: u32, }, }, Next: ?*IP_ADAPTER_MULTICAST_ADDRESS_XP, Address: SOCKET_ADDRESS, }; pub const IP_ADAPTER_DNS_SERVER_ADDRESS_XP = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, Reserved: u32, }, }, Next: ?*IP_ADAPTER_DNS_SERVER_ADDRESS_XP, Address: SOCKET_ADDRESS, }; pub const IP_ADAPTER_WINS_SERVER_ADDRESS_LH = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, Reserved: u32, }, }, Next: ?*IP_ADAPTER_WINS_SERVER_ADDRESS_LH, Address: SOCKET_ADDRESS, }; pub const IP_ADAPTER_GATEWAY_ADDRESS_LH = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, Reserved: u32, }, }, Next: ?*IP_ADAPTER_GATEWAY_ADDRESS_LH, Address: SOCKET_ADDRESS, }; pub const IP_ADAPTER_PREFIX_XP = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, Flags: u32, }, }, Next: ?*IP_ADAPTER_PREFIX_XP, Address: SOCKET_ADDRESS, PrefixLength: u32, }; pub const IP_ADAPTER_DNS_SUFFIX = extern struct { Next: ?*IP_ADAPTER_DNS_SUFFIX, String: [256]u16, }; pub const IP_ADAPTER_ADDRESSES_LH = extern struct { Anonymous1: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, IfIndex: u32, }, }, Next: ?*IP_ADAPTER_ADDRESSES_LH, AdapterName: ?[*]u8, FirstUnicastAddress: ?*IP_ADAPTER_UNICAST_ADDRESS_LH, FirstAnycastAddress: ?*IP_ADAPTER_ANYCAST_ADDRESS_XP, FirstMulticastAddress: ?*IP_ADAPTER_MULTICAST_ADDRESS_XP, FirstDnsServerAddress: ?*IP_ADAPTER_DNS_SERVER_ADDRESS_XP, DnsSuffix: ?[*]u16, Description: ?[*]u16, FriendlyName: ?[*]u16, PhysicalAddress: [8]u8, PhysicalAddressLength: u32, Anonymous2: extern union { Flags: u32, Anonymous: extern struct { _bitfield: u32, }, }, Mtu: u32, IfType: u32, OperStatus: IF_OPER_STATUS, Ipv6IfIndex: u32, ZoneIndices: [16]u32, FirstPrefix: ?*IP_ADAPTER_PREFIX_XP, TransmitLinkSpeed: u64, ReceiveLinkSpeed: u64, FirstWinsServerAddress: ?*IP_ADAPTER_WINS_SERVER_ADDRESS_LH, FirstGatewayAddress: ?*IP_ADAPTER_GATEWAY_ADDRESS_LH, Ipv4Metric: u32, Ipv6Metric: u32, Luid: NET_LUID_LH, Dhcpv4Server: SOCKET_ADDRESS, CompartmentId: u32, NetworkGuid: Guid, ConnectionType: NET_IF_CONNECTION_TYPE, TunnelType: TUNNEL_TYPE, Dhcpv6Server: SOCKET_ADDRESS, Dhcpv6ClientDuid: [130]u8, Dhcpv6ClientDuidLength: u32, Dhcpv6Iaid: u32, FirstDnsSuffix: ?*IP_ADAPTER_DNS_SUFFIX, }; pub const IP_ADAPTER_ADDRESSES_XP = extern struct { Anonymous: extern union { Alignment: u64, Anonymous: extern struct { Length: u32, IfIndex: u32, }, }, Next: ?*IP_ADAPTER_ADDRESSES_XP, AdapterName: ?[*]u8, FirstUnicastAddress: ?*IP_ADAPTER_UNICAST_ADDRESS_XP, FirstAnycastAddress: ?*IP_ADAPTER_ANYCAST_ADDRESS_XP, FirstMulticastAddress: ?*IP_ADAPTER_MULTICAST_ADDRESS_XP, FirstDnsServerAddress: ?*IP_ADAPTER_DNS_SERVER_ADDRESS_XP, DnsSuffix: ?[*]u16, Description: ?[*]u16, FriendlyName: ?[*]u16, PhysicalAddress: [8]u8, PhysicalAddressLength: u32, Flags: u32, Mtu: u32, IfType: u32, OperStatus: IF_OPER_STATUS, Ipv6IfIndex: u32, ZoneIndices: [16]u32, FirstPrefix: ?*IP_ADAPTER_PREFIX_XP, }; pub const IP_PER_ADAPTER_INFO_W2KSP1 = extern struct { AutoconfigEnabled: u32, AutoconfigActive: u32, CurrentDnsServer: ?*IP_ADDR_STRING, DnsServerList: IP_ADDR_STRING, }; pub const FIXED_INFO_W2KSP1 = extern struct { HostName: [132]CHAR, DomainName: [132]CHAR, CurrentDnsServer: ?*IP_ADDR_STRING, DnsServerList: IP_ADDR_STRING, NodeType: u32, ScopeId: [260]CHAR, EnableRouting: u32, EnableProxy: u32, EnableDns: u32, }; pub const ip_interface_name_info_w2ksp1 = extern struct { Index: u32, MediaType: u32, ConnectionType: u8, AccessType: u8, DeviceGuid: Guid, InterfaceGuid: Guid, }; pub const TCP_ESTATS_TYPE = enum(i32) { SynOpts = 0, Data = 1, SndCong = 2, Path = 3, SendBuff = 4, Rec = 5, ObsRec = 6, Bandwidth = 7, FineRtt = 8, Maximum = 9, }; pub const TcpConnectionEstatsSynOpts = TCP_ESTATS_TYPE.SynOpts; pub const TcpConnectionEstatsData = TCP_ESTATS_TYPE.Data; pub const TcpConnectionEstatsSndCong = TCP_ESTATS_TYPE.SndCong; pub const TcpConnectionEstatsPath = TCP_ESTATS_TYPE.Path; pub const TcpConnectionEstatsSendBuff = TCP_ESTATS_TYPE.SendBuff; pub const TcpConnectionEstatsRec = TCP_ESTATS_TYPE.Rec; pub const TcpConnectionEstatsObsRec = TCP_ESTATS_TYPE.ObsRec; pub const TcpConnectionEstatsBandwidth = TCP_ESTATS_TYPE.Bandwidth; pub const TcpConnectionEstatsFineRtt = TCP_ESTATS_TYPE.FineRtt; pub const TcpConnectionEstatsMaximum = TCP_ESTATS_TYPE.Maximum; pub const TCP_BOOLEAN_OPTIONAL = enum(i32) { Disabled = 0, Enabled = 1, Unchanged = -1, }; pub const TcpBoolOptDisabled = TCP_BOOLEAN_OPTIONAL.Disabled; pub const TcpBoolOptEnabled = TCP_BOOLEAN_OPTIONAL.Enabled; pub const TcpBoolOptUnchanged = TCP_BOOLEAN_OPTIONAL.Unchanged; pub const TCP_ESTATS_SYN_OPTS_ROS_v0 = extern struct { ActiveOpen: BOOLEAN, MssRcvd: u32, MssSent: u32, }; pub const TCP_SOFT_ERROR = enum(i32) { None = 0, BelowDataWindow = 1, AboveDataWindow = 2, BelowAckWindow = 3, AboveAckWindow = 4, BelowTsWindow = 5, AboveTsWindow = 6, DataChecksumError = 7, DataLengthError = 8, MaxSoftError = 9, }; pub const TcpErrorNone = TCP_SOFT_ERROR.None; pub const TcpErrorBelowDataWindow = TCP_SOFT_ERROR.BelowDataWindow; pub const TcpErrorAboveDataWindow = TCP_SOFT_ERROR.AboveDataWindow; pub const TcpErrorBelowAckWindow = TCP_SOFT_ERROR.BelowAckWindow; pub const TcpErrorAboveAckWindow = TCP_SOFT_ERROR.AboveAckWindow; pub const TcpErrorBelowTsWindow = TCP_SOFT_ERROR.BelowTsWindow; pub const TcpErrorAboveTsWindow = TCP_SOFT_ERROR.AboveTsWindow; pub const TcpErrorDataChecksumError = TCP_SOFT_ERROR.DataChecksumError; pub const TcpErrorDataLengthError = TCP_SOFT_ERROR.DataLengthError; pub const TcpErrorMaxSoftError = TCP_SOFT_ERROR.MaxSoftError; pub const TCP_ESTATS_DATA_ROD_v0 = extern struct { DataBytesOut: u64, DataSegsOut: u64, DataBytesIn: u64, DataSegsIn: u64, SegsOut: u64, SegsIn: u64, SoftErrors: u32, SoftErrorReason: u32, SndUna: u32, SndNxt: u32, SndMax: u32, ThruBytesAcked: u64, RcvNxt: u32, ThruBytesReceived: u64, }; pub const TCP_ESTATS_DATA_RW_v0 = extern struct { EnableCollection: BOOLEAN, }; pub const TCP_ESTATS_SND_CONG_ROD_v0 = extern struct { SndLimTransRwin: u32, SndLimTimeRwin: u32, SndLimBytesRwin: usize, SndLimTransCwnd: u32, SndLimTimeCwnd: u32, SndLimBytesCwnd: usize, SndLimTransSnd: u32, SndLimTimeSnd: u32, SndLimBytesSnd: usize, SlowStart: u32, CongAvoid: u32, OtherReductions: u32, CurCwnd: u32, MaxSsCwnd: u32, MaxCaCwnd: u32, CurSsthresh: u32, MaxSsthresh: u32, MinSsthresh: u32, }; pub const TCP_ESTATS_SND_CONG_ROS_v0 = extern struct { LimCwnd: u32, }; pub const TCP_ESTATS_SND_CONG_RW_v0 = extern struct { EnableCollection: BOOLEAN, }; pub const TCP_ESTATS_PATH_ROD_v0 = extern struct { FastRetran: u32, Timeouts: u32, SubsequentTimeouts: u32, CurTimeoutCount: u32, AbruptTimeouts: u32, PktsRetrans: u32, BytesRetrans: u32, DupAcksIn: u32, SacksRcvd: u32, SackBlocksRcvd: u32, CongSignals: u32, PreCongSumCwnd: u32, PreCongSumRtt: u32, PostCongSumRtt: u32, PostCongCountRtt: u32, EcnSignals: u32, EceRcvd: u32, SendStall: u32, QuenchRcvd: u32, RetranThresh: u32, SndDupAckEpisodes: u32, SumBytesReordered: u32, NonRecovDa: u32, NonRecovDaEpisodes: u32, AckAfterFr: u32, DsackDups: u32, SampleRtt: u32, SmoothedRtt: u32, RttVar: u32, MaxRtt: u32, MinRtt: u32, SumRtt: u32, CountRtt: u32, CurRto: u32, MaxRto: u32, MinRto: u32, CurMss: u32, MaxMss: u32, MinMss: u32, SpuriousRtoDetections: u32, }; pub const TCP_ESTATS_PATH_RW_v0 = extern struct { EnableCollection: BOOLEAN, }; pub const TCP_ESTATS_SEND_BUFF_ROD_v0 = extern struct { CurRetxQueue: usize, MaxRetxQueue: usize, CurAppWQueue: usize, MaxAppWQueue: usize, }; pub const TCP_ESTATS_SEND_BUFF_RW_v0 = extern struct { EnableCollection: BOOLEAN, }; pub const TCP_ESTATS_REC_ROD_v0 = extern struct { CurRwinSent: u32, MaxRwinSent: u32, MinRwinSent: u32, LimRwin: u32, DupAckEpisodes: u32, DupAcksOut: u32, CeRcvd: u32, EcnSent: u32, EcnNoncesRcvd: u32, CurReasmQueue: u32, MaxReasmQueue: u32, CurAppRQueue: usize, MaxAppRQueue: usize, WinScaleSent: u8, }; pub const TCP_ESTATS_REC_RW_v0 = extern struct { EnableCollection: BOOLEAN, }; pub const TCP_ESTATS_OBS_REC_ROD_v0 = extern struct { CurRwinRcvd: u32, MaxRwinRcvd: u32, MinRwinRcvd: u32, WinScaleRcvd: u8, }; pub const TCP_ESTATS_OBS_REC_RW_v0 = extern struct { EnableCollection: BOOLEAN, }; pub const TCP_ESTATS_BANDWIDTH_RW_v0 = extern struct { EnableCollectionOutbound: TCP_BOOLEAN_OPTIONAL, EnableCollectionInbound: TCP_BOOLEAN_OPTIONAL, }; pub const TCP_ESTATS_BANDWIDTH_ROD_v0 = extern struct { OutboundBandwidth: u64, InboundBandwidth: u64, OutboundInstability: u64, InboundInstability: u64, OutboundBandwidthPeaked: BOOLEAN, InboundBandwidthPeaked: BOOLEAN, }; pub const TCP_ESTATS_FINE_RTT_RW_v0 = extern struct { EnableCollection: BOOLEAN, }; pub const TCP_ESTATS_FINE_RTT_ROD_v0 = extern struct { RttVar: u32, MaxRtt: u32, MinRtt: u32, SumRtt: u32, }; pub const INTERFACE_HARDWARE_TIMESTAMP_CAPABILITIES = extern struct { PtpV2OverUdpIPv4EventMessageReceive: BOOLEAN, PtpV2OverUdpIPv4AllMessageReceive: BOOLEAN, PtpV2OverUdpIPv4EventMessageTransmit: BOOLEAN, PtpV2OverUdpIPv4AllMessageTransmit: BOOLEAN, PtpV2OverUdpIPv6EventMessageReceive: BOOLEAN, PtpV2OverUdpIPv6AllMessageReceive: BOOLEAN, PtpV2OverUdpIPv6EventMessageTransmit: BOOLEAN, PtpV2OverUdpIPv6AllMessageTransmit: BOOLEAN, AllReceive: BOOLEAN, AllTransmit: BOOLEAN, TaggedTransmit: BOOLEAN, }; pub const INTERFACE_SOFTWARE_TIMESTAMP_CAPABILITIES = extern struct { AllReceive: BOOLEAN, AllTransmit: BOOLEAN, TaggedTransmit: BOOLEAN, }; pub const INTERFACE_TIMESTAMP_CAPABILITIES = extern struct { HardwareClockFrequencyHz: u64, SupportsCrossTimestamp: BOOLEAN, HardwareCapabilities: INTERFACE_HARDWARE_TIMESTAMP_CAPABILITIES, SoftwareCapabilities: INTERFACE_SOFTWARE_TIMESTAMP_CAPABILITIES, }; pub const INTERFACE_HARDWARE_CROSSTIMESTAMP = extern struct { SystemTimestamp1: u64, HardwareClockTimestamp: u64, SystemTimestamp2: u64, }; pub const PINTERFACE_TIMESTAMP_CONFIG_CHANGE_CALLBACK = fn( CallerContext: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; pub const NET_ADDRESS_FORMAT = enum(i32) { FORMAT_UNSPECIFIED = 0, DNS_NAME = 1, IPV4 = 2, IPV6 = 3, }; pub const NET_ADDRESS_FORMAT_UNSPECIFIED = NET_ADDRESS_FORMAT.FORMAT_UNSPECIFIED; pub const NET_ADDRESS_DNS_NAME = NET_ADDRESS_FORMAT.DNS_NAME; pub const NET_ADDRESS_IPV4 = NET_ADDRESS_FORMAT.IPV4; pub const NET_ADDRESS_IPV6 = NET_ADDRESS_FORMAT.IPV6; pub const GLOBAL_FILTER = enum(i32) { FRAGMENTS = 2, STRONGHOST = 8, FRAGCACHE = 9, }; pub const GF_FRAGMENTS = GLOBAL_FILTER.FRAGMENTS; pub const GF_STRONGHOST = GLOBAL_FILTER.STRONGHOST; pub const GF_FRAGCACHE = GLOBAL_FILTER.FRAGCACHE; pub const PFFORWARD_ACTION = enum(i32) { FORWARD = 0, DROP = 1, }; pub const PF_ACTION_FORWARD = PFFORWARD_ACTION.FORWARD; pub const PF_ACTION_DROP = PFFORWARD_ACTION.DROP; pub const PFADDRESSTYPE = enum(i32) { @"4" = 0, @"6" = 1, }; pub const PF_IPV4 = PFADDRESSTYPE.@"4"; pub const PF_IPV6 = PFADDRESSTYPE.@"6"; pub const PF_FILTER_DESCRIPTOR = extern struct { dwFilterFlags: u32, dwRule: u32, pfatType: PFADDRESSTYPE, SrcAddr: ?*u8, SrcMask: ?*u8, DstAddr: ?*u8, DstMask: ?*u8, dwProtocol: u32, fLateBound: u32, wSrcPort: u16, wDstPort: u16, wSrcPortHighRange: u16, wDstPortHighRange: u16, }; pub const PF_FILTER_STATS = extern struct { dwNumPacketsFiltered: u32, info: PF_FILTER_DESCRIPTOR, }; pub const PF_INTERFACE_STATS = extern struct { pvDriverContext: ?*anyopaque, dwFlags: u32, dwInDrops: u32, dwOutDrops: u32, eaInAction: PFFORWARD_ACTION, eaOutAction: PFFORWARD_ACTION, dwNumInFilters: u32, dwNumOutFilters: u32, dwFrag: u32, dwSpoof: u32, dwReserved1: u32, dwReserved2: u32, liSYN: LARGE_INTEGER, liTotalLogged: LARGE_INTEGER, dwLostLogEntries: u32, FilterInfo: [1]PF_FILTER_STATS, }; pub const PF_LATEBIND_INFO = extern struct { SrcAddr: ?*u8, DstAddr: ?*u8, Mask: ?*u8, }; pub const PFFRAMETYPE = enum(i32) { FILTER = 1, FRAG = 2, SPOOF = 3, }; pub const PFFT_FILTER = PFFRAMETYPE.FILTER; pub const PFFT_FRAG = PFFRAMETYPE.FRAG; pub const PFFT_SPOOF = PFFRAMETYPE.SPOOF; pub const PFLOGFRAME = extern struct { Timestamp: LARGE_INTEGER, pfeTypeOfFrame: PFFRAMETYPE, dwTotalSizeUsed: u32, dwFilterRule: u32, wSizeOfAdditionalData: u16, wSizeOfIpHeader: u16, dwInterfaceName: u32, dwIPIndex: u32, bPacketData: [1]u8, }; pub const ip_option_information32 = switch(@import("../zig.zig").arch) { .X64, .Arm64 => extern struct { Ttl: u8, Tos: u8, Flags: u8, OptionsSize: u8, OptionsData: ?*u8, }, else => usize, // NOTE: this should be a @compileError but can't because of https://github.com/ziglang/zig/issues/9682 }; pub const icmp_echo_reply32 = switch(@import("../zig.zig").arch) { .X64, .Arm64 => extern struct { Address: u32, Status: u32, RoundTripTime: u32, DataSize: u16, Reserved: u16, Data: ?*anyopaque, Options: ip_option_information32, }, else => usize, // NOTE: this should be a @compileError but can't because of https://github.com/ziglang/zig/issues/9682 }; //-------------------------------------------------------------------------------- // Section: Functions (196) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIfEntry2( Row: ?*MIB_IF_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows10.0.15063' pub extern "IPHLPAPI" fn GetIfEntry2Ex( Level: MIB_IF_ENTRY_LEVEL, Row: ?*MIB_IF_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIfTable2( Table: ?*?*MIB_IF_TABLE2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIfTable2Ex( Level: MIB_IF_TABLE_LEVEL, Table: ?*?*MIB_IF_TABLE2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIfStackTable( Table: ?*?*MIB_IFSTACK_TABLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetInvertedIfStackTable( Table: ?*?*MIB_INVERTEDIFSTACK_TABLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIpInterfaceEntry( Row: ?*MIB_IPINTERFACE_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIpInterfaceTable( Family: u16, Table: ?*?*MIB_IPINTERFACE_TABLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn InitializeIpInterfaceEntry( Row: ?*MIB_IPINTERFACE_ROW, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn NotifyIpInterfaceChange( Family: u16, Callback: ?PIPINTERFACE_CHANGE_CALLBACK, CallerContext: ?*anyopaque, InitialNotification: BOOLEAN, NotificationHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn SetIpInterfaceEntry( Row: ?*MIB_IPINTERFACE_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows8.0' pub extern "IPHLPAPI" fn GetIpNetworkConnectionBandwidthEstimates( InterfaceIndex: u32, AddressFamily: u16, BandwidthEstimates: ?*MIB_IP_NETWORK_CONNECTION_BANDWIDTH_ESTIMATES, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn CreateUnicastIpAddressEntry( Row: ?*const MIB_UNICASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn DeleteUnicastIpAddressEntry( Row: ?*const MIB_UNICASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetUnicastIpAddressEntry( Row: ?*MIB_UNICASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetUnicastIpAddressTable( Family: u16, Table: ?*?*MIB_UNICASTIPADDRESS_TABLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn InitializeUnicastIpAddressEntry( Row: ?*MIB_UNICASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn NotifyUnicastIpAddressChange( Family: u16, Callback: ?PUNICAST_IPADDRESS_CHANGE_CALLBACK, CallerContext: ?*anyopaque, InitialNotification: BOOLEAN, NotificationHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn NotifyStableUnicastIpAddressTable( Family: u16, Table: ?*?*MIB_UNICASTIPADDRESS_TABLE, CallerCallback: ?PSTABLE_UNICAST_IPADDRESS_TABLE_CALLBACK, CallerContext: ?*anyopaque, NotificationHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn SetUnicastIpAddressEntry( Row: ?*const MIB_UNICASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn CreateAnycastIpAddressEntry( Row: ?*const MIB_ANYCASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn DeleteAnycastIpAddressEntry( Row: ?*const MIB_ANYCASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetAnycastIpAddressEntry( Row: ?*MIB_ANYCASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetAnycastIpAddressTable( Family: u16, Table: ?*?*MIB_ANYCASTIPADDRESS_TABLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetMulticastIpAddressEntry( Row: ?*MIB_MULTICASTIPADDRESS_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetMulticastIpAddressTable( Family: u16, Table: ?*?*MIB_MULTICASTIPADDRESS_TABLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn CreateIpForwardEntry2( Row: ?*const MIB_IPFORWARD_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn DeleteIpForwardEntry2( Row: ?*const MIB_IPFORWARD_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetBestRoute2( InterfaceLuid: ?*NET_LUID_LH, InterfaceIndex: u32, SourceAddress: ?*const SOCKADDR_INET, DestinationAddress: ?*const SOCKADDR_INET, AddressSortOptions: u32, BestRoute: ?*MIB_IPFORWARD_ROW2, BestSourceAddress: ?*SOCKADDR_INET, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIpForwardEntry2( Row: ?*MIB_IPFORWARD_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIpForwardTable2( Family: u16, Table: ?*?*MIB_IPFORWARD_TABLE2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn InitializeIpForwardEntry( Row: ?*MIB_IPFORWARD_ROW2, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn NotifyRouteChange2( AddressFamily: u16, Callback: ?PIPFORWARD_CHANGE_CALLBACK, CallerContext: ?*anyopaque, InitialNotification: BOOLEAN, NotificationHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn SetIpForwardEntry2( Route: ?*const MIB_IPFORWARD_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn FlushIpPathTable( Family: u16, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIpPathEntry( Row: ?*MIB_IPPATH_ROW, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIpPathTable( Family: u16, Table: ?*?*MIB_IPPATH_TABLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn CreateIpNetEntry2( Row: ?*const MIB_IPNET_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn DeleteIpNetEntry2( Row: ?*const MIB_IPNET_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn FlushIpNetTable2( Family: u16, InterfaceIndex: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIpNetEntry2( Row: ?*MIB_IPNET_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetIpNetTable2( Family: u16, Table: ?*?*MIB_IPNET_TABLE2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ResolveIpNetEntry2( Row: ?*MIB_IPNET_ROW2, SourceAddress: ?*const SOCKADDR_INET, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn SetIpNetEntry2( Row: ?*MIB_IPNET_ROW2, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn NotifyTeredoPortChange( Callback: ?PTEREDO_PORT_CHANGE_CALLBACK, CallerContext: ?*anyopaque, InitialNotification: BOOLEAN, NotificationHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetTeredoPort( Port: ?*u16, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn CancelMibChangeNotify2( NotificationHandle: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn FreeMibTable( Memory: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn CreateSortedAddressPairs( SourceAddressList: ?*const SOCKADDR_IN6, SourceAddressCount: u32, DestinationAddressList: ?*const SOCKADDR_IN6, DestinationAddressCount: u32, AddressSortOptions: u32, SortedAddressPairList: ?*?*SOCKADDR_IN6_PAIR, SortedAddressPairCount: ?*u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn ConvertCompartmentGuidToId( CompartmentGuid: ?*const Guid, CompartmentId: ?*u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn ConvertCompartmentIdToGuid( CompartmentId: u32, CompartmentGuid: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceNameToLuidA( InterfaceName: ?[*:0]const u8, InterfaceLuid: ?*NET_LUID_LH, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceNameToLuidW( InterfaceName: ?[*:0]const u16, InterfaceLuid: ?*NET_LUID_LH, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceLuidToNameA( InterfaceLuid: ?*const NET_LUID_LH, InterfaceName: [*:0]u8, Length: usize, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceLuidToNameW( InterfaceLuid: ?*const NET_LUID_LH, InterfaceName: [*:0]u16, Length: usize, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceLuidToIndex( InterfaceLuid: ?*const NET_LUID_LH, InterfaceIndex: ?*u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceIndexToLuid( InterfaceIndex: u32, InterfaceLuid: ?*NET_LUID_LH, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceLuidToAlias( InterfaceLuid: ?*const NET_LUID_LH, InterfaceAlias: [*:0]u16, Length: usize, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceAliasToLuid( InterfaceAlias: ?[*:0]const u16, InterfaceLuid: ?*NET_LUID_LH, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceLuidToGuid( InterfaceLuid: ?*const NET_LUID_LH, InterfaceGuid: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertInterfaceGuidToLuid( InterfaceGuid: ?*const Guid, InterfaceLuid: ?*NET_LUID_LH, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn if_nametoindex( InterfaceName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn if_indextoname( InterfaceIndex: u32, InterfaceName: *[256]u8, ) callconv(@import("std").os.windows.WINAPI) ?PSTR; pub extern "IPHLPAPI" fn GetCurrentThreadCompartmentId( ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn SetCurrentThreadCompartmentId( CompartmentId: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn GetCurrentThreadCompartmentScope( CompartmentScope: ?*u32, CompartmentId: ?*u32, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "IPHLPAPI" fn SetCurrentThreadCompartmentScope( CompartmentScope: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn GetJobCompartmentId( JobHandle: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn SetJobCompartmentId( JobHandle: ?HANDLE, CompartmentId: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn GetSessionCompartmentId( SessionId: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn SetSessionCompartmentId( SessionId: u32, CompartmentId: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows10.0.10240' pub extern "IPHLPAPI" fn GetDefaultCompartmentId( ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn GetNetworkInformation( NetworkGuid: ?*const Guid, CompartmentId: ?*u32, SiteId: ?*u32, NetworkName: [*]u16, Length: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn SetNetworkInformation( NetworkGuid: ?*const Guid, CompartmentId: u32, NetworkName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertLengthToIpv4Mask( MaskLength: u32, Mask: ?*u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn ConvertIpv4MaskToLength( Mask: u32, MaskLength: ?*u8, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn GetDnsSettings( Settings: ?*DNS_SETTINGS, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn FreeDnsSettings( Settings: ?*DNS_SETTINGS, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "IPHLPAPI" fn SetDnsSettings( Settings: ?*const DNS_SETTINGS, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn GetInterfaceDnsSettings( Interface: Guid, Settings: ?*DNS_INTERFACE_SETTINGS, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; pub extern "IPHLPAPI" fn FreeInterfaceDnsSettings( Settings: ?*DNS_INTERFACE_SETTINGS, ) callconv(@import("std").os.windows.WINAPI) void; pub extern "IPHLPAPI" fn SetInterfaceDnsSettings( Interface: Guid, Settings: ?*const DNS_INTERFACE_SETTINGS, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows10.0.19041' pub extern "IPHLPAPI" fn GetNetworkConnectivityHint( ConnectivityHint: ?*NL_NETWORK_CONNECTIVITY_HINT, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows10.0.19041' pub extern "IPHLPAPI" fn GetNetworkConnectivityHintForInterface( InterfaceIndex: u32, ConnectivityHint: ?*NL_NETWORK_CONNECTIVITY_HINT, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows10.0.19041' pub extern "IPHLPAPI" fn NotifyNetworkConnectivityHintChange( Callback: ?PNETWORK_CONNECTIVITY_HINT_CHANGE_CALLBACK, CallerContext: ?*anyopaque, InitialNotification: BOOLEAN, NotificationHandle: ?*?HANDLE, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn IcmpCreateFile( ) callconv(@import("std").os.windows.WINAPI) IcmpHandle; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn Icmp6CreateFile( ) callconv(@import("std").os.windows.WINAPI) IcmpHandle; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn IcmpCloseHandle( IcmpHandle: IcmpHandle, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn IcmpSendEcho( IcmpHandle: IcmpHandle, DestinationAddress: u32, // TODO: what to do with BytesParamIndex 3? RequestData: ?*anyopaque, RequestSize: u16, RequestOptions: ?*ip_option_information, // TODO: what to do with BytesParamIndex 6? ReplyBuffer: ?*anyopaque, ReplySize: u32, Timeout: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn IcmpSendEcho2( IcmpHandle: IcmpHandle, Event: ?HANDLE, ApcRoutine: ?PIO_APC_ROUTINE, ApcContext: ?*anyopaque, DestinationAddress: u32, // TODO: what to do with BytesParamIndex 6? RequestData: ?*anyopaque, RequestSize: u16, RequestOptions: ?*ip_option_information, // TODO: what to do with BytesParamIndex 9? ReplyBuffer: ?*anyopaque, ReplySize: u32, Timeout: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn IcmpSendEcho2Ex( IcmpHandle: IcmpHandle, Event: ?HANDLE, ApcRoutine: ?PIO_APC_ROUTINE, ApcContext: ?*anyopaque, SourceAddress: u32, DestinationAddress: u32, // TODO: what to do with BytesParamIndex 7? RequestData: ?*anyopaque, RequestSize: u16, RequestOptions: ?*ip_option_information, // TODO: what to do with BytesParamIndex 10? ReplyBuffer: ?*anyopaque, ReplySize: u32, Timeout: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn Icmp6SendEcho2( IcmpHandle: IcmpHandle, Event: ?HANDLE, ApcRoutine: ?PIO_APC_ROUTINE, ApcContext: ?*anyopaque, SourceAddress: ?*SOCKADDR_IN6, DestinationAddress: ?*SOCKADDR_IN6, // TODO: what to do with BytesParamIndex 7? RequestData: ?*anyopaque, RequestSize: u16, RequestOptions: ?*ip_option_information, // TODO: what to do with BytesParamIndex 10? ReplyBuffer: ?*anyopaque, ReplySize: u32, Timeout: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn IcmpParseReplies( // TODO: what to do with BytesParamIndex 1? ReplyBuffer: ?*anyopaque, ReplySize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn Icmp6ParseReplies( // TODO: what to do with BytesParamIndex 1? ReplyBuffer: ?*anyopaque, ReplySize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetNumberOfInterfaces( pdwNumIf: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetIfEntry( pIfRow: ?*MIB_IFROW, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetIfTable( // TODO: what to do with BytesParamIndex 1? pIfTable: ?*MIB_IFTABLE, pdwSize: ?*u32, bOrder: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetIpAddrTable( // TODO: what to do with BytesParamIndex 1? pIpAddrTable: ?*MIB_IPADDRTABLE, pdwSize: ?*u32, bOrder: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetIpNetTable( // TODO: what to do with BytesParamIndex 1? IpNetTable: ?*MIB_IPNETTABLE, SizePointer: ?*u32, Order: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetIpForwardTable( // TODO: what to do with BytesParamIndex 1? pIpForwardTable: ?*MIB_IPFORWARDTABLE, pdwSize: ?*u32, bOrder: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetTcpTable( // TODO: what to do with BytesParamIndex 1? TcpTable: ?*MIB_TCPTABLE, SizePointer: ?*u32, Order: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetExtendedTcpTable( // TODO: what to do with BytesParamIndex 1? pTcpTable: ?*anyopaque, pdwSize: ?*u32, bOrder: BOOL, ulAf: u32, TableClass: TCP_TABLE_CLASS, Reserved: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetOwnerModuleFromTcpEntry( pTcpEntry: ?*MIB_TCPROW_OWNER_MODULE, Class: TCPIP_OWNER_MODULE_INFO_CLASS, // TODO: what to do with BytesParamIndex 3? pBuffer: ?*anyopaque, pdwSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetUdpTable( // TODO: what to do with BytesParamIndex 1? UdpTable: ?*MIB_UDPTABLE, SizePointer: ?*u32, Order: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetExtendedUdpTable( // TODO: what to do with BytesParamIndex 1? pUdpTable: ?*anyopaque, pdwSize: ?*u32, bOrder: BOOL, ulAf: u32, TableClass: UDP_TABLE_CLASS, Reserved: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetOwnerModuleFromUdpEntry( pUdpEntry: ?*MIB_UDPROW_OWNER_MODULE, Class: TCPIP_OWNER_MODULE_INFO_CLASS, // TODO: what to do with BytesParamIndex 3? pBuffer: ?*anyopaque, pdwSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetTcpTable2( // TODO: what to do with BytesParamIndex 1? TcpTable: ?*MIB_TCPTABLE2, SizePointer: ?*u32, Order: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetTcp6Table( // TODO: what to do with BytesParamIndex 1? TcpTable: ?*MIB_TCP6TABLE, SizePointer: ?*u32, Order: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetTcp6Table2( // TODO: what to do with BytesParamIndex 1? TcpTable: ?*MIB_TCP6TABLE2, SizePointer: ?*u32, Order: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetPerTcpConnectionEStats( Row: ?*MIB_TCPROW_LH, EstatsType: TCP_ESTATS_TYPE, // TODO: what to do with BytesParamIndex 4? Rw: ?*u8, RwVersion: u32, RwSize: u32, // TODO: what to do with BytesParamIndex 7? Ros: ?*u8, RosVersion: u32, RosSize: u32, // TODO: what to do with BytesParamIndex 10? Rod: ?*u8, RodVersion: u32, RodSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn SetPerTcpConnectionEStats( Row: ?*MIB_TCPROW_LH, EstatsType: TCP_ESTATS_TYPE, // TODO: what to do with BytesParamIndex 4? Rw: ?*u8, RwVersion: u32, RwSize: u32, Offset: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetPerTcp6ConnectionEStats( Row: ?*MIB_TCP6ROW, EstatsType: TCP_ESTATS_TYPE, // TODO: what to do with BytesParamIndex 4? Rw: ?*u8, RwVersion: u32, RwSize: u32, // TODO: what to do with BytesParamIndex 7? Ros: ?*u8, RosVersion: u32, RosSize: u32, // TODO: what to do with BytesParamIndex 10? Rod: ?*u8, RodVersion: u32, RodSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn SetPerTcp6ConnectionEStats( Row: ?*MIB_TCP6ROW, EstatsType: TCP_ESTATS_TYPE, // TODO: what to do with BytesParamIndex 4? Rw: ?*u8, RwVersion: u32, RwSize: u32, Offset: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetOwnerModuleFromTcp6Entry( pTcpEntry: ?*MIB_TCP6ROW_OWNER_MODULE, Class: TCPIP_OWNER_MODULE_INFO_CLASS, // TODO: what to do with BytesParamIndex 3? pBuffer: ?*anyopaque, pdwSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetUdp6Table( // TODO: what to do with BytesParamIndex 1? Udp6Table: ?*MIB_UDP6TABLE, SizePointer: ?*u32, Order: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn GetOwnerModuleFromUdp6Entry( pUdpEntry: ?*MIB_UDP6ROW_OWNER_MODULE, Class: TCPIP_OWNER_MODULE_INFO_CLASS, // TODO: what to do with BytesParamIndex 3? pBuffer: ?*anyopaque, pdwSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn GetOwnerModuleFromPidAndInfo( ulPid: u32, pInfo: ?*u64, Class: TCPIP_OWNER_MODULE_INFO_CLASS, // TODO: what to do with BytesParamIndex 4? pBuffer: ?*anyopaque, pdwSize: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetIpStatistics( Statistics: ?*MIB_IPSTATS_LH, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetIcmpStatistics( Statistics: ?*MIB_ICMP, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetTcpStatistics( Statistics: ?*MIB_TCPSTATS_LH, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetUdpStatistics( Stats: ?*MIB_UDPSTATS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn SetIpStatisticsEx( Statistics: ?*MIB_IPSTATS_LH, Family: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn GetIpStatisticsEx( Statistics: ?*MIB_IPSTATS_LH, Family: ADDRESS_FAMILY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn GetIcmpStatisticsEx( Statistics: ?*MIB_ICMP_EX_XPSP1, Family: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn GetTcpStatisticsEx( Statistics: ?*MIB_TCPSTATS_LH, Family: ADDRESS_FAMILY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn GetUdpStatisticsEx( Statistics: ?*MIB_UDPSTATS, Family: ADDRESS_FAMILY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows10.0.16299' pub extern "IPHLPAPI" fn GetTcpStatisticsEx2( Statistics: ?*MIB_TCPSTATS2, Family: ADDRESS_FAMILY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows10.0.16299' pub extern "IPHLPAPI" fn GetUdpStatisticsEx2( Statistics: ?*MIB_UDPSTATS2, Family: ADDRESS_FAMILY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn SetIfEntry( pIfRow: ?*MIB_IFROW, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn CreateIpForwardEntry( pRoute: ?*MIB_IPFORWARDROW, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn SetIpForwardEntry( pRoute: ?*MIB_IPFORWARDROW, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn DeleteIpForwardEntry( pRoute: ?*MIB_IPFORWARDROW, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn SetIpStatistics( pIpStats: ?*MIB_IPSTATS_LH, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn SetIpTTL( nTTL: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn CreateIpNetEntry( pArpEntry: ?*MIB_IPNETROW_LH, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn SetIpNetEntry( pArpEntry: ?*MIB_IPNETROW_LH, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn DeleteIpNetEntry( pArpEntry: ?*MIB_IPNETROW_LH, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn FlushIpNetTable( dwIfIndex: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn CreateProxyArpEntry( dwAddress: u32, dwMask: u32, dwIfIndex: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn DeleteProxyArpEntry( dwAddress: u32, dwMask: u32, dwIfIndex: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn SetTcpEntry( pTcpRow: ?*MIB_TCPROW_LH, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetInterfaceInfo( // TODO: what to do with BytesParamIndex 1? pIfTable: ?*IP_INTERFACE_INFO, dwOutBufLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn GetUniDirectionalAdapterInfo( // TODO: what to do with BytesParamIndex 1? pIPIfInfo: ?*IP_UNIDIRECTIONAL_ADAPTER_ADDRESS, dwOutBufLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn NhpAllocateAndGetInterfaceInfoFromStack( ppTable: ?*?*ip_interface_name_info_w2ksp1, pdwCount: ?*u32, bOrder: BOOL, hHeap: ?HANDLE, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetBestInterface( dwDestAddr: u32, pdwBestIfIndex: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn GetBestInterfaceEx( pDestAddr: ?*SOCKADDR, pdwBestIfIndex: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetBestRoute( dwDestAddr: u32, dwSourceAddr: u32, pBestRoute: ?*MIB_IPFORWARDROW, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn NotifyAddrChange( Handle: ?*?HANDLE, overlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn NotifyRouteChange( Handle: ?*?HANDLE, overlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn CancelIPChangeNotify( notifyOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetAdapterIndex( AdapterName: ?PWSTR, IfIndex: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn AddIPAddress( Address: u32, IpMask: u32, IfIndex: u32, NTEContext: ?*u32, NTEInstance: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn DeleteIPAddress( NTEContext: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetNetworkParams( // TODO: what to do with BytesParamIndex 1? pFixedInfo: ?*FIXED_INFO_W2KSP1, pOutBufLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) WIN32_ERROR; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetAdaptersInfo( // TODO: what to do with BytesParamIndex 1? AdapterInfo: ?*IP_ADAPTER_INFO, SizePointer: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn GetAdapterOrderMap( ) callconv(@import("std").os.windows.WINAPI) ?*IP_ADAPTER_ORDER_MAP; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn GetAdaptersAddresses( Family: ADDRESS_FAMILY, Flags: GET_ADAPTERS_ADDRESSES_FLAGS, Reserved: ?*anyopaque, // TODO: what to do with BytesParamIndex 4? AdapterAddresses: ?*IP_ADAPTER_ADDRESSES_LH, SizePointer: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetPerAdapterInfo( IfIndex: u32, // TODO: what to do with BytesParamIndex 2? pPerAdapterInfo: ?*IP_PER_ADAPTER_INFO_W2KSP1, pOutBufLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn GetInterfaceActiveTimestampCapabilities( InterfaceLuid: ?*const NET_LUID_LH, TimestampCapabilites: ?*INTERFACE_TIMESTAMP_CAPABILITIES, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn GetInterfaceSupportedTimestampCapabilities( InterfaceLuid: ?*const NET_LUID_LH, TimestampCapabilites: ?*INTERFACE_TIMESTAMP_CAPABILITIES, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn CaptureInterfaceHardwareCrossTimestamp( InterfaceLuid: ?*const NET_LUID_LH, CrossTimestamp: ?*INTERFACE_HARDWARE_CROSSTIMESTAMP, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn RegisterInterfaceTimestampConfigChange( Callback: ?PINTERFACE_TIMESTAMP_CONFIG_CHANGE_CALLBACK, CallerContext: ?*anyopaque, NotificationHandle: ?*?HIFTIMESTAMPCHANGE, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn UnregisterInterfaceTimestampConfigChange( NotificationHandle: ?HIFTIMESTAMPCHANGE, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn IpReleaseAddress( AdapterInfo: ?*IP_ADAPTER_INDEX_MAP, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn IpRenewAddress( AdapterInfo: ?*IP_ADAPTER_INDEX_MAP, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn SendARP( DestIP: u32, SrcIP: u32, // TODO: what to do with BytesParamIndex 3? pMacAddr: ?*anyopaque, PhyAddrLen: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetRTTAndHopCount( DestIpAddress: u32, HopCount: ?*u32, MaxHops: u32, RTT: ?*u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn GetFriendlyIfIndex( IfIndex: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn EnableRouter( pHandle: ?*?HANDLE, pOverlapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "IPHLPAPI" fn UnenableRouter( pOverlapped: ?*OVERLAPPED, lpdwEnableCount: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn DisableMediaSense( pHandle: ?*?HANDLE, pOverLapped: ?*OVERLAPPED, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn RestoreMediaSense( pOverlapped: ?*OVERLAPPED, lpdwEnableCount: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn GetIpErrorString( ErrorCode: u32, Buffer: ?PWSTR, Size: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "IPHLPAPI" fn ResolveNeighbor( NetworkAddress: ?*SOCKADDR, // TODO: what to do with BytesParamIndex 2? PhysicalAddress: ?*anyopaque, PhysicalAddressLength: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn CreatePersistentTcpPortReservation( StartPort: u16, NumberOfPorts: u16, Token: ?*u64, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn CreatePersistentUdpPortReservation( StartPort: u16, NumberOfPorts: u16, Token: ?*u64, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn DeletePersistentTcpPortReservation( StartPort: u16, NumberOfPorts: u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn DeletePersistentUdpPortReservation( StartPort: u16, NumberOfPorts: u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn LookupPersistentTcpPortReservation( StartPort: u16, NumberOfPorts: u16, Token: ?*u64, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "IPHLPAPI" fn LookupPersistentUdpPortReservation( StartPort: u16, NumberOfPorts: u16, Token: ?*u64, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfCreateInterface( dwName: u32, inAction: PFFORWARD_ACTION, outAction: PFFORWARD_ACTION, bUseLog: BOOL, bMustBeUnique: BOOL, ppInterface: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfDeleteInterface( pInterface: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfAddFiltersToInterface( ih: ?*anyopaque, cInFilters: u32, pfiltIn: ?*PF_FILTER_DESCRIPTOR, cOutFilters: u32, pfiltOut: ?*PF_FILTER_DESCRIPTOR, pfHandle: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfRemoveFiltersFromInterface( ih: ?*anyopaque, cInFilters: u32, pfiltIn: ?*PF_FILTER_DESCRIPTOR, cOutFilters: u32, pfiltOut: ?*PF_FILTER_DESCRIPTOR, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfRemoveFilterHandles( pInterface: ?*anyopaque, cFilters: u32, pvHandles: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfUnBindInterface( pInterface: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfBindInterfaceToIndex( pInterface: ?*anyopaque, dwIndex: u32, pfatLinkType: PFADDRESSTYPE, LinkIPAddress: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfBindInterfaceToIPAddress( pInterface: ?*anyopaque, pfatType: PFADDRESSTYPE, IPAddress: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfRebindFilters( pInterface: ?*anyopaque, pLateBindInfo: ?*PF_LATEBIND_INFO, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfAddGlobalFilterToInterface( pInterface: ?*anyopaque, gfFilter: GLOBAL_FILTER, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfRemoveGlobalFilterFromInterface( pInterface: ?*anyopaque, gfFilter: GLOBAL_FILTER, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfMakeLog( hEvent: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfSetLogBuffer( pbBuffer: ?*u8, dwSize: u32, dwThreshold: u32, dwEntries: u32, pdwLoggedEntries: ?*u32, pdwLostEntries: ?*u32, pdwSizeUsed: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfDeleteLog( ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfGetInterfaceStatistics( pInterface: ?*anyopaque, ppfStats: ?*PF_INTERFACE_STATS, pdwBufferSize: ?*u32, fResetCounters: BOOL, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "IPHLPAPI" fn PfTestPacket( pInInterface: ?*anyopaque, pOutInterface: ?*anyopaque, cBytes: u32, pbPacket: ?*u8, ppAction: ?*PFFORWARD_ACTION, ) callconv(@import("std").os.windows.WINAPI) u32; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (2) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { pub const ConvertInterfaceNameToLuid = thismodule.ConvertInterfaceNameToLuidA; pub const ConvertInterfaceLuidToName = thismodule.ConvertInterfaceLuidToNameA; }, .wide => struct { pub const ConvertInterfaceNameToLuid = thismodule.ConvertInterfaceNameToLuidW; pub const ConvertInterfaceLuidToName = thismodule.ConvertInterfaceLuidToNameW; }, .unspecified => if (@import("builtin").is_test) struct { pub const ConvertInterfaceNameToLuid = *opaque{}; pub const ConvertInterfaceLuidToName = *opaque{}; } else struct { pub const ConvertInterfaceNameToLuid = @compileError("'ConvertInterfaceNameToLuid' requires that UNICODE be set to true or false in the root module"); pub const ConvertInterfaceLuidToName = @compileError("'ConvertInterfaceLuidToName' requires that UNICODE be set to true or false in the root module"); }, }; //-------------------------------------------------------------------------------- // Section: Imports (32) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const BOOL = @import("../foundation.zig").BOOL; const BOOLEAN = @import("../foundation.zig").BOOLEAN; const CHAR = @import("../foundation.zig").CHAR; const HANDLE = @import("../foundation.zig").HANDLE; const IN6_ADDR = @import("../networking/win_sock.zig").IN6_ADDR; const LARGE_INTEGER = @import("../foundation.zig").LARGE_INTEGER; const NDIS_MEDIUM = @import("../network_management/ndis.zig").NDIS_MEDIUM; const NDIS_PHYSICAL_MEDIUM = @import("../network_management/ndis.zig").NDIS_PHYSICAL_MEDIUM; const NL_BANDWIDTH_INFORMATION = @import("../networking/win_sock.zig").NL_BANDWIDTH_INFORMATION; const NL_DAD_STATE = @import("../networking/win_sock.zig").NL_DAD_STATE; const NL_INTERFACE_OFFLOAD_ROD = @import("../networking/win_sock.zig").NL_INTERFACE_OFFLOAD_ROD; const NL_LINK_LOCAL_ADDRESS_BEHAVIOR = @import("../networking/win_sock.zig").NL_LINK_LOCAL_ADDRESS_BEHAVIOR; const NL_NEIGHBOR_STATE = @import("../networking/win_sock.zig").NL_NEIGHBOR_STATE; const NL_NETWORK_CONNECTIVITY_HINT = @import("../networking/win_sock.zig").NL_NETWORK_CONNECTIVITY_HINT; const NL_PREFIX_ORIGIN = @import("../networking/win_sock.zig").NL_PREFIX_ORIGIN; const NL_ROUTE_ORIGIN = @import("../networking/win_sock.zig").NL_ROUTE_ORIGIN; const NL_ROUTE_PROTOCOL = @import("../networking/win_sock.zig").NL_ROUTE_PROTOCOL; const NL_ROUTER_DISCOVERY_BEHAVIOR = @import("../networking/win_sock.zig").NL_ROUTER_DISCOVERY_BEHAVIOR; const NL_SUFFIX_ORIGIN = @import("../networking/win_sock.zig").NL_SUFFIX_ORIGIN; const NTSTATUS = @import("../foundation.zig").NTSTATUS; const OVERLAPPED = @import("../system/io.zig").OVERLAPPED; const PIO_APC_ROUTINE = @import("../system/windows_programming.zig").PIO_APC_ROUTINE; const PSTR = @import("../foundation.zig").PSTR; const PWSTR = @import("../foundation.zig").PWSTR; const SCOPE_ID = @import("../networking/win_sock.zig").SCOPE_ID; const SOCKADDR = @import("../networking/win_sock.zig").SOCKADDR; const SOCKADDR_IN6 = @import("../networking/win_sock.zig").SOCKADDR_IN6; const SOCKADDR_IN6_PAIR = @import("../networking/win_sock.zig").SOCKADDR_IN6_PAIR; const SOCKADDR_INET = @import("../networking/win_sock.zig").SOCKADDR_INET; const SOCKET_ADDRESS = @import("../networking/win_sock.zig").SOCKET_ADDRESS; const WIN32_ERROR = @import("../foundation.zig").WIN32_ERROR; test { // The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476 if (@hasDecl(@This(), "PIPINTERFACE_CHANGE_CALLBACK")) { _ = PIPINTERFACE_CHANGE_CALLBACK; } if (@hasDecl(@This(), "PUNICAST_IPADDRESS_CHANGE_CALLBACK")) { _ = PUNICAST_IPADDRESS_CHANGE_CALLBACK; } if (@hasDecl(@This(), "PSTABLE_UNICAST_IPADDRESS_TABLE_CALLBACK")) { _ = PSTABLE_UNICAST_IPADDRESS_TABLE_CALLBACK; } if (@hasDecl(@This(), "PIPFORWARD_CHANGE_CALLBACK")) { _ = PIPFORWARD_CHANGE_CALLBACK; } if (@hasDecl(@This(), "PTEREDO_PORT_CHANGE_CALLBACK")) { _ = PTEREDO_PORT_CHANGE_CALLBACK; } if (@hasDecl(@This(), "PNETWORK_CONNECTIVITY_HINT_CHANGE_CALLBACK")) { _ = PNETWORK_CONNECTIVITY_HINT_CHANGE_CALLBACK; } if (@hasDecl(@This(), "PINTERFACE_TIMESTAMP_CONFIG_CHANGE_CALLBACK")) { _ = PINTERFACE_TIMESTAMP_CONFIG_CHANGE_CALLBACK; } @setEvalBranchQuota( @import("std").meta.declarations(@This()).len * 3 ); // reference all the pub declarations if (!@import("builtin").is_test) return; inline for (@import("std").meta.declarations(@This())) |decl| { if (decl.is_pub) { _ = decl; } } }
win32/network_management/ip_helper.zig
const std = @import("std"); const assert = std.debug.assert; const ExecError = error{InvalidOpcode}; fn exec(intcode: []i32) !void { var pos: usize = 0; while (true) { switch (intcode[pos]) { 99 => break, 1 => { const pos_x = @intCast(usize, intcode[pos + 1]); const pos_y = @intCast(usize, intcode[pos + 2]); const pos_result = @intCast(usize, intcode[pos + 3]); intcode[pos_result] = intcode[pos_x] + intcode[pos_y]; pos += 4; }, 2 => { const pos_x = @intCast(usize, intcode[pos + 1]); const pos_y = @intCast(usize, intcode[pos + 2]); const pos_result = @intCast(usize, intcode[pos + 3]); intcode[pos_result] = intcode[pos_x] * intcode[pos_y]; pos += 4; }, else => return error.InvalidOpcode, } } } test "test exec 1" { var intcode = [_]i32{ 1, 0, 0, 0, 99 }; try exec(intcode[0..]); assert(intcode[0] == 2); } test "test exec 2" { var intcode = [_]i32{ 2, 3, 0, 3, 99 }; try exec(intcode[0..]); assert(intcode[3] == 6); } test "test exec 3" { var intcode = [_]i32{ 2, 4, 4, 5, 99, 0 }; try exec(intcode[0..]); assert(intcode[5] == 9801); } pub fn main() !void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); const allocator = &arena.allocator; defer arena.deinit(); const stdin = std.io.getStdIn(); var stdreader = stdin.reader(); var buf: [1024]u8 = undefined; var ints = std.ArrayList(i32).init(allocator); // read everything into an int arraylist while (try stdreader.readUntilDelimiterOrEof(&buf, ',')) |item| { try ints.append(try std.fmt.parseInt(u8, item, 10)); } // try combinations of noun and verb const max_search: i32 = 100; const desired_result: i32 = 19690720; var noun: i32 = 0; var verb: i32 = 0; outer: while (noun < max_search) : (noun += 1) { verb = 0; inner: while (verb < max_search) : (verb += 1) { const copy = try std.mem.dupe(allocator, i32, ints.items); defer allocator.free(copy); copy[1] = noun; copy[2] = verb; try exec(copy); if (copy[0] == desired_result) break :outer; } } // output solution std.debug.warn("noun: {} verb: {}\n", .{ noun, verb }); std.debug.warn("100 * noun + verb = {}\n", .{100 * noun + verb}); }
zig/02_2.zig
const xcb = @import("../xcb.zig"); pub const id = xcb.Extension{ .name = "Composite", .global_id = 0 }; pub const Redirect = extern enum(c_uint) { @"Automatic" = 0, @"Manual" = 1, }; /// @brief QueryVersioncookie pub const QueryVersioncookie = struct { sequence: c_uint, }; /// @brief QueryVersionRequest pub const QueryVersionRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 0, @"length": u16, @"client_major_version": u32, @"client_minor_version": u32, }; /// @brief QueryVersionReply pub const QueryVersionReply = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, @"length": u32, @"major_version": u32, @"minor_version": u32, @"pad1": [16]u8, }; /// @brief RedirectWindowRequest pub const RedirectWindowRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 1, @"length": u16, @"window": xcb.WINDOW, @"update": u8, @"pad0": [3]u8, }; /// @brief RedirectSubwindowsRequest pub const RedirectSubwindowsRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 2, @"length": u16, @"window": xcb.WINDOW, @"update": u8, @"pad0": [3]u8, }; /// @brief UnredirectWindowRequest pub const UnredirectWindowRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 3, @"length": u16, @"window": xcb.WINDOW, @"update": u8, @"pad0": [3]u8, }; /// @brief UnredirectSubwindowsRequest pub const UnredirectSubwindowsRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 4, @"length": u16, @"window": xcb.WINDOW, @"update": u8, @"pad0": [3]u8, }; /// @brief CreateRegionFromBorderClipRequest pub const CreateRegionFromBorderClipRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 5, @"length": u16, @"region": xcb.xfixes.REGION, @"window": xcb.WINDOW, }; /// @brief NameWindowPixmapRequest pub const NameWindowPixmapRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 6, @"length": u16, @"window": xcb.WINDOW, @"pixmap": xcb.PIXMAP, }; /// @brief GetOverlayWindowcookie pub const GetOverlayWindowcookie = struct { sequence: c_uint, }; /// @brief GetOverlayWindowRequest pub const GetOverlayWindowRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 7, @"length": u16, @"window": xcb.WINDOW, }; /// @brief GetOverlayWindowReply pub const GetOverlayWindowReply = struct { @"response_type": u8, @"pad0": u8, @"sequence": u16, @"length": u32, @"overlay_win": xcb.WINDOW, @"pad1": [20]u8, }; /// @brief ReleaseOverlayWindowRequest pub const ReleaseOverlayWindowRequest = struct { @"major_opcode": u8, @"minor_opcode": u8 = 8, @"length": u16, @"window": xcb.WINDOW, }; test "" { @import("std").testing.refAllDecls(@This()); }
src/auto/composite.zig
const std = @import("std"); const js = @import("../quickjs.zig"); const GlobalContext = @import("../context.zig"); const E = js.JsCFunctionListEntry; pub const utf8 = opaque { fn encode(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { if (argc != 1) return ctx.throw(.{ .Type = "require 1 args" }); const str: js.JsString = argv[0].as(js.JsString, ctx) catch return ctx.throw(.{ .Type = "not a string" }); defer str.deinit(ctx); return js.JsValue.init(ctx, .{ .ArrayBuffer = str.data }); } fn decode(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { if (argc != 1) return ctx.throw(.{ .Type = "require 1 args" }); const buffer = argv[0].as([]u8, ctx) catch return ctx.throw(.{ .Type = "not an ArrayBuffer" }); if (!std.unicode.utf8ValidateSlice(buffer)) return ctx.throw(.{ .Range = "invalid utf8 data" }); return js.JsValue.init(ctx, .{ .String = buffer }); } pub const storage = [_]E{ E.genFunction("encode", .{ .length = 1, .func = .{ .generic = encode } }), E.genFunction("decode", .{ .length = 1, .func = .{ .generic = decode } }), }; }; pub const utf16 = opaque { fn toutf16(allocator: *std.mem.Allocator, data: []const u8) ![]u16 { var result = std.ArrayList(u16).init(allocator); try result.ensureCapacity(data.len + 1); const view = try std.unicode.Utf8View.init(data); var it = view.iterator(); while (it.nextCodepoint()) |codepoint| { if (codepoint < 0x10000) { const short = @intCast(u16, codepoint); try result.append(std.mem.nativeToLittle(u16, short)); } else { const high = @intCast(u16, (codepoint - 0x10000) >> 10) + 0xD800; const low = @intCast(u16, codepoint & 0x3FF) + 0xDC00; var out: [2]u16 = undefined; out[0] = std.mem.nativeToLittle(u16, high); out[1] = std.mem.nativeToLittle(u16, low); try result.appendSlice(out[0..]); } } return result.toOwnedSlice(); } fn encode(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { if (argc != 1) return ctx.throw(.{ .Type = "require 1 args" }); const str: js.JsString = argv[0].as(js.JsString, ctx) catch return ctx.throw(.{ .Type = "not a string" }); defer str.deinit(ctx); const allocator = ctx.getRuntime().getOpaqueT(GlobalContext).?.allocator; const out = toutf16(allocator, str.data) catch return ctx.throw(.OutOfMemory); defer allocator.free(out); return js.JsValue.init(ctx, .{ .ArrayBuffer = std.mem.sliceAsBytes(out) }); } fn decode(ctx: *js.JsContext, this: js.JsValue, argc: c_int, argv: [*]js.JsValue) callconv(.C) js.JsValue { if (argc != 1) return ctx.throw(.{ .Type = "require 1 args" }); const buffer: []u8 = argv[0].as([]u8, ctx) catch return ctx.throw(.{ .Type = "not an ArrayBuffer" }); if (buffer.len % 2 != 0) return ctx.throw(.{ .Type = "invalid utf16" }); if (buffer.len == 0) return js.JsValue.init(ctx, .{ .String = "" }); const allocator = ctx.getRuntime().getOpaqueT(GlobalContext).?.allocator; const addr = @ptrToInt(buffer.ptr); if (std.mem.isAligned(addr, @alignOf(*u16))) { const temp = @intToPtr([*]u16, addr)[0..@divExact(buffer.len, @sizeOf(u16))]; const ret = std.unicode.utf16leToUtf8Alloc(allocator, temp) catch return ctx.throw(.OutOfMemory); defer allocator.free(ret); return js.JsValue.init(ctx, .{ .String = ret }); } else { const aligned = allocator.allocAdvanced(u8, @alignOf(*u16), buffer.len, .at_least) catch return ctx.throw(.OutOfMemory); defer allocator.free(aligned); std.mem.copy(u8, aligned[0..], buffer[0..]); const temp = @ptrCast([*]u16, aligned.ptr)[0..@divExact(aligned.len, @sizeOf(u16))]; const ret = std.unicode.utf16leToUtf8Alloc(allocator, temp) catch return ctx.throw(.OutOfMemory); defer allocator.free(ret); return js.JsValue.init(ctx, .{ .String = ret }); } } pub const storage = [_]E{ E.genFunction("encode", .{ .length = 1, .func = .{ .generic = encode } }), E.genFunction("decode", .{ .length = 1, .func = .{ .generic = decode } }), }; };
src/mods/encoding.zig
const std = @import("std"); const warn = std.debug.print; const Allocator = std.mem.Allocator; const std_allocator = std.heap.c_allocator; // passing through pthread nope const util = @import("./util.zig"); const c = @cImport({ @cInclude("unistd.h"); @cInclude("nng/nng.h"); @cInclude("nng/protocol/pair0/pair.h"); @cInclude("nng/transport/ipc/ipc.h"); }); pub const sock = c.nng_socket; pub const Client = struct { srv: *sock, clnt: *sock }; const Url = "ipc:///tmp/nng-pair-"; pub fn init() void {} pub fn listen(socket: *sock, url: []u8) void { warn("nng master listen {} {}\n", socket, url); if (c.nng_listen(socket.*, util.sliceToCstr(std_allocator, url), @intToPtr([*c]c.struct_nng_listener_s, 0), 0) != 0) { warn("nng_listen FAIL\n"); } } pub fn wait(client: *Client, callback: fn (?*anyopaque) callconv(.C) void) void { // special nng alloc call var myAio: ?*c.nng_aio = undefined; warn("wait master nng_aio {*}\n", &myAio); var message = std_allocator.alloc(u8, 4) catch unreachable; message[0] = 'H'; message[1] = 2; message[2] = 1; message[3] = 0; _ = c.nng_aio_alloc(&myAio, callback, @ptrCast(?*anyopaque, &message)); warn("wait master nng_aio post {*}\n", myAio); warn("wait master nng_recv {}\n", client.srv); c.nng_recv_aio(client.srv.*, myAio); } pub fn dial(socket: *sock, url: []u8) void { warn("nng dial {} {s}\n", socket, util.sliceToCstr(std_allocator, url)); if (c.nng_dial(socket.*, util.sliceToCstr(std_allocator, url), @intToPtr([*c]c.struct_nng_dialer_s, 0), 0) != 0) { warn("nng_pair0_dial FAIL\n"); } } pub fn newClient(allocator: *Allocator) *Client { const client = allocator.create(Client) catch unreachable; var url_buf: [256]u8 = undefined; const myUrl = std.fmt.bufPrint(url_buf[0..], "{}{*}", Url, client) catch unreachable; warn("newClient {}\n", myUrl); const socket = allocator.create(sock) catch unreachable; client.srv = socket; var nng_ret = c.nng_pair0_open(client.srv); if (nng_ret != 0) { warn("nng_pair0_open FAIL {}\n", nng_ret); } listen(client.srv, myUrl); const socket2 = allocator.create(sock) catch unreachable; client.clnt = socket2; nng_ret = c.nng_pair0_open(client.clnt); if (nng_ret != 0) { warn("nng_pair0_open FAIL {}\n", nng_ret); } dial(client.clnt, myUrl); return client; } pub fn send(client: *Client) void { var payload = "X"; warn("nng send {} {}\n", client, payload); if (c.nng_send(client.clnt.*, util.sliceToCstr(std_allocator, payload), payload.len, 0) != 0) { warn("nng send to master FAIL\n"); } }
src/ipc/nng.zig
const std = @import("std"); const hex_print_bits = 64; const hex_print_t = std.meta.Int(.unsigned, hex_print_bits); const hex_print_nibbles = @divExact(hex_print_bits, 4); const printCharacter = @import("root").putchar; // zig fmt freaks out when it sees `noinline` for some reason(?) // zig fmt: off noinline fn printSentinelString(str_c: [*:0]const u8) void { var str = str_c; while (str[0] != 0) : (str += 1) { printCharacter(str[0]); } } noinline fn printSliceString(str: []const u8) void { for(str) |c| { printCharacter(c); } } noinline fn printPointerInt(ptr: usize) void { printSentinelString("0x"); printRuntimeValueAsZeroPaddedHex(ptr); } fn printPointer(ptr: anytype) callconv(.Inline) void { printPointerInt(@ptrToInt(ptr)); } const boolean_names = [2][*:0]const u8 { "false", "true", }; noinline fn printBoolean(value: bool) void { printSentinelString(boolean_names[@boolToInt(value)]); } const hex_chars: [*]const u8 = "0123456789ABCDEF"; noinline fn printRuntimeValueAsZeroPaddedHex(val_in: anytype) void { // Make it large enough for hex printing const val = if(@bitSizeOf(@TypeOf(val_in)) < 4) @as(u4, val_in) else val_in; comptime var i: u6 = @divFloor(@bitSizeOf(@TypeOf(val)) + 3, 4) - 1; inline while (true) : (i -= 1) { const v = @truncate(u4, val >> (4 * i)); printCharacter(hex_chars[v]); if (i == 0) break; } } fn comptimeValToZeroPaddedHexString(val: anytype) [@sizeOf(@TypeOf(val))*2:0]u8 { const numNibbles = @sizeOf(@TypeOf(val))*2; var i: u6 = 0; var result: [numNibbles:0]u8 = undefined; result[numNibbles] = 0; while (i < numNibbles) : (i += 1) { result[i] = hex_chars[@truncate(u4, val >> ((numNibbles - i - 1) * 4))]; } return result; } fn lengthOfIntAsString(num: anytype, comptime base: comptime_int) usize { if (num < base) return 1; const rest = num / base; return lengthOfIntAsString(rest, base) + 1; } fn comptimeValToString(val: anytype, comptime base: comptime_int) [lengthOfIntAsString(val, base)]u8 { const current = hex_chars[val % base]; const rest = val / base; if (rest == 0) return [_]u8{current}; return comptimeValToString(rest, base) ++ [_]u8{current}; } noinline fn printRuntimeValue(val: usize, comptime base: comptime_int) void { const rest = val / base; if (rest != 0) printRuntimeValue(rest, base); return printCharacter(hex_chars[val % base]); } fn putComptimeStr(comptime str: [:0]const u8) callconv(.Inline) void { if (comptime (str.len == 1)) { printCharacter(str[0]); } if (comptime (str.len > 1)) { printSentinelString(str.ptr); } } fn defaultFormatValue(value: anytype, comptime fmt_so_far: [:0]const u8) callconv(.Inline) void { switch(@typeInfo(@TypeOf(value.*))) { .Struct => { if (comptime @hasDecl(@TypeOf(value.*), "format")) { putComptimeStr(fmt_so_far); value.format(doFmtNoEndl); } else { putComptimeStr(defaultFormatStruct(value, fmt_so_far)); } }, .Enum, .Union => { if (comptime @hasDecl(@TypeOf(value.*), "format")) { putComptimeStr(fmt_so_far); value.format(doFmtNoEndl); } else { @compileError("Cannot format '" ++ @typeName(@TypeOf(value.*)) ++ "' yet"); } }, .Pointer => { defaultFormatValue(value.*, fmt_so_far); }, .Optional => { putComptimeStr(fmt_so_far); // Runtime if, flush before! if(value.* != null) { defaultFormatValue(&(value.*.?), ""); } else { putComptimeStr("null"); } }, else => @compileError("Type '" ++ @typeName(@TypeOf(value.*)) ++ "' not available for {}-formatting"), } } noinline fn defaultFormatStruct(value: anytype, comptime fmt_so_far: []const u8) [:0]const u8 { const arg_fields = @typeInfo(@TypeOf(value.*)).Struct.fields; comptime var current_fmt: [:0]const u8 = fmt_so_far ++ @typeName(@TypeOf(value.*)) ++ "{{ "; inline for (arg_fields) |field, i| { const trailing = defaultFormatValue(&@field(value.*, field.name), current_fmt ++ "." ++ field.name ++ " = "); current_fmt = trailing ++ if (i == current_fmt.len - 1) "" else ", "; } return current_fmt ++ " }}"; } pub fn doFmtNoEndl(comptime fmt: []const u8, args: anytype) void { comptime var fmt_idx = 0; comptime var arg_idx = 0; comptime var current_str: [:0]const u8 = ""; const arg_fields = @typeInfo(@TypeOf(args)).Struct.fields; @setEvalBranchQuota(9999999); inline while (fmt_idx < fmt.len) { if (fmt[fmt_idx] == '}') { // }} current_str = current_str ++ [_]u8{'}'}; fmt_idx += 2; } else if(fmt[fmt_idx] == '{') { if (fmt[fmt_idx + 1] == '{') { // {{ current_str = current_str ++ [_]u8{'{'}; fmt_idx += 2; } else if (fmt[fmt_idx + 1] == '0' and fmt[fmt_idx + 2] == 'X') { const value = &@field(args, arg_fields[arg_idx].name); if (arg_fields[arg_idx].is_comptime) { current_str = current_str ++ comptime comptimeValToZeroPaddedHexString(value.*); } else { putComptimeStr(current_str); current_str = ""; printRuntimeValueAsZeroPaddedHex(value.*); } fmt_idx += 4; arg_idx += 1; } else if (fmt[fmt_idx + 1] == 'X') { // {X} const value = &@field(args, arg_fields[arg_idx].name); if (arg_fields[arg_idx].is_comptime) { current_str = current_str ++ comptime comptimeValToString(value.*, 16); } else { putComptimeStr(current_str); current_str = ""; printRuntimeValue(value.*, 16); } fmt_idx += 3; arg_idx += 1; } else if (fmt[fmt_idx + 1] == 'd') { // {d} const value = &@field(args, arg_fields[arg_idx].name); if (arg_fields[arg_idx].is_comptime) { current_str = current_str ++ comptime comptimeValToString(value.*, 10); } else { putComptimeStr(current_str); current_str = ""; printRuntimeValue(value.*, 10); } fmt_idx += 3; arg_idx += 1; } else if (fmt[fmt_idx + 1] == 'e') { // {e} const value = &@field(args, arg_fields[arg_idx].name); switch (@typeInfo(@TypeOf(value.*))) { .Enum, .ErrorSet => current_str = current_str ++ @typeName(@TypeOf(value.*)), else => {}, } current_str = current_str ++ "."; if (arg_fields[arg_idx].is_comptime) { switch(@typeInfo(@TypeOf(value.*))) { .Enum => current_str = current_str ++ comptime @tagName(value.*), .ErrorSet => current_str = current_str ++ comptime @errorName(value.*), else => @compileError("Cannot format type '" ++ @typeName(@TypeOf(value.*)) ++ "' with {e}."), } } else { putComptimeStr(current_str); current_str = ""; switch(@typeInfo(@TypeOf(value.*))) { // switch to printSentinelString once we have in our compiler build https://github.com/ziglang/zig/pull/8636 .Enum => printSliceString(@tagName(value.*)), .ErrorSet => printSliceString(@errorName(value.*)), else => @compileError("Cannot format type '" ++ @typeName(@TypeOf(value.*)) ++ "' with {e}."), } } fmt_idx += 3; arg_idx += 1; } else if (fmt[fmt_idx + 1] == 's') { // {s} const value = &@field(args, arg_fields[arg_idx].name); if (arg_fields[arg_idx].is_comptime) { current_str = current_str ++ comptime value.*; } else { putComptimeStr(current_str); current_str = ""; switch(@TypeOf(value.*)) { [*:0]u8, [*:0]const u8 => printSentinelString(value.*), [:0]u8, [:0]const u8 => printSentinelString(value.ptr), []u8, []const u8 => printSliceString(value.*), else => @compileError("Bad type " ++ @typeName(@TypeOf(value.*)) ++ " for {s} formatting"), } } fmt_idx += 3; arg_idx += 1; } else if (fmt[fmt_idx + 1] == 'c') { // {c} const value = &@field(args, arg_fields[arg_idx].name); if (arg_fields[arg_idx].is_comptime) { current_str = current_str ++ comptime [_]u8{value.*}; } else { putComptimeStr(current_str); current_str = ""; printCharacter(value.*); } fmt_idx += 3; arg_idx += 1; } else if (fmt[fmt_idx + 1] == 'b') { // {b} const value = &@field(args, arg_fields[arg_idx].name); if (arg_fields[arg_idx].is_comptime) { current_str = current_str ++ if(value.*) "true" else "false"; } else { putComptimeStr(current_str); current_str = ""; printBoolean(value.*); } fmt_idx += 3; arg_idx += 1; } else if (fmt[fmt_idx + 1] == '*') { // {*} const value = &@field(args, arg_fields[arg_idx].name); putComptimeStr(current_str); current_str = ""; printPointer(value.*); fmt_idx += 3; arg_idx += 1; } else if (fmt[fmt_idx + 1] == '}') { // {} defaultFormatValue(&@field(args, arg_fields[arg_idx].name), current_str); current_str = ""; fmt_idx += 2; arg_idx += 1; } else { @compileError("Unknown format specifier: '" ++ [_]u8{fmt[fmt_idx + 1]} ++ "'"); } } else { current_str = current_str ++ [_]u8{fmt[fmt_idx]}; fmt_idx += 1; } } putComptimeStr(current_str); if (arg_idx < arg_fields.len) { @compileError("Unused fmt arguments!"); } } pub fn doFmt(comptime fmt: []const u8, args: anytype) callconv(.Inline) void { return doFmtNoEndl(fmt ++ "\n", args); }
lib/output/fmt.zig
const std = @import("std"); const builtin = @import("builtin"); const IsWasm = builtin.target.isWasm(); const stdx = @import("stdx"); const Duration = stdx.time.Duration; const platform = @import("platform"); const graphics = @import("graphics"); const Color = graphics.Color; const ui = @import("ui"); const Column = ui.widgets.Column; const Row = ui.widgets.Row; const Text = ui.widgets.Text; const Padding = ui.widgets.Padding; const Center = ui.widgets.Center; const TextField = ui.widgets.TextField; const Slider = ui.widgets.Slider; const Sized = ui.widgets.Sized; const ProgressBar = ui.widgets.ProgressBar; const TextButton = ui.widgets.TextButton; const Flex = ui.widgets.Flex; const helper = @import("helper.zig"); const log = stdx.log.scoped(.main); pub const App = struct { progress_bar: ui.WidgetRef(ProgressBar), duration_secs: f32, progress_ms: f32, step_interval: ?u32, ctx: *ui.CommonContext, node: *ui.Node, const Self = @This(); pub fn init(self: *Self, c: *ui.InitContext) void { self.step_interval = c.addInterval(Duration.initSecsF(0.01), self, onStep); self.progress_ms = 0; self.duration_secs = 15; self.ctx = c.common; self.node = c.node; } fn onStep(self: *Self, e: ui.IntervalEvent) void { self.progress_ms += e.progress_ms; if (self.progress_ms >= self.duration_secs * 1000) { self.progress_ms = self.duration_secs * 1000; e.ctx.removeInterval(self.step_interval.?); self.step_interval = null; } self.progress_bar.getWidget().setValue(self.progress_ms/1000); } fn reset(self: *Self) void { if (self.step_interval == null) { self.step_interval = self.ctx.addInterval(self.node, Duration.initSecsF(0.01), self, onStep); } else { self.ctx.resetInterval(self.step_interval.?); } self.progress_ms = 0; self.progress_bar.getWidget().setValue(self.progress_ms/1000); } pub fn build(self: *Self, c: *ui.BuildContext) ui.FrameId { const S = struct { fn onChangeDuration(self_: *Self, val: i32) void { const duration_secs = @intToFloat(f32, val); self_.duration_secs = duration_secs; self_.reset(); } fn onClickReset(self_: *Self, e: platform.MouseUpEvent) void { _ = e; self_.reset(); } }; return c.decl(Center, .{ .child = c.decl(Sized, .{ .width = 400, .child = c.decl(Column, .{ .expand = false, .spacing = 20, .children = c.list(.{ c.decl(Row, .{ .children = c.list(.{ c.decl(Text, .{ .text = "Elapsed Time: ", .color = Color.White, }), c.decl(Flex, .{ .child = c.decl(ProgressBar, .{ .bind = &self.progress_bar, .max_val = self.duration_secs, }), }), }), }), c.decl(Row, .{ .children = c.list(.{ c.decl(Text, .{ .text = c.fmt("{d:.0}ms", .{self.progress_ms}), .color = Color.Blue, }), }), }), c.decl(Row, .{ .children = c.list(.{ c.decl(Text, .{ .text = "Duration: ", .color = Color.White, }), c.decl(Flex, .{ .child = c.decl(Slider, .{ .init_val = @floatToInt(i32, self.duration_secs), .min_val = 1, .max_val = 30, .onChange = c.funcExt(self, S.onChangeDuration), }), }), }), }), c.decl(Row, .{ .children = c.list(.{ c.decl(Flex, .{ .child = c.decl(TextButton, .{ .text = "Reset", .corner_radius = 10, .onClick = c.funcExt(self, S.onClickReset), }), }), }), }), }), }), }), }); } }; var app: helper.App = undefined; pub fn main() !void { // This is the app loop for desktop. For web/wasm see wasm exports below. app.init("Timer"); defer app.deinit(); app.runEventLoop(update); } fn update(delta_ms: f32) void { const S = struct { fn buildRoot(_: void, c: *ui.BuildContext) ui.FrameId { return c.decl(App, .{}); } }; const ui_width = @intToFloat(f32, app.win.getWidth()); const ui_height = @intToFloat(f32, app.win.getHeight()); app.ui_mod.updateAndRender(delta_ms, {}, S.buildRoot, ui_width, ui_height) catch unreachable; } pub usingnamespace if (IsWasm) struct { export fn wasmInit() *const u8 { return helper.wasmInit(&app, "Timer"); } export fn wasmUpdate(cur_time_ms: f64, input_buffer_len: u32) *const u8 { return helper.wasmUpdate(cur_time_ms, input_buffer_len, &app, update); } /// Not that useful since it's a long lived process in the browser. export fn wasmDeinit() void { app.deinit(); stdx.wasm.deinit(); } } else struct {};
ui/examples/timer.zig
const std = @import("std"); const value = @import("value.zig"); const ArrayList = std.ArrayList; const Value = value.Value; const OpCode = enum(u8) { constant, ret, }; pub const Chunk = struct { code: ArrayList(u8), constants: ArrayList(Value), lines: ArrayList(usize), pub fn init(allocator: *std.mem.Allocator) Chunk { return .{ .code = ArrayList(u8).init(allocator), .constants = ArrayList(Value).init(allocator), .lines = ArrayList(usize).init(allocator), }; } pub fn deinit(self: *const Chunk) void { self.code.deinit(); self.constants.deinit(); self.lines.deinit(); } pub fn write(self: *Chunk, byte: u8, line: usize) !void { try self.code.append(byte); try self.lines.append(line); } pub fn writeOpCode(self: *Chunk, op: OpCode, line: usize) !void { try self.write(@enumToInt(op), line); } pub fn addConstant(self: *Chunk, val: Value) !u8 { const index = @intCast(u8, self.constants.items.len); try self.constants.append(val); return index; } pub fn disassemble(self: *Chunk, name: []const u8) void { std.debug.print("== {s} ==\n", .{name}); var offset: usize = 0; while (offset < self.code.items.len) { offset = self.disassembleInstruction(offset); } } pub fn disassembleInstruction(self: *Chunk, offset: usize) usize { std.debug.print("{d:0>4} ", .{offset}); if (offset > 0 and self.lines.items[offset] == self.lines.items[offset - 1]) { std.debug.print(" | ", .{}); } else { std.debug.print("{d: >4} ", .{self.lines.items[offset]}); } const instruction = @intToEnum(OpCode, self.code.items[offset]); return switch (instruction) { .constant => self.constantInstruction("constant", offset), .ret => simpleInstruction("ret", offset), }; } fn simpleInstruction(name: []const u8, offset: usize) usize { std.debug.print("{s}\n", .{name}); return offset + 1; } fn constantInstruction(self: *Chunk, name: []const u8, offset: usize) usize { const constant = self.code.items[offset + 1]; std.debug.print("{s: <16} {d: >4} '{d}'\n", .{ name, constant, self.constants.items[constant] }); return offset + 2; } }; const testing = std.testing; test "chunk init" { const chunk = Chunk.init(testing.allocator); defer chunk.deinit(); try testing.expectEqual(chunk.code.items.len, 0); try testing.expectEqual(chunk.code.capacity, 0); } test "chunk write" { var chunk = Chunk.init(testing.allocator); defer chunk.deinit(); try chunk.writeOpCode(.ret, 123); try testing.expectEqual(chunk.code.items.len, 1); }
src/chunk.zig
const std = @import("../std.zig"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; const ast = std.zig.ast; const Node = ast.Node; const Tree = ast.Tree; const AstError = ast.Error; const TokenIndex = ast.TokenIndex; const NodeIndex = ast.NodeIndex; const Token = std.zig.Token; pub const Error = error{ParseError} || Allocator.Error; /// Result should be freed with tree.deinit() when there are /// no more references to any of the tokens or nodes. pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!*Tree { var token_ids = std.ArrayList(Token.Id).init(gpa); defer token_ids.deinit(); var token_locs = std.ArrayList(Token.Loc).init(gpa); defer token_locs.deinit(); // Empirically, the zig std lib has an 8:1 ratio of source bytes to token count. const estimated_token_count = source.len / 8; try token_ids.ensureCapacity(estimated_token_count); try token_locs.ensureCapacity(estimated_token_count); var tokenizer = std.zig.Tokenizer.init(source); while (true) { const token = tokenizer.next(); try token_ids.append(token.id); try token_locs.append(token.loc); if (token.id == .Eof) break; } var parser: Parser = .{ .source = source, .arena = std.heap.ArenaAllocator.init(gpa), .gpa = gpa, .token_ids = token_ids.items, .token_locs = token_locs.items, .errors = .{}, .tok_i = 0, }; defer parser.errors.deinit(gpa); errdefer parser.arena.deinit(); while (token_ids.items[parser.tok_i] == .LineComment) parser.tok_i += 1; const root_node = try parser.parseRoot(); const tree = try parser.arena.allocator.create(Tree); tree.* = .{ .gpa = gpa, .source = source, .token_ids = token_ids.toOwnedSlice(), .token_locs = token_locs.toOwnedSlice(), .errors = parser.errors.toOwnedSlice(gpa), .root_node = root_node, .arena = parser.arena.state, }; return tree; } /// Represents in-progress parsing, will be converted to an ast.Tree after completion. const Parser = struct { arena: std.heap.ArenaAllocator, gpa: *Allocator, source: []const u8, token_ids: []const Token.Id, token_locs: []const Token.Loc, tok_i: TokenIndex, errors: std.ArrayListUnmanaged(AstError), /// Root <- skip ContainerMembers eof fn parseRoot(p: *Parser) Allocator.Error!*Node.Root { const decls = try parseContainerMembers(p, true); defer p.gpa.free(decls); // parseContainerMembers will try to skip as much // invalid tokens as it can so this can only be the EOF const eof_token = p.eatToken(.Eof).?; const decls_len = @intCast(NodeIndex, decls.len); const node = try Node.Root.create(&p.arena.allocator, decls_len, eof_token); std.mem.copy(*Node, node.decls(), decls); return node; } /// ContainerMembers /// <- TestDecl ContainerMembers /// / TopLevelComptime ContainerMembers /// / KEYWORD_pub? TopLevelDecl ContainerMembers /// / ContainerField COMMA ContainerMembers /// / ContainerField /// / fn parseContainerMembers(p: *Parser, top_level: bool) ![]*Node { var list = std.ArrayList(*Node).init(p.gpa); defer list.deinit(); var field_state: union(enum) { /// no fields have been seen none, /// currently parsing fields seen, /// saw fields and then a declaration after them. /// payload is first token of previous declaration. end: TokenIndex, /// ther was a declaration between fields, don't report more errors err, } = .none; while (true) { if (try p.parseContainerDocComments()) |node| { try list.append(node); continue; } const doc_comments = try p.parseDocComment(); if (p.parseTestDecl() catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.ParseError => { p.findNextContainerMember(); continue; }, }) |node| { if (field_state == .seen) { field_state = .{ .end = node.firstToken() }; } node.cast(Node.TestDecl).?.doc_comments = doc_comments; try list.append(node); continue; } if (p.parseTopLevelComptime() catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.ParseError => { p.findNextContainerMember(); continue; }, }) |node| { if (field_state == .seen) { field_state = .{ .end = node.firstToken() }; } node.cast(Node.Comptime).?.doc_comments = doc_comments; try list.append(node); continue; } const visib_token = p.eatToken(.Keyword_pub); if (p.parseTopLevelDecl() catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.ParseError => { p.findNextContainerMember(); continue; }, }) |node| { if (field_state == .seen) { field_state = .{ .end = visib_token orelse node.firstToken() }; } switch (node.id) { .FnProto => { node.cast(Node.FnProto).?.doc_comments = doc_comments; node.cast(Node.FnProto).?.visib_token = visib_token; }, .VarDecl => { node.cast(Node.VarDecl).?.doc_comments = doc_comments; node.cast(Node.VarDecl).?.visib_token = visib_token; }, .Use => { node.cast(Node.Use).?.doc_comments = doc_comments; node.cast(Node.Use).?.visib_token = visib_token; }, else => unreachable, } try list.append(node); if (try p.parseAppendedDocComment(node.lastToken())) |appended_comment| { switch (node.id) { .FnProto => {}, .VarDecl => node.cast(Node.VarDecl).?.doc_comments = appended_comment, .Use => node.cast(Node.Use).?.doc_comments = appended_comment, else => unreachable, } } continue; } if (visib_token != null) { try p.errors.append(p.gpa, .{ .ExpectedPubItem = .{ .token = p.tok_i }, }); // ignore this pub continue; } if (p.parseContainerField() catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.ParseError => { // attempt to recover p.findNextContainerMember(); continue; }, }) |node| { switch (field_state) { .none => field_state = .seen, .err, .seen => {}, .end => |tok| { try p.errors.append(p.gpa, .{ .DeclBetweenFields = .{ .token = tok }, }); // continue parsing, error will be reported later field_state = .err; }, } const field = node.cast(Node.ContainerField).?; field.doc_comments = doc_comments; try list.append(node); const comma = p.eatToken(.Comma) orelse { // try to continue parsing const index = p.tok_i; p.findNextContainerMember(); const next = p.token_ids[p.tok_i]; switch (next) { .Eof => break, else => { if (next == .RBrace) { if (!top_level) break; _ = p.nextToken(); } // add error and continue try p.errors.append(p.gpa, .{ .ExpectedToken = .{ .token = index, .expected_id = .Comma }, }); continue; }, } }; if (try p.parseAppendedDocComment(comma)) |appended_comment| field.doc_comments = appended_comment; continue; } // Dangling doc comment if (doc_comments != null) { try p.errors.append(p.gpa, .{ .UnattachedDocComment = .{ .token = doc_comments.?.firstToken() }, }); } const next = p.token_ids[p.tok_i]; switch (next) { .Eof => break, .Keyword_comptime => { _ = p.nextToken(); try p.errors.append(p.gpa, .{ .ExpectedBlockOrField = .{ .token = p.tok_i }, }); }, else => { const index = p.tok_i; if (next == .RBrace) { if (!top_level) break; _ = p.nextToken(); } // this was likely not supposed to end yet, // try to find the next declaration p.findNextContainerMember(); try p.errors.append(p.gpa, .{ .ExpectedContainerMembers = .{ .token = index }, }); }, } } return list.toOwnedSlice(); } /// Attempts to find next container member by searching for certain tokens fn findNextContainerMember(p: *Parser) void { var level: u32 = 0; while (true) { const tok = p.nextToken(); switch (p.token_ids[tok]) { // any of these can start a new top level declaration .Keyword_test, .Keyword_comptime, .Keyword_pub, .Keyword_export, .Keyword_extern, .Keyword_inline, .Keyword_noinline, .Keyword_usingnamespace, .Keyword_threadlocal, .Keyword_const, .Keyword_var, .Keyword_fn, .Identifier, => { if (level == 0) { p.putBackToken(tok); return; } }, .Comma, .Semicolon => { // this decl was likely meant to end here if (level == 0) { return; } }, .LParen, .LBracket, .LBrace => level += 1, .RParen, .RBracket => { if (level != 0) level -= 1; }, .RBrace => { if (level == 0) { // end of container, exit p.putBackToken(tok); return; } level -= 1; }, .Eof => { p.putBackToken(tok); return; }, else => {}, } } } /// Attempts to find the next statement by searching for a semicolon fn findNextStmt(p: *Parser) void { var level: u32 = 0; while (true) { const tok = p.nextToken(); switch (p.token_ids[tok]) { .LBrace => level += 1, .RBrace => { if (level == 0) { p.putBackToken(tok); return; } level -= 1; }, .Semicolon => { if (level == 0) { return; } }, .Eof => { p.putBackToken(tok); return; }, else => {}, } } } /// Eat a multiline container doc comment fn parseContainerDocComments(p: *Parser) !?*Node { if (p.eatToken(.ContainerDocComment)) |first_line| { while (p.eatToken(.ContainerDocComment)) |_| {} const node = try p.arena.allocator.create(Node.DocComment); node.* = .{ .first_line = first_line }; return &node.base; } return null; } /// TestDecl <- KEYWORD_test STRINGLITERALSINGLE Block fn parseTestDecl(p: *Parser) !?*Node { const test_token = p.eatToken(.Keyword_test) orelse return null; const name_node = try p.expectNode(parseStringLiteralSingle, .{ .ExpectedStringLiteral = .{ .token = p.tok_i }, }); const block_node = try p.expectNode(parseBlock, .{ .ExpectedLBrace = .{ .token = p.tok_i }, }); const test_node = try p.arena.allocator.create(Node.TestDecl); test_node.* = .{ .doc_comments = null, .test_token = test_token, .name = name_node, .body_node = block_node, }; return &test_node.base; } /// TopLevelComptime <- KEYWORD_comptime BlockExpr fn parseTopLevelComptime(p: *Parser) !?*Node { const tok = p.eatToken(.Keyword_comptime) orelse return null; const lbrace = p.eatToken(.LBrace) orelse { p.putBackToken(tok); return null; }; p.putBackToken(lbrace); const block_node = try p.expectNode(parseBlockExpr, .{ .ExpectedLabelOrLBrace = .{ .token = p.tok_i }, }); const comptime_node = try p.arena.allocator.create(Node.Comptime); comptime_node.* = .{ .doc_comments = null, .comptime_token = tok, .expr = block_node, }; return &comptime_node.base; } /// TopLevelDecl /// <- (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE? / (KEYWORD_inline / KEYWORD_noinline))? FnProto (SEMICOLON / Block) /// / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl /// / KEYWORD_usingnamespace Expr SEMICOLON fn parseTopLevelDecl(p: *Parser) !?*Node { var lib_name: ?*Node = null; const extern_export_inline_token = blk: { if (p.eatToken(.Keyword_export)) |token| break :blk token; if (p.eatToken(.Keyword_extern)) |token| { lib_name = try p.parseStringLiteralSingle(); break :blk token; } if (p.eatToken(.Keyword_inline)) |token| break :blk token; if (p.eatToken(.Keyword_noinline)) |token| break :blk token; break :blk null; }; if (try p.parseFnProto()) |node| { const fn_node = node.cast(Node.FnProto).?; fn_node.*.extern_export_inline_token = extern_export_inline_token; fn_node.*.lib_name = lib_name; if (p.eatToken(.Semicolon)) |_| return node; if (try p.expectNodeRecoverable(parseBlock, .{ // since parseBlock only return error.ParseError on // a missing '}' we can assume this function was // supposed to end here. .ExpectedSemiOrLBrace = .{ .token = p.tok_i }, })) |body_node| { fn_node.body_node = body_node; } return node; } if (extern_export_inline_token) |token| { if (p.token_ids[token] == .Keyword_inline or p.token_ids[token] == .Keyword_noinline) { try p.errors.append(p.gpa, .{ .ExpectedFn = .{ .token = p.tok_i }, }); return error.ParseError; } } const thread_local_token = p.eatToken(.Keyword_threadlocal); if (try p.parseVarDecl()) |node| { var var_decl = node.cast(Node.VarDecl).?; var_decl.*.thread_local_token = thread_local_token; var_decl.*.comptime_token = null; var_decl.*.extern_export_token = extern_export_inline_token; var_decl.*.lib_name = lib_name; return node; } if (thread_local_token != null) { try p.errors.append(p.gpa, .{ .ExpectedVarDecl = .{ .token = p.tok_i }, }); // ignore this and try again; return error.ParseError; } if (extern_export_inline_token) |token| { try p.errors.append(p.gpa, .{ .ExpectedVarDeclOrFn = .{ .token = p.tok_i }, }); // ignore this and try again; return error.ParseError; } return p.parseUse(); } /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) fn parseFnProto(p: *Parser) !?*Node { // TODO: Remove once extern/async fn rewriting is var is_async = false; var is_extern = false; const cc_token: ?TokenIndex = blk: { if (p.eatToken(.Keyword_extern)) |token| { is_extern = true; break :blk token; } if (p.eatToken(.Keyword_async)) |token| { is_async = true; break :blk token; } break :blk null; }; const fn_token = p.eatToken(.Keyword_fn) orelse { if (cc_token) |token| p.putBackToken(token); return null; }; const name_token = p.eatToken(.Identifier); const lparen = try p.expectToken(.LParen); const params = try p.parseParamDeclList(); defer p.gpa.free(params); const rparen = try p.expectToken(.RParen); const align_expr = try p.parseByteAlign(); const section_expr = try p.parseLinkSection(); const callconv_expr = try p.parseCallconv(); const exclamation_token = p.eatToken(.Bang); const return_type_expr = (try p.parseVarType()) orelse try p.expectNodeRecoverable(parseTypeExpr, .{ // most likely the user forgot to specify the return type. // Mark return type as invalid and try to continue. .ExpectedReturnType = .{ .token = p.tok_i }, }); // TODO https://github.com/ziglang/zig/issues/3750 const R = Node.FnProto.ReturnType; const return_type = if (return_type_expr == null) R{ .Invalid = rparen } else if (exclamation_token != null) R{ .InferErrorSet = return_type_expr.? } else R{ .Explicit = return_type_expr.? }; const var_args_token = if (params.len > 0) blk: { const param_type = params[params.len - 1].param_type; break :blk if (param_type == .var_args) param_type.var_args else null; } else null; const fn_proto_node = try Node.FnProto.alloc(&p.arena.allocator, params.len); fn_proto_node.* = .{ .doc_comments = null, .visib_token = null, .fn_token = fn_token, .name_token = name_token, .params_len = params.len, .return_type = return_type, .var_args_token = var_args_token, .extern_export_inline_token = null, .body_node = null, .lib_name = null, .align_expr = align_expr, .section_expr = section_expr, .callconv_expr = callconv_expr, .is_extern_prototype = is_extern, .is_async = is_async, }; std.mem.copy(Node.FnProto.ParamDecl, fn_proto_node.params(), params); return &fn_proto_node.base; } /// VarDecl <- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON fn parseVarDecl(p: *Parser) !?*Node { const mut_token = p.eatToken(.Keyword_const) orelse p.eatToken(.Keyword_var) orelse return null; const name_token = try p.expectToken(.Identifier); const type_node = if (p.eatToken(.Colon) != null) try p.expectNode(parseTypeExpr, .{ .ExpectedTypeExpr = .{ .token = p.tok_i }, }) else null; const align_node = try p.parseByteAlign(); const section_node = try p.parseLinkSection(); const eq_token = p.eatToken(.Equal); const init_node = if (eq_token != null) blk: { break :blk try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); } else null; const semicolon_token = try p.expectToken(.Semicolon); const node = try p.arena.allocator.create(Node.VarDecl); node.* = .{ .doc_comments = null, .visib_token = null, .thread_local_token = null, .name_token = name_token, .eq_token = eq_token, .mut_token = mut_token, .comptime_token = null, .extern_export_token = null, .lib_name = null, .type_node = type_node, .align_node = align_node, .section_node = section_node, .init_node = init_node, .semicolon_token = semicolon_token, }; return &node.base; } /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON TypeExpr ByteAlign?)? (EQUAL Expr)? fn parseContainerField(p: *Parser) !?*Node { const comptime_token = p.eatToken(.Keyword_comptime); const name_token = p.eatToken(.Identifier) orelse { if (comptime_token) |t| p.putBackToken(t); return null; }; var align_expr: ?*Node = null; var type_expr: ?*Node = null; if (p.eatToken(.Colon)) |_| { if (p.eatToken(.Keyword_var)) |var_tok| { const node = try p.arena.allocator.create(Node.VarType); node.* = .{ .token = var_tok }; type_expr = &node.base; } else { type_expr = try p.expectNode(parseTypeExpr, .{ .ExpectedTypeExpr = .{ .token = p.tok_i }, }); align_expr = try p.parseByteAlign(); } } const value_expr = if (p.eatToken(.Equal)) |_| try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }) else null; const node = try p.arena.allocator.create(Node.ContainerField); node.* = .{ .doc_comments = null, .comptime_token = comptime_token, .name_token = name_token, .type_expr = type_expr, .value_expr = value_expr, .align_expr = align_expr, }; return &node.base; } /// Statement /// <- KEYWORD_comptime? VarDecl /// / KEYWORD_comptime BlockExprStatement /// / KEYWORD_nosuspend BlockExprStatement /// / KEYWORD_suspend (SEMICOLON / BlockExprStatement) /// / KEYWORD_defer BlockExprStatement /// / KEYWORD_errdefer Payload? BlockExprStatement /// / IfStatement /// / LabeledStatement /// / SwitchExpr /// / AssignExpr SEMICOLON fn parseStatement(p: *Parser) Error!?*Node { const comptime_token = p.eatToken(.Keyword_comptime); const var_decl_node = try p.parseVarDecl(); if (var_decl_node) |node| { const var_decl = node.cast(Node.VarDecl).?; var_decl.comptime_token = comptime_token; return node; } if (comptime_token) |token| { const block_expr = try p.expectNode(parseBlockExprStatement, .{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.Comptime); node.* = .{ .doc_comments = null, .comptime_token = token, .expr = block_expr, }; return &node.base; } if (p.eatToken(.Keyword_nosuspend)) |nosuspend_token| { const block_expr = try p.expectNode(parseBlockExprStatement, .{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.Nosuspend); node.* = .{ .nosuspend_token = nosuspend_token, .expr = block_expr, }; return &node.base; } if (p.eatToken(.Keyword_suspend)) |suspend_token| { const semicolon = p.eatToken(.Semicolon); const body_node = if (semicolon == null) blk: { break :blk try p.expectNode(parseBlockExprStatement, .{ .ExpectedBlockOrExpression = .{ .token = p.tok_i }, }); } else null; const node = try p.arena.allocator.create(Node.Suspend); node.* = .{ .suspend_token = suspend_token, .body = body_node, }; return &node.base; } const defer_token = p.eatToken(.Keyword_defer) orelse p.eatToken(.Keyword_errdefer); if (defer_token) |token| { const payload = if (p.token_ids[token] == .Keyword_errdefer) try p.parsePayload() else null; const expr_node = try p.expectNode(parseBlockExprStatement, .{ .ExpectedBlockOrExpression = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.Defer); node.* = .{ .defer_token = token, .expr = expr_node, .payload = payload, }; return &node.base; } if (try p.parseIfStatement()) |node| return node; if (try p.parseLabeledStatement()) |node| return node; if (try p.parseSwitchExpr()) |node| return node; if (try p.parseAssignExpr()) |node| { _ = try p.expectTokenRecoverable(.Semicolon); return node; } return null; } /// IfStatement /// <- IfPrefix BlockExpr ( KEYWORD_else Payload? Statement )? /// / IfPrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement ) fn parseIfStatement(p: *Parser) !?*Node { const if_node = (try p.parseIfPrefix()) orelse return null; const if_prefix = if_node.cast(Node.If).?; const block_expr = (try p.parseBlockExpr()); const assign_expr = if (block_expr == null) try p.expectNode(parseAssignExpr, .{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, }) else null; const semicolon = if (assign_expr != null) p.eatToken(.Semicolon) else null; const else_node = if (semicolon == null) blk: { const else_token = p.eatToken(.Keyword_else) orelse break :blk null; const payload = try p.parsePayload(); const else_body = try p.expectNode(parseStatement, .{ .InvalidToken = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.Else); node.* = .{ .else_token = else_token, .payload = payload, .body = else_body, }; break :blk node; } else null; if (block_expr) |body| { if_prefix.body = body; if_prefix.@"else" = else_node; return if_node; } if (assign_expr) |body| { if_prefix.body = body; if (semicolon != null) return if_node; if (else_node != null) { if_prefix.@"else" = else_node; return if_node; } try p.errors.append(p.gpa, .{ .ExpectedSemiOrElse = .{ .token = p.tok_i }, }); } return if_node; } /// LabeledStatement <- BlockLabel? (Block / LoopStatement) fn parseLabeledStatement(p: *Parser) !?*Node { var colon: TokenIndex = undefined; const label_token = p.parseBlockLabel(&colon); if (try p.parseBlock()) |node| { node.cast(Node.Block).?.label = label_token; return node; } if (try p.parseLoopStatement()) |node| { if (node.cast(Node.For)) |for_node| { for_node.label = label_token; } else if (node.cast(Node.While)) |while_node| { while_node.label = label_token; } else unreachable; return node; } if (label_token != null) { try p.errors.append(p.gpa, .{ .ExpectedLabelable = .{ .token = p.tok_i }, }); return error.ParseError; } return null; } /// LoopStatement <- KEYWORD_inline? (ForStatement / WhileStatement) fn parseLoopStatement(p: *Parser) !?*Node { const inline_token = p.eatToken(.Keyword_inline); if (try p.parseForStatement()) |node| { node.cast(Node.For).?.inline_token = inline_token; return node; } if (try p.parseWhileStatement()) |node| { node.cast(Node.While).?.inline_token = inline_token; return node; } if (inline_token == null) return null; // If we've seen "inline", there should have been a "for" or "while" try p.errors.append(p.gpa, .{ .ExpectedInlinable = .{ .token = p.tok_i }, }); return error.ParseError; } /// ForStatement /// <- ForPrefix BlockExpr ( KEYWORD_else Statement )? /// / ForPrefix AssignExpr ( SEMICOLON / KEYWORD_else Statement ) fn parseForStatement(p: *Parser) !?*Node { const node = (try p.parseForPrefix()) orelse return null; const for_prefix = node.cast(Node.For).?; if (try p.parseBlockExpr()) |block_expr_node| { for_prefix.body = block_expr_node; if (p.eatToken(.Keyword_else)) |else_token| { const statement_node = try p.expectNode(parseStatement, .{ .InvalidToken = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = null, .body = statement_node, }; for_prefix.@"else" = else_node; return node; } return node; } for_prefix.body = try p.expectNode(parseAssignExpr, .{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, }); if (p.eatToken(.Semicolon) != null) return node; if (p.eatToken(.Keyword_else)) |else_token| { const statement_node = try p.expectNode(parseStatement, .{ .ExpectedStatement = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = null, .body = statement_node, }; for_prefix.@"else" = else_node; return node; } try p.errors.append(p.gpa, .{ .ExpectedSemiOrElse = .{ .token = p.tok_i }, }); return node; } /// WhileStatement /// <- WhilePrefix BlockExpr ( KEYWORD_else Payload? Statement )? /// / WhilePrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement ) fn parseWhileStatement(p: *Parser) !?*Node { const node = (try p.parseWhilePrefix()) orelse return null; const while_prefix = node.cast(Node.While).?; if (try p.parseBlockExpr()) |block_expr_node| { while_prefix.body = block_expr_node; if (p.eatToken(.Keyword_else)) |else_token| { const payload = try p.parsePayload(); const statement_node = try p.expectNode(parseStatement, .{ .InvalidToken = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = payload, .body = statement_node, }; while_prefix.@"else" = else_node; return node; } return node; } while_prefix.body = try p.expectNode(parseAssignExpr, .{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, }); if (p.eatToken(.Semicolon) != null) return node; if (p.eatToken(.Keyword_else)) |else_token| { const payload = try p.parsePayload(); const statement_node = try p.expectNode(parseStatement, .{ .ExpectedStatement = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = payload, .body = statement_node, }; while_prefix.@"else" = else_node; return node; } try p.errors.append(p.gpa, .{ .ExpectedSemiOrElse = .{ .token = p.tok_i }, }); return node; } /// BlockExprStatement /// <- BlockExpr /// / AssignExpr SEMICOLON fn parseBlockExprStatement(p: *Parser) !?*Node { if (try p.parseBlockExpr()) |node| return node; if (try p.parseAssignExpr()) |node| { _ = try p.expectTokenRecoverable(.Semicolon); return node; } return null; } /// BlockExpr <- BlockLabel? Block fn parseBlockExpr(p: *Parser) Error!?*Node { var colon: TokenIndex = undefined; const label_token = p.parseBlockLabel(&colon); const block_node = (try p.parseBlock()) orelse { if (label_token) |label| { p.putBackToken(label + 1); // ":" p.putBackToken(label); // IDENTIFIER } return null; }; block_node.cast(Node.Block).?.label = label_token; return block_node; } /// AssignExpr <- Expr (AssignOp Expr)? fn parseAssignExpr(p: *Parser) !?*Node { return p.parseBinOpExpr(parseAssignOp, parseExpr, .Once); } /// Expr <- KEYWORD_try* BoolOrExpr fn parseExpr(p: *Parser) Error!?*Node { return p.parsePrefixOpExpr(parseTry, parseBoolOrExpr); } /// BoolOrExpr <- BoolAndExpr (KEYWORD_or BoolAndExpr)* fn parseBoolOrExpr(p: *Parser) !?*Node { return p.parseBinOpExpr( SimpleBinOpParseFn(.Keyword_or, Node.InfixOp.Op.BoolOr), parseBoolAndExpr, .Infinitely, ); } /// BoolAndExpr <- CompareExpr (KEYWORD_and CompareExpr)* fn parseBoolAndExpr(p: *Parser) !?*Node { return p.parseBinOpExpr( SimpleBinOpParseFn(.Keyword_and, .BoolAnd), parseCompareExpr, .Infinitely, ); } /// CompareExpr <- BitwiseExpr (CompareOp BitwiseExpr)? fn parseCompareExpr(p: *Parser) !?*Node { return p.parseBinOpExpr(parseCompareOp, parseBitwiseExpr, .Once); } /// BitwiseExpr <- BitShiftExpr (BitwiseOp BitShiftExpr)* fn parseBitwiseExpr(p: *Parser) !?*Node { return p.parseBinOpExpr(parseBitwiseOp, parseBitShiftExpr, .Infinitely); } /// BitShiftExpr <- AdditionExpr (BitShiftOp AdditionExpr)* fn parseBitShiftExpr(p: *Parser) !?*Node { return p.parseBinOpExpr(parseBitShiftOp, parseAdditionExpr, .Infinitely); } /// AdditionExpr <- MultiplyExpr (AdditionOp MultiplyExpr)* fn parseAdditionExpr(p: *Parser) !?*Node { return p.parseBinOpExpr(parseAdditionOp, parseMultiplyExpr, .Infinitely); } /// MultiplyExpr <- PrefixExpr (MultiplyOp PrefixExpr)* fn parseMultiplyExpr(p: *Parser) !?*Node { return p.parseBinOpExpr(parseMultiplyOp, parsePrefixExpr, .Infinitely); } /// PrefixExpr <- PrefixOp* PrimaryExpr fn parsePrefixExpr(p: *Parser) !?*Node { return p.parsePrefixOpExpr(parsePrefixOp, parsePrimaryExpr); } /// PrimaryExpr /// <- AsmExpr /// / IfExpr /// / KEYWORD_break BreakLabel? Expr? /// / KEYWORD_comptime Expr /// / KEYWORD_nosuspend Expr /// / KEYWORD_continue BreakLabel? /// / KEYWORD_resume Expr /// / KEYWORD_return Expr? /// / BlockLabel? LoopExpr /// / Block /// / CurlySuffixExpr fn parsePrimaryExpr(p: *Parser) !?*Node { if (try p.parseAsmExpr()) |node| return node; if (try p.parseIfExpr()) |node| return node; if (p.eatToken(.Keyword_break)) |token| { const label = try p.parseBreakLabel(); const expr_node = try p.parseExpr(); const node = try p.arena.allocator.create(Node.ControlFlowExpression); node.* = .{ .ltoken = token, .kind = .{ .Break = label }, .rhs = expr_node, }; return &node.base; } if (p.eatToken(.Keyword_comptime)) |token| { const expr_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.Comptime); node.* = .{ .doc_comments = null, .comptime_token = token, .expr = expr_node, }; return &node.base; } if (p.eatToken(.Keyword_nosuspend)) |token| { const expr_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.Nosuspend); node.* = .{ .nosuspend_token = token, .expr = expr_node, }; return &node.base; } if (p.eatToken(.Keyword_continue)) |token| { const label = try p.parseBreakLabel(); const node = try p.arena.allocator.create(Node.ControlFlowExpression); node.* = .{ .ltoken = token, .kind = .{ .Continue = label }, .rhs = null, }; return &node.base; } if (p.eatToken(.Keyword_resume)) |token| { const expr_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = token, .op = .Resume, .rhs = expr_node, }; return &node.base; } if (p.eatToken(.Keyword_return)) |token| { const expr_node = try p.parseExpr(); const node = try p.arena.allocator.create(Node.ControlFlowExpression); node.* = .{ .ltoken = token, .kind = .Return, .rhs = expr_node, }; return &node.base; } var colon: TokenIndex = undefined; const label = p.parseBlockLabel(&colon); if (try p.parseLoopExpr()) |node| { if (node.cast(Node.For)) |for_node| { for_node.label = label; } else if (node.cast(Node.While)) |while_node| { while_node.label = label; } else unreachable; return node; } if (label) |token| { p.putBackToken(token + 1); // ":" p.putBackToken(token); // IDENTIFIER } if (try p.parseBlock()) |node| return node; if (try p.parseCurlySuffixExpr()) |node| return node; return null; } /// IfExpr <- IfPrefix Expr (KEYWORD_else Payload? Expr)? fn parseIfExpr(p: *Parser) !?*Node { return p.parseIf(parseExpr); } /// Block <- LBRACE Statement* RBRACE fn parseBlock(p: *Parser) !?*Node { const lbrace = p.eatToken(.LBrace) orelse return null; var statements = std.ArrayList(*Node).init(p.gpa); defer statements.deinit(); while (true) { const statement = (p.parseStatement() catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.ParseError => { // try to skip to the next statement p.findNextStmt(); continue; }, }) orelse break; try statements.append(statement); } const rbrace = try p.expectToken(.RBrace); const statements_len = @intCast(NodeIndex, statements.items.len); const block_node = try Node.Block.alloc(&p.arena.allocator, statements_len); block_node.* = .{ .label = null, .lbrace = lbrace, .statements_len = statements_len, .rbrace = rbrace, }; std.mem.copy(*Node, block_node.statements(), statements.items); return &block_node.base; } /// LoopExpr <- KEYWORD_inline? (ForExpr / WhileExpr) fn parseLoopExpr(p: *Parser) !?*Node { const inline_token = p.eatToken(.Keyword_inline); if (try p.parseForExpr()) |node| { node.cast(Node.For).?.inline_token = inline_token; return node; } if (try p.parseWhileExpr()) |node| { node.cast(Node.While).?.inline_token = inline_token; return node; } if (inline_token == null) return null; // If we've seen "inline", there should have been a "for" or "while" try p.errors.append(p.gpa, .{ .ExpectedInlinable = .{ .token = p.tok_i }, }); return error.ParseError; } /// ForExpr <- ForPrefix Expr (KEYWORD_else Expr)? fn parseForExpr(p: *Parser) !?*Node { const node = (try p.parseForPrefix()) orelse return null; const for_prefix = node.cast(Node.For).?; const body_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); for_prefix.body = body_node; if (p.eatToken(.Keyword_else)) |else_token| { const body = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = null, .body = body, }; for_prefix.@"else" = else_node; } return node; } /// WhileExpr <- WhilePrefix Expr (KEYWORD_else Payload? Expr)? fn parseWhileExpr(p: *Parser) !?*Node { const node = (try p.parseWhilePrefix()) orelse return null; const while_prefix = node.cast(Node.While).?; const body_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); while_prefix.body = body_node; if (p.eatToken(.Keyword_else)) |else_token| { const payload = try p.parsePayload(); const body = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = payload, .body = body, }; while_prefix.@"else" = else_node; } return node; } /// CurlySuffixExpr <- TypeExpr InitList? fn parseCurlySuffixExpr(p: *Parser) !?*Node { const lhs = (try p.parseTypeExpr()) orelse return null; const suffix_op = (try p.parseInitList(lhs)) orelse return lhs; return suffix_op; } /// InitList /// <- LBRACE FieldInit (COMMA FieldInit)* COMMA? RBRACE /// / LBRACE Expr (COMMA Expr)* COMMA? RBRACE /// / LBRACE RBRACE fn parseInitList(p: *Parser, lhs: *Node) !?*Node { const lbrace = p.eatToken(.LBrace) orelse return null; var init_list = std.ArrayList(*Node).init(p.gpa); defer init_list.deinit(); if (try p.parseFieldInit()) |field_init| { try init_list.append(field_init); while (p.eatToken(.Comma)) |_| { const next = (try p.parseFieldInit()) orelse break; try init_list.append(next); } const node = try Node.StructInitializer.alloc(&p.arena.allocator, init_list.items.len); node.* = .{ .lhs = lhs, .rtoken = try p.expectToken(.RBrace), .list_len = init_list.items.len, }; std.mem.copy(*Node, node.list(), init_list.items); return &node.base; } if (try p.parseExpr()) |expr| { try init_list.append(expr); while (p.eatToken(.Comma)) |_| { const next = (try p.parseExpr()) orelse break; try init_list.append(next); } const node = try Node.ArrayInitializer.alloc(&p.arena.allocator, init_list.items.len); node.* = .{ .lhs = lhs, .rtoken = try p.expectToken(.RBrace), .list_len = init_list.items.len, }; std.mem.copy(*Node, node.list(), init_list.items); return &node.base; } const node = try p.arena.allocator.create(Node.StructInitializer); node.* = .{ .lhs = lhs, .rtoken = try p.expectToken(.RBrace), .list_len = 0, }; return &node.base; } /// InitList /// <- LBRACE FieldInit (COMMA FieldInit)* COMMA? RBRACE /// / LBRACE Expr (COMMA Expr)* COMMA? RBRACE /// / LBRACE RBRACE fn parseAnonInitList(p: *Parser, dot: TokenIndex) !?*Node { const lbrace = p.eatToken(.LBrace) orelse return null; var init_list = std.ArrayList(*Node).init(p.gpa); defer init_list.deinit(); if (try p.parseFieldInit()) |field_init| { try init_list.append(field_init); while (p.eatToken(.Comma)) |_| { const next = (try p.parseFieldInit()) orelse break; try init_list.append(next); } const node = try Node.StructInitializerDot.alloc(&p.arena.allocator, init_list.items.len); node.* = .{ .dot = dot, .rtoken = try p.expectToken(.RBrace), .list_len = init_list.items.len, }; std.mem.copy(*Node, node.list(), init_list.items); return &node.base; } if (try p.parseExpr()) |expr| { try init_list.append(expr); while (p.eatToken(.Comma)) |_| { const next = (try p.parseExpr()) orelse break; try init_list.append(next); } const node = try Node.ArrayInitializerDot.alloc(&p.arena.allocator, init_list.items.len); node.* = .{ .dot = dot, .rtoken = try p.expectToken(.RBrace), .list_len = init_list.items.len, }; std.mem.copy(*Node, node.list(), init_list.items); return &node.base; } const node = try p.arena.allocator.create(Node.StructInitializerDot); node.* = .{ .dot = dot, .rtoken = try p.expectToken(.RBrace), .list_len = 0, }; return &node.base; } /// TypeExpr <- PrefixTypeOp* ErrorUnionExpr fn parseTypeExpr(p: *Parser) Error!?*Node { return p.parsePrefixOpExpr(parsePrefixTypeOp, parseErrorUnionExpr); } /// ErrorUnionExpr <- SuffixExpr (EXCLAMATIONMARK TypeExpr)? fn parseErrorUnionExpr(p: *Parser) !?*Node { const suffix_expr = (try p.parseSuffixExpr()) orelse return null; if (try SimpleBinOpParseFn(.Bang, Node.InfixOp.Op.ErrorUnion)(p)) |node| { const error_union = node.cast(Node.InfixOp).?; const type_expr = try p.expectNode(parseTypeExpr, .{ .ExpectedTypeExpr = .{ .token = p.tok_i }, }); error_union.lhs = suffix_expr; error_union.rhs = type_expr; return node; } return suffix_expr; } /// SuffixExpr /// <- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments /// / PrimaryTypeExpr (SuffixOp / FnCallArguments)* fn parseSuffixExpr(p: *Parser) !?*Node { const maybe_async = p.eatToken(.Keyword_async); if (maybe_async) |async_token| { const token_fn = p.eatToken(.Keyword_fn); if (token_fn != null) { // TODO: remove this hack when async fn rewriting is // HACK: If we see the keyword `fn`, then we assume that // we are parsing an async fn proto, and not a call. // We therefore put back all tokens consumed by the async // prefix... p.putBackToken(token_fn.?); p.putBackToken(async_token); return p.parsePrimaryTypeExpr(); } var res = try p.expectNode(parsePrimaryTypeExpr, .{ .ExpectedPrimaryTypeExpr = .{ .token = p.tok_i }, }); while (try p.parseSuffixOp()) |node| { switch (node.id) { .SuffixOp => node.cast(Node.SuffixOp).?.lhs = res, .InfixOp => node.cast(Node.InfixOp).?.lhs = res, else => unreachable, } res = node; } const params = (try p.parseFnCallArguments()) orelse { try p.errors.append(p.gpa, .{ .ExpectedParamList = .{ .token = p.tok_i }, }); // ignore this, continue parsing return res; }; defer p.gpa.free(params.list); const node = try Node.Call.alloc(&p.arena.allocator, params.list.len); node.* = .{ .lhs = res, .params_len = params.list.len, .async_token = async_token, .rtoken = params.rparen, }; std.mem.copy(*Node, node.params(), params.list); return &node.base; } if (try p.parsePrimaryTypeExpr()) |expr| { var res = expr; while (true) { if (try p.parseSuffixOp()) |node| { switch (node.id) { .SuffixOp => node.cast(Node.SuffixOp).?.lhs = res, .InfixOp => node.cast(Node.InfixOp).?.lhs = res, else => unreachable, } res = node; continue; } if (try p.parseFnCallArguments()) |params| { defer p.gpa.free(params.list); const call = try Node.Call.alloc(&p.arena.allocator, params.list.len); call.* = .{ .lhs = res, .params_len = params.list.len, .async_token = null, .rtoken = params.rparen, }; std.mem.copy(*Node, call.params(), params.list); res = &call.base; continue; } break; } return res; } return null; } /// PrimaryTypeExpr /// <- BUILTINIDENTIFIER FnCallArguments /// / CHAR_LITERAL /// / ContainerDecl /// / DOT IDENTIFIER /// / ErrorSetDecl /// / FLOAT /// / FnProto /// / GroupedExpr /// / LabeledTypeExpr /// / IDENTIFIER /// / IfTypeExpr /// / INTEGER /// / KEYWORD_comptime TypeExpr /// / KEYWORD_error DOT IDENTIFIER /// / KEYWORD_false /// / KEYWORD_null /// / KEYWORD_anyframe /// / KEYWORD_true /// / KEYWORD_undefined /// / KEYWORD_unreachable /// / STRINGLITERAL /// / SwitchExpr fn parsePrimaryTypeExpr(p: *Parser) !?*Node { if (try p.parseBuiltinCall()) |node| return node; if (p.eatToken(.CharLiteral)) |token| { const node = try p.arena.allocator.create(Node.CharLiteral); node.* = .{ .token = token, }; return &node.base; } if (try p.parseContainerDecl()) |node| return node; if (try p.parseAnonLiteral()) |node| return node; if (try p.parseErrorSetDecl()) |node| return node; if (try p.parseFloatLiteral()) |node| return node; if (try p.parseFnProto()) |node| return node; if (try p.parseGroupedExpr()) |node| return node; if (try p.parseLabeledTypeExpr()) |node| return node; if (try p.parseIdentifier()) |node| return node; if (try p.parseIfTypeExpr()) |node| return node; if (try p.parseIntegerLiteral()) |node| return node; if (p.eatToken(.Keyword_comptime)) |token| { const expr = (try p.parseTypeExpr()) orelse return null; const node = try p.arena.allocator.create(Node.Comptime); node.* = .{ .doc_comments = null, .comptime_token = token, .expr = expr, }; return &node.base; } if (p.eatToken(.Keyword_error)) |token| { const period = try p.expectTokenRecoverable(.Period); const identifier = try p.expectNodeRecoverable(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); const global_error_set = try p.createLiteral(Node.ErrorType, token); if (period == null or identifier == null) return global_error_set; const node = try p.arena.allocator.create(Node.InfixOp); node.* = .{ .op_token = period.?, .lhs = global_error_set, .op = .Period, .rhs = identifier.?, }; return &node.base; } if (p.eatToken(.Keyword_false)) |token| return p.createLiteral(Node.BoolLiteral, token); if (p.eatToken(.Keyword_null)) |token| return p.createLiteral(Node.NullLiteral, token); if (p.eatToken(.Keyword_anyframe)) |token| { const node = try p.arena.allocator.create(Node.AnyFrameType); node.* = .{ .anyframe_token = token, .result = null, }; return &node.base; } if (p.eatToken(.Keyword_true)) |token| return p.createLiteral(Node.BoolLiteral, token); if (p.eatToken(.Keyword_undefined)) |token| return p.createLiteral(Node.UndefinedLiteral, token); if (p.eatToken(.Keyword_unreachable)) |token| return p.createLiteral(Node.Unreachable, token); if (try p.parseStringLiteral()) |node| return node; if (try p.parseSwitchExpr()) |node| return node; return null; } /// ContainerDecl <- (KEYWORD_extern / KEYWORD_packed)? ContainerDeclAuto fn parseContainerDecl(p: *Parser) !?*Node { const layout_token = p.eatToken(.Keyword_extern) orelse p.eatToken(.Keyword_packed); const node = (try p.parseContainerDeclAuto()) orelse { if (layout_token) |token| p.putBackToken(token); return null; }; node.cast(Node.ContainerDecl).?.*.layout_token = layout_token; return node; } /// ErrorSetDecl <- KEYWORD_error LBRACE IdentifierList RBRACE fn parseErrorSetDecl(p: *Parser) !?*Node { const error_token = p.eatToken(.Keyword_error) orelse return null; if (p.eatToken(.LBrace) == null) { // Might parse as `KEYWORD_error DOT IDENTIFIER` later in PrimaryTypeExpr, so don't error p.putBackToken(error_token); return null; } const decls = try p.parseErrorTagList(); defer p.gpa.free(decls); const rbrace = try p.expectToken(.RBrace); const node = try Node.ErrorSetDecl.alloc(&p.arena.allocator, decls.len); node.* = .{ .error_token = error_token, .decls_len = decls.len, .rbrace_token = rbrace, }; std.mem.copy(*Node, node.decls(), decls); return &node.base; } /// GroupedExpr <- LPAREN Expr RPAREN fn parseGroupedExpr(p: *Parser) !?*Node { const lparen = p.eatToken(.LParen) orelse return null; const expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const rparen = try p.expectToken(.RParen); const node = try p.arena.allocator.create(Node.GroupedExpression); node.* = .{ .lparen = lparen, .expr = expr, .rparen = rparen, }; return &node.base; } /// IfTypeExpr <- IfPrefix TypeExpr (KEYWORD_else Payload? TypeExpr)? fn parseIfTypeExpr(p: *Parser) !?*Node { return p.parseIf(parseTypeExpr); } /// LabeledTypeExpr /// <- BlockLabel Block /// / BlockLabel? LoopTypeExpr fn parseLabeledTypeExpr(p: *Parser) !?*Node { var colon: TokenIndex = undefined; const label = p.parseBlockLabel(&colon); if (label) |token| { if (try p.parseBlock()) |node| { node.cast(Node.Block).?.label = token; return node; } } if (try p.parseLoopTypeExpr()) |node| { switch (node.id) { .For => node.cast(Node.For).?.label = label, .While => node.cast(Node.While).?.label = label, else => unreachable, } return node; } if (label) |token| { p.putBackToken(colon); p.putBackToken(token); } return null; } /// LoopTypeExpr <- KEYWORD_inline? (ForTypeExpr / WhileTypeExpr) fn parseLoopTypeExpr(p: *Parser) !?*Node { const inline_token = p.eatToken(.Keyword_inline); if (try p.parseForTypeExpr()) |node| { node.cast(Node.For).?.inline_token = inline_token; return node; } if (try p.parseWhileTypeExpr()) |node| { node.cast(Node.While).?.inline_token = inline_token; return node; } if (inline_token == null) return null; // If we've seen "inline", there should have been a "for" or "while" try p.errors.append(p.gpa, .{ .ExpectedInlinable = .{ .token = p.tok_i }, }); return error.ParseError; } /// ForTypeExpr <- ForPrefix TypeExpr (KEYWORD_else TypeExpr)? fn parseForTypeExpr(p: *Parser) !?*Node { const node = (try p.parseForPrefix()) orelse return null; const for_prefix = node.cast(Node.For).?; const type_expr = try p.expectNode(parseTypeExpr, .{ .ExpectedTypeExpr = .{ .token = p.tok_i }, }); for_prefix.body = type_expr; if (p.eatToken(.Keyword_else)) |else_token| { const else_expr = try p.expectNode(parseTypeExpr, .{ .ExpectedTypeExpr = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = null, .body = else_expr, }; for_prefix.@"else" = else_node; } return node; } /// WhileTypeExpr <- WhilePrefix TypeExpr (KEYWORD_else Payload? TypeExpr)? fn parseWhileTypeExpr(p: *Parser) !?*Node { const node = (try p.parseWhilePrefix()) orelse return null; const while_prefix = node.cast(Node.While).?; const type_expr = try p.expectNode(parseTypeExpr, .{ .ExpectedTypeExpr = .{ .token = p.tok_i }, }); while_prefix.body = type_expr; if (p.eatToken(.Keyword_else)) |else_token| { const payload = try p.parsePayload(); const else_expr = try p.expectNode(parseTypeExpr, .{ .ExpectedTypeExpr = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = null, .body = else_expr, }; while_prefix.@"else" = else_node; } return node; } /// SwitchExpr <- KEYWORD_switch LPAREN Expr RPAREN LBRACE SwitchProngList RBRACE fn parseSwitchExpr(p: *Parser) !?*Node { const switch_token = p.eatToken(.Keyword_switch) orelse return null; _ = try p.expectToken(.LParen); const expr_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); _ = try p.expectToken(.LBrace); const cases = try p.parseSwitchProngList(); defer p.gpa.free(cases); const rbrace = try p.expectToken(.RBrace); const node = try Node.Switch.alloc(&p.arena.allocator, cases.len); node.* = .{ .switch_token = switch_token, .expr = expr_node, .cases_len = cases.len, .rbrace = rbrace, }; std.mem.copy(*Node, node.cases(), cases); return &node.base; } /// AsmExpr <- KEYWORD_asm KEYWORD_volatile? LPAREN Expr AsmOutput? RPAREN /// AsmOutput <- COLON AsmOutputList AsmInput? /// AsmInput <- COLON AsmInputList AsmClobbers? /// AsmClobbers <- COLON StringList /// StringList <- (STRINGLITERAL COMMA)* STRINGLITERAL? fn parseAsmExpr(p: *Parser) !?*Node { const asm_token = p.eatToken(.Keyword_asm) orelse return null; const volatile_token = p.eatToken(.Keyword_volatile); _ = try p.expectToken(.LParen); const template = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); var arena_outputs: []Node.Asm.Output = &[0]Node.Asm.Output{}; var arena_inputs: []Node.Asm.Input = &[0]Node.Asm.Input{}; var arena_clobbers: []*Node = &[0]*Node{}; if (p.eatToken(.Colon) != null) { const outputs = try p.parseAsmOutputList(); defer p.gpa.free(outputs); arena_outputs = try p.arena.allocator.dupe(Node.Asm.Output, outputs); if (p.eatToken(.Colon) != null) { const inputs = try p.parseAsmInputList(); defer p.gpa.free(inputs); arena_inputs = try p.arena.allocator.dupe(Node.Asm.Input, inputs); if (p.eatToken(.Colon) != null) { const clobbers = try ListParseFn(*Node, parseStringLiteral)(p); defer p.gpa.free(clobbers); arena_clobbers = try p.arena.allocator.dupe(*Node, clobbers); } } } const node = try p.arena.allocator.create(Node.Asm); node.* = .{ .asm_token = asm_token, .volatile_token = volatile_token, .template = template, .outputs = arena_outputs, .inputs = arena_inputs, .clobbers = arena_clobbers, .rparen = try p.expectToken(.RParen), }; return &node.base; } /// DOT IDENTIFIER fn parseAnonLiteral(p: *Parser) !?*Node { const dot = p.eatToken(.Period) orelse return null; // anon enum literal if (p.eatToken(.Identifier)) |name| { const node = try p.arena.allocator.create(Node.EnumLiteral); node.* = .{ .dot = dot, .name = name, }; return &node.base; } if (try p.parseAnonInitList(dot)) |node| { return node; } p.putBackToken(dot); return null; } /// AsmOutputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN (MINUSRARROW TypeExpr / IDENTIFIER) RPAREN fn parseAsmOutputItem(p: *Parser) !?Node.Asm.Output { const lbracket = p.eatToken(.LBracket) orelse return null; const name = try p.expectNode(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RBracket); const constraint = try p.expectNode(parseStringLiteral, .{ .ExpectedStringLiteral = .{ .token = p.tok_i }, }); _ = try p.expectToken(.LParen); const kind: Node.Asm.Output.Kind = blk: { if (p.eatToken(.Arrow) != null) { const return_ident = try p.expectNode(parseTypeExpr, .{ .ExpectedTypeExpr = .{ .token = p.tok_i }, }); break :blk .{ .Return = return_ident }; } const variable = try p.expectNode(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); break :blk .{ .Variable = variable.cast(Node.Identifier).? }; }; const rparen = try p.expectToken(.RParen); return Node.Asm.Output{ .lbracket = lbracket, .symbolic_name = name, .constraint = constraint, .kind = kind, .rparen = rparen, }; } /// AsmInputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN Expr RPAREN fn parseAsmInputItem(p: *Parser) !?Node.Asm.Input { const lbracket = p.eatToken(.LBracket) orelse return null; const name = try p.expectNode(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RBracket); const constraint = try p.expectNode(parseStringLiteral, .{ .ExpectedStringLiteral = .{ .token = p.tok_i }, }); _ = try p.expectToken(.LParen); const expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const rparen = try p.expectToken(.RParen); return Node.Asm.Input{ .lbracket = lbracket, .symbolic_name = name, .constraint = constraint, .expr = expr, .rparen = rparen, }; } /// BreakLabel <- COLON IDENTIFIER fn parseBreakLabel(p: *Parser) !?*Node { _ = p.eatToken(.Colon) orelse return null; return try p.expectNode(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); } /// BlockLabel <- IDENTIFIER COLON fn parseBlockLabel(p: *Parser, colon_token: *TokenIndex) ?TokenIndex { const identifier = p.eatToken(.Identifier) orelse return null; if (p.eatToken(.Colon)) |colon| { colon_token.* = colon; return identifier; } p.putBackToken(identifier); return null; } /// FieldInit <- DOT IDENTIFIER EQUAL Expr fn parseFieldInit(p: *Parser) !?*Node { const period_token = p.eatToken(.Period) orelse return null; const name_token = p.eatToken(.Identifier) orelse { // Because of anon literals `.{` is also valid. p.putBackToken(period_token); return null; }; const eq_token = p.eatToken(.Equal) orelse { // `.Name` may also be an enum literal, which is a later rule. p.putBackToken(name_token); p.putBackToken(period_token); return null; }; const expr_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.FieldInitializer); node.* = .{ .period_token = period_token, .name_token = name_token, .expr = expr_node, }; return &node.base; } /// WhileContinueExpr <- COLON LPAREN AssignExpr RPAREN fn parseWhileContinueExpr(p: *Parser) !?*Node { _ = p.eatToken(.Colon) orelse return null; _ = try p.expectToken(.LParen); const node = try p.expectNode(parseAssignExpr, .{ .ExpectedExprOrAssignment = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); return node; } /// LinkSection <- KEYWORD_linksection LPAREN Expr RPAREN fn parseLinkSection(p: *Parser) !?*Node { _ = p.eatToken(.Keyword_linksection) orelse return null; _ = try p.expectToken(.LParen); const expr_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); return expr_node; } /// CallConv <- KEYWORD_callconv LPAREN Expr RPAREN fn parseCallconv(p: *Parser) !?*Node { _ = p.eatToken(.Keyword_callconv) orelse return null; _ = try p.expectToken(.LParen); const expr_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); return expr_node; } /// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType fn parseParamDecl(p: *Parser) !?Node.FnProto.ParamDecl { const doc_comments = try p.parseDocComment(); const noalias_token = p.eatToken(.Keyword_noalias); const comptime_token = if (noalias_token == null) p.eatToken(.Keyword_comptime) else null; const name_token = blk: { const identifier = p.eatToken(.Identifier) orelse break :blk null; if (p.eatToken(.Colon) != null) break :blk identifier; p.putBackToken(identifier); // ParamType may also be an identifier break :blk null; }; const param_type = (try p.parseParamType()) orelse { // Only return cleanly if no keyword, identifier, or doc comment was found if (noalias_token == null and comptime_token == null and name_token == null and doc_comments == null) { return null; } try p.errors.append(p.gpa, .{ .ExpectedParamType = .{ .token = p.tok_i }, }); return error.ParseError; }; return Node.FnProto.ParamDecl{ .doc_comments = doc_comments, .comptime_token = comptime_token, .noalias_token = noalias_token, .name_token = name_token, .param_type = param_type, }; } /// ParamType /// <- KEYWORD_var /// / DOT3 /// / TypeExpr fn parseParamType(p: *Parser) !?Node.FnProto.ParamDecl.ParamType { // TODO cast from tuple to error union is broken const P = Node.FnProto.ParamDecl.ParamType; if (try p.parseVarType()) |node| return P{ .var_type = node }; if (p.eatToken(.Ellipsis3)) |token| return P{ .var_args = token }; if (try p.parseTypeExpr()) |node| return P{ .type_expr = node }; return null; } /// IfPrefix <- KEYWORD_if LPAREN Expr RPAREN PtrPayload? fn parseIfPrefix(p: *Parser) !?*Node { const if_token = p.eatToken(.Keyword_if) orelse return null; _ = try p.expectToken(.LParen); const condition = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); const payload = try p.parsePtrPayload(); const node = try p.arena.allocator.create(Node.If); node.* = .{ .if_token = if_token, .condition = condition, .payload = payload, .body = undefined, // set by caller .@"else" = null, }; return &node.base; } /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? fn parseWhilePrefix(p: *Parser) !?*Node { const while_token = p.eatToken(.Keyword_while) orelse return null; _ = try p.expectToken(.LParen); const condition = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); const payload = try p.parsePtrPayload(); const continue_expr = try p.parseWhileContinueExpr(); const node = try p.arena.allocator.create(Node.While); node.* = .{ .label = null, .inline_token = null, .while_token = while_token, .condition = condition, .payload = payload, .continue_expr = continue_expr, .body = undefined, // set by caller .@"else" = null, }; return &node.base; } /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload fn parseForPrefix(p: *Parser) !?*Node { const for_token = p.eatToken(.Keyword_for) orelse return null; _ = try p.expectToken(.LParen); const array_expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); const payload = try p.expectNode(parsePtrIndexPayload, .{ .ExpectedPayload = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.For); node.* = .{ .label = null, .inline_token = null, .for_token = for_token, .array_expr = array_expr, .payload = payload, .body = undefined, // set by caller .@"else" = null, }; return &node.base; } /// Payload <- PIPE IDENTIFIER PIPE fn parsePayload(p: *Parser) !?*Node { const lpipe = p.eatToken(.Pipe) orelse return null; const identifier = try p.expectNode(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); const rpipe = try p.expectToken(.Pipe); const node = try p.arena.allocator.create(Node.Payload); node.* = .{ .lpipe = lpipe, .error_symbol = identifier, .rpipe = rpipe, }; return &node.base; } /// PtrPayload <- PIPE ASTERISK? IDENTIFIER PIPE fn parsePtrPayload(p: *Parser) !?*Node { const lpipe = p.eatToken(.Pipe) orelse return null; const asterisk = p.eatToken(.Asterisk); const identifier = try p.expectNode(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); const rpipe = try p.expectToken(.Pipe); const node = try p.arena.allocator.create(Node.PointerPayload); node.* = .{ .lpipe = lpipe, .ptr_token = asterisk, .value_symbol = identifier, .rpipe = rpipe, }; return &node.base; } /// PtrIndexPayload <- PIPE ASTERISK? IDENTIFIER (COMMA IDENTIFIER)? PIPE fn parsePtrIndexPayload(p: *Parser) !?*Node { const lpipe = p.eatToken(.Pipe) orelse return null; const asterisk = p.eatToken(.Asterisk); const identifier = try p.expectNode(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); const index = if (p.eatToken(.Comma) == null) null else try p.expectNode(parseIdentifier, .{ .ExpectedIdentifier = .{ .token = p.tok_i }, }); const rpipe = try p.expectToken(.Pipe); const node = try p.arena.allocator.create(Node.PointerIndexPayload); node.* = .{ .lpipe = lpipe, .ptr_token = asterisk, .value_symbol = identifier, .index_symbol = index, .rpipe = rpipe, }; return &node.base; } /// SwitchProng <- SwitchCase EQUALRARROW PtrPayload? AssignExpr fn parseSwitchProng(p: *Parser) !?*Node { const node = (try p.parseSwitchCase()) orelse return null; const arrow = try p.expectToken(.EqualAngleBracketRight); const payload = try p.parsePtrPayload(); const expr = try p.expectNode(parseAssignExpr, .{ .ExpectedExprOrAssignment = .{ .token = p.tok_i }, }); const switch_case = node.cast(Node.SwitchCase).?; switch_case.arrow_token = arrow; switch_case.payload = payload; switch_case.expr = expr; return node; } /// SwitchCase /// <- SwitchItem (COMMA SwitchItem)* COMMA? /// / KEYWORD_else fn parseSwitchCase(p: *Parser) !?*Node { var list = std.ArrayList(*Node).init(p.gpa); defer list.deinit(); if (try p.parseSwitchItem()) |first_item| { try list.append(first_item); while (p.eatToken(.Comma) != null) { const next_item = (try p.parseSwitchItem()) orelse break; try list.append(next_item); } } else if (p.eatToken(.Keyword_else)) |else_token| { const else_node = try p.arena.allocator.create(Node.SwitchElse); else_node.* = .{ .token = else_token, }; try list.append(&else_node.base); } else return null; const node = try Node.SwitchCase.alloc(&p.arena.allocator, list.items.len); node.* = .{ .items_len = list.items.len, .arrow_token = undefined, // set by caller .payload = null, .expr = undefined, // set by caller }; std.mem.copy(*Node, node.items(), list.items); return &node.base; } /// SwitchItem <- Expr (DOT3 Expr)? fn parseSwitchItem(p: *Parser) !?*Node { const expr = (try p.parseExpr()) orelse return null; if (p.eatToken(.Ellipsis3)) |token| { const range_end = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); const node = try p.arena.allocator.create(Node.InfixOp); node.* = .{ .op_token = token, .lhs = expr, .op = .Range, .rhs = range_end, }; return &node.base; } return expr; } /// AssignOp /// <- ASTERISKEQUAL /// / SLASHEQUAL /// / PERCENTEQUAL /// / PLUSEQUAL /// / MINUSEQUAL /// / LARROW2EQUAL /// / RARROW2EQUAL /// / AMPERSANDEQUAL /// / CARETEQUAL /// / PIPEEQUAL /// / ASTERISKPERCENTEQUAL /// / PLUSPERCENTEQUAL /// / MINUSPERCENTEQUAL /// / EQUAL fn parseAssignOp(p: *Parser) !?*Node { const token = p.nextToken(); const op: Node.InfixOp.Op = switch (p.token_ids[token]) { .AsteriskEqual => .AssignMul, .SlashEqual => .AssignDiv, .PercentEqual => .AssignMod, .PlusEqual => .AssignAdd, .MinusEqual => .AssignSub, .AngleBracketAngleBracketLeftEqual => .AssignBitShiftLeft, .AngleBracketAngleBracketRightEqual => .AssignBitShiftRight, .AmpersandEqual => .AssignBitAnd, .CaretEqual => .AssignBitXor, .PipeEqual => .AssignBitOr, .AsteriskPercentEqual => .AssignMulWrap, .PlusPercentEqual => .AssignAddWrap, .MinusPercentEqual => .AssignSubWrap, .Equal => .Assign, else => { p.putBackToken(token); return null; }, }; const node = try p.arena.allocator.create(Node.InfixOp); node.* = .{ .op_token = token, .lhs = undefined, // set by caller .op = op, .rhs = undefined, // set by caller }; return &node.base; } /// CompareOp /// <- EQUALEQUAL /// / EXCLAMATIONMARKEQUAL /// / LARROW /// / RARROW /// / LARROWEQUAL /// / RARROWEQUAL fn parseCompareOp(p: *Parser) !?*Node { const token = p.nextToken(); const op: Node.InfixOp.Op = switch (p.token_ids[token]) { .EqualEqual => .EqualEqual, .BangEqual => .BangEqual, .AngleBracketLeft => .LessThan, .AngleBracketRight => .GreaterThan, .AngleBracketLeftEqual => .LessOrEqual, .AngleBracketRightEqual => .GreaterOrEqual, else => { p.putBackToken(token); return null; }, }; return p.createInfixOp(token, op); } /// BitwiseOp /// <- AMPERSAND /// / CARET /// / PIPE /// / KEYWORD_orelse /// / KEYWORD_catch Payload? fn parseBitwiseOp(p: *Parser) !?*Node { const token = p.nextToken(); const op: Node.InfixOp.Op = switch (p.token_ids[token]) { .Ampersand => .BitAnd, .Caret => .BitXor, .Pipe => .BitOr, .Keyword_orelse => .UnwrapOptional, .Keyword_catch => .{ .Catch = try p.parsePayload() }, else => { p.putBackToken(token); return null; }, }; return p.createInfixOp(token, op); } /// BitShiftOp /// <- LARROW2 /// / RARROW2 fn parseBitShiftOp(p: *Parser) !?*Node { const token = p.nextToken(); const op: Node.InfixOp.Op = switch (p.token_ids[token]) { .AngleBracketAngleBracketLeft => .BitShiftLeft, .AngleBracketAngleBracketRight => .BitShiftRight, else => { p.putBackToken(token); return null; }, }; return p.createInfixOp(token, op); } /// AdditionOp /// <- PLUS /// / MINUS /// / PLUS2 /// / PLUSPERCENT /// / MINUSPERCENT fn parseAdditionOp(p: *Parser) !?*Node { const token = p.nextToken(); const op: Node.InfixOp.Op = switch (p.token_ids[token]) { .Plus => .Add, .Minus => .Sub, .PlusPlus => .ArrayCat, .PlusPercent => .AddWrap, .MinusPercent => .SubWrap, else => { p.putBackToken(token); return null; }, }; return p.createInfixOp(token, op); } /// MultiplyOp /// <- PIPE2 /// / ASTERISK /// / SLASH /// / PERCENT /// / ASTERISK2 /// / ASTERISKPERCENT fn parseMultiplyOp(p: *Parser) !?*Node { const token = p.nextToken(); const op: Node.InfixOp.Op = switch (p.token_ids[token]) { .PipePipe => .MergeErrorSets, .Asterisk => .Mul, .Slash => .Div, .Percent => .Mod, .AsteriskAsterisk => .ArrayMult, .AsteriskPercent => .MulWrap, else => { p.putBackToken(token); return null; }, }; return p.createInfixOp(token, op); } /// PrefixOp /// <- EXCLAMATIONMARK /// / MINUS /// / TILDE /// / MINUSPERCENT /// / AMPERSAND /// / KEYWORD_try /// / KEYWORD_await fn parsePrefixOp(p: *Parser) !?*Node { const token = p.nextToken(); const op: Node.PrefixOp.Op = switch (p.token_ids[token]) { .Bang => .BoolNot, .Minus => .Negation, .Tilde => .BitNot, .MinusPercent => .NegationWrap, .Ampersand => .AddressOf, .Keyword_try => .Try, .Keyword_await => .Await, else => { p.putBackToken(token); return null; }, }; const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = token, .op = op, .rhs = undefined, // set by caller }; return &node.base; } // TODO: ArrayTypeStart is either an array or a slice, but const/allowzero only work on // pointers. Consider updating this rule: // ... // / ArrayTypeStart // / SliceTypeStart (ByteAlign / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)* // / PtrTypeStart ... /// PrefixTypeOp /// <- QUESTIONMARK /// / KEYWORD_anyframe MINUSRARROW /// / ArrayTypeStart (ByteAlign / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)* /// / PtrTypeStart (KEYWORD_align LPAREN Expr (COLON INTEGER COLON INTEGER)? RPAREN / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)* fn parsePrefixTypeOp(p: *Parser) !?*Node { if (p.eatToken(.QuestionMark)) |token| { const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = token, .op = .OptionalType, .rhs = undefined, // set by caller }; return &node.base; } // TODO: Returning a AnyFrameType instead of PrefixOp makes casting and setting .rhs or // .return_type more difficult for the caller (see parsePrefixOpExpr helper). // Consider making the AnyFrameType a member of PrefixOp and add a // PrefixOp.AnyFrameType variant? if (p.eatToken(.Keyword_anyframe)) |token| { const arrow = p.eatToken(.Arrow) orelse { p.putBackToken(token); return null; }; const node = try p.arena.allocator.create(Node.AnyFrameType); node.* = .{ .anyframe_token = token, .result = .{ .arrow_token = arrow, .return_type = undefined, // set by caller }, }; return &node.base; } if (try p.parsePtrTypeStart()) |node| { // If the token encountered was **, there will be two nodes instead of one. // The attributes should be applied to the rightmost operator. const prefix_op = node.cast(Node.PrefixOp).?; var ptr_info = if (p.token_ids[prefix_op.op_token] == .AsteriskAsterisk) &prefix_op.rhs.cast(Node.PrefixOp).?.op.PtrType else &prefix_op.op.PtrType; while (true) { if (p.eatToken(.Keyword_align)) |align_token| { const lparen = try p.expectToken(.LParen); const expr_node = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); // Optional bit range const bit_range = if (p.eatToken(.Colon)) |_| bit_range_value: { const range_start = try p.expectNode(parseIntegerLiteral, .{ .ExpectedIntegerLiteral = .{ .token = p.tok_i }, }); _ = try p.expectToken(.Colon); const range_end = try p.expectNode(parseIntegerLiteral, .{ .ExpectedIntegerLiteral = .{ .token = p.tok_i }, }); break :bit_range_value Node.PrefixOp.PtrInfo.Align.BitRange{ .start = range_start, .end = range_end, }; } else null; _ = try p.expectToken(.RParen); if (ptr_info.align_info != null) { try p.errors.append(p.gpa, .{ .ExtraAlignQualifier = .{ .token = p.tok_i - 1 }, }); continue; } ptr_info.align_info = Node.PrefixOp.PtrInfo.Align{ .node = expr_node, .bit_range = bit_range, }; continue; } if (p.eatToken(.Keyword_const)) |const_token| { if (ptr_info.const_token != null) { try p.errors.append(p.gpa, .{ .ExtraConstQualifier = .{ .token = p.tok_i - 1 }, }); continue; } ptr_info.const_token = const_token; continue; } if (p.eatToken(.Keyword_volatile)) |volatile_token| { if (ptr_info.volatile_token != null) { try p.errors.append(p.gpa, .{ .ExtraVolatileQualifier = .{ .token = p.tok_i - 1 }, }); continue; } ptr_info.volatile_token = volatile_token; continue; } if (p.eatToken(.Keyword_allowzero)) |allowzero_token| { if (ptr_info.allowzero_token != null) { try p.errors.append(p.gpa, .{ .ExtraAllowZeroQualifier = .{ .token = p.tok_i - 1 }, }); continue; } ptr_info.allowzero_token = allowzero_token; continue; } break; } return node; } if (try p.parseArrayTypeStart()) |node| { switch (node.cast(Node.PrefixOp).?.op) { .ArrayType => {}, .SliceType => |*slice_type| { // Collect pointer qualifiers in any order, but disallow duplicates while (true) { if (try p.parseByteAlign()) |align_expr| { if (slice_type.align_info != null) { try p.errors.append(p.gpa, .{ .ExtraAlignQualifier = .{ .token = p.tok_i - 1 }, }); continue; } slice_type.align_info = Node.PrefixOp.PtrInfo.Align{ .node = align_expr, .bit_range = null, }; continue; } if (p.eatToken(.Keyword_const)) |const_token| { if (slice_type.const_token != null) { try p.errors.append(p.gpa, .{ .ExtraConstQualifier = .{ .token = p.tok_i - 1 }, }); continue; } slice_type.const_token = const_token; continue; } if (p.eatToken(.Keyword_volatile)) |volatile_token| { if (slice_type.volatile_token != null) { try p.errors.append(p.gpa, .{ .ExtraVolatileQualifier = .{ .token = p.tok_i - 1 }, }); continue; } slice_type.volatile_token = volatile_token; continue; } if (p.eatToken(.Keyword_allowzero)) |allowzero_token| { if (slice_type.allowzero_token != null) { try p.errors.append(p.gpa, .{ .ExtraAllowZeroQualifier = .{ .token = p.tok_i - 1 }, }); continue; } slice_type.allowzero_token = allowzero_token; continue; } break; } }, else => unreachable, } return node; } return null; } /// SuffixOp /// <- LBRACKET Expr (DOT2 (Expr (COLON Expr)?)?)? RBRACKET /// / DOT IDENTIFIER /// / DOTASTERISK /// / DOTQUESTIONMARK fn parseSuffixOp(p: *Parser) !?*Node { const OpAndToken = struct { op: Node.SuffixOp.Op, token: TokenIndex, }; const op_and_token: OpAndToken = blk: { if (p.eatToken(.LBracket)) |_| { const index_expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); if (p.eatToken(.Ellipsis2) != null) { const end_expr = try p.parseExpr(); const sentinel: ?*Node = if (p.eatToken(.Colon) != null) try p.parseExpr() else null; break :blk .{ .op = .{ .Slice = .{ .start = index_expr, .end = end_expr, .sentinel = sentinel, }, }, .token = try p.expectToken(.RBracket), }; } break :blk .{ .op = .{ .ArrayAccess = index_expr }, .token = try p.expectToken(.RBracket), }; } if (p.eatToken(.PeriodAsterisk)) |period_asterisk| { break :blk .{ .op = .Deref, .token = period_asterisk }; } if (p.eatToken(.Period)) |period| { if (try p.parseIdentifier()) |identifier| { // TODO: It's a bit weird to return an InfixOp from the SuffixOp parser. // Should there be an Node.SuffixOp.FieldAccess variant? Or should // this grammar rule be altered? const node = try p.arena.allocator.create(Node.InfixOp); node.* = .{ .op_token = period, .lhs = undefined, // set by caller .op = .Period, .rhs = identifier, }; return &node.base; } if (p.eatToken(.QuestionMark)) |question_mark| { break :blk .{ .op = .UnwrapOptional, .token = question_mark }; } try p.errors.append(p.gpa, .{ .ExpectedSuffixOp = .{ .token = p.tok_i }, }); return null; } return null; }; const node = try p.arena.allocator.create(Node.SuffixOp); node.* = .{ .lhs = undefined, // set by caller .op = op_and_token.op, .rtoken = op_and_token.token, }; return &node.base; } /// FnCallArguments <- LPAREN ExprList RPAREN /// ExprList <- (Expr COMMA)* Expr? fn parseFnCallArguments(p: *Parser) !?AnnotatedParamList { if (p.eatToken(.LParen) == null) return null; const list = try ListParseFn(*Node, parseExpr)(p); errdefer p.gpa.free(list); const rparen = try p.expectToken(.RParen); return AnnotatedParamList{ .list = list, .rparen = rparen }; } const AnnotatedParamList = struct { list: []*Node, rparen: TokenIndex, }; /// ArrayTypeStart <- LBRACKET Expr? RBRACKET fn parseArrayTypeStart(p: *Parser) !?*Node { const lbracket = p.eatToken(.LBracket) orelse return null; const expr = try p.parseExpr(); const sentinel = if (p.eatToken(.Colon)) |_| try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }) else null; const rbracket = try p.expectToken(.RBracket); const op: Node.PrefixOp.Op = if (expr) |len_expr| .{ .ArrayType = .{ .len_expr = len_expr, .sentinel = sentinel, }, } else .{ .SliceType = Node.PrefixOp.PtrInfo{ .allowzero_token = null, .align_info = null, .const_token = null, .volatile_token = null, .sentinel = sentinel, }, }; const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = lbracket, .op = op, .rhs = undefined, // set by caller }; return &node.base; } /// PtrTypeStart /// <- ASTERISK /// / ASTERISK2 /// / PTRUNKNOWN /// / PTRC fn parsePtrTypeStart(p: *Parser) !?*Node { if (p.eatToken(.Asterisk)) |asterisk| { const sentinel = if (p.eatToken(.Colon)) |_| try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }) else null; const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = asterisk, .op = .{ .PtrType = .{ .sentinel = sentinel } }, .rhs = undefined, // set by caller }; return &node.base; } if (p.eatToken(.AsteriskAsterisk)) |double_asterisk| { const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = double_asterisk, .op = .{ .PtrType = .{} }, .rhs = undefined, // set by caller }; // Special case for **, which is its own token const child = try p.arena.allocator.create(Node.PrefixOp); child.* = .{ .op_token = double_asterisk, .op = .{ .PtrType = .{} }, .rhs = undefined, // set by caller }; node.rhs = &child.base; return &node.base; } if (p.eatToken(.LBracket)) |lbracket| { const asterisk = p.eatToken(.Asterisk) orelse { p.putBackToken(lbracket); return null; }; if (p.eatToken(.Identifier)) |ident| { const token_loc = p.token_locs[ident]; const token_slice = p.source[token_loc.start..token_loc.end]; if (!std.mem.eql(u8, token_slice, "c")) { p.putBackToken(ident); } else { _ = try p.expectToken(.RBracket); const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = lbracket, .op = .{ .PtrType = .{} }, .rhs = undefined, // set by caller }; return &node.base; } } const sentinel = if (p.eatToken(.Colon)) |_| try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }) else null; _ = try p.expectToken(.RBracket); const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = lbracket, .op = .{ .PtrType = .{ .sentinel = sentinel } }, .rhs = undefined, // set by caller }; return &node.base; } return null; } /// ContainerDeclAuto <- ContainerDeclType LBRACE ContainerMembers RBRACE fn parseContainerDeclAuto(p: *Parser) !?*Node { const container_decl_type = (try p.parseContainerDeclType()) orelse return null; const lbrace = try p.expectToken(.LBrace); const members = try p.parseContainerMembers(false); defer p.gpa.free(members); const rbrace = try p.expectToken(.RBrace); const members_len = @intCast(NodeIndex, members.len); const node = try Node.ContainerDecl.alloc(&p.arena.allocator, members_len); node.* = .{ .layout_token = null, .kind_token = container_decl_type.kind_token, .init_arg_expr = container_decl_type.init_arg_expr, .fields_and_decls_len = members_len, .lbrace_token = lbrace, .rbrace_token = rbrace, }; std.mem.copy(*Node, node.fieldsAndDecls(), members); return &node.base; } /// Holds temporary data until we are ready to construct the full ContainerDecl AST node. const ContainerDeclType = struct { kind_token: TokenIndex, init_arg_expr: Node.ContainerDecl.InitArg, }; /// ContainerDeclType /// <- KEYWORD_struct /// / KEYWORD_enum (LPAREN Expr RPAREN)? /// / KEYWORD_union (LPAREN (KEYWORD_enum (LPAREN Expr RPAREN)? / Expr) RPAREN)? fn parseContainerDeclType(p: *Parser) !?ContainerDeclType { const kind_token = p.nextToken(); const init_arg_expr = switch (p.token_ids[kind_token]) { .Keyword_struct => Node.ContainerDecl.InitArg{ .None = {} }, .Keyword_enum => blk: { if (p.eatToken(.LParen) != null) { const expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); break :blk Node.ContainerDecl.InitArg{ .Type = expr }; } break :blk Node.ContainerDecl.InitArg{ .None = {} }; }, .Keyword_union => blk: { if (p.eatToken(.LParen) != null) { if (p.eatToken(.Keyword_enum) != null) { if (p.eatToken(.LParen) != null) { const expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); _ = try p.expectToken(.RParen); break :blk Node.ContainerDecl.InitArg{ .Enum = expr }; } _ = try p.expectToken(.RParen); break :blk Node.ContainerDecl.InitArg{ .Enum = null }; } const expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); break :blk Node.ContainerDecl.InitArg{ .Type = expr }; } break :blk Node.ContainerDecl.InitArg{ .None = {} }; }, else => { p.putBackToken(kind_token); return null; }, }; return ContainerDeclType{ .kind_token = kind_token, .init_arg_expr = init_arg_expr, }; } /// ByteAlign <- KEYWORD_align LPAREN Expr RPAREN fn parseByteAlign(p: *Parser) !?*Node { _ = p.eatToken(.Keyword_align) orelse return null; _ = try p.expectToken(.LParen); const expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }); _ = try p.expectToken(.RParen); return expr; } /// IdentifierList <- (IDENTIFIER COMMA)* IDENTIFIER? /// Only ErrorSetDecl parses an IdentifierList fn parseErrorTagList(p: *Parser) ![]*Node { return ListParseFn(*Node, parseErrorTag)(p); } /// SwitchProngList <- (SwitchProng COMMA)* SwitchProng? fn parseSwitchProngList(p: *Parser) ![]*Node { return ListParseFn(*Node, parseSwitchProng)(p); } /// AsmOutputList <- (AsmOutputItem COMMA)* AsmOutputItem? fn parseAsmOutputList(p: *Parser) Error![]Node.Asm.Output { return ListParseFn(Node.Asm.Output, parseAsmOutputItem)(p); } /// AsmInputList <- (AsmInputItem COMMA)* AsmInputItem? fn parseAsmInputList(p: *Parser) Error![]Node.Asm.Input { return ListParseFn(Node.Asm.Input, parseAsmInputItem)(p); } /// ParamDeclList <- (ParamDecl COMMA)* ParamDecl? fn parseParamDeclList(p: *Parser) ![]Node.FnProto.ParamDecl { return ListParseFn(Node.FnProto.ParamDecl, parseParamDecl)(p); } const NodeParseFn = fn (p: *Parser) Error!?*Node; fn ListParseFn(comptime E: type, comptime nodeParseFn: var) ParseFn([]E) { return struct { pub fn parse(p: *Parser) ![]E { var list = std.ArrayList(E).init(p.gpa); defer list.deinit(); while (try nodeParseFn(p)) |item| { try list.append(item); switch (p.token_ids[p.tok_i]) { .Comma => _ = p.nextToken(), // all possible delimiters .Colon, .RParen, .RBrace, .RBracket => break, else => { // this is likely just a missing comma, // continue parsing this list and give an error try p.errors.append(p.gpa, .{ .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, }); }, } } return list.toOwnedSlice(); } }.parse; } fn SimpleBinOpParseFn(comptime token: Token.Id, comptime op: Node.InfixOp.Op) NodeParseFn { return struct { pub fn parse(p: *Parser) Error!?*Node { const op_token = if (token == .Keyword_and) switch (p.token_ids[p.tok_i]) { .Keyword_and => p.nextToken(), .Invalid_ampersands => blk: { try p.errors.append(p.gpa, .{ .InvalidAnd = .{ .token = p.tok_i }, }); break :blk p.nextToken(); }, else => return null, } else p.eatToken(token) orelse return null; const node = try p.arena.allocator.create(Node.InfixOp); node.* = .{ .op_token = op_token, .lhs = undefined, // set by caller .op = op, .rhs = undefined, // set by caller }; return &node.base; } }.parse; } // Helper parsers not included in the grammar fn parseBuiltinCall(p: *Parser) !?*Node { const token = p.eatToken(.Builtin) orelse return null; const params = (try p.parseFnCallArguments()) orelse { try p.errors.append(p.gpa, .{ .ExpectedParamList = .{ .token = p.tok_i }, }); // lets pretend this was an identifier so we can continue parsing const node = try p.arena.allocator.create(Node.Identifier); node.* = .{ .token = token, }; return &node.base; }; defer p.gpa.free(params.list); const node = try Node.BuiltinCall.alloc(&p.arena.allocator, params.list.len); node.* = .{ .builtin_token = token, .params_len = params.list.len, .rparen_token = params.rparen, }; std.mem.copy(*Node, node.params(), params.list); return &node.base; } fn parseErrorTag(p: *Parser) !?*Node { const doc_comments = try p.parseDocComment(); // no need to rewind on failure const token = p.eatToken(.Identifier) orelse return null; const node = try p.arena.allocator.create(Node.ErrorTag); node.* = .{ .doc_comments = doc_comments, .name_token = token, }; return &node.base; } fn parseIdentifier(p: *Parser) !?*Node { const token = p.eatToken(.Identifier) orelse return null; const node = try p.arena.allocator.create(Node.Identifier); node.* = .{ .token = token, }; return &node.base; } fn parseVarType(p: *Parser) !?*Node { const token = p.eatToken(.Keyword_var) orelse return null; const node = try p.arena.allocator.create(Node.VarType); node.* = .{ .token = token, }; return &node.base; } fn createLiteral(p: *Parser, comptime T: type, token: TokenIndex) !*Node { const result = try p.arena.allocator.create(T); result.* = T{ .base = Node{ .id = Node.typeToId(T) }, .token = token, }; return &result.base; } fn parseStringLiteralSingle(p: *Parser) !?*Node { if (p.eatToken(.StringLiteral)) |token| { const node = try p.arena.allocator.create(Node.StringLiteral); node.* = .{ .token = token, }; return &node.base; } return null; } // string literal or multiline string literal fn parseStringLiteral(p: *Parser) !?*Node { if (try p.parseStringLiteralSingle()) |node| return node; if (p.eatToken(.MultilineStringLiteralLine)) |first_line| { const start_tok_i = p.tok_i; var tok_i = start_tok_i; var count: usize = 1; // including first_line while (true) : (tok_i += 1) { switch (p.token_ids[tok_i]) { .LineComment => continue, .MultilineStringLiteralLine => count += 1, else => break, } } const node = try Node.MultilineStringLiteral.alloc(&p.arena.allocator, count); node.* = .{ .lines_len = count }; const lines = node.lines(); tok_i = start_tok_i; lines[0] = first_line; count = 1; while (true) : (tok_i += 1) { switch (p.token_ids[tok_i]) { .LineComment => continue, .MultilineStringLiteralLine => { lines[count] = tok_i; count += 1; }, else => break, } } p.tok_i = tok_i; return &node.base; } return null; } fn parseIntegerLiteral(p: *Parser) !?*Node { const token = p.eatToken(.IntegerLiteral) orelse return null; const node = try p.arena.allocator.create(Node.IntegerLiteral); node.* = .{ .token = token, }; return &node.base; } fn parseFloatLiteral(p: *Parser) !?*Node { const token = p.eatToken(.FloatLiteral) orelse return null; const node = try p.arena.allocator.create(Node.FloatLiteral); node.* = .{ .token = token, }; return &node.base; } fn parseTry(p: *Parser) !?*Node { const token = p.eatToken(.Keyword_try) orelse return null; const node = try p.arena.allocator.create(Node.PrefixOp); node.* = .{ .op_token = token, .op = .Try, .rhs = undefined, // set by caller }; return &node.base; } fn parseUse(p: *Parser) !?*Node { const token = p.eatToken(.Keyword_usingnamespace) orelse return null; const node = try p.arena.allocator.create(Node.Use); node.* = .{ .doc_comments = null, .visib_token = null, .use_token = token, .expr = try p.expectNode(parseExpr, .{ .ExpectedExpr = .{ .token = p.tok_i }, }), .semicolon_token = try p.expectToken(.Semicolon), }; return &node.base; } /// IfPrefix Body (KEYWORD_else Payload? Body)? fn parseIf(p: *Parser, bodyParseFn: NodeParseFn) !?*Node { const node = (try p.parseIfPrefix()) orelse return null; const if_prefix = node.cast(Node.If).?; if_prefix.body = try p.expectNode(bodyParseFn, .{ .InvalidToken = .{ .token = p.tok_i }, }); const else_token = p.eatToken(.Keyword_else) orelse return node; const payload = try p.parsePayload(); const else_expr = try p.expectNode(bodyParseFn, .{ .InvalidToken = .{ .token = p.tok_i }, }); const else_node = try p.arena.allocator.create(Node.Else); else_node.* = .{ .else_token = else_token, .payload = payload, .body = else_expr, }; if_prefix.@"else" = else_node; return node; } /// Eat a multiline doc comment fn parseDocComment(p: *Parser) !?*Node.DocComment { if (p.eatToken(.DocComment)) |first_line| { while (p.eatToken(.DocComment)) |_| {} const node = try p.arena.allocator.create(Node.DocComment); node.* = .{ .first_line = first_line }; return node; } return null; } fn tokensOnSameLine(p: *Parser, token1: TokenIndex, token2: TokenIndex) bool { return std.mem.indexOfScalar(u8, p.source[p.token_locs[token1].end..p.token_locs[token2].start], '\n') == null; } /// Eat a single-line doc comment on the same line as another node fn parseAppendedDocComment(p: *Parser, after_token: TokenIndex) !?*Node.DocComment { const comment_token = p.eatToken(.DocComment) orelse return null; if (p.tokensOnSameLine(after_token, comment_token)) { const node = try p.arena.allocator.create(Node.DocComment); node.* = .{ .first_line = comment_token }; return node; } p.putBackToken(comment_token); return null; } /// Op* Child fn parsePrefixOpExpr(p: *Parser, comptime opParseFn: NodeParseFn, comptime childParseFn: NodeParseFn) Error!?*Node { if (try opParseFn(p)) |first_op| { var rightmost_op = first_op; while (true) { switch (rightmost_op.id) { .PrefixOp => { var prefix_op = rightmost_op.cast(Node.PrefixOp).?; // If the token encountered was **, there will be two nodes if (p.token_ids[prefix_op.op_token] == .AsteriskAsterisk) { rightmost_op = prefix_op.rhs; prefix_op = rightmost_op.cast(Node.PrefixOp).?; } if (try opParseFn(p)) |rhs| { prefix_op.rhs = rhs; rightmost_op = rhs; } else break; }, .AnyFrameType => { const prom = rightmost_op.cast(Node.AnyFrameType).?; if (try opParseFn(p)) |rhs| { prom.result.?.return_type = rhs; rightmost_op = rhs; } else break; }, else => unreachable, } } // If any prefix op existed, a child node on the RHS is required switch (rightmost_op.id) { .PrefixOp => { const prefix_op = rightmost_op.cast(Node.PrefixOp).?; prefix_op.rhs = try p.expectNode(childParseFn, .{ .InvalidToken = .{ .token = p.tok_i }, }); }, .AnyFrameType => { const prom = rightmost_op.cast(Node.AnyFrameType).?; prom.result.?.return_type = try p.expectNode(childParseFn, .{ .InvalidToken = .{ .token = p.tok_i }, }); }, else => unreachable, } return first_op; } // Otherwise, the child node is optional return childParseFn(p); } /// Child (Op Child)* /// Child (Op Child)? fn parseBinOpExpr( p: *Parser, opParseFn: NodeParseFn, childParseFn: NodeParseFn, chain: enum { Once, Infinitely, }, ) Error!?*Node { var res = (try childParseFn(p)) orelse return null; while (try opParseFn(p)) |node| { const right = try p.expectNode(childParseFn, .{ .InvalidToken = .{ .token = p.tok_i }, }); const left = res; res = node; const op = node.cast(Node.InfixOp).?; op.*.lhs = left; op.*.rhs = right; switch (chain) { .Once => break, .Infinitely => continue, } } return res; } fn createInfixOp(p: *Parser, index: TokenIndex, op: Node.InfixOp.Op) !*Node { const node = try p.arena.allocator.create(Node.InfixOp); node.* = .{ .op_token = index, .lhs = undefined, // set by caller .op = op, .rhs = undefined, // set by caller }; return &node.base; } fn eatToken(p: *Parser, id: Token.Id) ?TokenIndex { return if (p.token_ids[p.tok_i] == id) p.nextToken() else null; } fn expectToken(p: *Parser, id: Token.Id) Error!TokenIndex { return (try p.expectTokenRecoverable(id)) orelse error.ParseError; } fn expectTokenRecoverable(p: *Parser, id: Token.Id) !?TokenIndex { const token = p.nextToken(); if (p.token_ids[token] != id) { try p.errors.append(p.gpa, .{ .ExpectedToken = .{ .token = token, .expected_id = id }, }); // go back so that we can recover properly p.putBackToken(token); return null; } return token; } fn nextToken(p: *Parser) TokenIndex { const result = p.tok_i; p.tok_i += 1; assert(p.token_ids[result] != .LineComment); if (p.tok_i >= p.token_ids.len) return result; while (true) { if (p.token_ids[p.tok_i] != .LineComment) return result; p.tok_i += 1; } } fn putBackToken(p: *Parser, putting_back: TokenIndex) void { while (p.tok_i > 0) { p.tok_i -= 1; if (p.token_ids[p.tok_i] == .LineComment) continue; assert(putting_back == p.tok_i); return; } } fn expectNode( p: *Parser, parseFn: NodeParseFn, /// if parsing fails err: AstError, ) Error!*Node { return (try p.expectNodeRecoverable(parseFn, err)) orelse return error.ParseError; } fn expectNodeRecoverable( p: *Parser, parseFn: NodeParseFn, /// if parsing fails err: AstError, ) !?*Node { return (try parseFn(p)) orelse { try p.errors.append(p.gpa, err); return null; }; } }; fn ParseFn(comptime T: type) type { return fn (p: *Parser) Error!T; } test "std.zig.parser" { _ = @import("parser_test.zig"); }
lib/std/zig/parse.zig
const std = @import("std"); const crypto = std.crypto; const mem = std.mem; const fmt = std.fmt; const Sha512 = crypto.hash.sha2.Sha512; /// X25519 DH function. pub const X25519 = struct { /// The underlying elliptic curve. pub const Curve = @import("curve25519.zig").Curve25519; /// Length (in bytes) of a secret key. pub const secret_length = 32; /// Length (in bytes) of a public key. pub const public_length = 32; /// Length (in bytes) of the output of the DH function. pub const shared_length = 32; /// Seed (for key pair creation) length in bytes. pub const seed_length = 32; /// An X25519 key pair. pub const KeyPair = struct { /// Public part. public_key: [public_length]u8, /// Secret part. secret_key: [secret_length]u8, /// Create a new key pair using an optional seed. pub fn create(seed: ?[seed_length]u8) !KeyPair { const sk = seed orelse sk: { var random_seed: [seed_length]u8 = undefined; crypto.random.bytes(&random_seed); break :sk random_seed; }; var kp: KeyPair = undefined; mem.copy(u8, &kp.secret_key, sk[0..]); kp.public_key = try X25519.recoverPublicKey(sk); return kp; } /// Create a key pair from an Ed25519 key pair pub fn fromEd25519(ed25519_key_pair: crypto.sign.Ed25519.KeyPair) !KeyPair { const seed = ed25519_key_pair.secret_key[0..32]; var az: [Sha512.digest_length]u8 = undefined; Sha512.hash(seed, &az, .{}); var sk = az[0..32].*; Curve.scalar.clamp(&sk); const pk = try publicKeyFromEd25519(ed25519_key_pair.public_key); return KeyPair{ .public_key = pk, .secret_key = sk, }; } }; /// Compute the public key for a given private key. pub fn recoverPublicKey(secret_key: [secret_length]u8) ![public_length]u8 { const q = try Curve.basePoint.clampedMul(secret_key); return q.toBytes(); } /// Compute the X25519 equivalent to an Ed25519 public eky. pub fn publicKeyFromEd25519(ed25519_public_key: [crypto.sign.Ed25519.public_length]u8) ![public_length]u8 { const pk_ed = try crypto.ecc.Edwards25519.fromBytes(ed25519_public_key); const pk = try Curve.fromEdwards25519(pk_ed); return pk.toBytes(); } /// Compute the scalar product of a public key and a secret scalar. /// Note that the output should not be used as a shared secret without /// hashing it first. pub fn scalarmult(secret_key: [secret_length]u8, public_key: [public_length]u8) ![shared_length]u8 { const q = try Curve.fromBytes(public_key).clampedMul(secret_key); return q.toBytes(); } }; const htest = @import("../test.zig"); test "x25519 public key calculation from secret key" { var sk: [32]u8 = undefined; var pk_expected: [32]u8 = undefined; _ = try fmt.hexToBytes(sk[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); _ = try fmt.hexToBytes(pk_expected[0..], "f1814f0e8ff1043d8a44d25babff3cedcae6c22c3edaa48f857ae70de2baae50"); const pk_calculated = try X25519.recoverPublicKey(sk); std.testing.expectEqual(pk_calculated, pk_expected); } test "x25519 rfc7748 vector1" { const secret_key = [32]u8{ 0xa5, 0x46, 0xe3, 0x6b, 0xf0, 0x52, 0x7c, 0x9d, 0x3b, 0x16, 0x15, 0x4b, 0x82, 0x46, 0x5e, 0xdd, 0x62, 0x14, 0x4c, 0x0a, 0xc1, 0xfc, 0x5a, 0x18, 0x50, 0x6a, 0x22, 0x44, 0xba, <KEY> }; const public_key = [32]u8{ 0xe6, 0xdb, 0x68, 0x67, 0x58, 0x30, 0x30, 0xdb, 0x35, 0x94, 0xc1, 0xa4, 0x24, 0xb1, 0x5f, 0x7c, 0x72, 0x66, 0x24, 0xec, 0x26, 0xb3, 0x35, 0x3b, 0x10, 0xa9, 0x03, 0xa6, 0xd0, 0xab, 0x1c, 0x4c }; const expected_output = [32]u8{ 0xc3, 0xda, 0x55, 0x37, 0x9d, 0xe9, 0xc6, 0x90, 0x8e, 0x94, 0xea, 0x4d, 0xf2, 0x8d, 0x08, 0x4f, 0x32, 0xec, 0xcf, 0x03, 0x49, 0x1c, 0x71, 0xf7, 0x54, 0xb4, 0x07, 0x55, 0x77, 0xa2, 0x85, 0x52 }; const output = try X25519.scalarmult(secret_key, public_key); std.testing.expectEqual(output, expected_output); } test "x25519 rfc7748 vector2" { const secret_key = [32]u8{ 0x4b, 0x66, 0xe9, 0xd4, 0xd1, 0xb4, 0x67, 0x3c, 0x5a, 0xd2, 0x26, 0x91, 0x95, 0x7d, 0x6a, 0xf5, 0xc1, 0x1b, 0x64, 0x21, 0xe0, 0xea, 0x01, 0xd4, 0x2c, 0xa4, 0x16, 0x9e, 0x79, 0x18, 0xba, 0x0d }; const public_key = [32]u8{ <KEY>, 0x78, 0x68, 0x11, 0xd3, 0xf4, 0xb7, 0x95, 0x9d, 0x05, 0x38, 0xae, 0x2c, 0x31, 0xdb, 0xe7, 0x10, 0x6f, 0xc0, 0x3c, 0x3e, 0xfc, 0x4c, 0xd5, 0x49, 0xc7, 0x15, 0xa4, 0x93 }; const expected_output = [32]u8{ 0x95, 0xcb, 0xde, 0x94, 0x76, 0xe8, 0x90, 0x7d, 0x7a, 0xad, 0xe4, 0x5c, 0xb4, 0xb8, 0x73, 0xf8, 0x8b, 0x59, 0x5a, 0x68, 0x79, 0x9f, 0xa1, 0x52, 0xe6, 0xf8, 0xf7, 0x64, 0x7a, 0xac, 0x79, 0x57 }; const output = try X25519.scalarmult(secret_key, public_key); std.testing.expectEqual(output, expected_output); } test "x25519 rfc7748 one iteration" { const initial_value = [32]u8{ 0x09, 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 }; const expected_output = [32]u8{ 0x42, 0x2c, 0x8e, 0x7a, 0x62, 0x27, 0xd7, 0xbc, 0xa1, 0x35, 0x0b, 0x3e, 0x2b, 0xb7, 0x27, 0x9f, 0x78, 0x97, 0xb8, 0x7b, 0xb6, 0x85, 0x4b, 0x78, 0x3c, 0x60, 0xe8, 0x03, 0x11, 0xae, 0x30, 0x79 }; var k: [32]u8 = initial_value; var u: [32]u8 = initial_value; var i: usize = 0; while (i < 1) : (i += 1) { const output = try X25519.scalarmult(k, u); mem.copy(u8, u[0..], k[0..]); mem.copy(u8, k[0..], output[0..]); } std.testing.expectEqual(k, expected_output); } test "x25519 rfc7748 1,000 iterations" { // These iteration tests are slow so we always skip them. Results have been verified. if (true) { return error.SkipZigTest; } const initial_value = [32]u8{ 0x09, 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 }; const expected_output = [32]u8{ 0x68, 0x4c, 0xf5, 0x9b, 0xa8, 0x33, 0x09, 0x55, 0x28, 0x00, 0xef, 0x56, 0x6f, 0x2f, 0x4d, 0x3c, 0x1c, 0x38, 0x87, 0xc4, 0x93, 0x60, 0xe3, 0x87, 0x5f, 0x2e, 0xb9, 0x4d, 0x99, 0x53, 0x2c, 0x51 }; var k: [32]u8 = initial_value.*; var u: [32]u8 = initial_value.*; var i: usize = 0; while (i < 1000) : (i += 1) { const output = try X25519.scalarmult(&k, &u); mem.copy(u8, u[0..], k[0..]); mem.copy(u8, k[0..], output[0..]); } std.testing.expectEqual(k, expected_output); } test "x25519 rfc7748 1,000,000 iterations" { if (true) { return error.SkipZigTest; } const initial_value = [32]u8{ 0x09, 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 }; const expected_output = [32]u8{ 0x7c, 0x39, 0x11, 0xe0, 0xab, 0x25, 0x86, 0xfd, 0x86, 0x44, 0x97, 0x29, 0x7e, 0x57, 0x5e, 0x6f, 0x3b, 0xc6, 0x01, 0xc0, 0x88, 0x3c, 0x30, 0xdf, 0x5f, 0x4d, 0xd2, 0xd2, 0x4f, 0x66, 0x54, 0x24 }; var k: [32]u8 = initial_value.*; var u: [32]u8 = initial_value.*; var i: usize = 0; while (i < 1000000) : (i += 1) { const output = try X25519.scalarmult(&k, &u); mem.copy(u8, u[0..], k[0..]); mem.copy(u8, k[0..], output[0..]); } std.testing.expectEqual(k[0..], expected_output); } test "edwards25519 -> curve25519 map" { const ed_kp = try crypto.sign.Ed25519.KeyPair.create([_]u8{0x42} ** 32); const mont_kp = try X25519.KeyPair.fromEd25519(ed_kp); htest.assertEqual("90e7595fc89e52fdfddce9c6a43d74dbf6047025ee0462d2d172e8b6a2841d6e", &mont_kp.secret_key); htest.assertEqual("<KEY>", &mont_kp.public_key); }
lib/std/crypto/25519/x25519.zig
const std = @import("index.zig"); const builtin = @import("builtin"); const assert = std.debug.assert; const net = @This(); const posix = std.os.posix; const mem = std.mem; pub const TmpWinAddr = struct.{ family: u8, data: [14]u8, }; pub const OsAddress = switch (builtin.os) { builtin.Os.windows => TmpWinAddr, else => posix.sockaddr, }; pub const Address = struct.{ os_addr: OsAddress, pub fn initIp4(ip4: u32, port: u16) Address { return Address.{ .os_addr = posix.sockaddr.{ .in = posix.sockaddr_in.{ .family = posix.AF_INET, .port = std.mem.endianSwapIfLe(u16, port), .addr = ip4, .zero = []u8.{0} ** 8, }, }, }; } pub fn initIp6(ip6: *const Ip6Addr, port: u16) Address { return Address.{ .family = posix.AF_INET6, .os_addr = posix.sockaddr.{ .in6 = posix.sockaddr_in6.{ .family = posix.AF_INET6, .port = std.mem.endianSwapIfLe(u16, port), .flowinfo = 0, .addr = ip6.addr, .scope_id = ip6.scope_id, }, }, }; } pub fn initPosix(addr: posix.sockaddr) Address { return Address.{ .os_addr = addr }; } pub fn format(self: *const Address, out_stream: var) !void { switch (self.os_addr.in.family) { posix.AF_INET => { const native_endian_port = std.mem.endianSwapIfLe(u16, self.os_addr.in.port); const bytes = ([]const u8)((*self.os_addr.in.addr)[0..1]); try out_stream.print("{}.{}.{}.{}:{}", bytes[0], bytes[1], bytes[2], bytes[3], native_endian_port); }, posix.AF_INET6 => { const native_endian_port = std.mem.endianSwapIfLe(u16, self.os_addr.in6.port); try out_stream.print("[TODO render ip6 address]:{}", native_endian_port); }, else => try out_stream.write("(unrecognized address family)"), } } }; pub fn parseIp4(buf: []const u8) !u32 { var result: u32 = undefined; const out_ptr = @sliceToBytes((*[1]u32)(&result)[0..]); var x: u8 = 0; var index: u8 = 0; var saw_any_digits = false; for (buf) |c| { if (c == '.') { if (!saw_any_digits) { return error.InvalidCharacter; } if (index == 3) { return error.InvalidEnd; } out_ptr[index] = x; index += 1; x = 0; saw_any_digits = false; } else if (c >= '0' and c <= '9') { saw_any_digits = true; const digit = c - '0'; if (@mulWithOverflow(u8, x, 10, &x)) { return error.Overflow; } if (@addWithOverflow(u8, x, digit, &x)) { return error.Overflow; } } else { return error.InvalidCharacter; } } if (index == 3 and saw_any_digits) { out_ptr[index] = x; return result; } return error.Incomplete; } pub const Ip6Addr = struct.{ scope_id: u32, addr: [16]u8, }; pub fn parseIp6(buf: []const u8) !Ip6Addr { var result: Ip6Addr = undefined; result.scope_id = 0; const ip_slice = result.addr[0..]; var x: u16 = 0; var saw_any_digits = false; var index: u8 = 0; var scope_id = false; for (buf) |c| { if (scope_id) { if (c >= '0' and c <= '9') { const digit = c - '0'; if (@mulWithOverflow(u32, result.scope_id, 10, &result.scope_id)) { return error.Overflow; } if (@addWithOverflow(u32, result.scope_id, digit, &result.scope_id)) { return error.Overflow; } } else { return error.InvalidCharacter; } } else if (c == ':') { if (!saw_any_digits) { return error.InvalidCharacter; } if (index == 14) { return error.InvalidEnd; } ip_slice[index] = @truncate(u8, x >> 8); index += 1; ip_slice[index] = @truncate(u8, x); index += 1; x = 0; saw_any_digits = false; } else if (c == '%') { if (!saw_any_digits) { return error.InvalidCharacter; } if (index == 14) { ip_slice[index] = @truncate(u8, x >> 8); index += 1; ip_slice[index] = @truncate(u8, x); index += 1; } scope_id = true; saw_any_digits = false; } else { const digit = try std.fmt.charToDigit(c, 16); if (@mulWithOverflow(u16, x, 16, &x)) { return error.Overflow; } if (@addWithOverflow(u16, x, digit, &x)) { return error.Overflow; } saw_any_digits = true; } } if (!saw_any_digits) { return error.Incomplete; } if (scope_id) { return result; } if (index == 14) { ip_slice[14] = @truncate(u8, x >> 8); ip_slice[15] = @truncate(u8, x); return result; } return error.Incomplete; } test "std.net.parseIp4" { assert((try parseIp4("127.0.0.1")) == std.mem.endianSwapIfLe(u32, 0x7f000001)); testParseIp4Fail("256.0.0.1", error.Overflow); testParseIp4Fail("x.0.0.1", error.InvalidCharacter); testParseIp4Fail("127.0.0.1.1", error.InvalidEnd); testParseIp4Fail("127.0.0.", error.Incomplete); testParseIp4Fail("100..0.1", error.InvalidCharacter); } fn testParseIp4Fail(buf: []const u8, expected_err: error) void { if (parseIp4(buf)) |_| { @panic("expected error"); } else |e| { assert(e == expected_err); } } test "std.net.parseIp6" { const addr = try parseIp6("fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b"); assert(addr.addr[0] == 0xff); assert(addr.addr[1] == 0x01); assert(addr.addr[2] == 0x00); }
std/net.zig
const std = @import("std"); const builtin = std.builtin; const testing = std.testing; /// Thread-safe, lock-free integer pub fn Int(comptime T: type) type { if (!std.meta.trait.isIntegral(T)) @compileError("Expected integral type, got '" ++ @typeName(T) ++ "'"); return extern struct { unprotected_value: T, pub const Self = @This(); pub fn init(init_val: T) Self { return Self{ .unprotected_value = init_val }; } /// Read, Modify, Write pub fn rmw(self: *Self, comptime op: builtin.AtomicRmwOp, operand: T, comptime ordering: builtin.AtomicOrder) T { switch (ordering) { .Monotonic, .Acquire, .Release, .AcqRel, .SeqCst => {}, else => @compileError("Invalid ordering '" ++ @tagName(ordering) ++ "' for a RMW operation"), } return @atomicRmw(T, &self.unprotected_value, op, operand, ordering); } pub fn load(self: *const Self, comptime ordering: builtin.AtomicOrder) T { switch (ordering) { .Unordered, .Monotonic, .Acquire, .SeqCst => {}, else => @compileError("Invalid ordering '" ++ @tagName(ordering) ++ "' for a load operation"), } return @atomicLoad(T, &self.unprotected_value, ordering); } pub fn store(self: *Self, value: T, comptime ordering: builtin.AtomicOrder) void { switch (ordering) { .Unordered, .Monotonic, .Release, .SeqCst => {}, else => @compileError("Invalid ordering '" ++ @tagName(ordering) ++ "' for a store operation"), } @atomicStore(T, &self.unprotected_value, value, ordering); } /// Twos complement wraparound increment /// Returns previous value pub fn incr(self: *Self) T { return self.rmw(.Add, 1, .SeqCst); } /// Twos complement wraparound decrement /// Returns previous value pub fn decr(self: *Self) T { return self.rmw(.Sub, 1, .SeqCst); } pub fn get(self: *const Self) T { return self.load(.SeqCst); } pub fn set(self: *Self, new_value: T) void { self.store(new_value, .SeqCst); } pub fn xchg(self: *Self, new_value: T) T { return self.rmw(.Xchg, new_value, .SeqCst); } /// Twos complement wraparound add /// Returns previous value pub fn fetchAdd(self: *Self, op: T) T { return self.rmw(.Add, op, .SeqCst); } }; } test "std.atomic.Int" { var a = Int(u8).init(0); try testing.expectEqual(@as(u8, 0), a.incr()); try testing.expectEqual(@as(u8, 1), a.load(.SeqCst)); a.store(42, .SeqCst); try testing.expectEqual(@as(u8, 42), a.decr()); try testing.expectEqual(@as(u8, 41), a.xchg(100)); try testing.expectEqual(@as(u8, 100), a.fetchAdd(5)); try testing.expectEqual(@as(u8, 105), a.get()); a.set(200); }
lib/std/atomic/int.zig
const std = @import("std"); const print = std.debug.print; usingnamespace @import("imgui"); const upaya = @import("upaya"); const Texture = upaya.Texture; const rules_win = @import("windows/rules.zig"); const brushes_win = @import("windows/brushes.zig"); const tags_win = @import("windows/tags.zig"); const tile_definitions_win = @import("windows/tile_definitions.zig"); const objects_win = @import("windows/objects.zig"); const object_editor_win = @import("windows/object_editor.zig"); const animations_win = @import("windows/animations.zig"); const input_map_wins = @import("windows/maps.zig"); const output_map_win = @import("windows/output_map.zig"); const menu = @import("menu.zig"); pub const data = @import("map.zig"); pub const history = @import("history.zig"); pub const colors = @import("colors.zig"); pub const AppState = @import("app_state.zig").AppState; pub const Map = data.Map; pub const drawBrush = brushes_win.drawBrush; const files = @import("filebrowser"); pub const TileScript = struct { state: AppState, pub fn init() TileScript { colors.init(); history.init(); return .{ .state = AppState.init() }; } pub fn deinit(self: *TileScript) void { history.deinit(); self.state.texture.deinit(); self.state.map.deinit(); upaya.mem.allocator.free(self.state.processed_map_data); upaya.mem.allocator.free(self.state.final_map_data); upaya.mem.allocator.free(self.state.random_map_data); } pub fn handleDroppedFile(self: *TileScript, file: []const u8) void { if (std.mem.endsWith(u8, file, ".ts") or std.mem.endsWith(u8, file, ".tkp")) { self.state.loadMap(file) catch unreachable; } else if (std.mem.endsWith(u8, file, ".png")) { menu.loadTileset(file); } else { self.state.showToast("Invalid file.", 100); } } pub fn draw(self: *TileScript) void { menu.draw(&self.state); rules_win.draw(&self.state); brushes_win.drawWindow(&self.state); input_map_wins.drawWindows(&self.state); output_map_win.drawWindow(&self.state); brushes_win.drawPopup(&self.state, "##brushes-root"); tags_win.draw(&self.state); tile_definitions_win.draw(&self.state); objects_win.draw(&self.state); object_editor_win.draw(&self.state); animations_win.draw(&self.state); // toast notifications if (self.state.toast_timer > 0) { self.state.toast_timer -= 1; igPushStyleColorU32(ImGuiCol_WindowBg, colors.colorRgba(90, 90, 130, 255)); igSetNextWindowPos(ogGetWindowCenter(), ImGuiCond_Always, .{ .x = 0.5, .y = 0.5 }); if (igBegin("Toast Notification", null, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) { igText(&self.state.toast_text[0]); if (igIsItemHovered(ImGuiHoveredFlags_None) and igIsMouseClicked(ImGuiMouseButton_Left, false)) { self.state.toast_timer = -1; } } igEnd(); igPopStyleColor(1); } // igShowDemoWindow(null); } pub fn setupDockLayout(id: ImGuiID) void { var dock_main_id = id; // dock_main_id is the left node after this const right_id = igDockBuilderSplitNode(dock_main_id, ImGuiDir_Right, 0.37, null, &dock_main_id); igDockBuilderDockWindow("Rules", right_id); // dock_main_id is the bottom node after this const tl_id = igDockBuilderSplitNode(dock_main_id, ImGuiDir_Up, 0.48, null, &dock_main_id); igDockBuilderDockWindow("Input Map", tl_id); igDockBuilderDockWindow("Post Processed Map", dock_main_id); igDockBuilderDockWindow("Output Map", dock_main_id); igDockBuilderFinish(id); } }; // TODO: move these to a common utility file along with methods to draw brushes popup and tileset popup with single/multiple selection /// helper to find the tile under the mouse given a top-left position of the grid and a grid size pub fn tileIndexUnderMouse(rect_size: usize, origin: ImVec2) struct { x: usize, y: usize } { var pos = igGetIO().MousePos; pos.x -= origin.x; pos.y -= origin.y; return .{ .x = @divTrunc(@floatToInt(usize, pos.x), rect_size), .y = @divTrunc(@floatToInt(usize, pos.y), rect_size) }; } pub fn tileIndexUnderPos(position: ImVec2, rect_size: usize, origin: ImVec2) struct { x: usize, y: usize } { var pos = position; pos.x -= origin.x; pos.y -= origin.y; return .{ .x = @divTrunc(@floatToInt(usize, pos.x), rect_size), .y = @divTrunc(@floatToInt(usize, pos.y), rect_size) }; } /// helper to draw an image button with an image from the tileset pub fn tileImageButton(state: *AppState, size: f32, tile: usize) bool { const rect = uvsForTile(state, tile); const uv0 = ImVec2{ .x = rect.x, .y = rect.y }; const uv1 = ImVec2{ .x = rect.x + rect.w, .y = rect.y + rect.h }; const tint = colors.colorRgbaVec4(255, 255, 255, 255); return ogImageButton(state.texture.imTextureID(), .{ .x = size, .y = size }, uv0, uv1, 2, .{ .w = 1 }, tint); } pub fn uvsForTile(state: *AppState, tile: usize) upaya.math.Rect { const x = @intToFloat(f32, @mod(tile, state.tilesPerRow())); const y = @intToFloat(f32, @divTrunc(tile, state.tilesPerRow())); const inv_w = 1.0 / @intToFloat(f32, state.texture.width); const inv_h = 1.0 / @intToFloat(f32, state.texture.height); return .{ .x = (x * @intToFloat(f32, state.map.tile_size + state.map.tile_spacing) + @intToFloat(f32, state.map.tile_spacing)) * inv_w, .y = (y * @intToFloat(f32, state.map.tile_size + state.map.tile_spacing) + @intToFloat(f32, state.map.tile_spacing)) * inv_h, .w = @intToFloat(f32, state.map.tile_size) * inv_w, .h = @intToFloat(f32, state.map.tile_size) * inv_h, }; } /// adds a tile selection indicator to the draw list with an outline rectangle and a fill rectangle. Works for both tilesets and palettes. pub fn addTileToDrawList(tile_size: usize, content_start_pos: ImVec2, tile: u8, per_row: usize, tile_spacing: usize) void { const x = @mod(tile, per_row); const y = @divTrunc(tile, per_row); var tl = ImVec2{ .x = @intToFloat(f32, x) * @intToFloat(f32, tile_size + tile_spacing), .y = @intToFloat(f32, y) * @intToFloat(f32, tile_size + tile_spacing) }; tl.x += content_start_pos.x + @intToFloat(f32, tile_spacing); tl.y += content_start_pos.y + @intToFloat(f32, tile_spacing); ogAddQuadFilled(igGetWindowDrawList(), tl, @intToFloat(f32, tile_size), colors.rule_result_selected_fill); // offset by 1 extra pixel because quad outlines are drawn larger than the size passed in and we shrink the size by our outline width tl.x += 1; tl.y += 1; ogAddQuad(igGetWindowDrawList(), tl, @intToFloat(f32, tile_size - 2), colors.rule_result_selected_outline, 2); }
tilescript/tilescript.zig
const std = @import("std"); const Node = @This(); tag: ?[]u8 = null, text: ?[]u8 = null, escape_text: bool = true, attributes: std.ArrayListUnmanaged([]u8) = std.ArrayListUnmanaged([]u8){}, child_nodes: std.ArrayListUnmanaged(Node) = std.ArrayListUnmanaged(Node){}, pub fn write(self: Node, writer: anytype) @TypeOf(writer).Error!void { if (self.tag) |t| { try writer.writeAll("<"); try writer.writeAll(t); for (self.attributes.items) |attr| { try writer.writeAll(" "); try writer.writeAll(attr); } try writer.writeAll(">"); } for (self.child_nodes.items) |child| try child.write(writer); if (self.child_nodes.items.len == 0) { if (self.text) |text| { if (self.escape_text) { for (text) |byte| { try writer.writeAll(switch(byte) { '&' => "&amp", '<' => "&lt", '>' => "&gt", else => &[_]u8{byte}, }); } } else { try writer.print("{s}", .{text}); } } } if (self.tag) |t| try writer.print("</{s}>", .{t}); } pub fn addChild(self: *Node, allocator: *std.mem.Allocator, tag: ?[]const u8, text: ?[]const u8) !*Node { const new = Node{ .tag = if (tag) |t| try allocator.dupe(u8, t) else null, .text = if (text) |t| try allocator.dupe(u8, t) else null, }; try self.child_nodes.append(allocator, new); return &self.child_nodes.items[self.child_nodes.items.len - 1]; } pub fn addAttribute(self: *Node, allocator: *std.mem.Allocator, attr: []const u8) !void { try self.attributes.append(allocator, try allocator.dupe(u8, attr)); } pub fn deinit(self: *Node, allocator: *std.mem.Allocator) void { for (self.child_nodes.items) |*child| child.deinit(allocator); self.child_nodes.deinit(allocator); for (self.attributes.items) |attr| allocator.free(attr); self.attributes.deinit(allocator); if (self.text) |text| allocator.free(text); if (self.tag) |t| allocator.free(t); self.* = undefined; } test "usage" { const allocator = std.testing.allocator; var root = Node{}; defer root.deinit(allocator); var html = try root.addChild(allocator, "html", null); try html.addAttribute(allocator, "lang=\"en\""); var head = try html.addChild(allocator, "head", null); _ = try head.addChild(allocator, "title", "Hello, HTML!"); var body = try html.addChild(allocator, "body", null); _ = try body.addChild(allocator, "h1", "Heading"); _ = try body.addChild(allocator, "p", "Paragraph"); var out = std.ArrayList(u8).init(allocator); defer out.deinit(); try root.write(out.writer()); std.testing.expectEqualStrings( \\<html lang="en"><head><title>Hello, HTML!</title></head><body><h1>Heading</h1><p>Paragraph</p></body></html> , out.items, ); }
html-tree.zig
pub const DML_TARGET_VERSION = @as(u32, 16384); pub const DML_TENSOR_DIMENSION_COUNT_MAX = @as(u32, 5); pub const DML_TENSOR_DIMENSION_COUNT_MAX1 = @as(u32, 8); pub const DML_TEMPORARY_BUFFER_ALIGNMENT = @as(u32, 256); pub const DML_PERSISTENT_BUFFER_ALIGNMENT = @as(u32, 256); pub const DML_MINIMUM_BUFFER_TENSOR_ALIGNMENT = @as(u32, 16); //-------------------------------------------------------------------------------- // Section: Types (206) //-------------------------------------------------------------------------------- pub const DML_TENSOR_DATA_TYPE = enum(i32) { UNKNOWN = 0, FLOAT32 = 1, FLOAT16 = 2, UINT32 = 3, UINT16 = 4, UINT8 = 5, INT32 = 6, INT16 = 7, INT8 = 8, FLOAT64 = 9, UINT64 = 10, INT64 = 11, }; pub const DML_TENSOR_DATA_TYPE_UNKNOWN = DML_TENSOR_DATA_TYPE.UNKNOWN; pub const DML_TENSOR_DATA_TYPE_FLOAT32 = DML_TENSOR_DATA_TYPE.FLOAT32; pub const DML_TENSOR_DATA_TYPE_FLOAT16 = DML_TENSOR_DATA_TYPE.FLOAT16; pub const DML_TENSOR_DATA_TYPE_UINT32 = DML_TENSOR_DATA_TYPE.UINT32; pub const DML_TENSOR_DATA_TYPE_UINT16 = DML_TENSOR_DATA_TYPE.UINT16; pub const DML_TENSOR_DATA_TYPE_UINT8 = DML_TENSOR_DATA_TYPE.UINT8; pub const DML_TENSOR_DATA_TYPE_INT32 = DML_TENSOR_DATA_TYPE.INT32; pub const DML_TENSOR_DATA_TYPE_INT16 = DML_TENSOR_DATA_TYPE.INT16; pub const DML_TENSOR_DATA_TYPE_INT8 = DML_TENSOR_DATA_TYPE.INT8; pub const DML_TENSOR_DATA_TYPE_FLOAT64 = DML_TENSOR_DATA_TYPE.FLOAT64; pub const DML_TENSOR_DATA_TYPE_UINT64 = DML_TENSOR_DATA_TYPE.UINT64; pub const DML_TENSOR_DATA_TYPE_INT64 = DML_TENSOR_DATA_TYPE.INT64; pub const DML_TENSOR_TYPE = enum(i32) { INVALID = 0, BUFFER = 1, }; pub const DML_TENSOR_TYPE_INVALID = DML_TENSOR_TYPE.INVALID; pub const DML_TENSOR_TYPE_BUFFER = DML_TENSOR_TYPE.BUFFER; pub const DML_TENSOR_FLAGS = enum(u32) { NONE = 0, OWNED_BY_DML = 1, _, pub fn initFlags(o: struct { NONE: u1 = 0, OWNED_BY_DML: u1 = 0, }) DML_TENSOR_FLAGS { return @intToEnum(DML_TENSOR_FLAGS, (if (o.NONE == 1) @enumToInt(DML_TENSOR_FLAGS.NONE) else 0) | (if (o.OWNED_BY_DML == 1) @enumToInt(DML_TENSOR_FLAGS.OWNED_BY_DML) else 0) ); } }; pub const DML_TENSOR_FLAG_NONE = DML_TENSOR_FLAGS.NONE; pub const DML_TENSOR_FLAG_OWNED_BY_DML = DML_TENSOR_FLAGS.OWNED_BY_DML; pub const DML_BUFFER_TENSOR_DESC = extern struct { DataType: DML_TENSOR_DATA_TYPE, Flags: DML_TENSOR_FLAGS, DimensionCount: u32, Sizes: ?*const u32, Strides: ?*const u32, TotalTensorSizeInBytes: u64, GuaranteedBaseOffsetAlignment: u32, }; pub const DML_TENSOR_DESC = extern struct { Type: DML_TENSOR_TYPE, Desc: ?*const anyopaque, }; pub const DML_OPERATOR_TYPE = enum(i32) { INVALID = 0, ELEMENT_WISE_IDENTITY = 1, ELEMENT_WISE_ABS = 2, ELEMENT_WISE_ACOS = 3, ELEMENT_WISE_ADD = 4, ELEMENT_WISE_ASIN = 5, ELEMENT_WISE_ATAN = 6, ELEMENT_WISE_CEIL = 7, ELEMENT_WISE_CLIP = 8, ELEMENT_WISE_COS = 9, ELEMENT_WISE_DIVIDE = 10, ELEMENT_WISE_EXP = 11, ELEMENT_WISE_FLOOR = 12, ELEMENT_WISE_LOG = 13, ELEMENT_WISE_LOGICAL_AND = 14, ELEMENT_WISE_LOGICAL_EQUALS = 15, ELEMENT_WISE_LOGICAL_GREATER_THAN = 16, ELEMENT_WISE_LOGICAL_LESS_THAN = 17, ELEMENT_WISE_LOGICAL_NOT = 18, ELEMENT_WISE_LOGICAL_OR = 19, ELEMENT_WISE_LOGICAL_XOR = 20, ELEMENT_WISE_MAX = 21, ELEMENT_WISE_MEAN = 22, ELEMENT_WISE_MIN = 23, ELEMENT_WISE_MULTIPLY = 24, ELEMENT_WISE_POW = 25, ELEMENT_WISE_CONSTANT_POW = 26, ELEMENT_WISE_RECIP = 27, ELEMENT_WISE_SIN = 28, ELEMENT_WISE_SQRT = 29, ELEMENT_WISE_SUBTRACT = 30, ELEMENT_WISE_TAN = 31, ELEMENT_WISE_THRESHOLD = 32, ELEMENT_WISE_QUANTIZE_LINEAR = 33, ELEMENT_WISE_DEQUANTIZE_LINEAR = 34, ACTIVATION_ELU = 35, ACTIVATION_HARDMAX = 36, ACTIVATION_HARD_SIGMOID = 37, ACTIVATION_IDENTITY = 38, ACTIVATION_LEAKY_RELU = 39, ACTIVATION_LINEAR = 40, ACTIVATION_LOG_SOFTMAX = 41, ACTIVATION_PARAMETERIZED_RELU = 42, ACTIVATION_PARAMETRIC_SOFTPLUS = 43, ACTIVATION_RELU = 44, ACTIVATION_SCALED_ELU = 45, ACTIVATION_SCALED_TANH = 46, ACTIVATION_SIGMOID = 47, ACTIVATION_SOFTMAX = 48, ACTIVATION_SOFTPLUS = 49, ACTIVATION_SOFTSIGN = 50, ACTIVATION_TANH = 51, ACTIVATION_THRESHOLDED_RELU = 52, CONVOLUTION = 53, GEMM = 54, REDUCE = 55, AVERAGE_POOLING = 56, LP_POOLING = 57, MAX_POOLING = 58, ROI_POOLING = 59, SLICE = 60, CAST = 61, SPLIT = 62, JOIN = 63, PADDING = 64, VALUE_SCALE_2D = 65, UPSAMPLE_2D = 66, GATHER = 67, SPACE_TO_DEPTH = 68, DEPTH_TO_SPACE = 69, TILE = 70, TOP_K = 71, BATCH_NORMALIZATION = 72, MEAN_VARIANCE_NORMALIZATION = 73, LOCAL_RESPONSE_NORMALIZATION = 74, LP_NORMALIZATION = 75, RNN = 76, LSTM = 77, GRU = 78, ELEMENT_WISE_SIGN = 79, ELEMENT_WISE_IS_NAN = 80, ELEMENT_WISE_ERF = 81, ELEMENT_WISE_SINH = 82, ELEMENT_WISE_COSH = 83, ELEMENT_WISE_TANH = 84, ELEMENT_WISE_ASINH = 85, ELEMENT_WISE_ACOSH = 86, ELEMENT_WISE_ATANH = 87, ELEMENT_WISE_IF = 88, ELEMENT_WISE_ADD1 = 89, ACTIVATION_SHRINK = 90, MAX_POOLING1 = 91, MAX_UNPOOLING = 92, DIAGONAL_MATRIX = 93, SCATTER_ELEMENTS = 94, // SCATTER = 94, this enum value conflicts with SCATTER_ELEMENTS ONE_HOT = 95, RESAMPLE = 96, ELEMENT_WISE_BIT_SHIFT_LEFT = 97, ELEMENT_WISE_BIT_SHIFT_RIGHT = 98, ELEMENT_WISE_ROUND = 99, ELEMENT_WISE_IS_INFINITY = 100, ELEMENT_WISE_MODULUS_TRUNCATE = 101, ELEMENT_WISE_MODULUS_FLOOR = 102, FILL_VALUE_CONSTANT = 103, FILL_VALUE_SEQUENCE = 104, CUMULATIVE_SUMMATION = 105, REVERSE_SUBSEQUENCES = 106, GATHER_ELEMENTS = 107, GATHER_ND = 108, SCATTER_ND = 109, MAX_POOLING2 = 110, SLICE1 = 111, TOP_K1 = 112, DEPTH_TO_SPACE1 = 113, SPACE_TO_DEPTH1 = 114, MEAN_VARIANCE_NORMALIZATION1 = 115, RESAMPLE1 = 116, MATRIX_MULTIPLY_INTEGER = 117, QUANTIZED_LINEAR_MATRIX_MULTIPLY = 118, CONVOLUTION_INTEGER = 119, QUANTIZED_LINEAR_CONVOLUTION = 120, ELEMENT_WISE_BIT_AND = 121, ELEMENT_WISE_BIT_OR = 122, ELEMENT_WISE_BIT_XOR = 123, ELEMENT_WISE_BIT_NOT = 124, ELEMENT_WISE_BIT_COUNT = 125, ELEMENT_WISE_LOGICAL_GREATER_THAN_OR_EQUAL = 126, ELEMENT_WISE_LOGICAL_LESS_THAN_OR_EQUAL = 127, ACTIVATION_CELU = 128, ACTIVATION_RELU_GRAD = 129, AVERAGE_POOLING_GRAD = 130, MAX_POOLING_GRAD = 131, RANDOM_GENERATOR = 132, NONZERO_COORDINATES = 133, RESAMPLE_GRAD = 134, SLICE_GRAD = 135, ADAM_OPTIMIZER = 136, ARGMIN = 137, ARGMAX = 138, ROI_ALIGN = 139, GATHER_ND1 = 140, ELEMENT_WISE_ATAN_YX = 141, ELEMENT_WISE_CLIP_GRAD = 142, ELEMENT_WISE_DIFFERENCE_SQUARE = 143, LOCAL_RESPONSE_NORMALIZATION_GRAD = 144, CUMULATIVE_PRODUCT = 145, BATCH_NORMALIZATION_GRAD = 146, ELEMENT_WISE_QUANTIZED_LINEAR_ADD = 147, DYNAMIC_QUANTIZE_LINEAR = 148, ROI_ALIGN1 = 149, }; pub const DML_OPERATOR_INVALID = DML_OPERATOR_TYPE.INVALID; pub const DML_OPERATOR_ELEMENT_WISE_IDENTITY = DML_OPERATOR_TYPE.ELEMENT_WISE_IDENTITY; pub const DML_OPERATOR_ELEMENT_WISE_ABS = DML_OPERATOR_TYPE.ELEMENT_WISE_ABS; pub const DML_OPERATOR_ELEMENT_WISE_ACOS = DML_OPERATOR_TYPE.ELEMENT_WISE_ACOS; pub const DML_OPERATOR_ELEMENT_WISE_ADD = DML_OPERATOR_TYPE.ELEMENT_WISE_ADD; pub const DML_OPERATOR_ELEMENT_WISE_ASIN = DML_OPERATOR_TYPE.ELEMENT_WISE_ASIN; pub const DML_OPERATOR_ELEMENT_WISE_ATAN = DML_OPERATOR_TYPE.ELEMENT_WISE_ATAN; pub const DML_OPERATOR_ELEMENT_WISE_CEIL = DML_OPERATOR_TYPE.ELEMENT_WISE_CEIL; pub const DML_OPERATOR_ELEMENT_WISE_CLIP = DML_OPERATOR_TYPE.ELEMENT_WISE_CLIP; pub const DML_OPERATOR_ELEMENT_WISE_COS = DML_OPERATOR_TYPE.ELEMENT_WISE_COS; pub const DML_OPERATOR_ELEMENT_WISE_DIVIDE = DML_OPERATOR_TYPE.ELEMENT_WISE_DIVIDE; pub const DML_OPERATOR_ELEMENT_WISE_EXP = DML_OPERATOR_TYPE.ELEMENT_WISE_EXP; pub const DML_OPERATOR_ELEMENT_WISE_FLOOR = DML_OPERATOR_TYPE.ELEMENT_WISE_FLOOR; pub const DML_OPERATOR_ELEMENT_WISE_LOG = DML_OPERATOR_TYPE.ELEMENT_WISE_LOG; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_AND = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_AND; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_EQUALS = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_EQUALS; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_GREATER_THAN = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_GREATER_THAN; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_LESS_THAN = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_LESS_THAN; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_NOT = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_NOT; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_OR = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_OR; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_XOR = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_XOR; pub const DML_OPERATOR_ELEMENT_WISE_MAX = DML_OPERATOR_TYPE.ELEMENT_WISE_MAX; pub const DML_OPERATOR_ELEMENT_WISE_MEAN = DML_OPERATOR_TYPE.ELEMENT_WISE_MEAN; pub const DML_OPERATOR_ELEMENT_WISE_MIN = DML_OPERATOR_TYPE.ELEMENT_WISE_MIN; pub const DML_OPERATOR_ELEMENT_WISE_MULTIPLY = DML_OPERATOR_TYPE.ELEMENT_WISE_MULTIPLY; pub const DML_OPERATOR_ELEMENT_WISE_POW = DML_OPERATOR_TYPE.ELEMENT_WISE_POW; pub const DML_OPERATOR_ELEMENT_WISE_CONSTANT_POW = DML_OPERATOR_TYPE.ELEMENT_WISE_CONSTANT_POW; pub const DML_OPERATOR_ELEMENT_WISE_RECIP = DML_OPERATOR_TYPE.ELEMENT_WISE_RECIP; pub const DML_OPERATOR_ELEMENT_WISE_SIN = DML_OPERATOR_TYPE.ELEMENT_WISE_SIN; pub const DML_OPERATOR_ELEMENT_WISE_SQRT = DML_OPERATOR_TYPE.ELEMENT_WISE_SQRT; pub const DML_OPERATOR_ELEMENT_WISE_SUBTRACT = DML_OPERATOR_TYPE.ELEMENT_WISE_SUBTRACT; pub const DML_OPERATOR_ELEMENT_WISE_TAN = DML_OPERATOR_TYPE.ELEMENT_WISE_TAN; pub const DML_OPERATOR_ELEMENT_WISE_THRESHOLD = DML_OPERATOR_TYPE.ELEMENT_WISE_THRESHOLD; pub const DML_OPERATOR_ELEMENT_WISE_QUANTIZE_LINEAR = DML_OPERATOR_TYPE.ELEMENT_WISE_QUANTIZE_LINEAR; pub const DML_OPERATOR_ELEMENT_WISE_DEQUANTIZE_LINEAR = DML_OPERATOR_TYPE.ELEMENT_WISE_DEQUANTIZE_LINEAR; pub const DML_OPERATOR_ACTIVATION_ELU = DML_OPERATOR_TYPE.ACTIVATION_ELU; pub const DML_OPERATOR_ACTIVATION_HARDMAX = DML_OPERATOR_TYPE.ACTIVATION_HARDMAX; pub const DML_OPERATOR_ACTIVATION_HARD_SIGMOID = DML_OPERATOR_TYPE.ACTIVATION_HARD_SIGMOID; pub const DML_OPERATOR_ACTIVATION_IDENTITY = DML_OPERATOR_TYPE.ACTIVATION_IDENTITY; pub const DML_OPERATOR_ACTIVATION_LEAKY_RELU = DML_OPERATOR_TYPE.ACTIVATION_LEAKY_RELU; pub const DML_OPERATOR_ACTIVATION_LINEAR = DML_OPERATOR_TYPE.ACTIVATION_LINEAR; pub const DML_OPERATOR_ACTIVATION_LOG_SOFTMAX = DML_OPERATOR_TYPE.ACTIVATION_LOG_SOFTMAX; pub const DML_OPERATOR_ACTIVATION_PARAMETERIZED_RELU = DML_OPERATOR_TYPE.ACTIVATION_PARAMETERIZED_RELU; pub const DML_OPERATOR_ACTIVATION_PARAMETRIC_SOFTPLUS = DML_OPERATOR_TYPE.ACTIVATION_PARAMETRIC_SOFTPLUS; pub const DML_OPERATOR_ACTIVATION_RELU = DML_OPERATOR_TYPE.ACTIVATION_RELU; pub const DML_OPERATOR_ACTIVATION_SCALED_ELU = DML_OPERATOR_TYPE.ACTIVATION_SCALED_ELU; pub const DML_OPERATOR_ACTIVATION_SCALED_TANH = DML_OPERATOR_TYPE.ACTIVATION_SCALED_TANH; pub const DML_OPERATOR_ACTIVATION_SIGMOID = DML_OPERATOR_TYPE.ACTIVATION_SIGMOID; pub const DML_OPERATOR_ACTIVATION_SOFTMAX = DML_OPERATOR_TYPE.ACTIVATION_SOFTMAX; pub const DML_OPERATOR_ACTIVATION_SOFTPLUS = DML_OPERATOR_TYPE.ACTIVATION_SOFTPLUS; pub const DML_OPERATOR_ACTIVATION_SOFTSIGN = DML_OPERATOR_TYPE.ACTIVATION_SOFTSIGN; pub const DML_OPERATOR_ACTIVATION_TANH = DML_OPERATOR_TYPE.ACTIVATION_TANH; pub const DML_OPERATOR_ACTIVATION_THRESHOLDED_RELU = DML_OPERATOR_TYPE.ACTIVATION_THRESHOLDED_RELU; pub const DML_OPERATOR_CONVOLUTION = DML_OPERATOR_TYPE.CONVOLUTION; pub const DML_OPERATOR_GEMM = DML_OPERATOR_TYPE.GEMM; pub const DML_OPERATOR_REDUCE = DML_OPERATOR_TYPE.REDUCE; pub const DML_OPERATOR_AVERAGE_POOLING = DML_OPERATOR_TYPE.AVERAGE_POOLING; pub const DML_OPERATOR_LP_POOLING = DML_OPERATOR_TYPE.LP_POOLING; pub const DML_OPERATOR_MAX_POOLING = DML_OPERATOR_TYPE.MAX_POOLING; pub const DML_OPERATOR_ROI_POOLING = DML_OPERATOR_TYPE.ROI_POOLING; pub const DML_OPERATOR_SLICE = DML_OPERATOR_TYPE.SLICE; pub const DML_OPERATOR_CAST = DML_OPERATOR_TYPE.CAST; pub const DML_OPERATOR_SPLIT = DML_OPERATOR_TYPE.SPLIT; pub const DML_OPERATOR_JOIN = DML_OPERATOR_TYPE.JOIN; pub const DML_OPERATOR_PADDING = DML_OPERATOR_TYPE.PADDING; pub const DML_OPERATOR_VALUE_SCALE_2D = DML_OPERATOR_TYPE.VALUE_SCALE_2D; pub const DML_OPERATOR_UPSAMPLE_2D = DML_OPERATOR_TYPE.UPSAMPLE_2D; pub const DML_OPERATOR_GATHER = DML_OPERATOR_TYPE.GATHER; pub const DML_OPERATOR_SPACE_TO_DEPTH = DML_OPERATOR_TYPE.SPACE_TO_DEPTH; pub const DML_OPERATOR_DEPTH_TO_SPACE = DML_OPERATOR_TYPE.DEPTH_TO_SPACE; pub const DML_OPERATOR_TILE = DML_OPERATOR_TYPE.TILE; pub const DML_OPERATOR_TOP_K = DML_OPERATOR_TYPE.TOP_K; pub const DML_OPERATOR_BATCH_NORMALIZATION = DML_OPERATOR_TYPE.BATCH_NORMALIZATION; pub const DML_OPERATOR_MEAN_VARIANCE_NORMALIZATION = DML_OPERATOR_TYPE.MEAN_VARIANCE_NORMALIZATION; pub const DML_OPERATOR_LOCAL_RESPONSE_NORMALIZATION = DML_OPERATOR_TYPE.LOCAL_RESPONSE_NORMALIZATION; pub const DML_OPERATOR_LP_NORMALIZATION = DML_OPERATOR_TYPE.LP_NORMALIZATION; pub const DML_OPERATOR_RNN = DML_OPERATOR_TYPE.RNN; pub const DML_OPERATOR_LSTM = DML_OPERATOR_TYPE.LSTM; pub const DML_OPERATOR_GRU = DML_OPERATOR_TYPE.GRU; pub const DML_OPERATOR_ELEMENT_WISE_SIGN = DML_OPERATOR_TYPE.ELEMENT_WISE_SIGN; pub const DML_OPERATOR_ELEMENT_WISE_IS_NAN = DML_OPERATOR_TYPE.ELEMENT_WISE_IS_NAN; pub const DML_OPERATOR_ELEMENT_WISE_ERF = DML_OPERATOR_TYPE.ELEMENT_WISE_ERF; pub const DML_OPERATOR_ELEMENT_WISE_SINH = DML_OPERATOR_TYPE.ELEMENT_WISE_SINH; pub const DML_OPERATOR_ELEMENT_WISE_COSH = DML_OPERATOR_TYPE.ELEMENT_WISE_COSH; pub const DML_OPERATOR_ELEMENT_WISE_TANH = DML_OPERATOR_TYPE.ELEMENT_WISE_TANH; pub const DML_OPERATOR_ELEMENT_WISE_ASINH = DML_OPERATOR_TYPE.ELEMENT_WISE_ASINH; pub const DML_OPERATOR_ELEMENT_WISE_ACOSH = DML_OPERATOR_TYPE.ELEMENT_WISE_ACOSH; pub const DML_OPERATOR_ELEMENT_WISE_ATANH = DML_OPERATOR_TYPE.ELEMENT_WISE_ATANH; pub const DML_OPERATOR_ELEMENT_WISE_IF = DML_OPERATOR_TYPE.ELEMENT_WISE_IF; pub const DML_OPERATOR_ELEMENT_WISE_ADD1 = DML_OPERATOR_TYPE.ELEMENT_WISE_ADD1; pub const DML_OPERATOR_ACTIVATION_SHRINK = DML_OPERATOR_TYPE.ACTIVATION_SHRINK; pub const DML_OPERATOR_MAX_POOLING1 = DML_OPERATOR_TYPE.MAX_POOLING1; pub const DML_OPERATOR_MAX_UNPOOLING = DML_OPERATOR_TYPE.MAX_UNPOOLING; pub const DML_OPERATOR_DIAGONAL_MATRIX = DML_OPERATOR_TYPE.DIAGONAL_MATRIX; pub const DML_OPERATOR_SCATTER_ELEMENTS = DML_OPERATOR_TYPE.SCATTER_ELEMENTS; pub const DML_OPERATOR_SCATTER = DML_OPERATOR_TYPE.SCATTER_ELEMENTS; pub const DML_OPERATOR_ONE_HOT = DML_OPERATOR_TYPE.ONE_HOT; pub const DML_OPERATOR_RESAMPLE = DML_OPERATOR_TYPE.RESAMPLE; pub const DML_OPERATOR_ELEMENT_WISE_BIT_SHIFT_LEFT = DML_OPERATOR_TYPE.ELEMENT_WISE_BIT_SHIFT_LEFT; pub const DML_OPERATOR_ELEMENT_WISE_BIT_SHIFT_RIGHT = DML_OPERATOR_TYPE.ELEMENT_WISE_BIT_SHIFT_RIGHT; pub const DML_OPERATOR_ELEMENT_WISE_ROUND = DML_OPERATOR_TYPE.ELEMENT_WISE_ROUND; pub const DML_OPERATOR_ELEMENT_WISE_IS_INFINITY = DML_OPERATOR_TYPE.ELEMENT_WISE_IS_INFINITY; pub const DML_OPERATOR_ELEMENT_WISE_MODULUS_TRUNCATE = DML_OPERATOR_TYPE.ELEMENT_WISE_MODULUS_TRUNCATE; pub const DML_OPERATOR_ELEMENT_WISE_MODULUS_FLOOR = DML_OPERATOR_TYPE.ELEMENT_WISE_MODULUS_FLOOR; pub const DML_OPERATOR_FILL_VALUE_CONSTANT = DML_OPERATOR_TYPE.FILL_VALUE_CONSTANT; pub const DML_OPERATOR_FILL_VALUE_SEQUENCE = DML_OPERATOR_TYPE.FILL_VALUE_SEQUENCE; pub const DML_OPERATOR_CUMULATIVE_SUMMATION = DML_OPERATOR_TYPE.CUMULATIVE_SUMMATION; pub const DML_OPERATOR_REVERSE_SUBSEQUENCES = DML_OPERATOR_TYPE.REVERSE_SUBSEQUENCES; pub const DML_OPERATOR_GATHER_ELEMENTS = DML_OPERATOR_TYPE.GATHER_ELEMENTS; pub const DML_OPERATOR_GATHER_ND = DML_OPERATOR_TYPE.GATHER_ND; pub const DML_OPERATOR_SCATTER_ND = DML_OPERATOR_TYPE.SCATTER_ND; pub const DML_OPERATOR_MAX_POOLING2 = DML_OPERATOR_TYPE.MAX_POOLING2; pub const DML_OPERATOR_SLICE1 = DML_OPERATOR_TYPE.SLICE1; pub const DML_OPERATOR_TOP_K1 = DML_OPERATOR_TYPE.TOP_K1; pub const DML_OPERATOR_DEPTH_TO_SPACE1 = DML_OPERATOR_TYPE.DEPTH_TO_SPACE1; pub const DML_OPERATOR_SPACE_TO_DEPTH1 = DML_OPERATOR_TYPE.SPACE_TO_DEPTH1; pub const DML_OPERATOR_MEAN_VARIANCE_NORMALIZATION1 = DML_OPERATOR_TYPE.MEAN_VARIANCE_NORMALIZATION1; pub const DML_OPERATOR_RESAMPLE1 = DML_OPERATOR_TYPE.RESAMPLE1; pub const DML_OPERATOR_MATRIX_MULTIPLY_INTEGER = DML_OPERATOR_TYPE.MATRIX_MULTIPLY_INTEGER; pub const DML_OPERATOR_QUANTIZED_LINEAR_MATRIX_MULTIPLY = DML_OPERATOR_TYPE.QUANTIZED_LINEAR_MATRIX_MULTIPLY; pub const DML_OPERATOR_CONVOLUTION_INTEGER = DML_OPERATOR_TYPE.CONVOLUTION_INTEGER; pub const DML_OPERATOR_QUANTIZED_LINEAR_CONVOLUTION = DML_OPERATOR_TYPE.QUANTIZED_LINEAR_CONVOLUTION; pub const DML_OPERATOR_ELEMENT_WISE_BIT_AND = DML_OPERATOR_TYPE.ELEMENT_WISE_BIT_AND; pub const DML_OPERATOR_ELEMENT_WISE_BIT_OR = DML_OPERATOR_TYPE.ELEMENT_WISE_BIT_OR; pub const DML_OPERATOR_ELEMENT_WISE_BIT_XOR = DML_OPERATOR_TYPE.ELEMENT_WISE_BIT_XOR; pub const DML_OPERATOR_ELEMENT_WISE_BIT_NOT = DML_OPERATOR_TYPE.ELEMENT_WISE_BIT_NOT; pub const DML_OPERATOR_ELEMENT_WISE_BIT_COUNT = DML_OPERATOR_TYPE.ELEMENT_WISE_BIT_COUNT; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_GREATER_THAN_OR_EQUAL = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_GREATER_THAN_OR_EQUAL; pub const DML_OPERATOR_ELEMENT_WISE_LOGICAL_LESS_THAN_OR_EQUAL = DML_OPERATOR_TYPE.ELEMENT_WISE_LOGICAL_LESS_THAN_OR_EQUAL; pub const DML_OPERATOR_ACTIVATION_CELU = DML_OPERATOR_TYPE.ACTIVATION_CELU; pub const DML_OPERATOR_ACTIVATION_RELU_GRAD = DML_OPERATOR_TYPE.ACTIVATION_RELU_GRAD; pub const DML_OPERATOR_AVERAGE_POOLING_GRAD = DML_OPERATOR_TYPE.AVERAGE_POOLING_GRAD; pub const DML_OPERATOR_MAX_POOLING_GRAD = DML_OPERATOR_TYPE.MAX_POOLING_GRAD; pub const DML_OPERATOR_RANDOM_GENERATOR = DML_OPERATOR_TYPE.RANDOM_GENERATOR; pub const DML_OPERATOR_NONZERO_COORDINATES = DML_OPERATOR_TYPE.NONZERO_COORDINATES; pub const DML_OPERATOR_RESAMPLE_GRAD = DML_OPERATOR_TYPE.RESAMPLE_GRAD; pub const DML_OPERATOR_SLICE_GRAD = DML_OPERATOR_TYPE.SLICE_GRAD; pub const DML_OPERATOR_ADAM_OPTIMIZER = DML_OPERATOR_TYPE.ADAM_OPTIMIZER; pub const DML_OPERATOR_ARGMIN = DML_OPERATOR_TYPE.ARGMIN; pub const DML_OPERATOR_ARGMAX = DML_OPERATOR_TYPE.ARGMAX; pub const DML_OPERATOR_ROI_ALIGN = DML_OPERATOR_TYPE.ROI_ALIGN; pub const DML_OPERATOR_GATHER_ND1 = DML_OPERATOR_TYPE.GATHER_ND1; pub const DML_OPERATOR_ELEMENT_WISE_ATAN_YX = DML_OPERATOR_TYPE.ELEMENT_WISE_ATAN_YX; pub const DML_OPERATOR_ELEMENT_WISE_CLIP_GRAD = DML_OPERATOR_TYPE.ELEMENT_WISE_CLIP_GRAD; pub const DML_OPERATOR_ELEMENT_WISE_DIFFERENCE_SQUARE = DML_OPERATOR_TYPE.ELEMENT_WISE_DIFFERENCE_SQUARE; pub const DML_OPERATOR_LOCAL_RESPONSE_NORMALIZATION_GRAD = DML_OPERATOR_TYPE.LOCAL_RESPONSE_NORMALIZATION_GRAD; pub const DML_OPERATOR_CUMULATIVE_PRODUCT = DML_OPERATOR_TYPE.CUMULATIVE_PRODUCT; pub const DML_OPERATOR_BATCH_NORMALIZATION_GRAD = DML_OPERATOR_TYPE.BATCH_NORMALIZATION_GRAD; pub const DML_OPERATOR_ELEMENT_WISE_QUANTIZED_LINEAR_ADD = DML_OPERATOR_TYPE.ELEMENT_WISE_QUANTIZED_LINEAR_ADD; pub const DML_OPERATOR_DYNAMIC_QUANTIZE_LINEAR = DML_OPERATOR_TYPE.DYNAMIC_QUANTIZE_LINEAR; pub const DML_OPERATOR_ROI_ALIGN1 = DML_OPERATOR_TYPE.ROI_ALIGN1; pub const DML_REDUCE_FUNCTION = enum(i32) { ARGMAX = 0, ARGMIN = 1, AVERAGE = 2, L1 = 3, L2 = 4, LOG_SUM = 5, LOG_SUM_EXP = 6, MAX = 7, MIN = 8, MULTIPLY = 9, SUM = 10, SUM_SQUARE = 11, }; pub const DML_REDUCE_FUNCTION_ARGMAX = DML_REDUCE_FUNCTION.ARGMAX; pub const DML_REDUCE_FUNCTION_ARGMIN = DML_REDUCE_FUNCTION.ARGMIN; pub const DML_REDUCE_FUNCTION_AVERAGE = DML_REDUCE_FUNCTION.AVERAGE; pub const DML_REDUCE_FUNCTION_L1 = DML_REDUCE_FUNCTION.L1; pub const DML_REDUCE_FUNCTION_L2 = DML_REDUCE_FUNCTION.L2; pub const DML_REDUCE_FUNCTION_LOG_SUM = DML_REDUCE_FUNCTION.LOG_SUM; pub const DML_REDUCE_FUNCTION_LOG_SUM_EXP = DML_REDUCE_FUNCTION.LOG_SUM_EXP; pub const DML_REDUCE_FUNCTION_MAX = DML_REDUCE_FUNCTION.MAX; pub const DML_REDUCE_FUNCTION_MIN = DML_REDUCE_FUNCTION.MIN; pub const DML_REDUCE_FUNCTION_MULTIPLY = DML_REDUCE_FUNCTION.MULTIPLY; pub const DML_REDUCE_FUNCTION_SUM = DML_REDUCE_FUNCTION.SUM; pub const DML_REDUCE_FUNCTION_SUM_SQUARE = DML_REDUCE_FUNCTION.SUM_SQUARE; pub const DML_MATRIX_TRANSFORM = enum(i32) { NONE = 0, TRANSPOSE = 1, }; pub const DML_MATRIX_TRANSFORM_NONE = DML_MATRIX_TRANSFORM.NONE; pub const DML_MATRIX_TRANSFORM_TRANSPOSE = DML_MATRIX_TRANSFORM.TRANSPOSE; pub const DML_CONVOLUTION_MODE = enum(i32) { ONVOLUTION = 0, ROSS_CORRELATION = 1, }; pub const DML_CONVOLUTION_MODE_CONVOLUTION = DML_CONVOLUTION_MODE.ONVOLUTION; pub const DML_CONVOLUTION_MODE_CROSS_CORRELATION = DML_CONVOLUTION_MODE.ROSS_CORRELATION; pub const DML_CONVOLUTION_DIRECTION = enum(i32) { FORWARD = 0, BACKWARD = 1, }; pub const DML_CONVOLUTION_DIRECTION_FORWARD = DML_CONVOLUTION_DIRECTION.FORWARD; pub const DML_CONVOLUTION_DIRECTION_BACKWARD = DML_CONVOLUTION_DIRECTION.BACKWARD; pub const DML_PADDING_MODE = enum(i32) { CONSTANT = 0, EDGE = 1, REFLECTION = 2, SYMMETRIC = 3, }; pub const DML_PADDING_MODE_CONSTANT = DML_PADDING_MODE.CONSTANT; pub const DML_PADDING_MODE_EDGE = DML_PADDING_MODE.EDGE; pub const DML_PADDING_MODE_REFLECTION = DML_PADDING_MODE.REFLECTION; pub const DML_PADDING_MODE_SYMMETRIC = DML_PADDING_MODE.SYMMETRIC; pub const DML_INTERPOLATION_MODE = enum(i32) { NEAREST_NEIGHBOR = 0, LINEAR = 1, }; pub const DML_INTERPOLATION_MODE_NEAREST_NEIGHBOR = DML_INTERPOLATION_MODE.NEAREST_NEIGHBOR; pub const DML_INTERPOLATION_MODE_LINEAR = DML_INTERPOLATION_MODE.LINEAR; pub const DML_SCALE_BIAS = extern struct { Scale: f32, Bias: f32, }; pub const DML_SIZE_2D = extern struct { Width: u32, Height: u32, }; pub const DML_RECURRENT_NETWORK_DIRECTION = enum(i32) { FORWARD = 0, BACKWARD = 1, BIDIRECTIONAL = 2, }; pub const DML_RECURRENT_NETWORK_DIRECTION_FORWARD = DML_RECURRENT_NETWORK_DIRECTION.FORWARD; pub const DML_RECURRENT_NETWORK_DIRECTION_BACKWARD = DML_RECURRENT_NETWORK_DIRECTION.BACKWARD; pub const DML_RECURRENT_NETWORK_DIRECTION_BIDIRECTIONAL = DML_RECURRENT_NETWORK_DIRECTION.BIDIRECTIONAL; pub const DML_ROUNDING_MODE = enum(i32) { HALVES_TO_NEAREST_EVEN = 0, TOWARD_ZERO = 1, TOWARD_INFINITY = 2, }; pub const DML_ROUNDING_MODE_HALVES_TO_NEAREST_EVEN = DML_ROUNDING_MODE.HALVES_TO_NEAREST_EVEN; pub const DML_ROUNDING_MODE_TOWARD_ZERO = DML_ROUNDING_MODE.TOWARD_ZERO; pub const DML_ROUNDING_MODE_TOWARD_INFINITY = DML_ROUNDING_MODE.TOWARD_INFINITY; pub const DML_IS_INFINITY_MODE = enum(i32) { EITHER = 0, POSITIVE = 1, NEGATIVE = 2, }; pub const DML_IS_INFINITY_MODE_EITHER = DML_IS_INFINITY_MODE.EITHER; pub const DML_IS_INFINITY_MODE_POSITIVE = DML_IS_INFINITY_MODE.POSITIVE; pub const DML_IS_INFINITY_MODE_NEGATIVE = DML_IS_INFINITY_MODE.NEGATIVE; pub const DML_AXIS_DIRECTION = enum(i32) { INCREASING = 0, DECREASING = 1, }; pub const DML_AXIS_DIRECTION_INCREASING = DML_AXIS_DIRECTION.INCREASING; pub const DML_AXIS_DIRECTION_DECREASING = DML_AXIS_DIRECTION.DECREASING; pub const DML_DEPTH_SPACE_ORDER = enum(i32) { DEPTH_COLUMN_ROW = 0, COLUMN_ROW_DEPTH = 1, }; pub const DML_DEPTH_SPACE_ORDER_DEPTH_COLUMN_ROW = DML_DEPTH_SPACE_ORDER.DEPTH_COLUMN_ROW; pub const DML_DEPTH_SPACE_ORDER_COLUMN_ROW_DEPTH = DML_DEPTH_SPACE_ORDER.COLUMN_ROW_DEPTH; pub const DML_SCALAR_UNION = extern union { Bytes: [8]u8, Int8: i8, UInt8: u8, Int16: i16, UInt16: u16, Int32: i32, UInt32: u32, Int64: i64, UInt64: u64, Float32: f32, Float64: f64, }; pub const DML_RANDOM_GENERATOR_TYPE = enum(i32) { @"0" = 0, }; pub const DML_RANDOM_GENERATOR_TYPE_PHILOX_4X32_10 = DML_RANDOM_GENERATOR_TYPE.@"0"; pub const DML_OPERATOR_DESC = extern struct { Type: DML_OPERATOR_TYPE, Desc: ?*const anyopaque, }; pub const DML_ELEMENT_WISE_IDENTITY_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_ABS_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_ACOS_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_ADD_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_ADD1_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, FusedActivation: ?*const DML_OPERATOR_DESC, }; pub const DML_ELEMENT_WISE_ASIN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_ATAN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_CEIL_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_CLIP_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, Min: f32, Max: f32, }; pub const DML_ELEMENT_WISE_COS_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_DIVIDE_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_EXP_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_FLOOR_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_LOG_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_LOGICAL_AND_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_LOGICAL_EQUALS_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_LOGICAL_GREATER_THAN_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_LOGICAL_LESS_THAN_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_LOGICAL_NOT_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_LOGICAL_OR_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_LOGICAL_XOR_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_MAX_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_MEAN_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_MIN_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_MULTIPLY_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_POW_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, ExponentTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_CONSTANT_POW_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, Exponent: f32, }; pub const DML_ELEMENT_WISE_RECIP_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_SIN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_SQRT_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_SUBTRACT_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_TAN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_THRESHOLD_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, Min: f32, }; pub const DML_ELEMENT_WISE_QUANTIZE_LINEAR_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, ScaleTensor: ?*const DML_TENSOR_DESC, ZeroPointTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_DEQUANTIZE_LINEAR_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, ScaleTensor: ?*const DML_TENSOR_DESC, ZeroPointTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_ELU_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, }; pub const DML_ACTIVATION_HARDMAX_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_HARD_SIGMOID_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, Beta: f32, }; pub const DML_ACTIVATION_IDENTITY_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_LEAKY_RELU_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, }; pub const DML_ACTIVATION_LINEAR_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, Beta: f32, }; pub const DML_ACTIVATION_LOG_SOFTMAX_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_PARAMETERIZED_RELU_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, SlopeTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_PARAMETRIC_SOFTPLUS_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, Beta: f32, }; pub const DML_ACTIVATION_RELU_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_SCALED_ELU_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, Gamma: f32, }; pub const DML_ACTIVATION_SCALED_TANH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, Beta: f32, }; pub const DML_ACTIVATION_SIGMOID_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_SOFTMAX_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_SOFTPLUS_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Steepness: f32, }; pub const DML_ACTIVATION_SOFTSIGN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_TANH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_THRESHOLDED_RELU_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, }; pub const DML_CONVOLUTION_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, FilterTensor: ?*const DML_TENSOR_DESC, BiasTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Mode: DML_CONVOLUTION_MODE, Direction: DML_CONVOLUTION_DIRECTION, DimensionCount: u32, Strides: ?*const u32, Dilations: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, OutputPadding: ?*const u32, GroupCount: u32, FusedActivation: ?*const DML_OPERATOR_DESC, }; pub const DML_GEMM_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, CTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, TransA: DML_MATRIX_TRANSFORM, TransB: DML_MATRIX_TRANSFORM, Alpha: f32, Beta: f32, FusedActivation: ?*const DML_OPERATOR_DESC, }; pub const DML_REDUCE_OPERATOR_DESC = extern struct { Function: DML_REDUCE_FUNCTION, InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, AxisCount: u32, Axes: ?*const u32, }; pub const DML_AVERAGE_POOLING_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, WindowSize: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, IncludePadding: BOOL, }; pub const DML_LP_POOLING_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, WindowSize: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, P: u32, }; pub const DML_MAX_POOLING_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, WindowSize: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, }; pub const DML_ROI_POOLING_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, ROITensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, SpatialScale: f32, PooledSize: DML_SIZE_2D, }; pub const DML_SLICE_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Offsets: ?*const u32, Sizes: ?*const u32, Strides: ?*const u32, }; pub const DML_CAST_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_SPLIT_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputCount: u32, OutputTensors: ?*const DML_TENSOR_DESC, Axis: u32, }; pub const DML_JOIN_OPERATOR_DESC = extern struct { InputCount: u32, InputTensors: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, }; pub const DML_PADDING_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, PaddingMode: DML_PADDING_MODE, PaddingValue: f32, DimensionCount: u32, StartPadding: ?*const u32, EndPadding: ?*const u32, }; pub const DML_VALUE_SCALE_2D_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Scale: f32, ChannelCount: u32, Bias: ?*const f32, }; pub const DML_UPSAMPLE_2D_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleSize: DML_SIZE_2D, InterpolationMode: DML_INTERPOLATION_MODE, }; pub const DML_GATHER_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, IndicesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, IndexDimensions: u32, }; pub const DML_SPACE_TO_DEPTH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, BlockSize: u32, }; pub const DML_DEPTH_TO_SPACE_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, BlockSize: u32, }; pub const DML_TILE_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, RepeatsCount: u32, Repeats: ?*const u32, }; pub const DML_TOP_K_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputValueTensor: ?*const DML_TENSOR_DESC, OutputIndexTensor: ?*const DML_TENSOR_DESC, Axis: u32, K: u32, }; pub const DML_BATCH_NORMALIZATION_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, MeanTensor: ?*const DML_TENSOR_DESC, VarianceTensor: ?*const DML_TENSOR_DESC, ScaleTensor: ?*const DML_TENSOR_DESC, BiasTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Spatial: BOOL, Epsilon: f32, FusedActivation: ?*const DML_OPERATOR_DESC, }; pub const DML_MEAN_VARIANCE_NORMALIZATION_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, ScaleTensor: ?*const DML_TENSOR_DESC, BiasTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, CrossChannel: BOOL, NormalizeVariance: BOOL, Epsilon: f32, FusedActivation: ?*const DML_OPERATOR_DESC, }; pub const DML_LOCAL_RESPONSE_NORMALIZATION_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, CrossChannel: BOOL, LocalSize: u32, Alpha: f32, Beta: f32, Bias: f32, }; pub const DML_LP_NORMALIZATION_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, Epsilon: f32, P: u32, }; pub const DML_RNN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, WeightTensor: ?*const DML_TENSOR_DESC, RecurrenceTensor: ?*const DML_TENSOR_DESC, BiasTensor: ?*const DML_TENSOR_DESC, HiddenInitTensor: ?*const DML_TENSOR_DESC, SequenceLengthsTensor: ?*const DML_TENSOR_DESC, OutputSequenceTensor: ?*const DML_TENSOR_DESC, OutputSingleTensor: ?*const DML_TENSOR_DESC, ActivationDescCount: u32, ActivationDescs: ?*const DML_OPERATOR_DESC, Direction: DML_RECURRENT_NETWORK_DIRECTION, }; pub const DML_LSTM_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, WeightTensor: ?*const DML_TENSOR_DESC, RecurrenceTensor: ?*const DML_TENSOR_DESC, BiasTensor: ?*const DML_TENSOR_DESC, HiddenInitTensor: ?*const DML_TENSOR_DESC, CellMemInitTensor: ?*const DML_TENSOR_DESC, SequenceLengthsTensor: ?*const DML_TENSOR_DESC, PeepholeTensor: ?*const DML_TENSOR_DESC, OutputSequenceTensor: ?*const DML_TENSOR_DESC, OutputSingleTensor: ?*const DML_TENSOR_DESC, OutputCellSingleTensor: ?*const DML_TENSOR_DESC, ActivationDescCount: u32, ActivationDescs: ?*const DML_OPERATOR_DESC, Direction: DML_RECURRENT_NETWORK_DIRECTION, ClipThreshold: f32, UseClipThreshold: BOOL, CoupleInputForget: BOOL, }; pub const DML_GRU_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, WeightTensor: ?*const DML_TENSOR_DESC, RecurrenceTensor: ?*const DML_TENSOR_DESC, BiasTensor: ?*const DML_TENSOR_DESC, HiddenInitTensor: ?*const DML_TENSOR_DESC, SequenceLengthsTensor: ?*const DML_TENSOR_DESC, OutputSequenceTensor: ?*const DML_TENSOR_DESC, OutputSingleTensor: ?*const DML_TENSOR_DESC, ActivationDescCount: u32, ActivationDescs: ?*const DML_OPERATOR_DESC, Direction: DML_RECURRENT_NETWORK_DIRECTION, LinearBeforeReset: BOOL, }; pub const DML_ELEMENT_WISE_SIGN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_IS_NAN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_ERF_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_SINH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_COSH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_TANH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_ASINH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_ACOSH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_ATANH_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ScaleBias: ?*const DML_SCALE_BIAS, }; pub const DML_ELEMENT_WISE_IF_OPERATOR_DESC = extern struct { ConditionTensor: ?*const DML_TENSOR_DESC, ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_SHRINK_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Bias: f32, Threshold: f32, }; pub const DML_MAX_POOLING1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, OutputIndicesTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, WindowSize: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, }; pub const DML_MAX_UNPOOLING_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, IndicesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_DIAGONAL_MATRIX_OPERATOR_DESC = extern struct { OutputTensor: ?*const DML_TENSOR_DESC, Offset: i32, Value: f32, }; pub const DML_SCATTER_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, IndicesTensor: ?*const DML_TENSOR_DESC, UpdatesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, }; pub const DML_ONE_HOT_OPERATOR_DESC = extern struct { IndicesTensor: ?*const DML_TENSOR_DESC, ValuesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, }; pub const DML_RESAMPLE_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, InterpolationMode: DML_INTERPOLATION_MODE, ScaleCount: u32, Scales: ?*const f32, }; pub const DML_ELEMENT_WISE_BIT_SHIFT_LEFT_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_BIT_SHIFT_RIGHT_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_ROUND_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, RoundingMode: DML_ROUNDING_MODE, }; pub const DML_ELEMENT_WISE_IS_INFINITY_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, InfinityMode: DML_IS_INFINITY_MODE, }; pub const DML_ELEMENT_WISE_MODULUS_TRUNCATE_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_MODULUS_FLOOR_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_FILL_VALUE_CONSTANT_OPERATOR_DESC = extern struct { OutputTensor: ?*const DML_TENSOR_DESC, ValueDataType: DML_TENSOR_DATA_TYPE, Value: DML_SCALAR_UNION, }; pub const DML_FILL_VALUE_SEQUENCE_OPERATOR_DESC = extern struct { OutputTensor: ?*const DML_TENSOR_DESC, ValueDataType: DML_TENSOR_DATA_TYPE, ValueStart: DML_SCALAR_UNION, ValueDelta: DML_SCALAR_UNION, }; pub const DML_CUMULATIVE_SUMMATION_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, AxisDirection: DML_AXIS_DIRECTION, HasExclusiveSum: BOOL, }; pub const DML_REVERSE_SUBSEQUENCES_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, SequenceLengthsTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, }; pub const DML_GATHER_ELEMENTS_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, IndicesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, }; pub const DML_GATHER_ND_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, IndicesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, InputDimensionCount: u32, IndicesDimensionCount: u32, }; pub const DML_SCATTER_ND_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, IndicesTensor: ?*const DML_TENSOR_DESC, UpdatesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, InputDimensionCount: u32, IndicesDimensionCount: u32, }; pub const DML_MAX_POOLING2_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, OutputIndicesTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, WindowSize: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, Dilations: ?*const u32, }; pub const DML_SLICE1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, InputWindowOffsets: ?*const u32, InputWindowSizes: ?*const u32, InputWindowStrides: ?*const i32, }; pub const DML_TOP_K1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputValueTensor: ?*const DML_TENSOR_DESC, OutputIndexTensor: ?*const DML_TENSOR_DESC, Axis: u32, K: u32, AxisDirection: DML_AXIS_DIRECTION, }; pub const DML_DEPTH_TO_SPACE1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, BlockSize: u32, Order: DML_DEPTH_SPACE_ORDER, }; pub const DML_SPACE_TO_DEPTH1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, BlockSize: u32, Order: DML_DEPTH_SPACE_ORDER, }; pub const DML_MEAN_VARIANCE_NORMALIZATION1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, ScaleTensor: ?*const DML_TENSOR_DESC, BiasTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, AxisCount: u32, Axes: ?*const u32, NormalizeVariance: BOOL, Epsilon: f32, FusedActivation: ?*const DML_OPERATOR_DESC, }; pub const DML_RESAMPLE1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, InterpolationMode: DML_INTERPOLATION_MODE, DimensionCount: u32, Scales: ?*const f32, InputPixelOffsets: ?*const f32, OutputPixelOffsets: ?*const f32, }; pub const DML_MATRIX_MULTIPLY_INTEGER_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, AZeroPointTensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, BZeroPointTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_QUANTIZED_LINEAR_MATRIX_MULTIPLY_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, AScaleTensor: ?*const DML_TENSOR_DESC, AZeroPointTensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, BScaleTensor: ?*const DML_TENSOR_DESC, BZeroPointTensor: ?*const DML_TENSOR_DESC, OutputScaleTensor: ?*const DML_TENSOR_DESC, OutputZeroPointTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_CONVOLUTION_INTEGER_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, InputZeroPointTensor: ?*const DML_TENSOR_DESC, FilterTensor: ?*const DML_TENSOR_DESC, FilterZeroPointTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, Dilations: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, GroupCount: u32, }; pub const DML_QUANTIZED_LINEAR_CONVOLUTION_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, InputScaleTensor: ?*const DML_TENSOR_DESC, InputZeroPointTensor: ?*const DML_TENSOR_DESC, FilterTensor: ?*const DML_TENSOR_DESC, FilterScaleTensor: ?*const DML_TENSOR_DESC, FilterZeroPointTensor: ?*const DML_TENSOR_DESC, BiasTensor: ?*const DML_TENSOR_DESC, OutputScaleTensor: ?*const DML_TENSOR_DESC, OutputZeroPointTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, Dilations: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, GroupCount: u32, }; pub const DML_ELEMENT_WISE_BIT_AND_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_BIT_OR_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_BIT_XOR_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_BIT_NOT_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_BIT_COUNT_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_LOGICAL_GREATER_THAN_OR_EQUAL_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_LOGICAL_LESS_THAN_OR_EQUAL_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ACTIVATION_CELU_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Alpha: f32, }; pub const DML_ACTIVATION_RELU_GRAD_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, InputGradientTensor: ?*const DML_TENSOR_DESC, OutputGradientTensor: ?*const DML_TENSOR_DESC, }; pub const DML_AVERAGE_POOLING_GRAD_OPERATOR_DESC = extern struct { InputGradientTensor: ?*const DML_TENSOR_DESC, OutputGradientTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, WindowSize: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, IncludePadding: BOOL, }; pub const DML_MAX_POOLING_GRAD_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, InputGradientTensor: ?*const DML_TENSOR_DESC, OutputGradientTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, Strides: ?*const u32, WindowSize: ?*const u32, StartPadding: ?*const u32, EndPadding: ?*const u32, Dilations: ?*const u32, }; pub const DML_RANDOM_GENERATOR_OPERATOR_DESC = extern struct { InputStateTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, OutputStateTensor: ?*const DML_TENSOR_DESC, Type: DML_RANDOM_GENERATOR_TYPE, }; pub const DML_NONZERO_COORDINATES_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputCountTensor: ?*const DML_TENSOR_DESC, OutputCoordinatesTensor: ?*const DML_TENSOR_DESC, }; pub const DML_RESAMPLE_GRAD_OPERATOR_DESC = extern struct { InputGradientTensor: ?*const DML_TENSOR_DESC, OutputGradientTensor: ?*const DML_TENSOR_DESC, InterpolationMode: DML_INTERPOLATION_MODE, DimensionCount: u32, Scales: ?*const f32, InputPixelOffsets: ?*const f32, OutputPixelOffsets: ?*const f32, }; pub const DML_SLICE_GRAD_OPERATOR_DESC = extern struct { InputGradientTensor: ?*const DML_TENSOR_DESC, OutputGradientTensor: ?*const DML_TENSOR_DESC, DimensionCount: u32, InputWindowOffsets: ?*const u32, InputWindowSizes: ?*const u32, InputWindowStrides: ?*const i32, }; pub const DML_ADAM_OPTIMIZER_OPERATOR_DESC = extern struct { InputParametersTensor: ?*const DML_TENSOR_DESC, InputFirstMomentTensor: ?*const DML_TENSOR_DESC, InputSecondMomentTensor: ?*const DML_TENSOR_DESC, GradientTensor: ?*const DML_TENSOR_DESC, TrainingStepTensor: ?*const DML_TENSOR_DESC, OutputParametersTensor: ?*const DML_TENSOR_DESC, OutputFirstMomentTensor: ?*const DML_TENSOR_DESC, OutputSecondMomentTensor: ?*const DML_TENSOR_DESC, LearningRate: f32, Beta1: f32, Beta2: f32, Epsilon: f32, }; pub const DML_ARGMIN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, AxisCount: u32, Axes: ?*const u32, AxisDirection: DML_AXIS_DIRECTION, }; pub const DML_ARGMAX_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, AxisCount: u32, Axes: ?*const u32, AxisDirection: DML_AXIS_DIRECTION, }; pub const DML_ROI_ALIGN_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, ROITensor: ?*const DML_TENSOR_DESC, BatchIndicesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ReductionFunction: DML_REDUCE_FUNCTION, InterpolationMode: DML_INTERPOLATION_MODE, SpatialScaleX: f32, SpatialScaleY: f32, OutOfBoundsInputValue: f32, MinimumSamplesPerOutput: u32, MaximumSamplesPerOutput: u32, }; pub const DML_GATHER_ND1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, IndicesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, InputDimensionCount: u32, IndicesDimensionCount: u32, BatchDimensionCount: u32, }; pub const DML_ELEMENT_WISE_ATAN_YX_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ELEMENT_WISE_CLIP_GRAD_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, InputGradientTensor: ?*const DML_TENSOR_DESC, OutputGradientTensor: ?*const DML_TENSOR_DESC, Min: f32, Max: f32, }; pub const DML_ELEMENT_WISE_DIFFERENCE_SQUARE_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_LOCAL_RESPONSE_NORMALIZATION_GRAD_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, InputGradientTensor: ?*const DML_TENSOR_DESC, OutputGradientTensor: ?*const DML_TENSOR_DESC, CrossChannel: BOOL, LocalSize: u32, Alpha: f32, Beta: f32, Bias: f32, }; pub const DML_CUMULATIVE_PRODUCT_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, Axis: u32, AxisDirection: DML_AXIS_DIRECTION, HasExclusiveProduct: BOOL, }; pub const DML_BATCH_NORMALIZATION_GRAD_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, InputGradientTensor: ?*const DML_TENSOR_DESC, MeanTensor: ?*const DML_TENSOR_DESC, VarianceTensor: ?*const DML_TENSOR_DESC, ScaleTensor: ?*const DML_TENSOR_DESC, OutputGradientTensor: ?*const DML_TENSOR_DESC, OutputScaleGradientTensor: ?*const DML_TENSOR_DESC, OutputBiasGradientTensor: ?*const DML_TENSOR_DESC, Epsilon: f32, }; pub const DML_ELEMENT_WISE_QUANTIZED_LINEAR_ADD_OPERATOR_DESC = extern struct { ATensor: ?*const DML_TENSOR_DESC, AScaleTensor: ?*const DML_TENSOR_DESC, AZeroPointTensor: ?*const DML_TENSOR_DESC, BTensor: ?*const DML_TENSOR_DESC, BScaleTensor: ?*const DML_TENSOR_DESC, BZeroPointTensor: ?*const DML_TENSOR_DESC, OutputScaleTensor: ?*const DML_TENSOR_DESC, OutputZeroPointTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, }; pub const DML_DYNAMIC_QUANTIZE_LINEAR_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, OutputScaleTensor: ?*const DML_TENSOR_DESC, OutputZeroPointTensor: ?*const DML_TENSOR_DESC, }; pub const DML_ROI_ALIGN1_OPERATOR_DESC = extern struct { InputTensor: ?*const DML_TENSOR_DESC, ROITensor: ?*const DML_TENSOR_DESC, BatchIndicesTensor: ?*const DML_TENSOR_DESC, OutputTensor: ?*const DML_TENSOR_DESC, ReductionFunction: DML_REDUCE_FUNCTION, InterpolationMode: DML_INTERPOLATION_MODE, SpatialScaleX: f32, SpatialScaleY: f32, InputPixelOffset: f32, OutputPixelOffset: f32, OutOfBoundsInputValue: f32, MinimumSamplesPerOutput: u32, MaximumSamplesPerOutput: u32, AlignRegionsToCorners: BOOL, }; pub const DML_FEATURE_LEVEL = enum(i32) { @"1_0" = 4096, @"2_0" = 8192, @"2_1" = 8448, @"3_0" = 12288, @"3_1" = 12544, @"4_0" = 16384, }; pub const DML_FEATURE_LEVEL_1_0 = DML_FEATURE_LEVEL.@"1_0"; pub const DML_FEATURE_LEVEL_2_0 = DML_FEATURE_LEVEL.@"2_0"; pub const DML_FEATURE_LEVEL_2_1 = DML_FEATURE_LEVEL.@"2_1"; pub const DML_FEATURE_LEVEL_3_0 = DML_FEATURE_LEVEL.@"3_0"; pub const DML_FEATURE_LEVEL_3_1 = DML_FEATURE_LEVEL.@"3_1"; pub const DML_FEATURE_LEVEL_4_0 = DML_FEATURE_LEVEL.@"4_0"; pub const DML_FEATURE = enum(i32) { TENSOR_DATA_TYPE_SUPPORT = 0, FEATURE_LEVELS = 1, }; pub const DML_FEATURE_TENSOR_DATA_TYPE_SUPPORT = DML_FEATURE.TENSOR_DATA_TYPE_SUPPORT; pub const DML_FEATURE_FEATURE_LEVELS = DML_FEATURE.FEATURE_LEVELS; pub const DML_FEATURE_QUERY_TENSOR_DATA_TYPE_SUPPORT = extern struct { DataType: DML_TENSOR_DATA_TYPE, }; pub const DML_FEATURE_DATA_TENSOR_DATA_TYPE_SUPPORT = extern struct { IsSupported: BOOL, }; pub const DML_FEATURE_QUERY_FEATURE_LEVELS = extern struct { RequestedFeatureLevelCount: u32, RequestedFeatureLevels: ?*const DML_FEATURE_LEVEL, }; pub const DML_FEATURE_DATA_FEATURE_LEVELS = extern struct { MaxSupportedFeatureLevel: DML_FEATURE_LEVEL, }; pub const DML_BINDING_TABLE_DESC = extern struct { Dispatchable: ?*IDMLDispatchable, CPUDescriptorHandle: D3D12_CPU_DESCRIPTOR_HANDLE, GPUDescriptorHandle: D3D12_GPU_DESCRIPTOR_HANDLE, SizeInDescriptors: u32, }; pub const DML_EXECUTION_FLAGS = enum(u32) { NONE = 0, ALLOW_HALF_PRECISION_COMPUTATION = 1, DISABLE_META_COMMANDS = 2, DESCRIPTORS_VOLATILE = 4, _, pub fn initFlags(o: struct { NONE: u1 = 0, ALLOW_HALF_PRECISION_COMPUTATION: u1 = 0, DISABLE_META_COMMANDS: u1 = 0, DESCRIPTORS_VOLATILE: u1 = 0, }) DML_EXECUTION_FLAGS { return @intToEnum(DML_EXECUTION_FLAGS, (if (o.NONE == 1) @enumToInt(DML_EXECUTION_FLAGS.NONE) else 0) | (if (o.ALLOW_HALF_PRECISION_COMPUTATION == 1) @enumToInt(DML_EXECUTION_FLAGS.ALLOW_HALF_PRECISION_COMPUTATION) else 0) | (if (o.DISABLE_META_COMMANDS == 1) @enumToInt(DML_EXECUTION_FLAGS.DISABLE_META_COMMANDS) else 0) | (if (o.DESCRIPTORS_VOLATILE == 1) @enumToInt(DML_EXECUTION_FLAGS.DESCRIPTORS_VOLATILE) else 0) ); } }; pub const DML_EXECUTION_FLAG_NONE = DML_EXECUTION_FLAGS.NONE; pub const DML_EXECUTION_FLAG_ALLOW_HALF_PRECISION_COMPUTATION = DML_EXECUTION_FLAGS.ALLOW_HALF_PRECISION_COMPUTATION; pub const DML_EXECUTION_FLAG_DISABLE_META_COMMANDS = DML_EXECUTION_FLAGS.DISABLE_META_COMMANDS; pub const DML_EXECUTION_FLAG_DESCRIPTORS_VOLATILE = DML_EXECUTION_FLAGS.DESCRIPTORS_VOLATILE; pub const DML_CREATE_DEVICE_FLAGS = enum(u32) { NONE = 0, DEBUG = 1, _, pub fn initFlags(o: struct { NONE: u1 = 0, DEBUG: u1 = 0, }) DML_CREATE_DEVICE_FLAGS { return @intToEnum(DML_CREATE_DEVICE_FLAGS, (if (o.NONE == 1) @enumToInt(DML_CREATE_DEVICE_FLAGS.NONE) else 0) | (if (o.DEBUG == 1) @enumToInt(DML_CREATE_DEVICE_FLAGS.DEBUG) else 0) ); } }; pub const DML_CREATE_DEVICE_FLAG_NONE = DML_CREATE_DEVICE_FLAGS.NONE; pub const DML_CREATE_DEVICE_FLAG_DEBUG = DML_CREATE_DEVICE_FLAGS.DEBUG; const IID_IDMLObject_Value = Guid.initString("c8263aac-9e0c-4a2d-9b8e-007521a3317c"); pub const IID_IDMLObject = &IID_IDMLObject_Value; pub const IDMLObject = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, GetPrivateData: fn( self: *const IDMLObject, guid: ?*const Guid, dataSize: ?*u32, // TODO: what to do with BytesParamIndex 1? data: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetPrivateData: fn( self: *const IDMLObject, guid: ?*const Guid, dataSize: u32, // TODO: what to do with BytesParamIndex 1? data: ?*const anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetPrivateDataInterface: fn( self: *const IDMLObject, guid: ?*const Guid, data: ?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetName: fn( self: *const IDMLObject, name: ?[*: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 IDMLObject_GetPrivateData(self: *const T, guid: ?*const Guid, dataSize: ?*u32, data: ?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLObject.VTable, self.vtable).GetPrivateData(@ptrCast(*const IDMLObject, self), guid, dataSize, data); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLObject_SetPrivateData(self: *const T, guid: ?*const Guid, dataSize: u32, data: ?*const anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLObject.VTable, self.vtable).SetPrivateData(@ptrCast(*const IDMLObject, self), guid, dataSize, data); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLObject_SetPrivateDataInterface(self: *const T, guid: ?*const Guid, data: ?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLObject.VTable, self.vtable).SetPrivateDataInterface(@ptrCast(*const IDMLObject, self), guid, data); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLObject_SetName(self: *const T, name: ?[*:0]const u16) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLObject.VTable, self.vtable).SetName(@ptrCast(*const IDMLObject, self), name); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IDMLDevice_Value = Guid.initString("6dbd6437-96fd-423f-a98c-ae5e7c2a573f"); pub const IID_IDMLDevice = &IID_IDMLDevice_Value; pub const IDMLDevice = extern struct { pub const VTable = extern struct { base: IDMLObject.VTable, CheckFeatureSupport: fn( self: *const IDMLDevice, feature: DML_FEATURE, featureQueryDataSize: u32, // TODO: what to do with BytesParamIndex 1? featureQueryData: ?*const anyopaque, featureSupportDataSize: u32, // TODO: what to do with BytesParamIndex 3? featureSupportData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateOperator: fn( self: *const IDMLDevice, desc: ?*const DML_OPERATOR_DESC, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CompileOperator: fn( self: *const IDMLDevice, op: ?*IDMLOperator, flags: DML_EXECUTION_FLAGS, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateOperatorInitializer: fn( self: *const IDMLDevice, operatorCount: u32, operators: ?[*]?*IDMLCompiledOperator, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateCommandRecorder: fn( self: *const IDMLDevice, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateBindingTable: fn( self: *const IDMLDevice, desc: ?*const DML_BINDING_TABLE_DESC, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Evict: fn( self: *const IDMLDevice, count: u32, ppObjects: [*]?*IDMLPageable, ) callconv(@import("std").os.windows.WINAPI) HRESULT, MakeResident: fn( self: *const IDMLDevice, count: u32, ppObjects: [*]?*IDMLPageable, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDeviceRemovedReason: fn( self: *const IDMLDevice, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetParentDevice: fn( self: *const IDMLDevice, 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 IDMLObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_CheckFeatureSupport(self: *const T, feature: DML_FEATURE, featureQueryDataSize: u32, featureQueryData: ?*const anyopaque, featureSupportDataSize: u32, featureSupportData: ?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).CheckFeatureSupport(@ptrCast(*const IDMLDevice, self), feature, featureQueryDataSize, featureQueryData, featureSupportDataSize, featureSupportData); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_CreateOperator(self: *const T, desc: ?*const DML_OPERATOR_DESC, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).CreateOperator(@ptrCast(*const IDMLDevice, self), desc, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_CompileOperator(self: *const T, op: ?*IDMLOperator, flags: DML_EXECUTION_FLAGS, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).CompileOperator(@ptrCast(*const IDMLDevice, self), op, flags, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_CreateOperatorInitializer(self: *const T, operatorCount: u32, operators: ?[*]?*IDMLCompiledOperator, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).CreateOperatorInitializer(@ptrCast(*const IDMLDevice, self), operatorCount, operators, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_CreateCommandRecorder(self: *const T, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).CreateCommandRecorder(@ptrCast(*const IDMLDevice, self), riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_CreateBindingTable(self: *const T, desc: ?*const DML_BINDING_TABLE_DESC, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).CreateBindingTable(@ptrCast(*const IDMLDevice, self), desc, riid, ppv); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_Evict(self: *const T, count: u32, ppObjects: [*]?*IDMLPageable) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).Evict(@ptrCast(*const IDMLDevice, self), count, ppObjects); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_MakeResident(self: *const T, count: u32, ppObjects: [*]?*IDMLPageable) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).MakeResident(@ptrCast(*const IDMLDevice, self), count, ppObjects); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_GetDeviceRemovedReason(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).GetDeviceRemovedReason(@ptrCast(*const IDMLDevice, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice_GetParentDevice(self: *const T, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice.VTable, self.vtable).GetParentDevice(@ptrCast(*const IDMLDevice, self), riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IDMLDeviceChild_Value = Guid.initString("27e83142-8165-49e3-974e-2fd66e4cb69d"); pub const IID_IDMLDeviceChild = &IID_IDMLDeviceChild_Value; pub const IDMLDeviceChild = extern struct { pub const VTable = extern struct { base: IDMLObject.VTable, GetDevice: fn( self: *const IDMLDeviceChild, 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 IDMLObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDeviceChild_GetDevice(self: *const T, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDeviceChild.VTable, self.vtable).GetDevice(@ptrCast(*const IDMLDeviceChild, self), riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IDMLPageable_Value = Guid.initString("b1ab0825-4542-4a4b-8617-6dde6e8f6201"); pub const IID_IDMLPageable = &IID_IDMLPageable_Value; pub const IDMLPageable = extern struct { pub const VTable = extern struct { base: IDMLDeviceChild.VTable, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDMLDeviceChild.MethodMixin(T); };} pub usingnamespace MethodMixin(@This()); }; const IID_IDMLOperator_Value = Guid.initString("26caae7a-3081-4633-9581-226fbe57695d"); pub const IID_IDMLOperator = &IID_IDMLOperator_Value; pub const IDMLOperator = extern struct { pub const VTable = extern struct { base: IDMLDeviceChild.VTable, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDMLDeviceChild.MethodMixin(T); };} pub usingnamespace MethodMixin(@This()); }; pub const DML_BINDING_PROPERTIES = extern struct { RequiredDescriptorCount: u32, TemporaryResourceSize: u64, PersistentResourceSize: u64, }; const IID_IDMLDispatchable_Value = Guid.initString("dcb821a8-1039-441e-9f1c-b1759c2f3cec"); pub const IID_IDMLDispatchable = &IID_IDMLDispatchable_Value; pub const IDMLDispatchable = extern struct { pub const VTable = extern struct { base: IDMLPageable.VTable, GetBindingProperties: fn( self: *const IDMLDispatchable, ) callconv(@import("std").os.windows.WINAPI) DML_BINDING_PROPERTIES, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDMLPageable.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDispatchable_GetBindingProperties(self: *const T) callconv(.Inline) DML_BINDING_PROPERTIES { return @ptrCast(*const IDMLDispatchable.VTable, self.vtable).GetBindingProperties(@ptrCast(*const IDMLDispatchable, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IDMLCompiledOperator_Value = Guid.initString("6b15e56a-bf5c-4902-92d8-da3a650afea4"); pub const IID_IDMLCompiledOperator = &IID_IDMLCompiledOperator_Value; pub const IDMLCompiledOperator = extern struct { pub const VTable = extern struct { base: IDMLDispatchable.VTable, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDMLDispatchable.MethodMixin(T); };} pub usingnamespace MethodMixin(@This()); }; const IID_IDMLOperatorInitializer_Value = Guid.initString("427c1113-435c-469c-8676-4d5dd072f813"); pub const IID_IDMLOperatorInitializer = &IID_IDMLOperatorInitializer_Value; pub const IDMLOperatorInitializer = extern struct { pub const VTable = extern struct { base: IDMLDispatchable.VTable, Reset: fn( self: *const IDMLOperatorInitializer, operatorCount: u32, operators: ?[*]?*IDMLCompiledOperator, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDMLDispatchable.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLOperatorInitializer_Reset(self: *const T, operatorCount: u32, operators: ?[*]?*IDMLCompiledOperator) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLOperatorInitializer.VTable, self.vtable).Reset(@ptrCast(*const IDMLOperatorInitializer, self), operatorCount, operators); } };} pub usingnamespace MethodMixin(@This()); }; pub const DML_BINDING_TYPE = enum(i32) { NONE = 0, BUFFER = 1, BUFFER_ARRAY = 2, }; pub const DML_BINDING_TYPE_NONE = DML_BINDING_TYPE.NONE; pub const DML_BINDING_TYPE_BUFFER = DML_BINDING_TYPE.BUFFER; pub const DML_BINDING_TYPE_BUFFER_ARRAY = DML_BINDING_TYPE.BUFFER_ARRAY; pub const DML_BINDING_DESC = extern struct { Type: DML_BINDING_TYPE, Desc: ?*const anyopaque, }; pub const DML_BUFFER_BINDING = extern struct { Buffer: ?*ID3D12Resource, Offset: u64, SizeInBytes: u64, }; pub const DML_BUFFER_ARRAY_BINDING = extern struct { BindingCount: u32, Bindings: ?*const DML_BUFFER_BINDING, }; const IID_IDMLBindingTable_Value = Guid.initString("29c687dc-de74-4e3b-ab00-1168f2fc3cfc"); pub const IID_IDMLBindingTable = &IID_IDMLBindingTable_Value; pub const IDMLBindingTable = extern struct { pub const VTable = extern struct { base: IDMLDeviceChild.VTable, BindInputs: fn( self: *const IDMLBindingTable, bindingCount: u32, bindings: ?[*]const DML_BINDING_DESC, ) callconv(@import("std").os.windows.WINAPI) void, BindOutputs: fn( self: *const IDMLBindingTable, bindingCount: u32, bindings: ?[*]const DML_BINDING_DESC, ) callconv(@import("std").os.windows.WINAPI) void, BindTemporaryResource: fn( self: *const IDMLBindingTable, binding: ?*const DML_BINDING_DESC, ) callconv(@import("std").os.windows.WINAPI) void, BindPersistentResource: fn( self: *const IDMLBindingTable, binding: ?*const DML_BINDING_DESC, ) callconv(@import("std").os.windows.WINAPI) void, Reset: fn( self: *const IDMLBindingTable, desc: ?*const DML_BINDING_TABLE_DESC, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDMLDeviceChild.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLBindingTable_BindInputs(self: *const T, bindingCount: u32, bindings: ?[*]const DML_BINDING_DESC) callconv(.Inline) void { return @ptrCast(*const IDMLBindingTable.VTable, self.vtable).BindInputs(@ptrCast(*const IDMLBindingTable, self), bindingCount, bindings); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLBindingTable_BindOutputs(self: *const T, bindingCount: u32, bindings: ?[*]const DML_BINDING_DESC) callconv(.Inline) void { return @ptrCast(*const IDMLBindingTable.VTable, self.vtable).BindOutputs(@ptrCast(*const IDMLBindingTable, self), bindingCount, bindings); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLBindingTable_BindTemporaryResource(self: *const T, binding: ?*const DML_BINDING_DESC) callconv(.Inline) void { return @ptrCast(*const IDMLBindingTable.VTable, self.vtable).BindTemporaryResource(@ptrCast(*const IDMLBindingTable, self), binding); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLBindingTable_BindPersistentResource(self: *const T, binding: ?*const DML_BINDING_DESC) callconv(.Inline) void { return @ptrCast(*const IDMLBindingTable.VTable, self.vtable).BindPersistentResource(@ptrCast(*const IDMLBindingTable, self), binding); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLBindingTable_Reset(self: *const T, desc: ?*const DML_BINDING_TABLE_DESC) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLBindingTable.VTable, self.vtable).Reset(@ptrCast(*const IDMLBindingTable, self), desc); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IDMLCommandRecorder_Value = Guid.initString("e6857a76-2e3e-4fdd-bff4-5d2ba10fb453"); pub const IID_IDMLCommandRecorder = &IID_IDMLCommandRecorder_Value; pub const IDMLCommandRecorder = extern struct { pub const VTable = extern struct { base: IDMLDeviceChild.VTable, RecordDispatch: fn( self: *const IDMLCommandRecorder, commandList: ?*ID3D12CommandList, dispatchable: ?*IDMLDispatchable, bindings: ?*IDMLBindingTable, ) callconv(@import("std").os.windows.WINAPI) void, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDMLDeviceChild.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLCommandRecorder_RecordDispatch(self: *const T, commandList: ?*ID3D12CommandList, dispatchable: ?*IDMLDispatchable, bindings: ?*IDMLBindingTable) callconv(.Inline) void { return @ptrCast(*const IDMLCommandRecorder.VTable, self.vtable).RecordDispatch(@ptrCast(*const IDMLCommandRecorder, self), commandList, dispatchable, bindings); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IDMLDebugDevice_Value = Guid.initString("7d6f3ac9-394a-4ac3-92a7-390cc57a8217"); pub const IID_IDMLDebugDevice = &IID_IDMLDebugDevice_Value; pub const IDMLDebugDevice = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, SetMuteDebugOutput: fn( self: *const IDMLDebugDevice, mute: BOOL, ) callconv(@import("std").os.windows.WINAPI) void, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IUnknown.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDebugDevice_SetMuteDebugOutput(self: *const T, mute: BOOL) callconv(.Inline) void { return @ptrCast(*const IDMLDebugDevice.VTable, self.vtable).SetMuteDebugOutput(@ptrCast(*const IDMLDebugDevice, self), mute); } };} pub usingnamespace MethodMixin(@This()); }; pub const DML_GRAPH_EDGE_TYPE = enum(i32) { INVALID = 0, INPUT = 1, OUTPUT = 2, INTERMEDIATE = 3, }; pub const DML_GRAPH_EDGE_TYPE_INVALID = DML_GRAPH_EDGE_TYPE.INVALID; pub const DML_GRAPH_EDGE_TYPE_INPUT = DML_GRAPH_EDGE_TYPE.INPUT; pub const DML_GRAPH_EDGE_TYPE_OUTPUT = DML_GRAPH_EDGE_TYPE.OUTPUT; pub const DML_GRAPH_EDGE_TYPE_INTERMEDIATE = DML_GRAPH_EDGE_TYPE.INTERMEDIATE; pub const DML_GRAPH_EDGE_DESC = extern struct { Type: DML_GRAPH_EDGE_TYPE, Desc: ?*const anyopaque, }; pub const DML_INPUT_GRAPH_EDGE_DESC = extern struct { GraphInputIndex: u32, ToNodeIndex: u32, ToNodeInputIndex: u32, Name: ?[*:0]const u8, }; pub const DML_OUTPUT_GRAPH_EDGE_DESC = extern struct { FromNodeIndex: u32, FromNodeOutputIndex: u32, GraphOutputIndex: u32, Name: ?[*:0]const u8, }; pub const DML_INTERMEDIATE_GRAPH_EDGE_DESC = extern struct { FromNodeIndex: u32, FromNodeOutputIndex: u32, ToNodeIndex: u32, ToNodeInputIndex: u32, Name: ?[*:0]const u8, }; pub const DML_GRAPH_NODE_TYPE = enum(i32) { INVALID = 0, OPERATOR = 1, }; pub const DML_GRAPH_NODE_TYPE_INVALID = DML_GRAPH_NODE_TYPE.INVALID; pub const DML_GRAPH_NODE_TYPE_OPERATOR = DML_GRAPH_NODE_TYPE.OPERATOR; pub const DML_GRAPH_NODE_DESC = extern struct { Type: DML_GRAPH_NODE_TYPE, Desc: ?*const anyopaque, }; pub const DML_OPERATOR_GRAPH_NODE_DESC = extern struct { Operator: ?*IDMLOperator, Name: ?[*:0]const u8, }; pub const DML_GRAPH_DESC = extern struct { InputCount: u32, OutputCount: u32, NodeCount: u32, Nodes: ?*const DML_GRAPH_NODE_DESC, InputEdgeCount: u32, InputEdges: ?*const DML_GRAPH_EDGE_DESC, OutputEdgeCount: u32, OutputEdges: ?*const DML_GRAPH_EDGE_DESC, IntermediateEdgeCount: u32, IntermediateEdges: ?*const DML_GRAPH_EDGE_DESC, }; const IID_IDMLDevice1_Value = Guid.initString("a0884f9a-d2be-4355-aa5d-5901281ad1d2"); pub const IID_IDMLDevice1 = &IID_IDMLDevice1_Value; pub const IDMLDevice1 = extern struct { pub const VTable = extern struct { base: IDMLDevice.VTable, CompileGraph: fn( self: *const IDMLDevice1, desc: ?*const DML_GRAPH_DESC, flags: DML_EXECUTION_FLAGS, 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 IDMLDevice.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IDMLDevice1_CompileGraph(self: *const T, desc: ?*const DML_GRAPH_DESC, flags: DML_EXECUTION_FLAGS, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT { return @ptrCast(*const IDMLDevice1.VTable, self.vtable).CompileGraph(@ptrCast(*const IDMLDevice1, self), desc, flags, riid, ppv); } };} pub usingnamespace MethodMixin(@This()); }; //-------------------------------------------------------------------------------- // Section: Functions (2) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows10.0.10240' pub extern "DirectML" fn DMLCreateDevice( d3d12Device: ?*ID3D12Device, flags: DML_CREATE_DEVICE_FLAGS, riid: ?*const Guid, ppv: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "DirectML" fn DMLCreateDevice1( d3d12Device: ?*ID3D12Device, flags: DML_CREATE_DEVICE_FLAGS, minimumFeatureLevel: DML_FEATURE_LEVEL, 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 (11) //-------------------------------------------------------------------------------- const Guid = @import("../../zig.zig").Guid; const BOOL = @import("../../foundation.zig").BOOL; const D3D12_CPU_DESCRIPTOR_HANDLE = @import("../../graphics/direct3d12.zig").D3D12_CPU_DESCRIPTOR_HANDLE; const D3D12_GPU_DESCRIPTOR_HANDLE = @import("../../graphics/direct3d12.zig").D3D12_GPU_DESCRIPTOR_HANDLE; const HRESULT = @import("../../foundation.zig").HRESULT; const ID3D12CommandList = @import("../../graphics/direct3d12.zig").ID3D12CommandList; const ID3D12Device = @import("../../graphics/direct3d12.zig").ID3D12Device; const ID3D12Resource = @import("../../graphics/direct3d12.zig").ID3D12Resource; const IUnknown = @import("../../system/com.zig").IUnknown; const PSTR = @import("../../foundation.zig").PSTR; const PWSTR = @import("../../foundation.zig").PWSTR; 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/ai/machine_learning/direct_ml.zig
pub const CI_VERSION_WDS30 = @as(u32, 258); pub const CI_VERSION_WDS40 = @as(u32, 265); pub const CI_VERSION_WIN70 = @as(u32, 1792); pub const LIFF_LOAD_DEFINED_FILTER = @as(u32, 1); pub const LIFF_IMPLEMENT_TEXT_FILTER_FALLBACK_POLICY = @as(u32, 2); pub const LIFF_FORCE_TEXT_FILTER_FALLBACK = @as(u32, 3); pub const PID_FILENAME = @as(u32, 100); pub const DBPROP_CI_CATALOG_NAME = @as(u32, 2); pub const DBPROP_CI_INCLUDE_SCOPES = @as(u32, 3); pub const DBPROP_CI_DEPTHS = @as(u32, 4); pub const DBPROP_CI_SCOPE_FLAGS = @as(u32, 4); pub const DBPROP_CI_EXCLUDE_SCOPES = @as(u32, 5); pub const DBPROP_CI_SECURITY_ID = @as(u32, 6); pub const DBPROP_CI_QUERY_TYPE = @as(u32, 7); pub const DBPROP_CI_PROVIDER = @as(u32, 8); pub const CI_PROVIDER_MSSEARCH = @as(u32, 1); pub const CI_PROVIDER_INDEXING_SERVICE = @as(u32, 2); pub const CI_PROVIDER_ALL = @as(u32, 4294967295); pub const DBPROP_DEFAULT_EQUALS_BEHAVIOR = @as(u32, 2); pub const DBPROP_USECONTENTINDEX = @as(u32, 2); pub const DBPROP_DEFERNONINDEXEDTRIMMING = @as(u32, 3); pub const DBPROP_USEEXTENDEDDBTYPES = @as(u32, 4); pub const DBPROP_IGNORENOISEONLYCLAUSES = @as(u32, 5); pub const DBPROP_GENERICOPTIONS_STRING = @as(u32, 6); pub const DBPROP_FIRSTROWS = @as(u32, 7); pub const DBPROP_DEFERCATALOGVERIFICATION = @as(u32, 8); pub const DBPROP_CATALOGLISTID = @as(u32, 9); pub const DBPROP_GENERATEPARSETREE = @as(u32, 10); pub const DBPROP_APPLICATION_NAME = @as(u32, 11); pub const DBPROP_FREETEXTANYTERM = @as(u32, 12); pub const DBPROP_FREETEXTUSESTEMMING = @as(u32, 13); pub const DBPROP_IGNORESBRI = @as(u32, 14); pub const DBPROP_DONOTCOMPUTEEXPENSIVEPROPS = @as(u32, 15); pub const DBPROP_ENABLEROWSETEVENTS = @as(u32, 16); pub const DBPROP_MACHINE = @as(u32, 2); pub const DBPROP_CLIENT_CLSID = @as(u32, 3); pub const MSIDXSPROP_ROWSETQUERYSTATUS = @as(u32, 2); pub const MSIDXSPROP_COMMAND_LOCALE_STRING = @as(u32, 3); pub const MSIDXSPROP_QUERY_RESTRICTION = @as(u32, 4); pub const MSIDXSPROP_PARSE_TREE = @as(u32, 5); pub const MSIDXSPROP_MAX_RANK = @as(u32, 6); pub const MSIDXSPROP_RESULTS_FOUND = @as(u32, 7); pub const MSIDXSPROP_WHEREID = @as(u32, 8); pub const MSIDXSPROP_SERVER_VERSION = @as(u32, 9); pub const MSIDXSPROP_SERVER_WINVER_MAJOR = @as(u32, 10); pub const MSIDXSPROP_SERVER_WINVER_MINOR = @as(u32, 11); pub const MSIDXSPROP_SERVER_NLSVERSION = @as(u32, 12); pub const MSIDXSPROP_SERVER_NLSVER_DEFINED = @as(u32, 13); pub const MSIDXSPROP_SAME_SORTORDER_USED = @as(u32, 14); pub const STAT_BUSY = @as(u32, 0); pub const STAT_ERROR = @as(u32, 1); pub const STAT_DONE = @as(u32, 2); pub const STAT_REFRESH = @as(u32, 3); pub const STAT_PARTIAL_SCOPE = @as(u32, 8); pub const STAT_NOISE_WORDS = @as(u32, 16); pub const STAT_CONTENT_OUT_OF_DATE = @as(u32, 32); pub const STAT_REFRESH_INCOMPLETE = @as(u32, 64); pub const STAT_CONTENT_QUERY_INCOMPLETE = @as(u32, 128); pub const STAT_TIME_LIMIT_EXCEEDED = @as(u32, 256); pub const STAT_SHARING_VIOLATION = @as(u32, 512); pub const STAT_MISSING_RELDOC = @as(u32, 1024); pub const STAT_MISSING_PROP_IN_RELDOC = @as(u32, 2048); pub const STAT_RELDOC_ACCESS_DENIED = @as(u32, 4096); pub const STAT_COALESCE_COMP_ALL_NOISE = @as(u32, 8192); pub const QUERY_SHALLOW = @as(u32, 0); pub const QUERY_DEEP = @as(u32, 1); pub const QUERY_PHYSICAL_PATH = @as(u32, 0); pub const QUERY_VIRTUAL_PATH = @as(u32, 2); pub const PROPID_QUERY_WORKID = @as(u32, 5); pub const PROPID_QUERY_UNFILTERED = @as(u32, 7); pub const PROPID_QUERY_VIRTUALPATH = @as(u32, 9); pub const PROPID_QUERY_LASTSEENTIME = @as(u32, 10); pub const CICAT_STOPPED = @as(u32, 1); pub const CICAT_READONLY = @as(u32, 2); pub const CICAT_WRITABLE = @as(u32, 4); pub const CICAT_NO_QUERY = @as(u32, 8); pub const CICAT_GET_STATE = @as(u32, 16); pub const CICAT_ALL_OPENED = @as(u32, 32); pub const CI_STATE_SHADOW_MERGE = @as(u32, 1); pub const CI_STATE_MASTER_MERGE = @as(u32, 2); pub const CI_STATE_CONTENT_SCAN_REQUIRED = @as(u32, 4); pub const CI_STATE_ANNEALING_MERGE = @as(u32, 8); pub const CI_STATE_SCANNING = @as(u32, 16); pub const CI_STATE_RECOVERING = @as(u32, 32); pub const CI_STATE_INDEX_MIGRATION_MERGE = @as(u32, 64); pub const CI_STATE_LOW_MEMORY = @as(u32, 128); pub const CI_STATE_HIGH_IO = @as(u32, 256); pub const CI_STATE_MASTER_MERGE_PAUSED = @as(u32, 512); pub const CI_STATE_READ_ONLY = @as(u32, 1024); pub const CI_STATE_BATTERY_POWER = @as(u32, 2048); pub const CI_STATE_USER_ACTIVE = @as(u32, 4096); pub const CI_STATE_STARTING = @as(u32, 8192); pub const CI_STATE_READING_USNS = @as(u32, 16384); pub const CI_STATE_DELETION_MERGE = @as(u32, 32768); pub const CI_STATE_LOW_DISK = @as(u32, 65536); pub const CI_STATE_HIGH_CPU = @as(u32, 131072); pub const CI_STATE_BATTERY_POLICY = @as(u32, 262144); pub const GENERATE_METHOD_EXACT = @as(u32, 0); pub const GENERATE_METHOD_PREFIX = @as(u32, 1); pub const GENERATE_METHOD_INFLECT = @as(u32, 2); pub const SCOPE_FLAG_MASK = @as(u32, 255); pub const SCOPE_FLAG_INCLUDE = @as(u32, 1); pub const SCOPE_FLAG_DEEP = @as(u32, 2); pub const SCOPE_TYPE_MASK = @as(u32, 4294967040); pub const SCOPE_TYPE_WINPATH = @as(u32, 256); pub const SCOPE_TYPE_VPATH = @as(u32, 512); pub const PROPID_QUERY_RANKVECTOR = @as(u32, 2); pub const PROPID_QUERY_RANK = @as(u32, 3); pub const PROPID_QUERY_HITCOUNT = @as(u32, 4); pub const PROPID_QUERY_ALL = @as(u32, 6); pub const PROPID_STG_CONTENTS = @as(u32, 19); pub const VECTOR_RANK_MIN = @as(u32, 0); pub const VECTOR_RANK_MAX = @as(u32, 1); pub const VECTOR_RANK_INNER = @as(u32, 2); pub const VECTOR_RANK_DICE = @as(u32, 3); pub const VECTOR_RANK_JACCARD = @as(u32, 4); pub const DBSETFUNC_NONE = @as(u32, 0); pub const DBSETFUNC_ALL = @as(u32, 1); pub const DBSETFUNC_DISTINCT = @as(u32, 2); pub const PROXIMITY_UNIT_WORD = @as(u32, 0); pub const PROXIMITY_UNIT_SENTENCE = @as(u32, 1); pub const PROXIMITY_UNIT_PARAGRAPH = @as(u32, 2); pub const PROXIMITY_UNIT_CHAPTER = @as(u32, 3); pub const NOT_AN_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, 524288)); pub const FILTER_E_END_OF_CHUNKS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215616)); pub const FILTER_E_NO_MORE_TEXT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215615)); pub const FILTER_E_NO_MORE_VALUES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215614)); pub const FILTER_E_ACCESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215613)); pub const FILTER_W_MONIKER_CLIPPED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 268036)); pub const FILTER_E_NO_TEXT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215611)); pub const FILTER_E_NO_VALUES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215610)); pub const FILTER_E_EMBEDDING_UNAVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215609)); pub const FILTER_E_LINK_UNAVAILABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215608)); pub const FILTER_S_LAST_TEXT = @import("../zig.zig").typedConst(HRESULT, @as(i32, 268041)); pub const FILTER_S_LAST_VALUES = @import("../zig.zig").typedConst(HRESULT, @as(i32, 268042)); pub const FILTER_E_PASSWORD = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215605)); pub const FILTER_E_UNKNOWNFORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147215604)); //-------------------------------------------------------------------------------- // Section: Types (14) //-------------------------------------------------------------------------------- pub const CI_STATE = extern struct { cbStruct: u32, cWordList: u32, cPersistentIndex: u32, cQueries: u32, cDocuments: u32, cFreshTest: u32, dwMergeProgress: u32, eState: u32, cFilteredDocuments: u32, cTotalDocuments: u32, cPendingScans: u32, dwIndexSize: u32, cUniqueKeys: u32, cSecQDocuments: u32, dwPropCacheSize: u32, }; pub const FULLPROPSPEC = extern struct { guidPropSet: Guid, psProperty: PROPSPEC, }; pub const IFILTER_INIT = enum(i32) { CANON_PARAGRAPHS = 1, HARD_LINE_BREAKS = 2, CANON_HYPHENS = 4, CANON_SPACES = 8, APPLY_INDEX_ATTRIBUTES = 16, APPLY_OTHER_ATTRIBUTES = 32, APPLY_CRAWL_ATTRIBUTES = 256, INDEXING_ONLY = 64, SEARCH_LINKS = 128, FILTER_OWNED_VALUE_OK = 512, FILTER_AGGRESSIVE_BREAK = 1024, DISABLE_EMBEDDED = 2048, EMIT_FORMATTING = 4096, }; pub const IFILTER_INIT_CANON_PARAGRAPHS = IFILTER_INIT.CANON_PARAGRAPHS; pub const IFILTER_INIT_HARD_LINE_BREAKS = IFILTER_INIT.HARD_LINE_BREAKS; pub const IFILTER_INIT_CANON_HYPHENS = IFILTER_INIT.CANON_HYPHENS; pub const IFILTER_INIT_CANON_SPACES = IFILTER_INIT.CANON_SPACES; pub const IFILTER_INIT_APPLY_INDEX_ATTRIBUTES = IFILTER_INIT.APPLY_INDEX_ATTRIBUTES; pub const IFILTER_INIT_APPLY_OTHER_ATTRIBUTES = IFILTER_INIT.APPLY_OTHER_ATTRIBUTES; pub const IFILTER_INIT_APPLY_CRAWL_ATTRIBUTES = IFILTER_INIT.APPLY_CRAWL_ATTRIBUTES; pub const IFILTER_INIT_INDEXING_ONLY = IFILTER_INIT.INDEXING_ONLY; pub const IFILTER_INIT_SEARCH_LINKS = IFILTER_INIT.SEARCH_LINKS; pub const IFILTER_INIT_FILTER_OWNED_VALUE_OK = IFILTER_INIT.FILTER_OWNED_VALUE_OK; pub const IFILTER_INIT_FILTER_AGGRESSIVE_BREAK = IFILTER_INIT.FILTER_AGGRESSIVE_BREAK; pub const IFILTER_INIT_DISABLE_EMBEDDED = IFILTER_INIT.DISABLE_EMBEDDED; pub const IFILTER_INIT_EMIT_FORMATTING = IFILTER_INIT.EMIT_FORMATTING; pub const IFILTER_FLAGS = enum(i32) { S = 1, }; pub const IFILTER_FLAGS_OLE_PROPERTIES = IFILTER_FLAGS.S; pub const CHUNKSTATE = enum(i32) { TEXT = 1, VALUE = 2, FILTER_OWNED_VALUE = 4, }; pub const CHUNK_TEXT = CHUNKSTATE.TEXT; pub const CHUNK_VALUE = CHUNKSTATE.VALUE; pub const CHUNK_FILTER_OWNED_VALUE = CHUNKSTATE.FILTER_OWNED_VALUE; pub const CHUNK_BREAKTYPE = enum(i32) { NO_BREAK = 0, EOW = 1, EOS = 2, EOP = 3, EOC = 4, }; pub const CHUNK_NO_BREAK = CHUNK_BREAKTYPE.NO_BREAK; pub const CHUNK_EOW = CHUNK_BREAKTYPE.EOW; pub const CHUNK_EOS = CHUNK_BREAKTYPE.EOS; pub const CHUNK_EOP = CHUNK_BREAKTYPE.EOP; pub const CHUNK_EOC = CHUNK_BREAKTYPE.EOC; pub const FILTERREGION = extern struct { idChunk: u32, cwcStart: u32, cwcExtent: u32, }; pub const STAT_CHUNK = extern struct { idChunk: u32, breakType: CHUNK_BREAKTYPE, flags: CHUNKSTATE, locale: u32, attribute: FULLPROPSPEC, idChunkSource: u32, cwcStartSource: u32, cwcLenSource: u32, }; // TODO: this type is limited to platform 'windows5.0' const IID_IFilter_Value = Guid.initString("89bcb740-6119-101a-bcb7-00dd010655af"); pub const IID_IFilter = &IID_IFilter_Value; pub const IFilter = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, Init: fn( self: *const IFilter, grfFlags: u32, cAttributes: u32, aAttributes: [*]const FULLPROPSPEC, pFlags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32, GetChunk: fn( self: *const IFilter, pStat: ?*STAT_CHUNK, ) callconv(@import("std").os.windows.WINAPI) i32, GetText: fn( self: *const IFilter, pcwcBuffer: ?*u32, awcBuffer: [*:0]u16, ) callconv(@import("std").os.windows.WINAPI) i32, GetValue: fn( self: *const IFilter, ppPropValue: ?*?*PROPVARIANT, ) callconv(@import("std").os.windows.WINAPI) i32, BindRegion: fn( self: *const IFilter, origPos: FILTERREGION, riid: ?*const Guid, ppunk: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) i32, }; 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 IFilter_Init(self: *const T, grfFlags: u32, cAttributes: u32, aAttributes: [*]const FULLPROPSPEC, pFlags: ?*u32) callconv(.Inline) i32 { return @ptrCast(*const IFilter.VTable, self.vtable).Init(@ptrCast(*const IFilter, self), grfFlags, cAttributes, aAttributes, pFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFilter_GetChunk(self: *const T, pStat: ?*STAT_CHUNK) callconv(.Inline) i32 { return @ptrCast(*const IFilter.VTable, self.vtable).GetChunk(@ptrCast(*const IFilter, self), pStat); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFilter_GetText(self: *const T, pcwcBuffer: ?*u32, awcBuffer: [*:0]u16) callconv(.Inline) i32 { return @ptrCast(*const IFilter.VTable, self.vtable).GetText(@ptrCast(*const IFilter, self), pcwcBuffer, awcBuffer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFilter_GetValue(self: *const T, ppPropValue: ?*?*PROPVARIANT) callconv(.Inline) i32 { return @ptrCast(*const IFilter.VTable, self.vtable).GetValue(@ptrCast(*const IFilter, self), ppPropValue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFilter_BindRegion(self: *const T, origPos: FILTERREGION, riid: ?*const Guid, ppunk: ?*?*anyopaque) callconv(.Inline) i32 { return @ptrCast(*const IFilter.VTable, self.vtable).BindRegion(@ptrCast(*const IFilter, self), origPos, riid, ppunk); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows5.0' const IID_IPhraseSink_Value = Guid.initString("cc906ff0-c058-101a-b554-08002b33b0e6"); pub const IID_IPhraseSink = &IID_IPhraseSink_Value; pub const IPhraseSink = extern struct { pub const VTable = extern struct { base: IUnknown.VTable, PutSmallPhrase: fn( self: *const IPhraseSink, pwcNoun: ?[*:0]const u16, cwcNoun: u32, pwcModifier: ?[*:0]const u16, cwcModifier: u32, ulAttachmentType: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PutPhrase: fn( self: *const IPhraseSink, pwcPhrase: ?[*:0]const u16, cwcPhrase: 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 IPhraseSink_PutSmallPhrase(self: *const T, pwcNoun: ?[*:0]const u16, cwcNoun: u32, pwcModifier: ?[*:0]const u16, cwcModifier: u32, ulAttachmentType: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPhraseSink.VTable, self.vtable).PutSmallPhrase(@ptrCast(*const IPhraseSink, self), pwcNoun, cwcNoun, pwcModifier, cwcModifier, ulAttachmentType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IPhraseSink_PutPhrase(self: *const T, pwcPhrase: ?[*:0]const u16, cwcPhrase: u32) callconv(.Inline) HRESULT { return @ptrCast(*const IPhraseSink.VTable, self.vtable).PutPhrase(@ptrCast(*const IPhraseSink, self), pwcPhrase, cwcPhrase); } };} pub usingnamespace MethodMixin(@This()); }; pub const WORDREP_BREAK_TYPE = enum(i32) { W = 0, S = 1, P = 2, C = 3, }; pub const WORDREP_BREAK_EOW = WORDREP_BREAK_TYPE.W; pub const WORDREP_BREAK_EOS = WORDREP_BREAK_TYPE.S; pub const WORDREP_BREAK_EOP = WORDREP_BREAK_TYPE.P; pub const WORDREP_BREAK_EOC = WORDREP_BREAK_TYPE.C; pub const DBKINDENUM = enum(i32) { GUID_NAME = 0, GUID_PROPID = 1, NAME = 2, PGUID_NAME = 3, PGUID_PROPID = 4, PROPID = 5, GUID = 6, }; pub const DBKIND_GUID_NAME = DBKINDENUM.GUID_NAME; pub const DBKIND_GUID_PROPID = DBKINDENUM.GUID_PROPID; pub const DBKIND_NAME = DBKINDENUM.NAME; pub const DBKIND_PGUID_NAME = DBKINDENUM.PGUID_NAME; pub const DBKIND_PGUID_PROPID = DBKINDENUM.PGUID_PROPID; pub const DBKIND_PROPID = DBKINDENUM.PROPID; pub const DBKIND_GUID = DBKINDENUM.GUID; pub const DBID = switch(@import("../zig.zig").arch) { .X64, .Arm64 => extern struct { uGuid: extern union { guid: Guid, pguid: ?*Guid, }, eKind: u32, uName: extern union { pwszName: ?PWSTR, ulPropid: u32, }, }, .X86 => extern struct { // WARNING: unable to add field alignment because it's causing a compiler bug uGuid: extern union { // WARNING: unable to add field alignment because it's not implemented for unions guid: Guid, pguid: ?*Guid, }, eKind: u32, uName: extern union { // WARNING: unable to add field alignment because it's not implemented for unions pwszName: ?PWSTR, ulPropid: u32, }, }, }; //-------------------------------------------------------------------------------- // Section: Functions (4) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows5.0' pub extern "query" fn LoadIFilter( pwcsPath: ?[*:0]const u16, pUnkOuter: ?*IUnknown, ppIUnk: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "query" fn LoadIFilterEx( pwcsPath: ?[*:0]const u16, dwFlags: u32, riid: ?*const Guid, ppIUnk: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.0' pub extern "query" fn BindIFilterFromStorage( pStg: ?*IStorage, pUnkOuter: ?*IUnknown, ppIUnk: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.0' pub extern "query" fn BindIFilterFromStream( pStm: ?*IStream, pUnkOuter: ?*IUnknown, ppIUnk: ?*?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (0) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { }, .wide => struct { }, .unspecified => if (@import("builtin").is_test) struct { } else struct { }, }; //-------------------------------------------------------------------------------- // Section: Imports (8) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const HRESULT = @import("../foundation.zig").HRESULT; const IStorage = @import("../system/com/structured_storage.zig").IStorage; const IStream = @import("../system/com.zig").IStream; const IUnknown = @import("../system/com.zig").IUnknown; const PROPSPEC = @import("../system/com/structured_storage.zig").PROPSPEC; const PROPVARIANT = @import("../system/com/structured_storage.zig").PROPVARIANT; const PWSTR = @import("../foundation.zig").PWSTR; test { @setEvalBranchQuota( @import("std").meta.declarations(@This()).len * 3 ); // reference all the pub declarations if (!@import("builtin").is_test) return; inline for (@import("std").meta.declarations(@This())) |decl| { if (decl.is_pub) { _ = decl; } } }
win32/storage/index_server.zig
const std = @import("std"); const c = @import("internal/c.zig"); const internal = @import("internal/internal.zig"); const bitjuggle = @import("internal/bitjuggle.zig"); const log = std.log.scoped(.git); const git = @import("git.zig"); const hasCredential = @hasDecl(c, "git_credential"); const RawCredentialType = if (hasCredential) c.git_credential else c.git_cred; pub const Credential = extern struct { credtype: CredentialType, free: ?fn (*Credential) callconv(.C) void, pub fn deinit(self: *Credential) void { log.debug("Credential.deinit called", .{}); if (hasCredential) { c.git_credential_free(@ptrCast(*RawCredentialType, self)); } else { c.git_cred_free(@ptrCast(*RawCredentialType, self)); } log.debug("credential freed successfully", .{}); } pub fn hasUsername(self: *Credential) bool { log.debug("Credential.hasUsername called", .{}); var ret: bool = undefined; if (hasCredential) { ret = c.git_credential_has_username(@ptrCast(*RawCredentialType, self)) != 0; } else { ret = c.git_cred_has_username(@ptrCast(*RawCredentialType, self)) != 0; } log.debug("credential has username: {}", .{ret}); return ret; } pub fn getUsername(self: *Credential) ?[:0]const u8 { log.debug("Credential.getUsername called", .{}); const opt_username: [*c]const u8 = if (hasCredential) c.git_credential_get_username(@ptrCast(*RawCredentialType, self)) else c.git_cred_get_username(@ptrCast(*RawCredentialType, self)); if (opt_username) |username| { const slice = std.mem.sliceTo(username, 0); log.debug("credential has username: {s}", .{slice}); return slice; } else { log.debug("credential has no username", .{}); return null; } } pub fn initUserPassPlaintext(username: [:0]const u8, password: [:0]const u8) !*Credential { log.debug("Credential.initUserPassPlaintext called, username={s}, password={s}", .{ username, password }); var cred: *Credential = undefined; if (hasCredential) { try internal.wrapCall("git_credential_userpass_plaintext_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, password.ptr, }); } else { try internal.wrapCall("git_cred_userpass_plaintext_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, password.ptr, }); } log.debug("created new credential {*}", .{cred}); return cred; } /// Create a "default" credential usable for Negotiate mechanisms like NTLM or Kerberos authentication. pub fn initDefault() !*Credential { log.debug("Credential.initDefault", .{}); var cred: *Credential = undefined; if (hasCredential) { try internal.wrapCall("git_credential_default_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), }); } else { try internal.wrapCall("git_cred_default_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), }); } log.debug("created new credential {*}", .{cred}); return cred; } /// Create a credential to specify a username. /// /// This is used with ssh authentication to query for the username if none is specified in the url. pub fn initUsername(username: [:0]const u8) !*Credential { log.debug("Credential.initUsername called, username={s}", .{username}); var cred: *Credential = undefined; if (hasCredential) { try internal.wrapCall("git_credential_username_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, }); } else { try internal.wrapCall("git_cred_username_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, }); } log.debug("created new credential {*}", .{cred}); return cred; } /// Create a new passphrase-protected ssh key credential object. /// /// ## Parameters /// * `username` - username to use to authenticate /// * `publickey` - The path to the public key of the credential. /// * `privatekey` - The path to the private key of the credential. /// * `passphrase` - The passphrase of the credential. pub fn initSshKey( username: [:0]const u8, publickey: ?[:0]const u8, privatekey: [:0]const u8, passphrase: ?[:0]const u8, ) !*Credential { log.debug( "Credential.initSshKey called, username={s}, publickey={s}, privatekey={s}, passphrase={s}", .{ username, publickey, privatekey, passphrase }, ); var cred: *Credential = undefined; const publickey_c = if (publickey) |str| str.ptr else null; const passphrase_c = if (passphrase) |str| str.ptr else null; if (hasCredential) { try internal.wrapCall("git_credential_ssh_key_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, publickey_c, privatekey.ptr, passphrase_c, }); } else { try internal.wrapCall("git_cred_ssh_key_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, publickey_c, privatekey.ptr, passphrase_c, }); } log.debug("created new credential {*}", .{cred}); return cred; } /// Create a new ssh key credential object reading the keys from memory. /// /// ## Parameters /// * `username` - username to use to authenticate /// * `publickey` - The public key of the credential. /// * `privatekey` - TThe private key of the credential. /// * `passphrase` - The passphrase of the credential. pub fn initSshKeyMemory( username: [:0]const u8, publickey: ?[:0]const u8, privatekey: [:0]const u8, passphrase: ?[:0]const u8, ) !*Credential { log.debug("Credential.initSshKeyMemory called", .{}); var cred: *Credential = undefined; const publickey_c = if (publickey) |str| str.ptr else null; const passphrase_c = if (passphrase) |str| str.ptr else null; if (hasCredential) { try internal.wrapCall("git_credential_ssh_key_memory_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, publickey_c, privatekey.ptr, passphrase_c, }); } else { try internal.wrapCall("git_cred_ssh_key_memory_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, publickey_c, privatekey.ptr, passphrase_c, }); } log.debug("created new credential {*}", .{cred}); return cred; } /// Create a new ssh keyboard-interactive based credential object. /// /// ## Parameters /// * `username` - Username to use to authenticate. /// * `user_data` - pointer to user data to be passed to the callback /// * `callback_fn` - the callback function pub fn initSshKeyInteractive( username: [:0]const u8, user_data: anytype, comptime callback_fn: fn ( name: []const u8, instruction: []const u8, prompts: []*const c.LIBSSH2_USERAUTH_KBDINT_PROMPT, responses: []*c.LIBSSH2_USERAUTH_KBDINT_RESPONSE, abstract: [*c]?*anyopaque, ) void, ) !*Credential { // TODO: This callback needs to be massively cleaned up const cb = struct { pub fn cb( name: [*c]const u8, name_len: c_int, instruction: [*c]const u8, instruction_len: c_int, num_prompts: c_int, prompts: ?*const c.LIBSSH2_USERAUTH_KBDINT_PROMPT, responses: ?*c.LIBSSH2_USERAUTH_KBDINT_RESPONSE, abstract: [*c]?*anyopaque, ) callconv(.C) void { callback_fn( name[0..name_len], instruction[0..instruction_len], prompts[0..num_prompts], responses[0..num_prompts], abstract, ); } }.cb; log.debug("Credential.initSshKeyInteractive called, username={s}", .{username}); var cred: *Credential = undefined; if (hasCredential) { try internal.wrapCall("git_credential_ssh_interactive_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, cb, user_data, }); } else { try internal.wrapCall("git_cred_ssh_interactive_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, cb, user_data, }); } log.debug("created new credential {*}", .{cred}); return cred; } pub fn initSshKeyFromAgent(username: [:0]const u8) !*Credential { log.debug("Credential.initSshKeyFromAgent called, username={s}", .{username}); var cred: *Credential = undefined; if (hasCredential) { try internal.wrapCall("git_credential_ssh_key_from_agent", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, }); } else { try internal.wrapCall("git_cred_ssh_key_from_agent", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, }); } log.debug("created new credential {*}", .{cred}); return cred; } pub fn initSshKeyCustom( username: [:0]const u8, publickey: []const u8, user_data: anytype, comptime callback_fn: fn ( session: *c.LIBSSH2_SESSION, out_signature: *[]const u8, data: []const u8, abstract: [*c]?*anyopaque, ) c_int, ) !*Credential { const cb = struct { pub fn cb( session: ?*c.LIBSSH2_SESSION, sig: [*c][*c]u8, sign_len: [*c]usize, data: [*c]const u8, data_len: usize, abstract: [*c]?*anyopaque, ) callconv(.C) c_int { var out_sig: []const u8 = undefined; const result = callback_fn( session, &out_sig, data[0..data_len], abstract, ); sig.* = out_sig.ptr; sign_len.* = out_sig.len; return result; } }.cb; log.debug("Credential.initSshKeyCustom called, username={s}", .{username}); var cred: *Credential = undefined; if (hasCredential) { try internal.wrapCall("git_credential_ssh_custom_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, publickey.ptr, publickey.len, cb, user_data, }); } else { try internal.wrapCall("git_cred_ssh_custom_new", .{ @ptrCast(*[*c]RawCredentialType, &cred), username.ptr, publickey.ptr, publickey.len, cb, user_data, }); } log.debug("created new credential {*}", .{cred}); return cred; } pub const CredentialType = extern union { /// A vanilla user/password request /// @see git_credential_userpass_plaintext_new userpass_plaintext: bitjuggle.Boolean(c_uint, 0), /// An SSH key-based authentication request /// @see git_credential_ssh_key_new ssh_key: bitjuggle.Boolean(c_uint, 1), /// An SSH key-based authentication request, with a custom signature /// @see git_credential_ssh_custom_new ssh_custom: bitjuggle.Boolean(c_uint, 2), /// An NTLM/Negotiate-based authentication request. /// @see git_credential_default default: bitjuggle.Boolean(c_uint, 3), /// An SSH interactive authentication request /// @see git_credential_ssh_interactive_new ssh_interactive: bitjuggle.Boolean(c_uint, 4), /// Username-only authentication request /// /// Used as a pre-authentication step if the underlying transport /// (eg. SSH, with no username in its URL) does not know which username /// to use. /// /// @see git_credential_username_new username: bitjuggle.Boolean(c_uint, 5), /// An SSH key-based authentication request /// /// Allows credentials to be read from memory instead of files. /// Note that because of differences in crypto backend support, it might /// not be functional. /// /// @see git_credential_ssh_key_memory_new ssh_memory: bitjuggle.Boolean(c_uint, 6), value: c_uint, comptime { std.testing.refAllDecls(@This()); } }; comptime { std.testing.refAllDecls(@This()); } }; comptime { std.testing.refAllDecls(@This()); }
src/credential.zig
const std = @import("std"); const cast = std.meta.cast; const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels /// The function addcarryxU56 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 addcarryxU56(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { @setRuntimeSafety(mode == .Debug); const x1 = ((cast(u64, arg1) + arg2) + arg3); const x2 = (x1 & 0xffffffffffffff); const x3 = cast(u1, (x1 >> 56)); out1.* = x2; out2.* = x3; } /// The function subborrowxU56 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 subborrowxU56(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { @setRuntimeSafety(mode == .Debug); const x1 = cast(i64, (cast(i128, cast(i64, (cast(i128, arg2) - cast(i128, arg1)))) - cast(i128, arg3))); const x2 = cast(i1, (x1 >> 56)); const x3 = cast(u64, (cast(i128, x1) & cast(i128, 0xffffffffffffff))); out1.* = x3; out2.* = cast(u1, (cast(i2, 0x0) - cast(i2, x2))); } /// The function cmovznzU64 is a single-word conditional move. /// Postconditions: /// out1 = (if arg1 = 0 then arg2 else arg3) /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { @setRuntimeSafety(mode == .Debug); const x1 = (~(~arg1)); const x2 = cast(u64, (cast(i128, cast(i1, (cast(i2, 0x0) - cast(i2, x1)))) & cast(i128, 0xffffffffffffffff))); const x3 = ((x2 & arg3) | ((~x2) & arg2)); out1.* = x3; } /// The function carryMul 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 carryMul(out1: *[8]u64, arg1: [8]u64, arg2: [8]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (cast(u128, (arg1[7])) * cast(u128, (arg2[7]))); const x2 = (cast(u128, (arg1[7])) * cast(u128, (arg2[6]))); const x3 = (cast(u128, (arg1[7])) * cast(u128, (arg2[5]))); const x4 = (cast(u128, (arg1[6])) * cast(u128, (arg2[7]))); const x5 = (cast(u128, (arg1[6])) * cast(u128, (arg2[6]))); const x6 = (cast(u128, (arg1[5])) * cast(u128, (arg2[7]))); const x7 = (cast(u128, (arg1[7])) * cast(u128, (arg2[7]))); const x8 = (cast(u128, (arg1[7])) * cast(u128, (arg2[6]))); const x9 = (cast(u128, (arg1[7])) * cast(u128, (arg2[5]))); const x10 = (cast(u128, (arg1[6])) * cast(u128, (arg2[7]))); const x11 = (cast(u128, (arg1[6])) * cast(u128, (arg2[6]))); const x12 = (cast(u128, (arg1[5])) * cast(u128, (arg2[7]))); const x13 = (cast(u128, (arg1[7])) * cast(u128, (arg2[7]))); const x14 = (cast(u128, (arg1[7])) * cast(u128, (arg2[6]))); const x15 = (cast(u128, (arg1[7])) * cast(u128, (arg2[5]))); const x16 = (cast(u128, (arg1[7])) * cast(u128, (arg2[4]))); const x17 = (cast(u128, (arg1[7])) * cast(u128, (arg2[3]))); const x18 = (cast(u128, (arg1[7])) * cast(u128, (arg2[2]))); const x19 = (cast(u128, (arg1[7])) * cast(u128, (arg2[1]))); const x20 = (cast(u128, (arg1[6])) * cast(u128, (arg2[7]))); const x21 = (cast(u128, (arg1[6])) * cast(u128, (arg2[6]))); const x22 = (cast(u128, (arg1[6])) * cast(u128, (arg2[5]))); const x23 = (cast(u128, (arg1[6])) * cast(u128, (arg2[4]))); const x24 = (cast(u128, (arg1[6])) * cast(u128, (arg2[3]))); const x25 = (cast(u128, (arg1[6])) * cast(u128, (arg2[2]))); const x26 = (cast(u128, (arg1[5])) * cast(u128, (arg2[7]))); const x27 = (cast(u128, (arg1[5])) * cast(u128, (arg2[6]))); const x28 = (cast(u128, (arg1[5])) * cast(u128, (arg2[5]))); const x29 = (cast(u128, (arg1[5])) * cast(u128, (arg2[4]))); const x30 = (cast(u128, (arg1[5])) * cast(u128, (arg2[3]))); const x31 = (cast(u128, (arg1[4])) * cast(u128, (arg2[7]))); const x32 = (cast(u128, (arg1[4])) * cast(u128, (arg2[6]))); const x33 = (cast(u128, (arg1[4])) * cast(u128, (arg2[5]))); const x34 = (cast(u128, (arg1[4])) * cast(u128, (arg2[4]))); const x35 = (cast(u128, (arg1[3])) * cast(u128, (arg2[7]))); const x36 = (cast(u128, (arg1[3])) * cast(u128, (arg2[6]))); const x37 = (cast(u128, (arg1[3])) * cast(u128, (arg2[5]))); const x38 = (cast(u128, (arg1[2])) * cast(u128, (arg2[7]))); const x39 = (cast(u128, (arg1[2])) * cast(u128, (arg2[6]))); const x40 = (cast(u128, (arg1[1])) * cast(u128, (arg2[7]))); const x41 = (cast(u128, (arg1[7])) * cast(u128, (arg2[4]))); const x42 = (cast(u128, (arg1[7])) * cast(u128, (arg2[3]))); const x43 = (cast(u128, (arg1[7])) * cast(u128, (arg2[2]))); const x44 = (cast(u128, (arg1[7])) * cast(u128, (arg2[1]))); const x45 = (cast(u128, (arg1[6])) * cast(u128, (arg2[5]))); const x46 = (cast(u128, (arg1[6])) * cast(u128, (arg2[4]))); const x47 = (cast(u128, (arg1[6])) * cast(u128, (arg2[3]))); const x48 = (cast(u128, (arg1[6])) * cast(u128, (arg2[2]))); const x49 = (cast(u128, (arg1[5])) * cast(u128, (arg2[6]))); const x50 = (cast(u128, (arg1[5])) * cast(u128, (arg2[5]))); const x51 = (cast(u128, (arg1[5])) * cast(u128, (arg2[4]))); const x52 = (cast(u128, (arg1[5])) * cast(u128, (arg2[3]))); const x53 = (cast(u128, (arg1[4])) * cast(u128, (arg2[7]))); const x54 = (cast(u128, (arg1[4])) * cast(u128, (arg2[6]))); const x55 = (cast(u128, (arg1[4])) * cast(u128, (arg2[5]))); const x56 = (cast(u128, (arg1[4])) * cast(u128, (arg2[4]))); const x57 = (cast(u128, (arg1[3])) * cast(u128, (arg2[7]))); const x58 = (cast(u128, (arg1[3])) * cast(u128, (arg2[6]))); const x59 = (cast(u128, (arg1[3])) * cast(u128, (arg2[5]))); const x60 = (cast(u128, (arg1[2])) * cast(u128, (arg2[7]))); const x61 = (cast(u128, (arg1[2])) * cast(u128, (arg2[6]))); const x62 = (cast(u128, (arg1[1])) * cast(u128, (arg2[7]))); const x63 = (cast(u128, (arg1[7])) * cast(u128, (arg2[0]))); const x64 = (cast(u128, (arg1[6])) * cast(u128, (arg2[1]))); const x65 = (cast(u128, (arg1[6])) * cast(u128, (arg2[0]))); const x66 = (cast(u128, (arg1[5])) * cast(u128, (arg2[2]))); const x67 = (cast(u128, (arg1[5])) * cast(u128, (arg2[1]))); const x68 = (cast(u128, (arg1[5])) * cast(u128, (arg2[0]))); const x69 = (cast(u128, (arg1[4])) * cast(u128, (arg2[3]))); const x70 = (cast(u128, (arg1[4])) * cast(u128, (arg2[2]))); const x71 = (cast(u128, (arg1[4])) * cast(u128, (arg2[1]))); const x72 = (cast(u128, (arg1[4])) * cast(u128, (arg2[0]))); const x73 = (cast(u128, (arg1[3])) * cast(u128, (arg2[4]))); const x74 = (cast(u128, (arg1[3])) * cast(u128, (arg2[3]))); const x75 = (cast(u128, (arg1[3])) * cast(u128, (arg2[2]))); const x76 = (cast(u128, (arg1[3])) * cast(u128, (arg2[1]))); const x77 = (cast(u128, (arg1[3])) * cast(u128, (arg2[0]))); const x78 = (cast(u128, (arg1[2])) * cast(u128, (arg2[5]))); const x79 = (cast(u128, (arg1[2])) * cast(u128, (arg2[4]))); const x80 = (cast(u128, (arg1[2])) * cast(u128, (arg2[3]))); const x81 = (cast(u128, (arg1[2])) * cast(u128, (arg2[2]))); const x82 = (cast(u128, (arg1[2])) * cast(u128, (arg2[1]))); const x83 = (cast(u128, (arg1[2])) * cast(u128, (arg2[0]))); const x84 = (cast(u128, (arg1[1])) * cast(u128, (arg2[6]))); const x85 = (cast(u128, (arg1[1])) * cast(u128, (arg2[5]))); const x86 = (cast(u128, (arg1[1])) * cast(u128, (arg2[4]))); const x87 = (cast(u128, (arg1[1])) * cast(u128, (arg2[3]))); const x88 = (cast(u128, (arg1[1])) * cast(u128, (arg2[2]))); const x89 = (cast(u128, (arg1[1])) * cast(u128, (arg2[1]))); const x90 = (cast(u128, (arg1[1])) * cast(u128, (arg2[0]))); const x91 = (cast(u128, (arg1[0])) * cast(u128, (arg2[7]))); const x92 = (cast(u128, (arg1[0])) * cast(u128, (arg2[6]))); const x93 = (cast(u128, (arg1[0])) * cast(u128, (arg2[5]))); const x94 = (cast(u128, (arg1[0])) * cast(u128, (arg2[4]))); const x95 = (cast(u128, (arg1[0])) * cast(u128, (arg2[3]))); const x96 = (cast(u128, (arg1[0])) * cast(u128, (arg2[2]))); const x97 = (cast(u128, (arg1[0])) * cast(u128, (arg2[1]))); const x98 = (cast(u128, (arg1[0])) * cast(u128, (arg2[0]))); const x99 = (x95 + (x88 + (x82 + (x77 + (x31 + (x27 + (x22 + x16))))))); const x100 = cast(u64, (x99 >> 56)); const x101 = cast(u64, (x99 & cast(u128, 0xffffffffffffff))); const x102 = (x91 + (x84 + (x78 + (x73 + (x69 + (x66 + (x64 + (x63 + (x53 + (x49 + (x45 + x41))))))))))); const x103 = (x92 + (x85 + (x79 + (x74 + (x70 + (x67 + (x65 + (x57 + (x54 + (x50 + (x46 + (x42 + (x13 + x7))))))))))))); const x104 = (x93 + (x86 + (x80 + (x75 + (x71 + (x68 + (x60 + (x58 + (x55 + (x51 + (x47 + (x43 + (x20 + (x14 + (x10 + x8))))))))))))))); const x105 = (x94 + (x87 + (x81 + (x76 + (x72 + (x62 + (x61 + (x59 + (x56 + (x52 + (x48 + (x44 + (x26 + (x21 + (x15 + (x12 + (x11 + x9))))))))))))))))); const x106 = (x96 + (x89 + (x83 + (x35 + (x32 + (x28 + (x23 + (x17 + x1)))))))); const x107 = (x97 + (x90 + (x38 + (x36 + (x33 + (x29 + (x24 + (x18 + (x4 + x2))))))))); const x108 = (x98 + (x40 + (x39 + (x37 + (x34 + (x30 + (x25 + (x19 + (x6 + (x5 + x3)))))))))); const x109 = (cast(u128, x100) + x105); const x110 = cast(u64, (x102 >> 56)); const x111 = cast(u64, (x102 & cast(u128, 0xffffffffffffff))); const x112 = (x109 + cast(u128, x110)); const x113 = cast(u64, (x112 >> 56)); const x114 = cast(u64, (x112 & cast(u128, 0xffffffffffffff))); const x115 = (x108 + cast(u128, x110)); const x116 = (cast(u128, x113) + x104); const x117 = cast(u64, (x115 >> 56)); const x118 = cast(u64, (x115 & cast(u128, 0xffffffffffffff))); const x119 = (cast(u128, x117) + x107); const x120 = cast(u64, (x116 >> 56)); const x121 = cast(u64, (x116 & cast(u128, 0xffffffffffffff))); const x122 = (cast(u128, x120) + x103); const x123 = cast(u64, (x119 >> 56)); const x124 = cast(u64, (x119 & cast(u128, 0xffffffffffffff))); const x125 = (cast(u128, x123) + x106); const x126 = cast(u64, (x122 >> 56)); const x127 = cast(u64, (x122 & cast(u128, 0xffffffffffffff))); const x128 = (x126 + x111); const x129 = cast(u64, (x125 >> 56)); const x130 = cast(u64, (x125 & cast(u128, 0xffffffffffffff))); const x131 = (x129 + x101); const x132 = (x128 >> 56); const x133 = (x128 & 0xffffffffffffff); const x134 = (x131 >> 56); const x135 = (x131 & 0xffffffffffffff); const x136 = (x114 + x132); const x137 = (x118 + x132); const x138 = (x134 + x136); const x139 = cast(u1, (x138 >> 56)); const x140 = (x138 & 0xffffffffffffff); const x141 = (cast(u64, x139) + x121); const x142 = cast(u1, (x137 >> 56)); const x143 = (x137 & 0xffffffffffffff); const x144 = (cast(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 carrySquare 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 carrySquare(out1: *[8]u64, arg1: [8]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[7]); const x2 = (arg1[7]); const x3 = (x1 * 0x2); const x4 = (x2 * 0x2); const x5 = ((arg1[7]) * 0x2); const x6 = (arg1[6]); const x7 = (arg1[6]); const x8 = (x6 * 0x2); const x9 = (x7 * 0x2); const x10 = ((arg1[6]) * 0x2); const x11 = (arg1[5]); const x12 = (arg1[5]); const x13 = (x11 * 0x2); const x14 = (x12 * 0x2); const x15 = ((arg1[5]) * 0x2); const x16 = (arg1[4]); const x17 = (arg1[4]); const x18 = ((arg1[4]) * 0x2); const x19 = ((arg1[3]) * 0x2); const x20 = ((arg1[2]) * 0x2); const x21 = ((arg1[1]) * 0x2); const x22 = (cast(u128, (arg1[7])) * cast(u128, x1)); const x23 = (cast(u128, (arg1[6])) * cast(u128, x3)); const x24 = (cast(u128, (arg1[6])) * cast(u128, x6)); const x25 = (cast(u128, (arg1[5])) * cast(u128, x3)); const x26 = (cast(u128, (arg1[7])) * cast(u128, x1)); const x27 = (cast(u128, (arg1[6])) * cast(u128, x3)); const x28 = (cast(u128, (arg1[6])) * cast(u128, x6)); const x29 = (cast(u128, (arg1[5])) * cast(u128, x3)); const x30 = (cast(u128, (arg1[7])) * cast(u128, x2)); const x31 = (cast(u128, (arg1[6])) * cast(u128, x4)); const x32 = (cast(u128, (arg1[6])) * cast(u128, x7)); const x33 = (cast(u128, (arg1[5])) * cast(u128, x4)); const x34 = (cast(u128, (arg1[5])) * cast(u128, x9)); const x35 = (cast(u128, (arg1[5])) * cast(u128, x8)); const x36 = (cast(u128, (arg1[5])) * cast(u128, x12)); const x37 = (cast(u128, (arg1[5])) * cast(u128, x11)); const x38 = (cast(u128, (arg1[4])) * cast(u128, x4)); const x39 = (cast(u128, (arg1[4])) * cast(u128, x3)); const x40 = (cast(u128, (arg1[4])) * cast(u128, x9)); const x41 = (cast(u128, (arg1[4])) * cast(u128, x8)); const x42 = (cast(u128, (arg1[4])) * cast(u128, x14)); const x43 = (cast(u128, (arg1[4])) * cast(u128, x13)); const x44 = (cast(u128, (arg1[4])) * cast(u128, x17)); const x45 = (cast(u128, (arg1[4])) * cast(u128, x16)); const x46 = (cast(u128, (arg1[3])) * cast(u128, x4)); const x47 = (cast(u128, (arg1[3])) * cast(u128, x3)); const x48 = (cast(u128, (arg1[3])) * cast(u128, x9)); const x49 = (cast(u128, (arg1[3])) * cast(u128, x8)); const x50 = (cast(u128, (arg1[3])) * cast(u128, x14)); const x51 = (cast(u128, (arg1[3])) * cast(u128, x13)); const x52 = (cast(u128, (arg1[3])) * cast(u128, x18)); const x53 = (cast(u128, (arg1[3])) * cast(u128, (arg1[3]))); const x54 = (cast(u128, (arg1[2])) * cast(u128, x4)); const x55 = (cast(u128, (arg1[2])) * cast(u128, x3)); const x56 = (cast(u128, (arg1[2])) * cast(u128, x9)); const x57 = (cast(u128, (arg1[2])) * cast(u128, x8)); const x58 = (cast(u128, (arg1[2])) * cast(u128, x15)); const x59 = (cast(u128, (arg1[2])) * cast(u128, x18)); const x60 = (cast(u128, (arg1[2])) * cast(u128, x19)); const x61 = (cast(u128, (arg1[2])) * cast(u128, (arg1[2]))); const x62 = (cast(u128, (arg1[1])) * cast(u128, x4)); const x63 = (cast(u128, (arg1[1])) * cast(u128, x3)); const x64 = (cast(u128, (arg1[1])) * cast(u128, x10)); const x65 = (cast(u128, (arg1[1])) * cast(u128, x15)); const x66 = (cast(u128, (arg1[1])) * cast(u128, x18)); const x67 = (cast(u128, (arg1[1])) * cast(u128, x19)); const x68 = (cast(u128, (arg1[1])) * cast(u128, x20)); const x69 = (cast(u128, (arg1[1])) * cast(u128, (arg1[1]))); const x70 = (cast(u128, (arg1[0])) * cast(u128, x5)); const x71 = (cast(u128, (arg1[0])) * cast(u128, x10)); const x72 = (cast(u128, (arg1[0])) * cast(u128, x15)); const x73 = (cast(u128, (arg1[0])) * cast(u128, x18)); const x74 = (cast(u128, (arg1[0])) * cast(u128, x19)); const x75 = (cast(u128, (arg1[0])) * cast(u128, x20)); const x76 = (cast(u128, (arg1[0])) * cast(u128, x21)); const x77 = (cast(u128, (arg1[0])) * cast(u128, (arg1[0]))); const x78 = (x74 + (x68 + (x38 + x34))); const x79 = cast(u64, (x78 >> 56)); const x80 = cast(u64, (x78 & cast(u128, 0xffffffffffffff))); const x81 = (x70 + (x64 + (x58 + (x52 + (x39 + x35))))); const x82 = (x71 + (x65 + (x59 + (x53 + (x47 + (x41 + (x37 + (x30 + x26)))))))); const x83 = (x72 + (x66 + (x60 + (x55 + (x49 + (x43 + (x31 + x27))))))); const x84 = (x73 + (x67 + (x63 + (x61 + (x57 + (x51 + (x45 + (x33 + (x32 + (x29 + x28)))))))))); const x85 = (x75 + (x69 + (x46 + (x40 + (x36 + x22))))); const x86 = (x76 + (x54 + (x48 + (x42 + x23)))); const x87 = (x77 + (x62 + (x56 + (x50 + (x44 + (x25 + x24)))))); const x88 = (cast(u128, x79) + x84); const x89 = cast(u64, (x81 >> 56)); const x90 = cast(u64, (x81 & cast(u128, 0xffffffffffffff))); const x91 = (x88 + cast(u128, x89)); const x92 = cast(u64, (x91 >> 56)); const x93 = cast(u64, (x91 & cast(u128, 0xffffffffffffff))); const x94 = (x87 + cast(u128, x89)); const x95 = (cast(u128, x92) + x83); const x96 = cast(u64, (x94 >> 56)); const x97 = cast(u64, (x94 & cast(u128, 0xffffffffffffff))); const x98 = (cast(u128, x96) + x86); const x99 = cast(u64, (x95 >> 56)); const x100 = cast(u64, (x95 & cast(u128, 0xffffffffffffff))); const x101 = (cast(u128, x99) + x82); const x102 = cast(u64, (x98 >> 56)); const x103 = cast(u64, (x98 & cast(u128, 0xffffffffffffff))); const x104 = (cast(u128, x102) + x85); const x105 = cast(u64, (x101 >> 56)); const x106 = cast(u64, (x101 & cast(u128, 0xffffffffffffff))); const x107 = (x105 + x90); const x108 = cast(u64, (x104 >> 56)); const x109 = cast(u64, (x104 & cast(u128, 0xffffffffffffff))); const x110 = (x108 + x80); const x111 = (x107 >> 56); const x112 = (x107 & 0xffffffffffffff); const x113 = (x110 >> 56); const x114 = (x110 & 0xffffffffffffff); const x115 = (x93 + x111); const x116 = (x97 + x111); const x117 = (x113 + x115); const x118 = cast(u1, (x117 >> 56)); const x119 = (x117 & 0xffffffffffffff); const x120 = (cast(u64, x118) + x100); const x121 = cast(u1, (x116 >> 56)); const x122 = (x116 & 0xffffffffffffff); const x123 = (cast(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 carry 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 carry(out1: *[8]u64, arg1: [8]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (arg1[3]); const x2 = (arg1[7]); const x3 = (x2 >> 56); const x4 = (((x1 >> 56) + (arg1[4])) + x3); const x5 = ((arg1[0]) + x3); const x6 = ((x4 >> 56) + (arg1[5])); const x7 = ((x5 >> 56) + (arg1[1])); const x8 = ((x6 >> 56) + (arg1[6])); const x9 = ((x7 >> 56) + (arg1[2])); const x10 = ((x8 >> 56) + (x2 & 0xffffffffffffff)); const x11 = ((x9 >> 56) + (x1 & 0xffffffffffffff)); const x12 = cast(u1, (x10 >> 56)); const x13 = ((x5 & 0xffffffffffffff) + cast(u64, x12)); const x14 = (cast(u64, cast(u1, (x11 >> 56))) + ((x4 & 0xffffffffffffff) + cast(u64, x12))); const x15 = (x13 & 0xffffffffffffff); const x16 = (cast(u64, cast(u1, (x13 >> 56))) + (x7 & 0xffffffffffffff)); const x17 = (x9 & 0xffffffffffffff); const x18 = (x11 & 0xffffffffffffff); const x19 = (x14 & 0xffffffffffffff); const x20 = (cast(u64, cast(u1, (x14 >> 56))) + (x6 & 0xffffffffffffff)); const x21 = (x8 & 0xffffffffffffff); const x22 = (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 add 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 add(out1: *[8]u64, arg1: [8]u64, arg2: [8]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = ((arg1[0]) + (arg2[0])); const x2 = ((arg1[1]) + (arg2[1])); const x3 = ((arg1[2]) + (arg2[2])); const x4 = ((arg1[3]) + (arg2[3])); const x5 = ((arg1[4]) + (arg2[4])); const x6 = ((arg1[5]) + (arg2[5])); const x7 = ((arg1[6]) + (arg2[6])); const x8 = ((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 sub 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 sub(out1: *[8]u64, arg1: [8]u64, arg2: [8]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = ((0x1fffffffffffffe + (arg1[0])) - (arg2[0])); const x2 = ((0x1fffffffffffffe + (arg1[1])) - (arg2[1])); const x3 = ((0x1fffffffffffffe + (arg1[2])) - (arg2[2])); const x4 = ((0x1fffffffffffffe + (arg1[3])) - (arg2[3])); const x5 = ((0x1fffffffffffffc + (arg1[4])) - (arg2[4])); const x6 = ((0x1fffffffffffffe + (arg1[5])) - (arg2[5])); const x7 = ((0x1fffffffffffffe + (arg1[6])) - (arg2[6])); const x8 = ((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 opp 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 opp(out1: *[8]u64, arg1: [8]u64) void { @setRuntimeSafety(mode == .Debug); const x1 = (0x1fffffffffffffe - (arg1[0])); const x2 = (0x1fffffffffffffe - (arg1[1])); const x3 = (0x1fffffffffffffe - (arg1[2])); const x4 = (0x1fffffffffffffe - (arg1[3])); const x5 = (0x1fffffffffffffc - (arg1[4])); const x6 = (0x1fffffffffffffe - (arg1[5])); const x7 = (0x1fffffffffffffe - (arg1[6])); const x8 = (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 selectznz is a multi-limb conditional select. /// Postconditions: /// eval out1 = (if arg1 = 0 then eval arg2 else eval arg3) /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [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 selectznz(out1: *[8]u64, arg1: u1, arg2: [8]u64, arg3: [8]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); var x2: u64 = undefined; cmovznzU64(&x2, arg1, (arg2[1]), (arg3[1])); var x3: u64 = undefined; cmovznzU64(&x3, arg1, (arg2[2]), (arg3[2])); var x4: u64 = undefined; cmovznzU64(&x4, arg1, (arg2[3]), (arg3[3])); var x5: u64 = undefined; cmovznzU64(&x5, arg1, (arg2[4]), (arg3[4])); var x6: u64 = undefined; cmovznzU64(&x6, arg1, (arg2[5]), (arg3[5])); var x7: u64 = undefined; cmovznzU64(&x7, arg1, (arg2[6]), (arg3[6])); var x8: u64 = undefined; cmovznzU64(&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 toBytes 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 toBytes(out1: *[56]u8, arg1: [8]u64) void { @setRuntimeSafety(mode == .Debug); var x1: u64 = undefined; var x2: u1 = undefined; subborrowxU56(&x1, &x2, 0x0, (arg1[0]), 0xffffffffffffff); var x3: u64 = undefined; var x4: u1 = undefined; subborrowxU56(&x3, &x4, x2, (arg1[1]), 0xffffffffffffff); var x5: u64 = undefined; var x6: u1 = undefined; subborrowxU56(&x5, &x6, x4, (arg1[2]), 0xffffffffffffff); var x7: u64 = undefined; var x8: u1 = undefined; subborrowxU56(&x7, &x8, x6, (arg1[3]), 0xffffffffffffff); var x9: u64 = undefined; var x10: u1 = undefined; subborrowxU56(&x9, &x10, x8, (arg1[4]), 0xfffffffffffffe); var x11: u64 = undefined; var x12: u1 = undefined; subborrowxU56(&x11, &x12, x10, (arg1[5]), 0xffffffffffffff); var x13: u64 = undefined; var x14: u1 = undefined; subborrowxU56(&x13, &x14, x12, (arg1[6]), 0xffffffffffffff); var x15: u64 = undefined; var x16: u1 = undefined; subborrowxU56(&x15, &x16, x14, (arg1[7]), 0xffffffffffffff); var x17: u64 = undefined; cmovznzU64(&x17, x16, cast(u64, 0x0), 0xffffffffffffffff); var x18: u64 = undefined; var x19: u1 = undefined; addcarryxU56(&x18, &x19, 0x0, x1, (x17 & 0xffffffffffffff)); var x20: u64 = undefined; var x21: u1 = undefined; addcarryxU56(&x20, &x21, x19, x3, (x17 & 0xffffffffffffff)); var x22: u64 = undefined; var x23: u1 = undefined; addcarryxU56(&x22, &x23, x21, x5, (x17 & 0xffffffffffffff)); var x24: u64 = undefined; var x25: u1 = undefined; addcarryxU56(&x24, &x25, x23, x7, (x17 & 0xffffffffffffff)); var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU56(&x26, &x27, x25, x9, (x17 & 0xfffffffffffffe)); var x28: u64 = undefined; var x29: u1 = undefined; addcarryxU56(&x28, &x29, x27, x11, (x17 & 0xffffffffffffff)); var x30: u64 = undefined; var x31: u1 = undefined; addcarryxU56(&x30, &x31, x29, x13, (x17 & 0xffffffffffffff)); var x32: u64 = undefined; var x33: u1 = undefined; addcarryxU56(&x32, &x33, x31, x15, (x17 & 0xffffffffffffff)); const x34 = cast(u8, (x18 & cast(u64, 0xff))); const x35 = (x18 >> 8); const x36 = cast(u8, (x35 & cast(u64, 0xff))); const x37 = (x35 >> 8); const x38 = cast(u8, (x37 & cast(u64, 0xff))); const x39 = (x37 >> 8); const x40 = cast(u8, (x39 & cast(u64, 0xff))); const x41 = (x39 >> 8); const x42 = cast(u8, (x41 & cast(u64, 0xff))); const x43 = (x41 >> 8); const x44 = cast(u8, (x43 & cast(u64, 0xff))); const x45 = cast(u8, (x43 >> 8)); const x46 = cast(u8, (x20 & cast(u64, 0xff))); const x47 = (x20 >> 8); const x48 = cast(u8, (x47 & cast(u64, 0xff))); const x49 = (x47 >> 8); const x50 = cast(u8, (x49 & cast(u64, 0xff))); const x51 = (x49 >> 8); const x52 = cast(u8, (x51 & cast(u64, 0xff))); const x53 = (x51 >> 8); const x54 = cast(u8, (x53 & cast(u64, 0xff))); const x55 = (x53 >> 8); const x56 = cast(u8, (x55 & cast(u64, 0xff))); const x57 = cast(u8, (x55 >> 8)); const x58 = cast(u8, (x22 & cast(u64, 0xff))); const x59 = (x22 >> 8); const x60 = cast(u8, (x59 & cast(u64, 0xff))); const x61 = (x59 >> 8); const x62 = cast(u8, (x61 & cast(u64, 0xff))); const x63 = (x61 >> 8); const x64 = cast(u8, (x63 & cast(u64, 0xff))); const x65 = (x63 >> 8); const x66 = cast(u8, (x65 & cast(u64, 0xff))); const x67 = (x65 >> 8); const x68 = cast(u8, (x67 & cast(u64, 0xff))); const x69 = cast(u8, (x67 >> 8)); const x70 = cast(u8, (x24 & cast(u64, 0xff))); const x71 = (x24 >> 8); const x72 = cast(u8, (x71 & cast(u64, 0xff))); const x73 = (x71 >> 8); const x74 = cast(u8, (x73 & cast(u64, 0xff))); const x75 = (x73 >> 8); const x76 = cast(u8, (x75 & cast(u64, 0xff))); const x77 = (x75 >> 8); const x78 = cast(u8, (x77 & cast(u64, 0xff))); const x79 = (x77 >> 8); const x80 = cast(u8, (x79 & cast(u64, 0xff))); const x81 = cast(u8, (x79 >> 8)); const x82 = cast(u8, (x26 & cast(u64, 0xff))); const x83 = (x26 >> 8); const x84 = cast(u8, (x83 & cast(u64, 0xff))); const x85 = (x83 >> 8); const x86 = cast(u8, (x85 & cast(u64, 0xff))); const x87 = (x85 >> 8); const x88 = cast(u8, (x87 & cast(u64, 0xff))); const x89 = (x87 >> 8); const x90 = cast(u8, (x89 & cast(u64, 0xff))); const x91 = (x89 >> 8); const x92 = cast(u8, (x91 & cast(u64, 0xff))); const x93 = cast(u8, (x91 >> 8)); const x94 = cast(u8, (x28 & cast(u64, 0xff))); const x95 = (x28 >> 8); const x96 = cast(u8, (x95 & cast(u64, 0xff))); const x97 = (x95 >> 8); const x98 = cast(u8, (x97 & cast(u64, 0xff))); const x99 = (x97 >> 8); const x100 = cast(u8, (x99 & cast(u64, 0xff))); const x101 = (x99 >> 8); const x102 = cast(u8, (x101 & cast(u64, 0xff))); const x103 = (x101 >> 8); const x104 = cast(u8, (x103 & cast(u64, 0xff))); const x105 = cast(u8, (x103 >> 8)); const x106 = cast(u8, (x30 & cast(u64, 0xff))); const x107 = (x30 >> 8); const x108 = cast(u8, (x107 & cast(u64, 0xff))); const x109 = (x107 >> 8); const x110 = cast(u8, (x109 & cast(u64, 0xff))); const x111 = (x109 >> 8); const x112 = cast(u8, (x111 & cast(u64, 0xff))); const x113 = (x111 >> 8); const x114 = cast(u8, (x113 & cast(u64, 0xff))); const x115 = (x113 >> 8); const x116 = cast(u8, (x115 & cast(u64, 0xff))); const x117 = cast(u8, (x115 >> 8)); const x118 = cast(u8, (x32 & cast(u64, 0xff))); const x119 = (x32 >> 8); const x120 = cast(u8, (x119 & cast(u64, 0xff))); const x121 = (x119 >> 8); const x122 = cast(u8, (x121 & cast(u64, 0xff))); const x123 = (x121 >> 8); const x124 = cast(u8, (x123 & cast(u64, 0xff))); const x125 = (x123 >> 8); const x126 = cast(u8, (x125 & cast(u64, 0xff))); const x127 = (x125 >> 8); const x128 = cast(u8, (x127 & cast(u64, 0xff))); const x129 = cast(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 fromBytes 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 fromBytes(out1: *[8]u64, arg1: [56]u8) void { @setRuntimeSafety(mode == .Debug); const x1 = (cast(u64, (arg1[55])) << 48); const x2 = (cast(u64, (arg1[54])) << 40); const x3 = (cast(u64, (arg1[53])) << 32); const x4 = (cast(u64, (arg1[52])) << 24); const x5 = (cast(u64, (arg1[51])) << 16); const x6 = (cast(u64, (arg1[50])) << 8); const x7 = (arg1[49]); const x8 = (cast(u64, (arg1[48])) << 48); const x9 = (cast(u64, (arg1[47])) << 40); const x10 = (cast(u64, (arg1[46])) << 32); const x11 = (cast(u64, (arg1[45])) << 24); const x12 = (cast(u64, (arg1[44])) << 16); const x13 = (cast(u64, (arg1[43])) << 8); const x14 = (arg1[42]); const x15 = (cast(u64, (arg1[41])) << 48); const x16 = (cast(u64, (arg1[40])) << 40); const x17 = (cast(u64, (arg1[39])) << 32); const x18 = (cast(u64, (arg1[38])) << 24); const x19 = (cast(u64, (arg1[37])) << 16); const x20 = (cast(u64, (arg1[36])) << 8); const x21 = (arg1[35]); const x22 = (cast(u64, (arg1[34])) << 48); const x23 = (cast(u64, (arg1[33])) << 40); const x24 = (cast(u64, (arg1[32])) << 32); const x25 = (cast(u64, (arg1[31])) << 24); const x26 = (cast(u64, (arg1[30])) << 16); const x27 = (cast(u64, (arg1[29])) << 8); const x28 = (arg1[28]); const x29 = (cast(u64, (arg1[27])) << 48); const x30 = (cast(u64, (arg1[26])) << 40); const x31 = (cast(u64, (arg1[25])) << 32); const x32 = (cast(u64, (arg1[24])) << 24); const x33 = (cast(u64, (arg1[23])) << 16); const x34 = (cast(u64, (arg1[22])) << 8); const x35 = (arg1[21]); const x36 = (cast(u64, (arg1[20])) << 48); const x37 = (cast(u64, (arg1[19])) << 40); const x38 = (cast(u64, (arg1[18])) << 32); const x39 = (cast(u64, (arg1[17])) << 24); const x40 = (cast(u64, (arg1[16])) << 16); const x41 = (cast(u64, (arg1[15])) << 8); const x42 = (arg1[14]); const x43 = (cast(u64, (arg1[13])) << 48); const x44 = (cast(u64, (arg1[12])) << 40); const x45 = (cast(u64, (arg1[11])) << 32); const x46 = (cast(u64, (arg1[10])) << 24); const x47 = (cast(u64, (arg1[9])) << 16); const x48 = (cast(u64, (arg1[8])) << 8); const x49 = (arg1[7]); const x50 = (cast(u64, (arg1[6])) << 48); const x51 = (cast(u64, (arg1[5])) << 40); const x52 = (cast(u64, (arg1[4])) << 32); const x53 = (cast(u64, (arg1[3])) << 24); const x54 = (cast(u64, (arg1[2])) << 16); const x55 = (cast(u64, (arg1[1])) << 8); const x56 = (arg1[0]); const x57 = (x55 + cast(u64, x56)); const x58 = (x54 + x57); const x59 = (x53 + x58); const x60 = (x52 + x59); const x61 = (x51 + x60); const x62 = (x50 + x61); const x63 = (x48 + cast(u64, x49)); const x64 = (x47 + x63); const x65 = (x46 + x64); const x66 = (x45 + x65); const x67 = (x44 + x66); const x68 = (x43 + x67); const x69 = (x41 + cast(u64, x42)); const x70 = (x40 + x69); const x71 = (x39 + x70); const x72 = (x38 + x71); const x73 = (x37 + x72); const x74 = (x36 + x73); const x75 = (x34 + cast(u64, x35)); const x76 = (x33 + x75); const x77 = (x32 + x76); const x78 = (x31 + x77); const x79 = (x30 + x78); const x80 = (x29 + x79); const x81 = (x27 + cast(u64, x28)); const x82 = (x26 + x81); const x83 = (x25 + x82); const x84 = (x24 + x83); const x85 = (x23 + x84); const x86 = (x22 + x85); const x87 = (x20 + cast(u64, x21)); const x88 = (x19 + x87); const x89 = (x18 + x88); const x90 = (x17 + x89); const x91 = (x16 + x90); const x92 = (x15 + x91); const x93 = (x13 + cast(u64, x14)); const x94 = (x12 + x93); const x95 = (x11 + x94); const x96 = (x10 + x95); const x97 = (x9 + x96); const x98 = (x8 + x97); const x99 = (x6 + cast(u64, x7)); const x100 = (x5 + x99); const x101 = (x4 + x100); const x102 = (x3 + x101); const x103 = (x2 + x102); const x104 = (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 c = @import("../../c_global.zig").c_imp; // dross-zig const app = @import("../../core/application.zig"); const gly = @import("glyph.zig"); const Glyph = gly.Glyph; // ----------------------------------------------------------------------------- // ----------------------------------------- // - Font Helpers - // ----------------------------------------- /// Returns the width of the string `text` with scaling of `scale` /// using the currently set Font. pub fn getStringWidth(text: []const u8, scale: f32) f32 { const text_length = text.len; var index: usize = 0; var total_width: f32 = 0; while (index < text_length) : (index += 1) { const character: u8 = text[index]; const glyph = app.default_font.?.glyph(character) catch |err| { std.debug.print("[Font]: Error occurred when retrieving glyph {}! {s}\n", .{ character, err }); @panic("[Font]: Failed to find glyph!"); }; const advance = glyph.advance(); const shifted = @intToFloat(f32, (advance >> 6)) * scale; total_width += shifted; } return total_width; } /// Returns the height of the tallest glyph in the string `text` with scaling of `scale` /// using the currently set Font. pub fn getStringHeight(text: []const u8, scale: f32) f32 { const text_length = text.len; var index: usize = 0; var tallest: f32 = 0; while (index < text_length) : (index += 1) { const character: u8 = text[index]; const glyph = app.default_font.?.glyph(character) catch |err| { std.debug.print("[Font]: Error occurred when retrieving glyph {}! {s}\n", .{ character, err }); @panic("[Font]: Failed to find glyph!"); }; const glyph_height = @intToFloat(f32, glyph.rows()); const height = glyph_height * scale; if (tallest < height) tallest = height; } return tallest; }
src/renderer/font/font_helpers.zig
const std = @import("std"); const print = @import("std").debug.print; const fs = std.fs; const mem = @import("std").mem; const web = @import("zhp"); const handlers = @import("handlers.zig"); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; pub const io_mode = .evented; const spi = @import("bus/spi.zig"); const led_driver = @import("led_driver.zig"); const gnss = @import("gnss.zig"); const threads = @import("threads.zig"); const info = @import("info.zig"); fn write_info_json() !void { if (try info.stat()) |stat| { print("stat {any}\n", .{stat}); const file = try std.fs.cwd().createFile("test.json", .{}); defer file.close(); try std.json.stringify(stat, std.json.StringifyOptions{ .whitespace = .{ .indent = .{ .Space = 2 } }, }, file.writer()); } } pub const routes = [_]web.Route{ web.Route.create("", "/", handlers.MainHandler), web.Route.create("api", "/api", handlers.MainHandler), web.Route.create("api/info", "/api/info", handlers.InfoHandler), web.Route.create("api/gnss/pvt", "/api/gnss/pvt", handlers.GnssPvtHandler), web.Route.static("static", "/static/", "static/"), }; pub fn main() anyerror!void { defer std.debug.assert(!gpa.deinit()); const allocator = &gpa.allocator; var loop: std.event.Loop = undefined; try loop.initMultiThreaded(); defer loop.deinit(); var i2c_fd = try fs.openFileAbsolute("/dev/i2c-1", fs.File.OpenFlags{ .read = true, .write = true }); defer i2c_fd.close(); var spi01_fd = try fs.openFileAbsolute("/dev/spidev0.1", fs.File.OpenFlags{ .read = true, .write = true }); defer spi01_fd.close(); const led = led_driver.LP50xx{ .fd = i2c_fd }; if (led.read_register(0x00, 1)) |value| { print("CONFIG0 = 0x{s}\n", .{std.fmt.fmtSliceHexUpper(value)}); } if (led.read_register(0x01, 1)) |value| { print("CONFIG1 = 0x{s}\n", .{std.fmt.fmtSliceHexUpper(value)}); } led.off(); led.enable(); led.set_brightness(0x30); led.set(0, [_]u8{ 0, 0, 0 }); led.set(1, [_]u8{ 0, 0, 0 }); led.set(2, [_]u8{ 0, 0, 0 }); var led_ctx = threads.HeartBeatContext{ .led = led, .idx = 2 }; try loop.runDetached(allocator, threads.heartbeat_thread, .{led_ctx}); var handle = spi.SPI{ .fd = spi01_fd }; print("SPI configure {any}\n", .{handle.configure(0, 5500)}); var pos = gnss.init(handle); pos.configure(); threads.gnss_ctx = threads.GnssContext{ .led = led, .gnss = &pos }; try loop.runDetached(allocator, threads.gnss_thread, .{threads.gnss_ctx}); var app = web.Application.init(allocator, .{ .debug = true }); var app_ctx = threads.AppContext{ .app = &app }; try loop.runDetached(allocator, threads.app_thread, .{app_ctx}); loop.run(); }
src/main.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const ArrayList = std.ArrayList; pub fn Args(comptime FlagSpec: type) type { return struct { const Self = this; flags: FlagSpec, // Could expose a []const []const u8 directly since we don't want modifiable. positionals: ArrayList([]const u8), pub fn parse(allocator: &Allocator, args: []const []const u8) !Self { var self = Self { .flags = undefined, .positionals = ArrayList([]const u8).init(allocator), }; // zero-initialize flags entry by field, either false or null. next: for (args) |arg| { if (mem.eql(u8, "--", arg[0..2])) { for (@fieldsOf(FlagSpec)) |field| { // note: transform name at compile-time '_' -> '-' if (mem.eql(u8, arg[2..], field.name)) { // need lookup by string (see #383). switch (field.type) { ?bool => { parsed.flags[field.name] = true; }, ?[]const u8 => { parsed.flags[field.name] = try nextPositional(); }, // multi-positional argument else => {}, } } continue :next; } // TODO: Better errors with context return error.UnknownArgument; } else { try parsed.positionals.append(arg); } } return parsed; } pub fn deinit(self: &Self) { self.positionals.deinit(); } } } test "example" { const flag_spec = struct { help: ?bool, init: ?bool, build_file: ?[]const u8, cache_dir: ?[]const u8, verbose: ?bool, prefix: ?[]const u8, build_file: ?[]const u8, cache_dir: ?[]const u8, verbose_tokenize: ?bool, verbose_ast: ?bool, verbose_link: ?bool, verbose_ir: ?bool, verbose_llvm_ir: ?bool, verbose_cimport: ?bool, }; const cliargs = []const []const u8 { "zig", "build", "--help", "value", "--init", "pos1", "pos2", "pos3", "pos4", }; var arguments = try Args(flag_spec).parse(std.debug.global_allocator, cliargs); const flags = arguments.flags; const positionals = arguments.positionals; std.debug.warn("help: {}\n", flags.help) std.debug.warn("init: {}\n", flags.init) // Compile-error to access a non-specified flag // std.debug.warn("init2: {}\n", flags.init2) const fallback = flags.build ?? "build.zig" }
src/arg_comptime.zig
const std = @import("std"); const builtin = @import("builtin"); const compiler_rt = @import("index.zig"); pub extern fn __addtf3(a: f128, b: f128) f128 { return addXf3(f128, a, b); } pub extern fn __subtf3(a: f128, b: f128) f128 { const neg_b = @bitCast(f128, @bitCast(u128, b) ^ (u128(1) << 127)); return addXf3(f128, a, neg_b); } inline fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 { const Z = @IntType(false, T.bit_count); const significandBits = std.math.floatMantissaBits(T); const implicitBit = Z(1) << significandBits; const shift = @clz(significand.*) - @clz(implicitBit); significand.* <<= @intCast(u7, shift); return 1 - shift; } inline fn addXf3(comptime T: type, a: T, b: T) T { const Z = @IntType(false, T.bit_count); const typeWidth = T.bit_count; const significandBits = std.math.floatMantissaBits(T); const exponentBits = std.math.floatExponentBits(T); const signBit = (Z(1) << (significandBits + exponentBits)); const maxExponent = ((1 << exponentBits) - 1); const exponentBias = (maxExponent >> 1); const implicitBit = (Z(1) << significandBits); const quietBit = implicitBit >> 1; const significandMask = implicitBit - 1; const absMask = signBit - 1; const exponentMask = absMask ^ significandMask; const qnanRep = exponentMask | quietBit; var aRep = @bitCast(Z, a); var bRep = @bitCast(Z, b); const aAbs = aRep & absMask; const bAbs = bRep & absMask; const negative = (aRep & signBit) != 0; const exponent = @intCast(i32, aAbs >> significandBits) - exponentBias; const significand = (aAbs & significandMask) | implicitBit; const infRep = @bitCast(Z, std.math.inf(T)); // Detect if a or b is zero, infinity, or NaN. if (aAbs - Z(1) >= infRep - Z(1) or bAbs - Z(1) >= infRep - Z(1)) { // NaN + anything = qNaN if (aAbs > infRep) return @bitCast(T, @bitCast(Z, a) | quietBit); // anything + NaN = qNaN if (bAbs > infRep) return @bitCast(T, @bitCast(Z, b) | quietBit); if (aAbs == infRep) { // +/-infinity + -/+infinity = qNaN if ((@bitCast(Z, a) ^ @bitCast(Z, b)) == signBit) { return @bitCast(T, qnanRep); } // +/-infinity + anything remaining = +/- infinity else { return a; } } // anything remaining + +/-infinity = +/-infinity if (bAbs == infRep) return b; // zero + anything = anything if (aAbs == 0) { // but we need to get the sign right for zero + zero if (bAbs == 0) { return @bitCast(T, @bitCast(Z, a) & @bitCast(Z, b)); } else { return b; } } // anything + zero = anything if (bAbs == 0) return a; } // Swap a and b if necessary so that a has the larger absolute value. if (bAbs > aAbs) { const temp = aRep; aRep = bRep; bRep = temp; } // Extract the exponent and significand from the (possibly swapped) a and b. var aExponent = @intCast(i32, (aRep >> significandBits) & maxExponent); var bExponent = @intCast(i32, (bRep >> significandBits) & maxExponent); var aSignificand = aRep & significandMask; var bSignificand = bRep & significandMask; // Normalize any denormals, and adjust the exponent accordingly. if (aExponent == 0) aExponent = normalize(T, &aSignificand); if (bExponent == 0) bExponent = normalize(T, &bSignificand); // The sign of the result is the sign of the larger operand, a. If they // have opposite signs, we are performing a subtraction; otherwise addition. const resultSign = aRep & signBit; const subtraction = (aRep ^ bRep) & signBit != 0; // Shift the significands to give us round, guard and sticky, and or in the // implicit significand bit. (If we fell through from the denormal path it // was already set by normalize( ), but setting it twice won't hurt // anything.) aSignificand = (aSignificand | implicitBit) << 3; bSignificand = (bSignificand | implicitBit) << 3; // Shift the significand of b by the difference in exponents, with a sticky // bottom bit to get rounding correct. const @"align" = @intCast(Z, aExponent - bExponent); if (@"align" != 0) { if (@"align" < typeWidth) { const sticky = if (bSignificand << @intCast(u7, typeWidth - @"align") != 0) Z(1) else 0; bSignificand = (bSignificand >> @truncate(u7, @"align")) | sticky; } else { bSignificand = 1; // sticky; b is known to be non-zero. } } if (subtraction) { aSignificand -= bSignificand; // If a == -b, return +zero. if (aSignificand == 0) return @bitCast(T, Z(0)); // If partial cancellation occured, we need to left-shift the result // and adjust the exponent: if (aSignificand < implicitBit << 3) { const shift = @intCast(i32, @clz(aSignificand)) - @intCast(i32, @clz(implicitBit << 3)); aSignificand <<= @intCast(u7, shift); aExponent -= shift; } } else { // addition aSignificand += bSignificand; // If the addition carried up, we need to right-shift the result and // adjust the exponent: if (aSignificand & (implicitBit << 4) != 0) { const sticky = aSignificand & 1; aSignificand = aSignificand >> 1 | sticky; aExponent += 1; } } // If we have overflowed the type, return +/- infinity: if (aExponent >= maxExponent) return @bitCast(T, infRep | resultSign); if (aExponent <= 0) { // Result is denormal before rounding; the exponent is zero and we // need to shift the significand. const shift = @intCast(Z, 1 - aExponent); const sticky = if (aSignificand << @intCast(u7, typeWidth - shift) != 0) Z(1) else 0; aSignificand = aSignificand >> @intCast(u7, shift | sticky); aExponent = 0; } // Low three bits are round, guard, and sticky. const roundGuardSticky = aSignificand & 0x7; // Shift the significand into place, and mask off the implicit bit. var result = (aSignificand >> 3) & significandMask; // Insert the exponent and sign. result |= @intCast(Z, aExponent) << significandBits; result |= resultSign; // Final rounding. The result may overflow to infinity, but that is the // correct result in that case. if (roundGuardSticky > 0x4) result += 1; if (roundGuardSticky == 0x4) result += result & 1; return @bitCast(T, result); } test "import addXf3" { _ = @import("addXf3_test.zig"); }
std/special/compiler_rt/addXf3.zig
const __floattitf = @import("floattitf.zig").__floattitf; const testing = @import("std").testing; fn test__floattitf(a: i128, expected: f128) void { const x = __floattitf(a); testing.expect(x == expected); } test "floattitf" { if (@import("std").Target.current.os.tag == .windows) { // TODO https://github.com/ziglang/zig/issues/508 return error.SkipZigTest; } test__floattitf(0, 0.0); test__floattitf(1, 1.0); test__floattitf(2, 2.0); test__floattitf(20, 20.0); test__floattitf(-1, -1.0); test__floattitf(-2, -2.0); test__floattitf(-20, -20.0); test__floattitf(0x7FFFFF8000000000, 0x1.FFFFFEp+62); test__floattitf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62); test__floattitf(0x7FFFFF0000000000, 0x1.FFFFFCp+62); test__floattitf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62); test__floattitf(make_ti(0x8000008000000000, 0), -0x1.FFFFFEp+126); test__floattitf(make_ti(0x8000000000000800, 0), -0x1.FFFFFFFFFFFFEp+126); test__floattitf(make_ti(0x8000010000000000, 0), -0x1.FFFFFCp+126); test__floattitf(make_ti(0x8000000000001000, 0), -0x1.FFFFFFFFFFFFCp+126); test__floattitf(make_ti(0x8000000000000000, 0), -0x1.000000p+127); test__floattitf(make_ti(0x8000000000000001, 0), -0x1.FFFFFFFFFFFFFFFCp+126); test__floattitf(0x0007FB72E8000000, 0x1.FEDCBAp+50); test__floattitf(0x0007FB72EA000000, 0x1.FEDCBA8p+50); test__floattitf(0x0007FB72EB000000, 0x1.FEDCBACp+50); test__floattitf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50); test__floattitf(0x0007FB72EC000000, 0x1.FEDCBBp+50); test__floattitf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50); test__floattitf(0x0007FB72E6000000, 0x1.FEDCB98p+50); test__floattitf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50); test__floattitf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50); test__floattitf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50); test__floattitf(0x0007FB72E4000000, 0x1.FEDCB9p+50); test__floattitf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57); test__floattitf(0x023479FD0E092DA1, 0x1.1A3CFE870496D08p+57); test__floattitf(0x023479FD0E092DB0, 0x1.1A3CFE870496D8p+57); test__floattitf(0x023479FD0E092DB8, 0x1.1A3CFE870496DCp+57); test__floattitf(0x023479FD0E092DB6, 0x1.1A3CFE870496DBp+57); test__floattitf(0x023479FD0E092DBF, 0x1.1A3CFE870496DF8p+57); test__floattitf(0x023479FD0E092DC1, 0x1.1A3CFE870496E08p+57); test__floattitf(0x023479FD0E092DC7, 0x1.1A3CFE870496E38p+57); test__floattitf(0x023479FD0E092DC8, 0x1.1A3CFE870496E4p+57); test__floattitf(0x023479FD0E092DCF, 0x1.1A3CFE870496E78p+57); test__floattitf(0x023479FD0E092DD0, 0x1.1A3CFE870496E8p+57); test__floattitf(0x023479FD0E092DD1, 0x1.1A3CFE870496E88p+57); test__floattitf(0x023479FD0E092DD8, 0x1.1A3CFE870496ECp+57); test__floattitf(0x023479FD0E092DDF, 0x1.1A3CFE870496EF8p+57); test__floattitf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57); test__floattitf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121); test__floattitf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496D08p+121); test__floattitf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496D8p+121); test__floattitf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496DCp+121); test__floattitf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496DBp+121); test__floattitf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496DF8p+121); test__floattitf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496E08p+121); test__floattitf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496E38p+121); test__floattitf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496E4p+121); test__floattitf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496E78p+121); test__floattitf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496E8p+121); test__floattitf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496E88p+121); test__floattitf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496ECp+121); test__floattitf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496EF8p+121); test__floattitf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121); test__floattitf(make_ti(0, 0xFFFFFFFFFFFFFFFF), 0x1.FFFFFFFFFFFFFFFEp+63); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC2801), 0x1.23456789ABCDEF0123456789ABC3p+124); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC3000), 0x1.23456789ABCDEF0123456789ABC3p+124); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC37FF), 0x1.23456789ABCDEF0123456789ABC3p+124); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC3800), 0x1.23456789ABCDEF0123456789ABC4p+124); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4000), 0x1.23456789ABCDEF0123456789ABC4p+124); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC47FF), 0x1.23456789ABCDEF0123456789ABC4p+124); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4800), 0x1.23456789ABCDEF0123456789ABC4p+124); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4801), 0x1.23456789ABCDEF0123456789ABC5p+124); test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC57FF), 0x1.23456789ABCDEF0123456789ABC5p+124); } fn make_ti(high: u64, low: u64) i128 { var result: u128 = high; result <<= 64; result |= low; return @bitCast(i128, result); }
lib/std/special/compiler_rt/floattitf_test.zig
pub const Registry = struct { copyright: []const u8, decls: []Declaration, api_constants: []ApiConstant, tags: []Tag, features: []Feature, extensions: []Extension, }; pub const Declaration = struct { name: []const u8, decl_type: DeclarationType, }; pub const DeclarationType = union(enum) { container: Container, enumeration: Enum, bitmask: Bitmask, handle: Handle, command: Command, alias: Alias, foreign: Foreign, typedef: TypeInfo, external, }; pub const Alias = struct { pub const Target = enum { other_command, other_type, }; name: []const u8, target: Target, }; pub const ApiConstant = struct { pub const Value = union(enum) { expr: []const u8, version: [3][]const u8, }; name: []const u8, value: Value, }; pub const Tag = struct { name: []const u8, author: []const u8, }; pub const TypeInfo = union(enum) { name: []const u8, command_ptr: Command, pointer: Pointer, array: Array, }; pub const Container = struct { pub const Field = struct { name: []const u8, field_type: TypeInfo, bits: ?usize, is_buffer_len: bool, }; stype: ?[]const u8, fields: []Field, is_union: bool, }; pub const Enum = struct { pub const Value = union(enum) { bitpos: u5, // 1 << bitpos bit_vector: i32, // Combined flags & some vendor IDs int: i32, alias: struct { name: []const u8, is_compat_alias: bool, } }; pub const Field = struct { name: []const u8, value: Value, }; fields: []Field, is_bitmask: bool, }; pub const Bitmask = struct { bits_enum: ?[]const u8, }; pub const Handle = struct { parent: ?[]const u8, // XrInstance has no parent is_dispatchable: bool, }; pub const Command = struct { pub const Param = struct { name: []const u8, param_type: TypeInfo, is_buffer_len: bool, }; params: []Param, return_type: *TypeInfo, success_codes: [][]const u8, error_codes: [][]const u8, }; pub const Pointer = struct { pub const PointerSize = union(enum) { one, many, // The length is given by some complex expression, possibly involving another field other_field: []const u8, // The length is given by some other field or parameter zero_terminated }; is_const: bool, is_optional: bool, size: PointerSize, child: *TypeInfo, }; pub const Array = struct { pub const ArraySize = union(enum) { int: usize, alias: []const u8, // Field size is given by an api constant }; size: ArraySize, child: *TypeInfo, }; pub const Foreign = struct { depends: []const u8, // Either a header or openxr_platform_defines }; pub const Feature = struct { name: []const u8, level: FeatureLevel, // from 'number' requires: []Require, }; pub const Extension = struct { pub const ExtensionType = enum { instance, device, }; pub const Promotion = union(enum) { none, feature: FeatureLevel, extension: []const u8, }; name: []const u8, number: u31, version: u32, extension_type: ?ExtensionType, depends: []const []const u8, // Other extensions promoted_to: Promotion, platform: ?[]const u8, required_feature_level: ?FeatureLevel, requires: []Require, }; pub const Require = struct { pub const EnumExtension = struct { extends: []const u8, extnumber: ?u31, field: Enum.Field, }; extends: []EnumExtension, types: []const []const u8, commands: []const []const u8, required_feature_level: ?FeatureLevel, required_extension: ?[]const u8, }; pub const FeatureLevel = struct { major: u32, minor: u32, };
generator/openxr/registry.zig
const std = @import("std"); const builtin = @import("builtin"); const is_windows: bool = builtin.os.tag == .windows; const System = @import("../interface/System.zig"); const Dir = @import("../interface/Dir.zig"); const File = @import("../interface/File.zig"); const Config = @import("../config/Config.zig"); const FileSystemDescription = @import("../config/FileSystemDescription.zig"); pub fn FileSystem(comptime config: Config) type { if (!config.file_system) return struct {}; return struct { allocator: std.mem.Allocator, entries: std.AutoHashMapUnmanaged(*Entry, void), views: std.AutoHashMapUnmanaged(*View, void), root: *Entry, cwd_entry: *Entry, const CWD = @intToPtr(*anyopaque, std.mem.alignBackward(std.math.maxInt(usize), @alignOf(View))); const Self = @This(); const FileSystemType = Self; const log = std.log.scoped(config.logging_scope); // ** INITALIZATION ** pub fn init(allocator: std.mem.Allocator, fsd: *const FileSystemDescription) !*Self { var self = try allocator.create(Self); self.* = .{ .allocator = allocator, .entries = .{}, .views = .{}, .root = undefined, .cwd_entry = undefined, }; errdefer self.deinit(); try self.entries.ensureTotalCapacity(allocator, @intCast(u32, fsd.entries.items.len)); var opt_root: ?*Entry = null; var opt_cwd_entry: ?*Entry = null; _ = try self.initAddDirAndRecurse( fsd, fsd.root, fsd.getCwd(), &opt_root, &opt_cwd_entry, ); if (opt_root) |root| { self.root = root; self.root.incrementReference(); } else return error.NoRootDirectory; if (opt_cwd_entry) |cwd_entry| { try self.setCwd(cwd_entry, false); } else return error.NoCwd; return self; } pub fn deinit(self: *Self) void { if (config.log) { log.debug("deinitializing FileSystem", .{}); } { var iter = self.views.keyIterator(); while (iter.next()) |view| { view.*.deinit(); } self.views.deinit(self.allocator); } { var iter = self.entries.keyIterator(); while (iter.next()) |entry| { entry.*.deinit(); } self.entries.deinit(self.allocator); } self.allocator.destroy(self); } fn initAddDirAndRecurse( self: *Self, fsd: *const FileSystemDescription, current_dir: *const FileSystemDescription.EntryDescription, ptr_to_inital_cwd: *const FileSystemDescription.EntryDescription, opt_root: *?*Entry, opt_cwd_entry: *?*Entry, ) (error{DuplicateEntry} || std.mem.Allocator.Error)!*Entry { std.debug.assert(current_dir.subdata == .dir); const dir_entry = try self.addDirEntry(current_dir.name); if (opt_root.* == null) opt_root.* = dir_entry; if (opt_cwd_entry.* == null and current_dir == ptr_to_inital_cwd) opt_cwd_entry.* = dir_entry; for (current_dir.subdata.dir.entries.items) |entry| { const new_entry: *Entry = switch (entry.subdata) { .file => |file| try self.addFileEntry(entry.name, file.contents), .dir => try self.initAddDirAndRecurse(fsd, entry, ptr_to_inital_cwd, opt_root, opt_cwd_entry), }; try dir_entry.addEntry(new_entry); } return dir_entry; } // ** INTERNAL API fn addFileEntry(self: *Self, name: []const u8, contents: []const u8) !*Entry { const entry = try Entry.createFile(self.allocator, self, name, contents); errdefer entry.deinit(); try self.entries.putNoClobber(self.allocator, entry, {}); return entry; } fn addDirEntry(self: *Self, name: []const u8) !*Entry { const entry = try Entry.createDir(self.allocator, self, name); errdefer entry.deinit(); try self.entries.putNoClobber(self.allocator, entry, {}); return entry; } fn addView(self: *Self, entry: *Entry) !*View { entry.incrementReference(); errdefer _ = entry.decrementReference(); var view = try self.allocator.create(View); errdefer self.allocator.destroy(view); view.* = .{ .entry = entry, .file_system = self, }; try self.views.putNoClobber(self.allocator, view, {}); return view; } fn removeView(self: *Self, view: *View) void { _ = view.entry.decrementReference(); _ = self.views.remove(view); view.deinit(); } fn setCwd(self: *Self, entry: *Entry, dereference_old_cwd: bool) !void { entry.incrementReference(); if (dereference_old_cwd) _ = self.cwd_entry.decrementReference(); self.cwd_entry = entry; } inline fn isCwd(ptr: *anyopaque) bool { return CWD == ptr; } inline fn toView(self: *Self, ptr: *anyopaque) ?*View { const view = @ptrCast(*View, @alignCast(@alignOf(View), ptr)); if (self.views.contains(view)) { return view; } return null; } fn cwdOrEntry(self: *Self, ptr: *anyopaque) ?*Entry { if (isCwd(ptr)) return self.cwd_entry; if (self.toView(ptr)) |v| return v.entry; return null; } fn resolveSearchRootFromPath(self: *Self, possible_parent: *Entry, path: []const u8) *Entry { return if (std.fs.path.isAbsolute(path)) self.root else possible_parent; } fn resolveEntry(self: *Self, search_root: *Entry, path: []const u8) !?*Entry { _ = self; var entry: *Entry = undefined; var search_entry = search_root; var path_iter = std.mem.tokenize(u8, path, std.fs.path.sep_str); path_loop: while (path_iter.next()) |section| { if (config.log) { log.debug("current search entry: {*}, search entry name: \"{s}\", section: \"{s}\"", .{ search_entry, search_entry.name, section, }); } if (section.len == 0) continue; if (std.mem.eql(u8, section, ".")) { if (config.log) { log.debug("skipping current directory section", .{}); } continue; } if (std.mem.eql(u8, section, "..")) { if (config.log) { log.debug("traverse to parent directory section", .{}); } if (search_entry.parent) |search_entry_parent| { entry = search_entry_parent; search_entry = search_entry_parent; } else if (search_entry != self.root) { // TODO: This should instead return an error, but what error? FileNotFound? @panic("attempted to traverse to parent of search entry with no parent"); } continue; } var iter = search_entry.subdata.dir.entries.iterator(); while (iter.next()) |e| { const child = e.key_ptr.*; if (std.mem.eql(u8, child.name, section)) { if (config.log) { log.debug("found entry: {*}, name: \"{s}\", type: {s}", .{ child, child.name, @tagName(child.subdata) }); } switch (child.subdata) { .dir => { entry = child; search_entry = child; continue :path_loop; }, .file => { if (path_iter.next() != null) { if (config.log) { log.err("file encountered in middle of path", .{}); } return File.OpenError.NotDir; } entry = child; break :path_loop; }, } } } else { if (config.log) { log.err("search directory \"{s}\" does not contain an entry \"{s}\"", .{ search_entry.name, section }); } return null; } } return entry; } // ** EXTERNAL API pub fn cwd(self: *Self) *anyopaque { _ = self; if (config.log) { log.info("cwd called", .{}); } return CWD; } pub fn openFileFromDir( self: *Self, ptr: *anyopaque, sub_path: []const u8, flags: File.OpenFlags, ) File.OpenError!*anyopaque { if (is_windows) { // TODO: Implement windows @compileError("Windows support is unimplemented"); } if (flags.mode != .read_only) { // TODO: Implement *not* read_only std.debug.panic("file mode '{s}' is unimplemented", .{@tagName(flags.mode)}); } if (flags.lock != .None) { // TODO: Implement lock @panic("lock is unimplemented"); } if (flags.allow_ctty) { @panic("allow_ctty is unsupported"); } const dir_entry = self.cwdOrEntry(ptr) orelse return File.OpenError.NoDevice; if (config.log) { log.info("openFileFromDir called, entry: {*}, sub_path: \"{s}\", flags: {}", .{ dir_entry, sub_path, flags }); } const search_root = self.resolveSearchRootFromPath(dir_entry, sub_path); if (config.log) { log.debug("initial search entry: {*}, name: \"{s}\"", .{ search_root, search_root.name }); } const entry = (try self.resolveEntry(search_root, sub_path)) orelse return File.OpenError.FileNotFound; const view = self.addView(entry) catch return error.SystemResources; if (config.log) { log.debug("opened view, view: {*}, entry: {*}, entry name: \"{s}\"", .{ view, entry, entry.name }); } return view; } pub fn readFile(self: *Self, ptr: *anyopaque, buffer: []u8) std.os.ReadError!usize { const view = self.toView(ptr) orelse return error.NotOpenForReading; if (config.log) { log.info("readFile called, view: {*}, buffer len: {}", .{ view, buffer.len }); } const entry = view.entry; switch (entry.subdata) { .dir => { if (config.log) { log.err("entry is a dir", .{}); } return std.os.ReadError.IsDir; }, .file => |file| { const size = std.math.min(buffer.len, file.contents.len - view.position); const end = view.position + size; std.mem.copy(u8, buffer, file.contents[view.position..end]); view.position = end; return size; }, } } pub fn closeFile(self: *Self, ptr: *anyopaque) void { const view = self.toView(ptr) orelse return; if (config.log) { log.info("closeFile called, view: {*}", .{view}); } if (config.log) { log.debug("closed view {*}, entry: {*}, entry name: \"{s}\"", .{ view, view.entry, view.entry.name }); } self.removeView(view); } const Entry = struct { ref_count: usize = 0, name: []const u8, subdata: SubData, parent: ?*Entry = null, allocator: std.mem.Allocator, file_system: *FileSystemType, const SubData = union(enum) { file: FileData, dir: DirData, const FileData = struct { contents: []const u8, }; const DirData = struct { entries: std.AutoArrayHashMapUnmanaged(*Entry, void) = .{}, }; }; fn createFile( allocator: std.mem.Allocator, file_system: *FileSystemType, name: []const u8, contents: []const u8, ) !*Entry { const dupe_name = try allocator.dupe(u8, name); errdefer allocator.free(dupe_name); const dupe_content = try allocator.dupe(u8, contents); errdefer allocator.free(dupe_content); var entry = try allocator.create(Entry); errdefer allocator.destroy(entry); entry.* = .{ .allocator = allocator, .file_system = file_system, .name = dupe_name, .subdata = .{ .file = .{ .contents = dupe_content } }, }; return entry; } fn createDir(allocator: std.mem.Allocator, file_system: *FileSystemType, name: []const u8) !*Entry { const dupe_name = try allocator.dupe(u8, name); errdefer allocator.free(dupe_name); var entry = try allocator.create(Entry); errdefer allocator.destroy(entry); entry.* = .{ .allocator = allocator, .file_system = file_system, .name = dupe_name, .subdata = .{ .dir = .{} }, }; return entry; } fn incrementReference(self: *Entry) void { self.ref_count += 1; } /// Returns `true` if the entry has been destroyed fn decrementReference(self: *Entry) bool { self.ref_count -= 1; if (self.ref_count == 0) { if (config.log) { log.debug("entry {*} reference count reached zero, entry name: \"{s}\"", .{ self, self.name }); } self.deinit(); return true; } return false; } fn setParent(self: *Entry, parent: *Entry) !void { if (self.parent) |old_parent| { _ = old_parent.decrementReference(); } else { self.incrementReference(); } self.parent = parent; } /// Returns `true` if the entry has been destroyed fn unsetParent(self: *Entry) bool { if (self.parent) |old_parent| { _ = old_parent.decrementReference(); } if (self.decrementReference()) { return true; } self.parent = null; return false; } fn addEntry(self: *Entry, entry: *Entry) !void { std.debug.assert(self.subdata == .dir); self.incrementReference(); errdefer _ = self.decrementReference(); if (try self.subdata.dir.entries.fetchPut(self.allocator, entry, {})) |_| { return error.DuplicateEntry; } errdefer _ = self.subdata.dir.entries.swapRemove(entry); try entry.setParent(self); } /// Returns true if the entry has been destroyed fn removeEntry(self: *Entry, entry: *Entry) bool { std.debug.assert(self.subdata == .dir); if (self.subdata.dir.entries.fetchSwapRemove(entry)) |e| { return e.key.unsetParent(); } return false; } fn deinit(self: *Entry) void { self.allocator.free(self.name); switch (self.subdata) { .file => |file| self.allocator.free(file.contents), .dir => |*dir| dir.entries.deinit(self.allocator), } self.allocator.destroy(self); } comptime { std.testing.refAllDecls(@This()); } }; const View = struct { entry: *Entry, position: usize = 0, file_system: *FileSystemType, pub fn deinit(self: *View) void { self.file_system.allocator.destroy(self); } comptime { std.testing.refAllDecls(@This()); } }; comptime { std.testing.refAllDecls(@This()); } }; } comptime { @import("../internal.zig").referenceAllIterations(FileSystem); } comptime { std.testing.refAllDecls(@This()); }
src/backend/FileSystem.zig
const builtin = @import("builtin"); const TypeId = builtin.TypeId; const std = @import("std"); const math = std.math; const assert = std.debug.assert; const warn = std.debug.warn; const bufPrint = std.fmt.bufPrint; const matrix = @import("matrix.zig"); const Matrix = matrix.Matrix; const M44f32 = matrix.M44f32; const m44f32_unit = matrix.m44f32_unit; const ae = @import("modules/zig-approxeql/approxeql.zig"); const tc = @import("typeconversions.zig"); const misc = @import("modules/zig-misc/index.zig"); const testExpected = misc.testExpected; const degToRad = @import("degrad.zig").degToRad; const DBG = false; pub fn Vec(comptime T: type, comptime size: usize) type { if (@typeId(T) != TypeId.Float) @compileError("Vec only support TypeId.Floats at this time"); switch (size) { 2 => { return struct { const Self = @This(); pub data: [2]T, pub fn init(xp: T, yp: T) Self { return Self{ .data = []T{ xp, yp } }; } pub fn initVal(val: T) Self { return Vec(T, size).init(val, val); } pub fn x(pSelf: *const Self) T { return pSelf.data[0]; } pub fn y(pSelf: *const Self) T { return pSelf.data[1]; } pub fn set(pSelf: *Self, vx: T, vy: T) void { pSelf.setX(vx); pSelf.setY(vy); } pub fn setX(pSelf: *Self, v: T) void { pSelf.data[0] = v; } pub fn setY(pSelf: *Self, v: T) void { pSelf.data[1] = v; } pub fn eql(pSelf: *const Self, pOther: *const Self) bool { return pSelf.x() == pOther.x() and pSelf.y() == pOther.y(); } pub fn approxEql(pSelf: *const Self, pOther: *const Self, digits: usize) bool { return ae.approxEql(pSelf.x(), pOther.x(), digits) and ae.approxEql(pSelf.y(), pOther.y(), digits); } pub fn neg(pSelf: *const Self) Self { return Vec(T, size).init(-pSelf.x(), -pSelf.y()); } pub fn scale(pSelf: *const Self, factor: T) Self { return Vec(T, size).init(pSelf.x() * factor, pSelf.y() * factor); } pub fn add(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init((pSelf.x() + pOther.x()), (pSelf.y() + pOther.y())); } pub fn sub(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init( (pSelf.x() - pOther.x()), (pSelf.y() - pOther.y()), ); } pub fn mul(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init( (pSelf.x() * pOther.x()), (pSelf.y() * pOther.y()), ); } pub fn div(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init( (pSelf.x() / pOther.x()), (pSelf.y() / pOther.y()), ); } /// Returns the length as a f64, f32 or f16 pub fn length(pSelf: *const Self) T { return math.sqrt(pSelf.normal()); } pub fn dot(pSelf: *const Self, pOther: *const Self) T { return (pSelf.x() * pOther.x()) + (pSelf.y() * pOther.y()); } pub fn normal(pSelf: *const Self) T { return (pSelf.x() * pSelf.x()) + (pSelf.y() * pSelf.y()); } pub fn normalize(pSelf: *const Self) Self { var len = pSelf.length(); var v: Self = undefined; if (len > 0) { v.setX(pSelf.x() / len); v.setY(pSelf.y() / len); } else { v = pSelf.*; } return v; } // The cross product of 2D vectors returns the signed magnitude of the // z component if we assume the 2D vectors are in the xy plane of a 3D // coordinate space and thus each have a z component of 0. pub fn cross(pSelf: *const Self, pOther: *const Self) T { return (pSelf.x() * pOther.y()) - (pSelf.y() * pOther.x()); } /// Custom format routine pub fn format( self: *const Self, comptime fmt: []const u8, context: var, comptime FmtError: type, output: fn (@typeOf(context), []const u8) FmtError!void, ) FmtError!void { try formatVec(T, size, self, fmt, context, FmtError, output); } }; }, 3 => { return struct { const Self = @This(); pub data: [3]T, pub fn init(xp: T, yp: T, zp: T) Self { return Self{ .data = []T{ xp, yp, zp } }; } pub fn initVal(val: T) Self { return Vec(T, size).init(val, val, val); } pub fn unitX() Self { return Self.init(1, 0, 0); } pub fn unitY() Self { return Self.init(0, 1, 0); } pub fn unitZ() Self { return Self.init(0, 0, 1); } pub fn x(pSelf: *const Self) T { return pSelf.data[0]; } pub fn y(pSelf: *const Self) T { return pSelf.data[1]; } pub fn z(pSelf: *const Self) T { return pSelf.data[2]; } pub fn set(pSelf: *Self, vx: T, vy: T, vz: T) void { pSelf.setX(vx); pSelf.setY(vy); pSelf.setZ(vz); } pub fn setX(pSelf: *Self, v: T) void { pSelf.data[0] = v; } pub fn setY(pSelf: *Self, v: T) void { pSelf.data[1] = v; } pub fn setZ(pSelf: *Self, v: T) void { pSelf.data[2] = v; } pub fn eql(pSelf: *const Self, pOther: *const Self) bool { return pSelf.x() == pOther.x() and pSelf.y() == pOther.y() and pSelf.z() == pOther.z(); } pub fn approxEql(pSelf: *const Self, pOther: *const Self, digits: usize) bool { return ae.approxEql(pSelf.x(), pOther.x(), digits) and ae.approxEql(pSelf.y(), pOther.y(), digits) and ae.approxEql(pSelf.z(), pOther.z(), digits); } pub fn neg(pSelf: *const Self) Self { return Vec(T, size).init(-pSelf.x(), -pSelf.y(), -pSelf.z()); } pub fn scale(pSelf: *const Self, factor: T) Self { return Vec(T, size).init(pSelf.x() * factor, pSelf.y() * factor, pSelf.z() * factor); } pub fn add(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init( (pSelf.x() + pOther.x()), (pSelf.y() + pOther.y()), (pSelf.z() + pOther.z()), ); } pub fn sub(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init( (pSelf.x() - pOther.x()), (pSelf.y() - pOther.y()), (pSelf.z() - pOther.z()), ); } pub fn mul(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init( (pSelf.x() * pOther.x()), (pSelf.y() * pOther.y()), (pSelf.z() * pOther.z()), ); } pub fn div(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init( (pSelf.x() / pOther.x()), (pSelf.y() / pOther.y()), (pSelf.z() / pOther.z()), ); } /// Returns the length as a f64, f32 or f16 pub fn length(pSelf: *const Self) T { return math.sqrt(pSelf.normal()); } pub fn dot(pSelf: *const Self, pOther: *const Self) T { return (pSelf.x() * pOther.x()) + (pSelf.y() * pOther.y()) + (pSelf.z() * pOther.z()); } pub fn normal(pSelf: *const Self) T { return (pSelf.x() * pSelf.x()) + (pSelf.y() * pSelf.y()) + (pSelf.z() * pSelf.z()); } pub fn normalize(pSelf: *const Self) Self { var len = pSelf.length(); var v: Self = undefined; if (len > 0) { v.setX(pSelf.x() / len); v.setY(pSelf.y() / len); v.setZ(pSelf.z() / len); } else { v = pSelf.*; } return v; } pub fn cross(pSelf: *const Self, pOther: *const Self) Self { return Vec(T, size).init( (pSelf.y() * pOther.z()) - (pSelf.z() * pOther.y()), (pSelf.z() * pOther.x()) - (pSelf.x() * pOther.z()), (pSelf.x() * pOther.y()) - (pSelf.y() * pOther.x()), ); } pub fn transform(pSelf: *const Self, m: *const Matrix(T, 4, 4)) Self { var vx = pSelf.x(); var vy = pSelf.y(); var vz = pSelf.z(); const rx = (vx * m.data[0][0]) + (vy * m.data[1][0]) + (vz * m.data[2][0]) + m.data[3][0]; const ry = (vx * m.data[0][1]) + (vy * m.data[1][1]) + (vz * m.data[2][1]) + m.data[3][1]; const rz = (vx * m.data[0][2]) + (vy * m.data[1][2]) + (vz * m.data[2][2]) + m.data[3][2]; var rw = (vx * m.data[0][3]) + (vy * m.data[1][3]) + (vz * m.data[2][3]) + m.data[3][3]; if (rw != 1) { rw = 1.0 / rw; } return Self.init(rx * rw, ry * rw, rz * rw); } pub fn transformNormal(pSelf: *const Self, m: *const Matrix(T, 4, 4)) Self { var vx = pSelf.x(); var vy = pSelf.y(); var vz = pSelf.z(); const rx = (vx * m.data[0][0]) + (vy * m.data[1][0]) + (vz * m.data[2][0]); const ry = (vx * m.data[0][1]) + (vy * m.data[1][1]) + (vz * m.data[2][1]); const rz = (vx * m.data[0][2]) + (vy * m.data[1][2]) + (vz * m.data[2][2]); return Self.init(rx, ry, rz); } /// Custom format routine pub fn format( self: *const Self, comptime fmt: []const u8, context: var, comptime FmtError: type, output: fn (@typeOf(context), []const u8) FmtError!void, ) FmtError!void { try formatVec(T, size, self, fmt, context, FmtError, output); } }; }, else => @compileError("Only Vec size 2 and 3 supported"), } } pub const V2f32 = Vec(f32, 2); pub const V3f32 = Vec(f32, 3); /// Custom format routine fn formatVec( comptime T: type, comptime size: usize, pSelf: *const Vec(T, size), comptime fmt: []const u8, context: var, comptime FmtError: type, output: fn (@typeOf(context), []const u8) FmtError!void, ) FmtError!void { try std.fmt.format(context, FmtError, output, "[]{} {{ ", @typeName(T)); for (pSelf.data) |col, i| { try std.fmt.format(context, FmtError, output, "{}{.5}{}", if (math.signbit(col)) "-" else " ", if (math.signbit(col)) -col else col, if (i < (pSelf.data.len - 1)) ", " else " "); } try std.fmt.format(context, FmtError, output, "}}"); } test "vec3.init" { const vf64 = Vec(f64, 3).initVal(0); assert(vf64.x() == 0); assert(vf64.y() == 0); assert(vf64.z() == 0); const vf32 = Vec(f32, 3).initVal(1); assert(vf32.x() == 1); assert(vf32.y() == 1); assert(vf32.z() == 1); var v1 = V3f32.init(1, 2, 3); assert(v1.x() == 1); assert(v1.y() == 2); assert(v1.z() == 3); v1 = V3f32.unitX(); assert(v1.x() == 1); assert(v1.y() == 0); assert(v1.z() == 0); v1 = V3f32.unitY(); assert(v1.x() == 0); assert(v1.y() == 1); assert(v1.z() == 0); v1 = V3f32.unitZ(); assert(v1.x() == 0); assert(v1.y() == 0); assert(v1.z() == 1); } test "vec3.copy" { var v1 = Vec(f32, 3).init(1, 2, 3); assert(v1.x() == 1); assert(v1.y() == 2); assert(v1.z() == 3); // Copy a vector var v2 = v1; assert(v2.x() == 1); assert(v2.y() == 2); assert(v2.z() == 3); // Copy via a pointer var pV1 = &v1; var v3 = pV1.*; assert(v3.x() == 1); assert(v3.y() == 2); assert(v3.z() == 3); } test "vec3.eql" { const v1 = Vec(f32, 3).init(1.2345678, 2.3456789, 3.4567890); const v2 = Vec(f32, 3).init(1.2345678, 2.3456789, 3.4567890); assert(v1.eql(&v2)); } test "vec3.approxEql" { const v1 = Vec(f32, 3).init(1.2345678, 2.3456789, 3.4567890); const v2 = Vec(f32, 3).init(1.2345600, 2.3456700, 3.4567800); assert(v1.approxEql(&v2, 1)); assert(v1.approxEql(&v2, 2)); assert(v1.approxEql(&v2, 3)); assert(v1.approxEql(&v2, 4)); assert(v1.approxEql(&v2, 5)); assert(v1.approxEql(&v2, 6)); assert(!v1.approxEql(&v2, 7)); assert(!v1.approxEql(&v2, 8)); } test "vec2.neg" { const v1 = V2f32.init(1, 2); const v2 = V2f32.init(-1, -2); assert(v2.eql(&v1.neg())); } test "vec3.neg" { const v1 = V3f32.init(1, 2, 3); const v2 = V3f32.init(-1, -2, -3); assert(v2.eql(&v1.neg())); } test "vec2.scale" { const factor = f32(0.5); const v1 = V2f32.init(1, 2); const v2 = V2f32.init(1 * factor, 2 * factor); assert(v2.eql(&v1.scale(factor))); } test "vec3.scale" { const factor = f32(0.5); const v1 = V3f32.init(1, 2, 3); const v2 = V3f32.init(1 * factor, 2 * factor, 3 * factor); assert(v2.eql(&v1.scale(factor))); } test "vec3.add" { const v1 = Vec(f32, 3).init(3, 2, 1); const v2 = Vec(f32, 3).init(1, 2, 3); const v3 = v1.add(&v2); assert(v3.x() == 4); assert(v3.y() == 4); assert(v3.z() == 4); } test "vec3.sub" { const v1 = Vec(f32, 3).init(3, 2, 1); const v2 = Vec(f32, 3).init(1, 2, 3); const v3 = v1.sub(&v2); assert(v3.x() == 2); assert(v3.y() == 0); assert(v3.z() == -2); } test "vec3.mul" { const v1 = Vec(f32, 3).init(3, 2, 1); const v2 = Vec(f32, 3).init(1, 2, 3); const v3 = v1.mul(&v2); assert(v3.x() == 3); assert(v3.y() == 4); assert(v3.z() == 3); } test "vec3.div" { const v1 = Vec(f32, 3).init(3, 2, 1); const v2 = Vec(f32, 3).init(1, 2, 3); const v3 = v1.div(&v2); assert(v3.x() == 3); assert(v3.y() == 1); assert(v3.z() == f32(1.0 / 3.0)); } test "vec2.format" { var buf: [100]u8 = undefined; const v2 = Vec(f32, 2).init(2, 1); var result = try bufPrint(buf[0..], "v2={}", v2); if (DBG) warn("\nvec.format: {}\n", result); assert(testExpected("v2=[]f32 { 2.00000, 1.00000 }", result)); } test "vec3.format" { var buf: [100]u8 = undefined; const v3 = Vec(f32, 3).init(3, 2, 1); var result = try bufPrint(buf[0..], "v3={}", v3); if (DBG) warn("vec3.format: {}\n", result); assert(testExpected("v3=[]f32 { 3.00000, 2.00000, 1.00000 }", result)); } test "vec2.length" { const x = f32(3); const y = f32(4); const v1 = V2f32.init(x, y); var len = v1.length(); if (DBG) warn("vec2.length: {}\n", len); assert(len == math.sqrt((x * x) + (y * y))); } test "vec3.length" { const x = f32(3); const y = f32(4); const z = f32(5); const v1 = V3f32.init(x, y, z); var len = v1.length(); if (DBG) warn("vec3.length: {}\n", len); assert(len == math.sqrt((x * x) + (y * y) + (z * z))); } test "vec3.dot" { if (DBG) warn("\n"); const v1 = Vec(f32, 3).init(3, 2, 1); const v2 = Vec(f32, 3).init(1, 2, 3); var d = v1.dot(&v2); if (DBG) warn("d={.3}\n", d); assert(d == (3 * 1) + (2 * 2) + (3 * 1)); // Sqrt of the dot product of itself is the length assert(math.sqrt(v2.dot(&v2)) == v2.length()); } test "vec3.normal" { var v0 = Vec(f32, 3).initVal(0); assert(v0.normal() == 0); v0 = Vec(f32, 3).init(4, 5, 6); assert(v0.normal() == 4 * 4 + 5 * 5 + 6 * 6); } test "vec3.normalize" { var v0 = Vec(f32, 3).initVal(0); var v1 = v0.normalize(); assert(v1.x() == 0); assert(v1.y() == 0); assert(v1.z() == 0); v0 = Vec(f32, 3).init(1, 1, 1); v1 = v0.normalize(); var len: f32 = math.sqrt(1.0 + 1.0 + 1.0); assert(v1.x() == 1.0 / len); assert(v1.y() == 1.0 / len); assert(v1.z() == 1.0 / len); } test "vec2.cross" { if (DBG) warn("\n"); var v3_1 = V3f32.init(1, 0, 0); var v3_2 = V3f32.init(0, 1, 0); // Calculate cross of a V3 in both dirctions var v3_cross = v3_1.cross(&v3_2); assert(v3_cross.x() == 0); assert(v3_cross.y() == 0); assert(v3_cross.z() == 1); // Assert cross of two v2's is equal v3_cross.z() var v2_1 = V2f32.init(1, 0); var v2_2 = V2f32.init(0, 1); assert(v2_1.cross(&v2_2) == v3_cross.z()); assert(v2_1.cross(&v2_2) == 1); // Change order and the sign's will be negative v3_cross = v3_2.cross(&v3_1); assert(v3_cross.x() == 0); assert(v3_cross.y() == 0); assert(v3_cross.z() == -1); assert(v2_2.cross(&v2_1) == v3_cross.z()); assert(v2_2.cross(&v2_1) == -1); // Check changing both signs v3_1.set(-1.0, 0.0, 0.0); v3_2.set(0.0, -1.0, 0.0); v2_1.set(-1.0, 0.0); v2_2.set(0.0, -1.0); assert(v2_1.cross(&v2_2) == v3_1.cross(&v3_2).z()); assert(v2_1.cross(&v2_2) == 1); assert(v2_2.cross(&v2_1) == v3_2.cross(&v3_1).z()); assert(v2_2.cross(&v2_1) == -1); // Check changing one sign v3_1.set(-1.0, 0.0, 0.0); v3_2.set(0.0, 1.0, 0.0); v2_1.set(-1.0, 0.0); v2_2.set(0.0, 1.0); assert(v2_1.cross(&v2_2) == v3_1.cross(&v3_2).z()); assert(v2_1.cross(&v2_2) == -1); assert(v2_2.cross(&v2_1) == v3_2.cross(&v3_1).z()); assert(v2_2.cross(&v2_1) == 1); // Check you don't need unit vectors v3_1.set(1.5, 1.5, 0.0); v3_2.set(2.5, 1.5, 0.0); v2_1.set(1.5, 1.5); v2_2.set(2.5, 1.5); assert(v2_1.cross(&v2_2) == v3_1.cross(&v3_2).z()); } test "vec3.cross" { if (DBG) warn("\n"); var v1 = Vec(f32, 3).init(1, 0, 0); // Unit Vector X var v2 = Vec(f32, 3).init(0, 1, 0); // Unit Vector Y // Cross product of two unit vectors on X,Y yields unit vector Z var v3 = v1.cross(&v2); assert(v3.x() == 0); assert(v3.y() == 0); assert(v3.z() == 1); v1 = V3f32.init(1.5, 2.5, 3.5); v2 = V3f32.init(4.5, 3.5, 2.5); v3 = v1.cross(&v2); if (DBG) warn("v3={}\n", &v3); assert(v3.eql(&V3f32.init( (v1.y() * v2.z()) - (v1.z() * v2.y()), (v1.z() * v2.x()) - (v1.x() * v2.z()), (v1.x() * v2.y()) - (v1.y() * v2.x()) )) ); v1 = Vec(f32, 3).init(3, 2, 1); v2 = Vec(f32, 3).init(1, 2, 3); v3 = v1.cross(&v2); assert(v3.x() == 4); assert(v3.y() == -8); assert(v3.z() == 4); // Changing the order yields neg. var v4 = v2.cross(&v1); assert(v3.x() == -v4.x()); assert(v3.y() == -v4.y()); assert(v3.z() == -v4.z()); assert(v4.eql(&v3.neg())); } test "vec3.transform" { if (DBG) warn("\n"); var v1 = V3f32.init(2, 3, 4); var v2 = v1.transform(&m44f32_unit); assert(v1.eql(&v2)); var m1 = M44f32.initVal(0.2); v1 = V3f32.init(0.5, 0.5, 0.5); v2 = v1.transform(&m1); if (DBG) warn("v1:\n{}\nm1:\n{}\nv2:\n{}\n", &v1, &m1, &v2); assert(v2.eql(&V3f32.init(1, 1, 1))); m1.data[3][3] = 1; v2 = v1.transform(&m1); if (DBG) warn("v1:\n{}\nm1:\n{}\nv2:\n{}\n", &v1, &m1, &v2); assert(v2.approxEql(&V3f32.init(0.3846154, 0.3846154, 0.3846154), 6)); } test "vec3.world.to.screen" { if (DBG) warn("\n"); const T = f32; const M44 = Matrix(T, 4, 4); const fov: T = 90; const widthf: T = 512; const heightf: T = 512; const width: u32 = @floatToInt(u32, 512); const height: u32 = @floatToInt(u32, 512); const aspect: T = widthf / heightf; const znear: T = 0.01; const zfar: T = 1.0; var camera_to_perspective_matrix = matrix.perspectiveM44(T, fov, aspect, znear, zfar); var world_to_camera_matrix = M44f32.initUnit(); world_to_camera_matrix.data[3][2] = 2; var world_vertexs = []V3f32{ V3f32.init(0, 1.0, 0), V3f32.init(0, -1.0, 0), V3f32.init(0, 1.0, 0.2), V3f32.init(0, -1.0, -0.2), }; var expected_camera_vertexs = []V3f32{ V3f32.init(0, 1.0, 2), V3f32.init(0, -1.0, 2.0), V3f32.init(0, 1.0, 2.2), V3f32.init(0, -1.0, 1.8), }; var expected_projected_vertexs = []V3f32{ V3f32.init(0, 0.30869, 1.00505), V3f32.init(0, -0.30869, 1.00505), V3f32.init(0, 0.28062, 1.00551), V3f32.init(0, -0.34298, 1.00449), }; var expected_screen_vertexs = [][2]u32{ []u32{ 256, 176 }, []u32{ 256, 335 }, []u32{ 256, 184 }, []u32{ 256, 343 }, }; for (world_vertexs) |world_vert, i| { if (DBG) warn("world_vert[{}] = {}\n", i, &world_vert); var camera_vert = world_vert.transform(&world_to_camera_matrix); if (DBG) warn("camera_vert = {}\n", camera_vert); assert(camera_vert.approxEql(&expected_camera_vertexs[i], 6)); var projected_vert = camera_vert.transform(&camera_to_perspective_matrix); if (DBG) warn("projected_vert = {}", projected_vert); assert(projected_vert.approxEql(&expected_projected_vertexs[i], 6)); var xf = projected_vert.x(); var yf = projected_vert.y(); if (DBG) warn(" {.3}:{.3}", xf, yf); if ((xf < -1) or (xf > 1) or (yf < -1) or (yf > 1)) { if (DBG) warn(" clipped\n"); } var x = @floatToInt(u32, math.min(widthf - 1, (xf + 1) * 0.5 * widthf)); var y = @floatToInt(u32, math.min(heightf - 1, (1 - (yf + 1) * 0.5) * heightf)); if (DBG) warn(" visible {}:{}\n", x, y); assert(x == expected_screen_vertexs[i][0]); assert(y == expected_screen_vertexs[i][1]); } }
vec.zig
pub const RGB = struct { const base = 0xe0006800; /// This is the value for the SB_LEDDA_IP.DAT register. /// It is directly written into the SB_LEDDA_IP hardware block, so you /// should refer to http://www.latticesemi.com/view_document?document_id=50668. /// The contents of this register are written to the address specified /// in ADDR immediately upon writing this register. pub const DAT = @intToPtr(*volatile u8, base + 0x0); /// This register is directly connected to SB_LEDDA_IP.ADDR. /// This register controls the address that is updated whenever DAT is written. /// Writing to this register has no immediate effect – data isn’t written until the DAT register is written. pub const ADDR = @intToPtr(*volatile u4, base + 0x4); pub const Register = enum { PWRR = 1, PWRG = 2, PWRB = 3, BCRR = 5, BCFR = 6, CR0 = 8, BR = 9, ONR = 10, OFR = 11, }; pub fn setRegister(reg: Register, value: u8) void { ADDR.* = @enumToInt(reg); DAT.* = value; } const CR0 = packed struct { BRMSBEXT: u2, pwm_mode: enum(u1) { linear = 0, /// The Polynomial for the LFSR is X^(8) + X^(5) + X^3 + X + 1 LFSR = 1, }, quick_stop: bool, outskew: bool, /// PWM output polarity output_polarity: enum(u1) { active_high = 0, active_low = 1, }, /// Flick rate for PWM (in Hz) fr: enum(u1) { @"125" = 0, @"250" = 1, }, /// LED Driver enabled? enable: bool, }; pub fn setControlRegister(value: CR0) void { setRegister(.CR0, @bitCast(u8, value)); } pub const Breathe = packed struct { /// Breathe rate is in 128 ms increments rate: u4, _pad: u1 = 0, mode: enum(u1) { fixed = 0, modulate = 1, }, pwm_range_extend: bool, enable: bool, }; pub fn setBreatheRegister(reg: enum { On, Off, }, value: Breathe) void { setRegister(switch (reg) { .On => .BCRR, .Off => .BCFR, }, @bitCast(u8, value)); } /// Control logic for the RGB LED and LEDDA hardware PWM LED block. pub const CTRL = @intToPtr(*volatile packed struct { /// Enable the fading pattern? /// Connected to `SB_LEDDA_IP.LEDDEXE`. EXE: bool, /// Enable the current source? /// Connected to `SB_RGBA_DRV.CURREN`. CURREN: bool, /// Enable the RGB PWM control logic? /// Connected to `SB_RGBA_DRV.RGBLEDEN`. RGBLEDEN: bool, /// Enable raw control of the red LED via the RAW.R register. RRAW: bool, /// Enable raw control of the green LED via the RAW.G register. GRAW: bool, /// Enable raw control of the blue LED via the RAW.B register. BRAW: bool, }, base + 0x8); /// Normally the hardware SB_LEDDA_IP block controls the brightness of the /// LED, creating a gentle fading pattern. /// However, by setting the appropriate bit in CTRL, it is possible to /// manually control the three individual LEDs. pub const RAW = @intToPtr(*volatile packed struct { /// Red R: bool, /// Green G: bool, /// Blue B: bool, }, base + 0xc); pub fn setColour(r: u8, g: u8, b: u8) void { setRegister(.PWRR, r); setRegister(.PWRG, g); setRegister(.PWRB, b); } };
riscv-zig-blink/src/fomu/rgb.zig
pub const NERR_BASE = @as(u32, 2100); pub const NERR_PasswordExpired = @as(u32, 2242); pub const CNLEN = @as(u32, 15); pub const LM20_CNLEN = @as(u32, 15); pub const UNCLEN = @as(u32, 17); pub const LM20_UNCLEN = @as(u32, 17); pub const LM20_NNLEN = @as(u32, 12); pub const SNLEN = @as(u32, 80); pub const LM20_SNLEN = @as(u32, 15); pub const STXTLEN = @as(u32, 256); pub const LM20_STXTLEN = @as(u32, 63); pub const PATHLEN = @as(u32, 256); pub const LM20_PATHLEN = @as(u32, 256); pub const DEVLEN = @as(u32, 80); pub const LM20_DEVLEN = @as(u32, 8); pub const EVLEN = @as(u32, 16); pub const UNLEN = @as(u32, 256); pub const LM20_UNLEN = @as(u32, 20); pub const PWLEN = @as(u32, 256); pub const LM20_PWLEN = @as(u32, 14); pub const SHPWLEN = @as(u32, 8); pub const CLTYPE_LEN = @as(u32, 12); pub const MAXCOMMENTSZ = @as(u32, 256); pub const LM20_MAXCOMMENTSZ = @as(u32, 48); pub const ALERTSZ = @as(u32, 128); pub const NETBIOS_NAME_LEN = @as(u32, 16); pub const MAX_PREFERRED_LENGTH = @as(u32, 4294967295); pub const CRYPT_KEY_LEN = @as(u32, 7); pub const CRYPT_TXT_LEN = @as(u32, 8); pub const ENCRYPTED_PWLEN = @as(u32, 16); pub const SESSION_PWLEN = @as(u32, 24); pub const SESSION_CRYPT_KLEN = @as(u32, 21); pub const PARMNUM_ALL = @as(u32, 0); pub const PARM_ERROR_UNKNOWN = @as(u32, 4294967295); pub const PARM_ERROR_NONE = @as(u32, 0); pub const PARMNUM_BASE_INFOLEVEL = @as(u32, 1000); pub const PLATFORM_ID_DOS = @as(u32, 300); pub const PLATFORM_ID_OS2 = @as(u32, 400); pub const PLATFORM_ID_NT = @as(u32, 500); pub const PLATFORM_ID_OSF = @as(u32, 600); pub const PLATFORM_ID_VMS = @as(u32, 700); pub const MAX_LANMAN_MESSAGE_ID = @as(u32, 5899); pub const NERR_Success = @as(u32, 0); pub const NERR_NetNotStarted = @as(u32, 2102); pub const NERR_UnknownServer = @as(u32, 2103); pub const NERR_ShareMem = @as(u32, 2104); pub const NERR_NoNetworkResource = @as(u32, 2105); pub const NERR_RemoteOnly = @as(u32, 2106); pub const NERR_DevNotRedirected = @as(u32, 2107); pub const NERR_ServerNotStarted = @as(u32, 2114); pub const NERR_ItemNotFound = @as(u32, 2115); pub const NERR_UnknownDevDir = @as(u32, 2116); pub const NERR_RedirectedPath = @as(u32, 2117); pub const NERR_DuplicateShare = @as(u32, 2118); pub const NERR_NoRoom = @as(u32, 2119); pub const NERR_TooManyItems = @as(u32, 2121); pub const NERR_InvalidMaxUsers = @as(u32, 2122); pub const NERR_BufTooSmall = @as(u32, 2123); pub const NERR_RemoteErr = @as(u32, 2127); pub const NERR_LanmanIniError = @as(u32, 2131); pub const NERR_NetworkError = @as(u32, 2136); pub const NERR_WkstaInconsistentState = @as(u32, 2137); pub const NERR_WkstaNotStarted = @as(u32, 2138); pub const NERR_BrowserNotStarted = @as(u32, 2139); pub const NERR_InternalError = @as(u32, 2140); pub const NERR_BadTransactConfig = @as(u32, 2141); pub const NERR_InvalidAPI = @as(u32, 2142); pub const NERR_BadEventName = @as(u32, 2143); pub const NERR_DupNameReboot = @as(u32, 2144); pub const NERR_CfgCompNotFound = @as(u32, 2146); pub const NERR_CfgParamNotFound = @as(u32, 2147); pub const NERR_LineTooLong = @as(u32, 2149); pub const NERR_QNotFound = @as(u32, 2150); pub const NERR_JobNotFound = @as(u32, 2151); pub const NERR_DestNotFound = @as(u32, 2152); pub const NERR_DestExists = @as(u32, 2153); pub const NERR_QExists = @as(u32, 2154); pub const NERR_QNoRoom = @as(u32, 2155); pub const NERR_JobNoRoom = @as(u32, 2156); pub const NERR_DestNoRoom = @as(u32, 2157); pub const NERR_DestIdle = @as(u32, 2158); pub const NERR_DestInvalidOp = @as(u32, 2159); pub const NERR_ProcNoRespond = @as(u32, 2160); pub const NERR_SpoolerNotLoaded = @as(u32, 2161); pub const NERR_DestInvalidState = @as(u32, 2162); pub const NERR_QInvalidState = @as(u32, 2163); pub const NERR_JobInvalidState = @as(u32, 2164); pub const NERR_SpoolNoMemory = @as(u32, 2165); pub const NERR_DriverNotFound = @as(u32, 2166); pub const NERR_DataTypeInvalid = @as(u32, 2167); pub const NERR_ProcNotFound = @as(u32, 2168); pub const NERR_ServiceTableLocked = @as(u32, 2180); pub const NERR_ServiceTableFull = @as(u32, 2181); pub const NERR_ServiceInstalled = @as(u32, 2182); pub const NERR_ServiceEntryLocked = @as(u32, 2183); pub const NERR_ServiceNotInstalled = @as(u32, 2184); pub const NERR_BadServiceName = @as(u32, 2185); pub const NERR_ServiceCtlTimeout = @as(u32, 2186); pub const NERR_ServiceCtlBusy = @as(u32, 2187); pub const NERR_BadServiceProgName = @as(u32, 2188); pub const NERR_ServiceNotCtrl = @as(u32, 2189); pub const NERR_ServiceKillProc = @as(u32, 2190); pub const NERR_ServiceCtlNotValid = @as(u32, 2191); pub const NERR_NotInDispatchTbl = @as(u32, 2192); pub const NERR_BadControlRecv = @as(u32, 2193); pub const NERR_ServiceNotStarting = @as(u32, 2194); pub const NERR_AlreadyLoggedOn = @as(u32, 2200); pub const NERR_NotLoggedOn = @as(u32, 2201); pub const NERR_BadUsername = @as(u32, 2202); pub const NERR_BadPassword = @as(u32, 2203); pub const NERR_UnableToAddName_W = @as(u32, 2204); pub const NERR_UnableToAddName_F = @as(u32, 2205); pub const NERR_UnableToDelName_W = @as(u32, 2206); pub const NERR_UnableToDelName_F = @as(u32, 2207); pub const NERR_LogonsPaused = @as(u32, 2209); pub const NERR_LogonServerConflict = @as(u32, 2210); pub const NERR_LogonNoUserPath = @as(u32, 2211); pub const NERR_LogonScriptError = @as(u32, 2212); pub const NERR_StandaloneLogon = @as(u32, 2214); pub const NERR_LogonServerNotFound = @as(u32, 2215); pub const NERR_LogonDomainExists = @as(u32, 2216); pub const NERR_NonValidatedLogon = @as(u32, 2217); pub const NERR_ACFNotFound = @as(u32, 2219); pub const NERR_GroupNotFound = @as(u32, 2220); pub const NERR_UserNotFound = @as(u32, 2221); pub const NERR_ResourceNotFound = @as(u32, 2222); pub const NERR_GroupExists = @as(u32, 2223); pub const NERR_UserExists = @as(u32, 2224); pub const NERR_ResourceExists = @as(u32, 2225); pub const NERR_NotPrimary = @as(u32, 2226); pub const NERR_ACFNotLoaded = @as(u32, 2227); pub const NERR_ACFNoRoom = @as(u32, 2228); pub const NERR_ACFFileIOFail = @as(u32, 2229); pub const NERR_ACFTooManyLists = @as(u32, 2230); pub const NERR_UserLogon = @as(u32, 2231); pub const NERR_ACFNoParent = @as(u32, 2232); pub const NERR_CanNotGrowSegment = @as(u32, 2233); pub const NERR_SpeGroupOp = @as(u32, 2234); pub const NERR_NotInCache = @as(u32, 2235); pub const NERR_UserInGroup = @as(u32, 2236); pub const NERR_UserNotInGroup = @as(u32, 2237); pub const NERR_AccountUndefined = @as(u32, 2238); pub const NERR_AccountExpired = @as(u32, 2239); pub const NERR_InvalidWorkstation = @as(u32, 2240); pub const NERR_InvalidLogonHours = @as(u32, 2241); pub const NERR_PasswordCantChange = @as(u32, 2243); pub const NERR_PasswordHistConflict = @as(u32, 2244); pub const NERR_PasswordTooShort = @as(u32, 2245); pub const NERR_PasswordTooRecent = @as(u32, 2246); pub const NERR_InvalidDatabase = @as(u32, 2247); pub const NERR_DatabaseUpToDate = @as(u32, 2248); pub const NERR_SyncRequired = @as(u32, 2249); pub const NERR_UseNotFound = @as(u32, 2250); pub const NERR_BadAsgType = @as(u32, 2251); pub const NERR_DeviceIsShared = @as(u32, 2252); pub const NERR_SameAsComputerName = @as(u32, 2253); pub const NERR_NoComputerName = @as(u32, 2270); pub const NERR_MsgAlreadyStarted = @as(u32, 2271); pub const NERR_MsgInitFailed = @as(u32, 2272); pub const NERR_NameNotFound = @as(u32, 2273); pub const NERR_AlreadyForwarded = @as(u32, 2274); pub const NERR_AddForwarded = @as(u32, 2275); pub const NERR_AlreadyExists = @as(u32, 2276); pub const NERR_TooManyNames = @as(u32, 2277); pub const NERR_DelComputerName = @as(u32, 2278); pub const NERR_LocalForward = @as(u32, 2279); pub const NERR_GrpMsgProcessor = @as(u32, 2280); pub const NERR_PausedRemote = @as(u32, 2281); pub const NERR_BadReceive = @as(u32, 2282); pub const NERR_NameInUse = @as(u32, 2283); pub const NERR_MsgNotStarted = @as(u32, 2284); pub const NERR_NotLocalName = @as(u32, 2285); pub const NERR_NoForwardName = @as(u32, 2286); pub const NERR_RemoteFull = @as(u32, 2287); pub const NERR_NameNotForwarded = @as(u32, 2288); pub const NERR_TruncatedBroadcast = @as(u32, 2289); pub const NERR_InvalidDevice = @as(u32, 2294); pub const NERR_WriteFault = @as(u32, 2295); pub const NERR_DuplicateName = @as(u32, 2297); pub const NERR_DeleteLater = @as(u32, 2298); pub const NERR_IncompleteDel = @as(u32, 2299); pub const NERR_MultipleNets = @as(u32, 2300); pub const NERR_NetNameNotFound = @as(u32, 2310); pub const NERR_DeviceNotShared = @as(u32, 2311); pub const NERR_ClientNameNotFound = @as(u32, 2312); pub const NERR_FileIdNotFound = @as(u32, 2314); pub const NERR_ExecFailure = @as(u32, 2315); pub const NERR_TmpFile = @as(u32, 2316); pub const NERR_TooMuchData = @as(u32, 2317); pub const NERR_DeviceShareConflict = @as(u32, 2318); pub const NERR_BrowserTableIncomplete = @as(u32, 2319); pub const NERR_NotLocalDomain = @as(u32, 2320); pub const NERR_IsDfsShare = @as(u32, 2321); pub const NERR_DevInvalidOpCode = @as(u32, 2331); pub const NERR_DevNotFound = @as(u32, 2332); pub const NERR_DevNotOpen = @as(u32, 2333); pub const NERR_BadQueueDevString = @as(u32, 2334); pub const NERR_BadQueuePriority = @as(u32, 2335); pub const NERR_NoCommDevs = @as(u32, 2337); pub const NERR_QueueNotFound = @as(u32, 2338); pub const NERR_BadDevString = @as(u32, 2340); pub const NERR_BadDev = @as(u32, 2341); pub const NERR_InUseBySpooler = @as(u32, 2342); pub const NERR_CommDevInUse = @as(u32, 2343); pub const NERR_InvalidComputer = @as(u32, 2351); pub const NERR_MaxLenExceeded = @as(u32, 2354); pub const NERR_BadComponent = @as(u32, 2356); pub const NERR_CantType = @as(u32, 2357); pub const NERR_TooManyEntries = @as(u32, 2362); pub const NERR_ProfileFileTooBig = @as(u32, 2370); pub const NERR_ProfileOffset = @as(u32, 2371); pub const NERR_ProfileCleanup = @as(u32, 2372); pub const NERR_ProfileUnknownCmd = @as(u32, 2373); pub const NERR_ProfileLoadErr = @as(u32, 2374); pub const NERR_ProfileSaveErr = @as(u32, 2375); pub const NERR_LogOverflow = @as(u32, 2377); pub const NERR_LogFileChanged = @as(u32, 2378); pub const NERR_LogFileCorrupt = @as(u32, 2379); pub const NERR_SourceIsDir = @as(u32, 2380); pub const NERR_BadSource = @as(u32, 2381); pub const NERR_BadDest = @as(u32, 2382); pub const NERR_DifferentServers = @as(u32, 2383); pub const NERR_RunSrvPaused = @as(u32, 2385); pub const NERR_ErrCommRunSrv = @as(u32, 2389); pub const NERR_ErrorExecingGhost = @as(u32, 2391); pub const NERR_ShareNotFound = @as(u32, 2392); pub const NERR_InvalidLana = @as(u32, 2400); pub const NERR_OpenFiles = @as(u32, 2401); pub const NERR_ActiveConns = @as(u32, 2402); pub const NERR_BadPasswordCore = @as(u32, 2403); pub const NERR_DevInUse = @as(u32, 2404); pub const NERR_LocalDrive = @as(u32, 2405); pub const NERR_AlertExists = @as(u32, 2430); pub const NERR_TooManyAlerts = @as(u32, 2431); pub const NERR_NoSuchAlert = @as(u32, 2432); pub const NERR_BadRecipient = @as(u32, 2433); pub const NERR_AcctLimitExceeded = @as(u32, 2434); pub const NERR_InvalidLogSeek = @as(u32, 2440); pub const NERR_BadUasConfig = @as(u32, 2450); pub const NERR_InvalidUASOp = @as(u32, 2451); pub const NERR_LastAdmin = @as(u32, 2452); pub const NERR_DCNotFound = @as(u32, 2453); pub const NERR_LogonTrackingError = @as(u32, 2454); pub const NERR_NetlogonNotStarted = @as(u32, 2455); pub const NERR_CanNotGrowUASFile = @as(u32, 2456); pub const NERR_TimeDiffAtDC = @as(u32, 2457); pub const NERR_PasswordMismatch = @as(u32, 2458); pub const NERR_NoSuchServer = @as(u32, 2460); pub const NERR_NoSuchSession = @as(u32, 2461); pub const NERR_NoSuchConnection = @as(u32, 2462); pub const NERR_TooManyServers = @as(u32, 2463); pub const NERR_TooManySessions = @as(u32, 2464); pub const NERR_TooManyConnections = @as(u32, 2465); pub const NERR_TooManyFiles = @as(u32, 2466); pub const NERR_NoAlternateServers = @as(u32, 2467); pub const NERR_TryDownLevel = @as(u32, 2470); pub const NERR_UPSDriverNotStarted = @as(u32, 2480); pub const NERR_UPSInvalidConfig = @as(u32, 2481); pub const NERR_UPSInvalidCommPort = @as(u32, 2482); pub const NERR_UPSSignalAsserted = @as(u32, 2483); pub const NERR_UPSShutdownFailed = @as(u32, 2484); pub const NERR_BadDosRetCode = @as(u32, 2500); pub const NERR_ProgNeedsExtraMem = @as(u32, 2501); pub const NERR_BadDosFunction = @as(u32, 2502); pub const NERR_RemoteBootFailed = @as(u32, 2503); pub const NERR_BadFileCheckSum = @as(u32, 2504); pub const NERR_NoRplBootSystem = @as(u32, 2505); pub const NERR_RplLoadrNetBiosErr = @as(u32, 2506); pub const NERR_RplLoadrDiskErr = @as(u32, 2507); pub const NERR_ImageParamErr = @as(u32, 2508); pub const NERR_TooManyImageParams = @as(u32, 2509); pub const NERR_NonDosFloppyUsed = @as(u32, 2510); pub const NERR_RplBootRestart = @as(u32, 2511); pub const NERR_RplSrvrCallFailed = @as(u32, 2512); pub const NERR_CantConnectRplSrvr = @as(u32, 2513); pub const NERR_CantOpenImageFile = @as(u32, 2514); pub const NERR_CallingRplSrvr = @as(u32, 2515); pub const NERR_StartingRplBoot = @as(u32, 2516); pub const NERR_RplBootServiceTerm = @as(u32, 2517); pub const NERR_RplBootStartFailed = @as(u32, 2518); pub const NERR_RPL_CONNECTED = @as(u32, 2519); pub const NERR_BrowserConfiguredToNotRun = @as(u32, 2550); pub const NERR_RplNoAdaptersStarted = @as(u32, 2610); pub const NERR_RplBadRegistry = @as(u32, 2611); pub const NERR_RplBadDatabase = @as(u32, 2612); pub const NERR_RplRplfilesShare = @as(u32, 2613); pub const NERR_RplNotRplServer = @as(u32, 2614); pub const NERR_RplCannotEnum = @as(u32, 2615); pub const NERR_RplWkstaInfoCorrupted = @as(u32, 2616); pub const NERR_RplWkstaNotFound = @as(u32, 2617); pub const NERR_RplWkstaNameUnavailable = @as(u32, 2618); pub const NERR_RplProfileInfoCorrupted = @as(u32, 2619); pub const NERR_RplProfileNotFound = @as(u32, 2620); pub const NERR_RplProfileNameUnavailable = @as(u32, 2621); pub const NERR_RplProfileNotEmpty = @as(u32, 2622); pub const NERR_RplConfigInfoCorrupted = @as(u32, 2623); pub const NERR_RplConfigNotFound = @as(u32, 2624); pub const NERR_RplAdapterInfoCorrupted = @as(u32, 2625); pub const NERR_RplInternal = @as(u32, 2626); pub const NERR_RplVendorInfoCorrupted = @as(u32, 2627); pub const NERR_RplBootInfoCorrupted = @as(u32, 2628); pub const NERR_RplWkstaNeedsUserAcct = @as(u32, 2629); pub const NERR_RplNeedsRPLUSERAcct = @as(u32, 2630); pub const NERR_RplBootNotFound = @as(u32, 2631); pub const NERR_RplIncompatibleProfile = @as(u32, 2632); pub const NERR_RplAdapterNameUnavailable = @as(u32, 2633); pub const NERR_RplConfigNotEmpty = @as(u32, 2634); pub const NERR_RplBootInUse = @as(u32, 2635); pub const NERR_RplBackupDatabase = @as(u32, 2636); pub const NERR_RplAdapterNotFound = @as(u32, 2637); pub const NERR_RplVendorNotFound = @as(u32, 2638); pub const NERR_RplVendorNameUnavailable = @as(u32, 2639); pub const NERR_RplBootNameUnavailable = @as(u32, 2640); pub const NERR_RplConfigNameUnavailable = @as(u32, 2641); pub const NERR_DfsInternalCorruption = @as(u32, 2660); pub const NERR_DfsVolumeDataCorrupt = @as(u32, 2661); pub const NERR_DfsNoSuchVolume = @as(u32, 2662); pub const NERR_DfsVolumeAlreadyExists = @as(u32, 2663); pub const NERR_DfsAlreadyShared = @as(u32, 2664); pub const NERR_DfsNoSuchShare = @as(u32, 2665); pub const NERR_DfsNotALeafVolume = @as(u32, 2666); pub const NERR_DfsLeafVolume = @as(u32, 2667); pub const NERR_DfsVolumeHasMultipleServers = @as(u32, 2668); pub const NERR_DfsCantCreateJunctionPoint = @as(u32, 2669); pub const NERR_DfsServerNotDfsAware = @as(u32, 2670); pub const NERR_DfsBadRenamePath = @as(u32, 2671); pub const NERR_DfsVolumeIsOffline = @as(u32, 2672); pub const NERR_DfsNoSuchServer = @as(u32, 2673); pub const NERR_DfsCyclicalName = @as(u32, 2674); pub const NERR_DfsNotSupportedInServerDfs = @as(u32, 2675); pub const NERR_DfsDuplicateService = @as(u32, 2676); pub const NERR_DfsCantRemoveLastServerShare = @as(u32, 2677); pub const NERR_DfsVolumeIsInterDfs = @as(u32, 2678); pub const NERR_DfsInconsistent = @as(u32, 2679); pub const NERR_DfsServerUpgraded = @as(u32, 2680); pub const NERR_DfsDataIsIdentical = @as(u32, 2681); pub const NERR_DfsCantRemoveDfsRoot = @as(u32, 2682); pub const NERR_DfsChildOrParentInDfs = @as(u32, 2683); pub const NERR_DfsInternalError = @as(u32, 2690); pub const NERR_SetupAlreadyJoined = @as(u32, 2691); pub const NERR_SetupNotJoined = @as(u32, 2692); pub const NERR_SetupDomainController = @as(u32, 2693); pub const NERR_DefaultJoinRequired = @as(u32, 2694); pub const NERR_InvalidWorkgroupName = @as(u32, 2695); pub const NERR_NameUsesIncompatibleCodePage = @as(u32, 2696); pub const NERR_ComputerAccountNotFound = @as(u32, 2697); pub const NERR_PersonalSku = @as(u32, 2698); pub const NERR_SetupCheckDNSConfig = @as(u32, 2699); pub const NERR_AlreadyCloudDomainJoined = @as(u32, 2700); pub const NERR_PasswordMustChange = @as(u32, 2701); pub const NERR_AccountLockedOut = @as(u32, 2702); pub const NERR_PasswordTooLong = @as(u32, 2703); pub const NERR_PasswordNotComplexEnough = @as(u32, 2704); pub const NERR_PasswordFilterError = @as(u32, 2705); pub const NERR_NoOfflineJoinInfo = @as(u32, 2709); pub const NERR_BadOfflineJoinInfo = @as(u32, 2710); pub const NERR_CantCreateJoinInfo = @as(u32, 2711); pub const NERR_BadDomainJoinInfo = @as(u32, 2712); pub const NERR_JoinPerformedMustRestart = @as(u32, 2713); pub const NERR_NoJoinPending = @as(u32, 2714); pub const NERR_ValuesNotSet = @as(u32, 2715); pub const NERR_CantVerifyHostname = @as(u32, 2716); pub const NERR_CantLoadOfflineHive = @as(u32, 2717); pub const NERR_ConnectionInsecure = @as(u32, 2718); pub const NERR_ProvisioningBlobUnsupported = @as(u32, 2719); pub const NERR_DS8DCRequired = @as(u32, 2720); pub const NERR_LDAPCapableDCRequired = @as(u32, 2721); pub const NERR_DS8DCNotFound = @as(u32, 2722); pub const NERR_TargetVersionUnsupported = @as(u32, 2723); pub const NERR_InvalidMachineNameForJoin = @as(u32, 2724); pub const NERR_DS9DCNotFound = @as(u32, 2725); pub const NERR_PlainTextSecretsRequired = @as(u32, 2726); pub const NERR_CannotUnjoinAadDomain = @as(u32, 2727); pub const MAX_NERR = @as(u32, 2999); pub const UF_TEMP_DUPLICATE_ACCOUNT = @as(u32, 256); pub const UF_NORMAL_ACCOUNT = @as(u32, 512); pub const UF_INTERDOMAIN_TRUST_ACCOUNT = @as(u32, 2048); pub const UF_WORKSTATION_TRUST_ACCOUNT = @as(u32, 4096); pub const UF_SERVER_TRUST_ACCOUNT = @as(u32, 8192); pub const UF_MNS_LOGON_ACCOUNT = @as(u32, 131072); pub const UF_NO_AUTH_DATA_REQUIRED = @as(u32, 33554432); pub const UF_PARTIAL_SECRETS_ACCOUNT = @as(u32, 67108864); pub const UF_USE_AES_KEYS = @as(u32, 134217728); pub const LG_INCLUDE_INDIRECT = @as(u32, 1); pub const USER_NAME_PARMNUM = @as(u32, 1); pub const USER_PASSWORD_PARMNUM = @as(u32, 3); pub const USER_PASSWORD_AGE_PARMNUM = @as(u32, 4); pub const USER_PRIV_PARMNUM = @as(u32, 5); pub const USER_HOME_DIR_PARMNUM = @as(u32, 6); pub const USER_COMMENT_PARMNUM = @as(u32, 7); pub const USER_FLAGS_PARMNUM = @as(u32, 8); pub const USER_SCRIPT_PATH_PARMNUM = @as(u32, 9); pub const USER_AUTH_FLAGS_PARMNUM = @as(u32, 10); pub const USER_FULL_NAME_PARMNUM = @as(u32, 11); pub const USER_USR_COMMENT_PARMNUM = @as(u32, 12); pub const USER_PARMS_PARMNUM = @as(u32, 13); pub const USER_WORKSTATIONS_PARMNUM = @as(u32, 14); pub const USER_LAST_LOGON_PARMNUM = @as(u32, 15); pub const USER_LAST_LOGOFF_PARMNUM = @as(u32, 16); pub const USER_ACCT_EXPIRES_PARMNUM = @as(u32, 17); pub const USER_MAX_STORAGE_PARMNUM = @as(u32, 18); pub const USER_UNITS_PER_WEEK_PARMNUM = @as(u32, 19); pub const USER_LOGON_HOURS_PARMNUM = @as(u32, 20); pub const USER_PAD_PW_COUNT_PARMNUM = @as(u32, 21); pub const USER_NUM_LOGONS_PARMNUM = @as(u32, 22); pub const USER_LOGON_SERVER_PARMNUM = @as(u32, 23); pub const USER_COUNTRY_CODE_PARMNUM = @as(u32, 24); pub const USER_CODE_PAGE_PARMNUM = @as(u32, 25); pub const USER_PRIMARY_GROUP_PARMNUM = @as(u32, 51); pub const USER_PROFILE = @as(u32, 52); pub const USER_PROFILE_PARMNUM = @as(u32, 52); pub const USER_HOME_DIR_DRIVE_PARMNUM = @as(u32, 53); pub const UNITS_PER_DAY = @as(u32, 24); pub const USER_PRIV_MASK = @as(u32, 3); pub const DEF_MIN_PWLEN = @as(u32, 6); pub const DEF_PWUNIQUENESS = @as(u32, 5); pub const DEF_MAX_PWHIST = @as(u32, 8); pub const DEF_MAX_BADPW = @as(u32, 0); pub const VALIDATED_LOGON = @as(u32, 0); pub const PASSWORD_EXPIRED = @as(u32, 2); pub const NON_VALIDATED_LOGON = @as(u32, 3); pub const VALID_LOGOFF = @as(u32, 1); pub const MODALS_MIN_PASSWD_LEN_PARMNUM = @as(u32, 1); pub const MODALS_MAX_PASSWD_AGE_PARMNUM = @as(u32, 2); pub const MODALS_MIN_PASSWD_AGE_PARMNUM = @as(u32, 3); pub const MODALS_FORCE_LOGOFF_PARMNUM = @as(u32, 4); pub const MODALS_PASSWD_HIST_LEN_PARMNUM = @as(u32, 5); pub const MODALS_ROLE_PARMNUM = @as(u32, 6); pub const MODALS_PRIMARY_PARMNUM = @as(u32, 7); pub const MODALS_DOMAIN_NAME_PARMNUM = @as(u32, 8); pub const MODALS_DOMAIN_ID_PARMNUM = @as(u32, 9); pub const MODALS_LOCKOUT_DURATION_PARMNUM = @as(u32, 10); pub const MODALS_LOCKOUT_OBSERVATION_WINDOW_PARMNUM = @as(u32, 11); pub const MODALS_LOCKOUT_THRESHOLD_PARMNUM = @as(u32, 12); pub const GROUPIDMASK = @as(u32, 32768); pub const GROUP_ALL_PARMNUM = @as(u32, 0); pub const GROUP_NAME_PARMNUM = @as(u32, 1); pub const GROUP_COMMENT_PARMNUM = @as(u32, 2); pub const GROUP_ATTRIBUTES_PARMNUM = @as(u32, 3); pub const LOCALGROUP_NAME_PARMNUM = @as(u32, 1); pub const LOCALGROUP_COMMENT_PARMNUM = @as(u32, 2); pub const MAXPERMENTRIES = @as(u32, 64); pub const ACCESS_NONE = @as(u32, 0); pub const ACCESS_GROUP = @as(u32, 32768); pub const ACCESS_AUDIT = @as(u32, 1); pub const ACCESS_SUCCESS_OPEN = @as(u32, 16); pub const ACCESS_SUCCESS_WRITE = @as(u32, 32); pub const ACCESS_SUCCESS_DELETE = @as(u32, 64); pub const ACCESS_SUCCESS_ACL = @as(u32, 128); pub const ACCESS_SUCCESS_MASK = @as(u32, 240); pub const ACCESS_FAIL_OPEN = @as(u32, 256); pub const ACCESS_FAIL_WRITE = @as(u32, 512); pub const ACCESS_FAIL_DELETE = @as(u32, 1024); pub const ACCESS_FAIL_ACL = @as(u32, 2048); pub const ACCESS_FAIL_MASK = @as(u32, 3840); pub const ACCESS_FAIL_SHIFT = @as(u32, 4); pub const ACCESS_RESOURCE_NAME_PARMNUM = @as(u32, 1); pub const ACCESS_ATTR_PARMNUM = @as(u32, 2); pub const ACCESS_COUNT_PARMNUM = @as(u32, 3); pub const ACCESS_ACCESS_LIST_PARMNUM = @as(u32, 4); pub const NET_VALIDATE_PASSWORD_LAST_SET = @as(u32, 1); pub const NET_VALIDATE_BAD_PASSWORD_TIME = @as(u32, 2); pub const NET_VALIDATE_LOCKOUT_TIME = @as(u32, 4); pub const NET_VALIDATE_BAD_PASSWORD_COUNT = @as(u32, 8); pub const NET_VALIDATE_PASSWORD_HISTORY_LENGTH = @as(u32, 16); pub const NET_VALIDATE_PASSWORD_HISTORY = @as(u32, 32); pub const NETLOGON_CONTROL_QUERY = @as(u32, 1); pub const NETLOGON_CONTROL_REPLICATE = @as(u32, 2); pub const NETLOGON_CONTROL_SYNCHRONIZE = @as(u32, 3); pub const NETLOGON_CONTROL_PDC_REPLICATE = @as(u32, 4); pub const NETLOGON_CONTROL_REDISCOVER = @as(u32, 5); pub const NETLOGON_CONTROL_TC_QUERY = @as(u32, 6); pub const NETLOGON_CONTROL_TRANSPORT_NOTIFY = @as(u32, 7); pub const NETLOGON_CONTROL_FIND_USER = @as(u32, 8); pub const NETLOGON_CONTROL_CHANGE_PASSWORD = @as(u32, 9); pub const NETLOGON_CONTROL_TC_VERIFY = @as(u32, 10); pub const NETLOGON_CONTROL_FORCE_DNS_REG = @as(u32, 11); pub const NETLOGON_CONTROL_QUERY_DNS_REG = @as(u32, 12); pub const NETLOGON_CONTROL_QUERY_ENC_TYPES = @as(u32, 13); pub const NETLOGON_CONTROL_UNLOAD_NETLOGON_DLL = @as(u32, 65531); pub const NETLOGON_CONTROL_BACKUP_CHANGE_LOG = @as(u32, 65532); pub const NETLOGON_CONTROL_TRUNCATE_LOG = @as(u32, 65533); pub const NETLOGON_CONTROL_SET_DBFLAG = @as(u32, 65534); pub const NETLOGON_CONTROL_BREAKPOINT = @as(u32, 65535); pub const NETLOGON_REPLICATION_NEEDED = @as(u32, 1); pub const NETLOGON_REPLICATION_IN_PROGRESS = @as(u32, 2); pub const NETLOGON_FULL_SYNC_REPLICATION = @as(u32, 4); pub const NETLOGON_REDO_NEEDED = @as(u32, 8); pub const NETLOGON_HAS_IP = @as(u32, 16); pub const NETLOGON_HAS_TIMESERV = @as(u32, 32); pub const NETLOGON_DNS_UPDATE_FAILURE = @as(u32, 64); pub const NETLOGON_VERIFY_STATUS_RETURNED = @as(u32, 128); pub const ServiceAccountPasswordGUID = Guid.initString("<PASSWORD>"); pub const SERVICE_ACCOUNT_FLAG_LINK_TO_HOST_ONLY = @as(i32, 1); pub const SERVICE_ACCOUNT_FLAG_ADD_AGAINST_RODC = @as(i32, 2); pub const SERVICE_ACCOUNT_FLAG_UNLINK_FROM_HOST_ONLY = @as(i32, 1); pub const SERVICE_ACCOUNT_FLAG_REMOVE_OFFLINE = @as(i32, 2); pub const PRJOB_QSTATUS = @as(u32, 3); pub const PRJOB_DEVSTATUS = @as(u32, 508); pub const PRJOB_COMPLETE = @as(u32, 4); pub const PRJOB_INTERV = @as(u32, 8); pub const PRJOB_ERROR = @as(u32, 16); pub const PRJOB_DESTOFFLINE = @as(u32, 32); pub const PRJOB_DESTPAUSED = @as(u32, 64); pub const PRJOB_NOTIFY = @as(u32, 128); pub const PRJOB_DESTNOPAPER = @as(u32, 256); pub const PRJOB_DELETED = @as(u32, 32768); pub const PRJOB_QS_QUEUED = @as(u32, 0); pub const PRJOB_QS_PAUSED = @as(u32, 1); pub const PRJOB_QS_SPOOLING = @as(u32, 2); pub const PRJOB_QS_PRINTING = @as(u32, 3); pub const JOB_RUN_PERIODICALLY = @as(u32, 1); pub const JOB_EXEC_ERROR = @as(u32, 2); pub const JOB_RUNS_TODAY = @as(u32, 4); pub const JOB_ADD_CURRENT_DATE = @as(u32, 8); pub const JOB_NONINTERACTIVE = @as(u32, 16); pub const LOGFLAGS_FORWARD = @as(u32, 0); pub const LOGFLAGS_BACKWARD = @as(u32, 1); pub const LOGFLAGS_SEEK = @as(u32, 2); pub const ACTION_LOCKOUT = @as(u32, 0); pub const ACTION_ADMINUNLOCK = @as(u32, 1); pub const AE_SRVSTATUS = @as(u32, 0); pub const AE_SESSLOGON = @as(u32, 1); pub const AE_SESSLOGOFF = @as(u32, 2); pub const AE_SESSPWERR = @as(u32, 3); pub const AE_CONNSTART = @as(u32, 4); pub const AE_CONNSTOP = @as(u32, 5); pub const AE_CONNREJ = @as(u32, 6); pub const AE_RESACCESS = @as(u32, 7); pub const AE_RESACCESSREJ = @as(u32, 8); pub const AE_CLOSEFILE = @as(u32, 9); pub const AE_SERVICESTAT = @as(u32, 11); pub const AE_ACLMOD = @as(u32, 12); pub const AE_UASMOD = @as(u32, 13); pub const AE_NETLOGON = @as(u32, 14); pub const AE_NETLOGOFF = @as(u32, 15); pub const AE_NETLOGDENIED = @as(u32, 16); pub const AE_ACCLIMITEXCD = @as(u32, 17); pub const AE_RESACCESS2 = @as(u32, 18); pub const AE_ACLMODFAIL = @as(u32, 19); pub const AE_LOCKOUT = @as(u32, 20); pub const AE_GENERIC_TYPE = @as(u32, 21); pub const AE_SRVSTART = @as(u32, 0); pub const AE_SRVPAUSED = @as(u32, 1); pub const AE_SRVCONT = @as(u32, 2); pub const AE_SRVSTOP = @as(u32, 3); pub const AE_GUEST = @as(u32, 0); pub const AE_USER = @as(u32, 1); pub const AE_ADMIN = @as(u32, 2); pub const AE_NORMAL = @as(u32, 0); pub const AE_USERLIMIT = @as(u32, 0); pub const AE_GENERAL = @as(u32, 0); pub const AE_ERROR = @as(u32, 1); pub const AE_SESSDIS = @as(u32, 1); pub const AE_BADPW = @as(u32, 1); pub const AE_AUTODIS = @as(u32, 2); pub const AE_UNSHARE = @as(u32, 2); pub const AE_ADMINPRIVREQD = @as(u32, 2); pub const AE_ADMINDIS = @as(u32, 3); pub const AE_NOACCESSPERM = @as(u32, 3); pub const AE_ACCRESTRICT = @as(u32, 4); pub const AE_NORMAL_CLOSE = @as(u32, 0); pub const AE_SES_CLOSE = @as(u32, 1); pub const AE_ADMIN_CLOSE = @as(u32, 2); pub const AE_LIM_UNKNOWN = @as(u32, 0); pub const AE_LIM_LOGONHOURS = @as(u32, 1); pub const AE_LIM_EXPIRED = @as(u32, 2); pub const AE_LIM_INVAL_WKSTA = @as(u32, 3); pub const AE_LIM_DISABLED = @as(u32, 4); pub const AE_LIM_DELETED = @as(u32, 5); pub const AE_MOD = @as(u32, 0); pub const AE_DELETE = @as(u32, 1); pub const AE_ADD = @as(u32, 2); pub const AE_UAS_USER = @as(u32, 0); pub const AE_UAS_GROUP = @as(u32, 1); pub const AE_UAS_MODALS = @as(u32, 2); pub const SVAUD_SERVICE = @as(u32, 1); pub const SVAUD_GOODSESSLOGON = @as(u32, 6); pub const SVAUD_BADSESSLOGON = @as(u32, 24); pub const SVAUD_GOODNETLOGON = @as(u32, 96); pub const SVAUD_BADNETLOGON = @as(u32, 384); pub const SVAUD_GOODUSE = @as(u32, 1536); pub const SVAUD_BADUSE = @as(u32, 6144); pub const SVAUD_USERLIST = @as(u32, 8192); pub const SVAUD_PERMISSIONS = @as(u32, 16384); pub const SVAUD_RESOURCE = @as(u32, 32768); pub const SVAUD_LOGONLIM = @as(u32, 65536); pub const AA_AUDIT_ALL = @as(u32, 1); pub const AA_A_OWNER = @as(u32, 4); pub const AA_CLOSE = @as(u32, 8); pub const AA_S_OPEN = @as(u32, 16); pub const AA_S_WRITE = @as(u32, 32); pub const AA_S_CREATE = @as(u32, 32); pub const AA_S_DELETE = @as(u32, 64); pub const AA_S_ACL = @as(u32, 128); pub const AA_F_OPEN = @as(u32, 256); pub const AA_F_WRITE = @as(u32, 512); pub const AA_F_CREATE = @as(u32, 512); pub const AA_F_DELETE = @as(u32, 1024); pub const AA_F_ACL = @as(u32, 2048); pub const AA_A_OPEN = @as(u32, 4096); pub const AA_A_WRITE = @as(u32, 8192); pub const AA_A_CREATE = @as(u32, 8192); pub const AA_A_DELETE = @as(u32, 16384); pub const AA_A_ACL = @as(u32, 32768); pub const ERRLOG_BASE = @as(u32, 3100); pub const NELOG_Internal_Error = @as(u32, 3100); pub const NELOG_Resource_Shortage = @as(u32, 3101); pub const NELOG_Unable_To_Lock_Segment = @as(u32, 3102); pub const NELOG_Unable_To_Unlock_Segment = @as(u32, 3103); pub const NELOG_Uninstall_Service = @as(u32, 3104); pub const NELOG_Init_Exec_Fail = @as(u32, 3105); pub const NELOG_Ncb_Error = @as(u32, 3106); pub const NELOG_Net_Not_Started = @as(u32, 3107); pub const NELOG_Ioctl_Error = @as(u32, 3108); pub const NELOG_System_Semaphore = @as(u32, 3109); pub const NELOG_Init_OpenCreate_Err = @as(u32, 3110); pub const NELOG_NetBios = @as(u32, 3111); pub const NELOG_SMB_Illegal = @as(u32, 3112); pub const NELOG_Service_Fail = @as(u32, 3113); pub const NELOG_Entries_Lost = @as(u32, 3114); pub const NELOG_Init_Seg_Overflow = @as(u32, 3120); pub const NELOG_Srv_No_Mem_Grow = @as(u32, 3121); pub const NELOG_Access_File_Bad = @as(u32, 3122); pub const NELOG_Srvnet_Not_Started = @as(u32, 3123); pub const NELOG_Init_Chardev_Err = @as(u32, 3124); pub const NELOG_Remote_API = @as(u32, 3125); pub const NELOG_Ncb_TooManyErr = @as(u32, 3126); pub const NELOG_Mailslot_err = @as(u32, 3127); pub const NELOG_ReleaseMem_Alert = @as(u32, 3128); pub const NELOG_AT_cannot_write = @as(u32, 3129); pub const NELOG_Cant_Make_Msg_File = @as(u32, 3130); pub const NELOG_Exec_Netservr_NoMem = @as(u32, 3131); pub const NELOG_Server_Lock_Failure = @as(u32, 3132); pub const NELOG_Msg_Shutdown = @as(u32, 3140); pub const NELOG_Msg_Sem_Shutdown = @as(u32, 3141); pub const NELOG_Msg_Log_Err = @as(u32, 3150); pub const NELOG_VIO_POPUP_ERR = @as(u32, 3151); pub const NELOG_Msg_Unexpected_SMB_Type = @as(u32, 3152); pub const NELOG_Wksta_Infoseg = @as(u32, 3160); pub const NELOG_Wksta_Compname = @as(u32, 3161); pub const NELOG_Wksta_BiosThreadFailure = @as(u32, 3162); pub const NELOG_Wksta_IniSeg = @as(u32, 3163); pub const NELOG_Wksta_HostTab_Full = @as(u32, 3164); pub const NELOG_Wksta_Bad_Mailslot_SMB = @as(u32, 3165); pub const NELOG_Wksta_UASInit = @as(u32, 3166); pub const NELOG_Wksta_SSIRelogon = @as(u32, 3167); pub const NELOG_Build_Name = @as(u32, 3170); pub const NELOG_Name_Expansion = @as(u32, 3171); pub const NELOG_Message_Send = @as(u32, 3172); pub const NELOG_Mail_Slt_Err = @as(u32, 3173); pub const NELOG_AT_cannot_read = @as(u32, 3174); pub const NELOG_AT_sched_err = @as(u32, 3175); pub const NELOG_AT_schedule_file_created = @as(u32, 3176); pub const NELOG_Srvnet_NB_Open = @as(u32, 3177); pub const NELOG_AT_Exec_Err = @as(u32, 3178); pub const NELOG_Lazy_Write_Err = @as(u32, 3180); pub const NELOG_HotFix = @as(u32, 3181); pub const NELOG_HardErr_From_Server = @as(u32, 3182); pub const NELOG_LocalSecFail1 = @as(u32, 3183); pub const NELOG_LocalSecFail2 = @as(u32, 3184); pub const NELOG_LocalSecFail3 = @as(u32, 3185); pub const NELOG_LocalSecGeneralFail = @as(u32, 3186); pub const NELOG_NetWkSta_Internal_Error = @as(u32, 3190); pub const NELOG_NetWkSta_No_Resource = @as(u32, 3191); pub const NELOG_NetWkSta_SMB_Err = @as(u32, 3192); pub const NELOG_NetWkSta_VC_Err = @as(u32, 3193); pub const NELOG_NetWkSta_Stuck_VC_Err = @as(u32, 3194); pub const NELOG_NetWkSta_NCB_Err = @as(u32, 3195); pub const NELOG_NetWkSta_Write_Behind_Err = @as(u32, 3196); pub const NELOG_NetWkSta_Reset_Err = @as(u32, 3197); pub const NELOG_NetWkSta_Too_Many = @as(u32, 3198); pub const NELOG_Srv_Thread_Failure = @as(u32, 3204); pub const NELOG_Srv_Close_Failure = @as(u32, 3205); pub const NELOG_ReplUserCurDir = @as(u32, 3206); pub const NELOG_ReplCannotMasterDir = @as(u32, 3207); pub const NELOG_ReplUpdateError = @as(u32, 3208); pub const NELOG_ReplLostMaster = @as(u32, 3209); pub const NELOG_NetlogonAuthDCFail = @as(u32, 3210); pub const NELOG_ReplLogonFailed = @as(u32, 3211); pub const NELOG_ReplNetErr = @as(u32, 3212); pub const NELOG_ReplMaxFiles = @as(u32, 3213); pub const NELOG_ReplMaxTreeDepth = @as(u32, 3214); pub const NELOG_ReplBadMsg = @as(u32, 3215); pub const NELOG_ReplSysErr = @as(u32, 3216); pub const NELOG_ReplUserLoged = @as(u32, 3217); pub const NELOG_ReplBadImport = @as(u32, 3218); pub const NELOG_ReplBadExport = @as(u32, 3219); pub const NELOG_ReplSignalFileErr = @as(u32, 3220); pub const NELOG_DiskFT = @as(u32, 3221); pub const NELOG_ReplAccessDenied = @as(u32, 3222); pub const NELOG_NetlogonFailedPrimary = @as(u32, 3223); pub const NELOG_NetlogonPasswdSetFailed = @as(u32, 3224); pub const NELOG_NetlogonTrackingError = @as(u32, 3225); pub const NELOG_NetlogonSyncError = @as(u32, 3226); pub const NELOG_NetlogonRequireSignOrSealError = @as(u32, 3227); pub const NELOG_UPS_PowerOut = @as(u32, 3230); pub const NELOG_UPS_Shutdown = @as(u32, 3231); pub const NELOG_UPS_CmdFileError = @as(u32, 3232); pub const NELOG_UPS_CannotOpenDriver = @as(u32, 3233); pub const NELOG_UPS_PowerBack = @as(u32, 3234); pub const NELOG_UPS_CmdFileConfig = @as(u32, 3235); pub const NELOG_UPS_CmdFileExec = @as(u32, 3236); pub const NELOG_Missing_Parameter = @as(u32, 3250); pub const NELOG_Invalid_Config_Line = @as(u32, 3251); pub const NELOG_Invalid_Config_File = @as(u32, 3252); pub const NELOG_File_Changed = @as(u32, 3253); pub const NELOG_Files_Dont_Fit = @as(u32, 3254); pub const NELOG_Wrong_DLL_Version = @as(u32, 3255); pub const NELOG_Error_in_DLL = @as(u32, 3256); pub const NELOG_System_Error = @as(u32, 3257); pub const NELOG_FT_ErrLog_Too_Large = @as(u32, 3258); pub const NELOG_FT_Update_In_Progress = @as(u32, 3259); pub const NELOG_Joined_Domain = @as(u32, 3260); pub const NELOG_Joined_Workgroup = @as(u32, 3261); pub const NELOG_OEM_Code = @as(u32, 3299); pub const ERRLOG2_BASE = @as(u32, 5700); pub const NELOG_NetlogonSSIInitError = @as(u32, 5700); pub const NELOG_NetlogonFailedToUpdateTrustList = @as(u32, 5701); pub const NELOG_NetlogonFailedToAddRpcInterface = @as(u32, 5702); pub const NELOG_NetlogonFailedToReadMailslot = @as(u32, 5703); pub const NELOG_NetlogonFailedToRegisterSC = @as(u32, 5704); pub const NELOG_NetlogonChangeLogCorrupt = @as(u32, 5705); pub const NELOG_NetlogonFailedToCreateShare = @as(u32, 5706); pub const NELOG_NetlogonDownLevelLogonFailed = @as(u32, 5707); pub const NELOG_NetlogonDownLevelLogoffFailed = @as(u32, 5708); pub const NELOG_NetlogonNTLogonFailed = @as(u32, 5709); pub const NELOG_NetlogonNTLogoffFailed = @as(u32, 5710); pub const NELOG_NetlogonPartialSyncCallSuccess = @as(u32, 5711); pub const NELOG_NetlogonPartialSyncCallFailed = @as(u32, 5712); pub const NELOG_NetlogonFullSyncCallSuccess = @as(u32, 5713); pub const NELOG_NetlogonFullSyncCallFailed = @as(u32, 5714); pub const NELOG_NetlogonPartialSyncSuccess = @as(u32, 5715); pub const NELOG_NetlogonPartialSyncFailed = @as(u32, 5716); pub const NELOG_NetlogonFullSyncSuccess = @as(u32, 5717); pub const NELOG_NetlogonFullSyncFailed = @as(u32, 5718); pub const NELOG_NetlogonAuthNoDomainController = @as(u32, 5719); pub const NELOG_NetlogonAuthNoTrustLsaSecret = @as(u32, 5720); pub const NELOG_NetlogonAuthNoTrustSamAccount = @as(u32, 5721); pub const NELOG_NetlogonServerAuthFailed = @as(u32, 5722); pub const NELOG_NetlogonServerAuthNoTrustSamAccount = @as(u32, 5723); pub const NELOG_FailedToRegisterSC = @as(u32, 5724); pub const NELOG_FailedToSetServiceStatus = @as(u32, 5725); pub const NELOG_FailedToGetComputerName = @as(u32, 5726); pub const NELOG_DriverNotLoaded = @as(u32, 5727); pub const NELOG_NoTranportLoaded = @as(u32, 5728); pub const NELOG_NetlogonFailedDomainDelta = @as(u32, 5729); pub const NELOG_NetlogonFailedGlobalGroupDelta = @as(u32, 5730); pub const NELOG_NetlogonFailedLocalGroupDelta = @as(u32, 5731); pub const NELOG_NetlogonFailedUserDelta = @as(u32, 5732); pub const NELOG_NetlogonFailedPolicyDelta = @as(u32, 5733); pub const NELOG_NetlogonFailedTrustedDomainDelta = @as(u32, 5734); pub const NELOG_NetlogonFailedAccountDelta = @as(u32, 5735); pub const NELOG_NetlogonFailedSecretDelta = @as(u32, 5736); pub const NELOG_NetlogonSystemError = @as(u32, 5737); pub const NELOG_NetlogonDuplicateMachineAccounts = @as(u32, 5738); pub const NELOG_NetlogonTooManyGlobalGroups = @as(u32, 5739); pub const NELOG_NetlogonBrowserDriver = @as(u32, 5740); pub const NELOG_NetlogonAddNameFailure = @as(u32, 5741); pub const NELOG_RplMessages = @as(u32, 5742); pub const NELOG_RplXnsBoot = @as(u32, 5743); pub const NELOG_RplSystem = @as(u32, 5744); pub const NELOG_RplWkstaTimeout = @as(u32, 5745); pub const NELOG_RplWkstaFileOpen = @as(u32, 5746); pub const NELOG_RplWkstaFileRead = @as(u32, 5747); pub const NELOG_RplWkstaMemory = @as(u32, 5748); pub const NELOG_RplWkstaFileChecksum = @as(u32, 5749); pub const NELOG_RplWkstaFileLineCount = @as(u32, 5750); pub const NELOG_RplWkstaBbcFile = @as(u32, 5751); pub const NELOG_RplWkstaFileSize = @as(u32, 5752); pub const NELOG_RplWkstaInternal = @as(u32, 5753); pub const NELOG_RplWkstaWrongVersion = @as(u32, 5754); pub const NELOG_RplWkstaNetwork = @as(u32, 5755); pub const NELOG_RplAdapterResource = @as(u32, 5756); pub const NELOG_RplFileCopy = @as(u32, 5757); pub const NELOG_RplFileDelete = @as(u32, 5758); pub const NELOG_RplFilePerms = @as(u32, 5759); pub const NELOG_RplCheckConfigs = @as(u32, 5760); pub const NELOG_RplCreateProfiles = @as(u32, 5761); pub const NELOG_RplRegistry = @as(u32, 5762); pub const NELOG_RplReplaceRPLDISK = @as(u32, 5763); pub const NELOG_RplCheckSecurity = @as(u32, 5764); pub const NELOG_RplBackupDatabase = @as(u32, 5765); pub const NELOG_RplInitDatabase = @as(u32, 5766); pub const NELOG_RplRestoreDatabaseFailure = @as(u32, 5767); pub const NELOG_RplRestoreDatabaseSuccess = @as(u32, 5768); pub const NELOG_RplInitRestoredDatabase = @as(u32, 5769); pub const NELOG_NetlogonSessionTypeWrong = @as(u32, 5770); pub const NELOG_RplUpgradeDBTo40 = @as(u32, 5771); pub const NELOG_NetlogonLanmanBdcsNotAllowed = @as(u32, 5772); pub const NELOG_NetlogonNoDynamicDns = @as(u32, 5773); pub const NELOG_NetlogonDynamicDnsRegisterFailure = @as(u32, 5774); pub const NELOG_NetlogonDynamicDnsDeregisterFailure = @as(u32, 5775); pub const NELOG_NetlogonFailedFileCreate = @as(u32, 5776); pub const NELOG_NetlogonGetSubnetToSite = @as(u32, 5777); pub const NELOG_NetlogonNoSiteForClient = @as(u32, 5778); pub const NELOG_NetlogonBadSiteName = @as(u32, 5779); pub const NELOG_NetlogonBadSubnetName = @as(u32, 5780); pub const NELOG_NetlogonDynamicDnsServerFailure = @as(u32, 5781); pub const NELOG_NetlogonDynamicDnsFailure = @as(u32, 5782); pub const NELOG_NetlogonRpcCallCancelled = @as(u32, 5783); pub const NELOG_NetlogonDcSiteCovered = @as(u32, 5784); pub const NELOG_NetlogonDcSiteNotCovered = @as(u32, 5785); pub const NELOG_NetlogonGcSiteCovered = @as(u32, 5786); pub const NELOG_NetlogonGcSiteNotCovered = @as(u32, 5787); pub const NELOG_NetlogonFailedSpnUpdate = @as(u32, 5788); pub const NELOG_NetlogonFailedDnsHostNameUpdate = @as(u32, 5789); pub const NELOG_NetlogonAuthNoUplevelDomainController = @as(u32, 5790); pub const NELOG_NetlogonAuthDomainDowngraded = @as(u32, 5791); pub const NELOG_NetlogonNdncSiteCovered = @as(u32, 5792); pub const NELOG_NetlogonNdncSiteNotCovered = @as(u32, 5793); pub const NELOG_NetlogonDcOldSiteCovered = @as(u32, 5794); pub const NELOG_NetlogonDcSiteNotCoveredAuto = @as(u32, 5795); pub const NELOG_NetlogonGcOldSiteCovered = @as(u32, 5796); pub const NELOG_NetlogonGcSiteNotCoveredAuto = @as(u32, 5797); pub const NELOG_NetlogonNdncOldSiteCovered = @as(u32, 5798); pub const NELOG_NetlogonNdncSiteNotCoveredAuto = @as(u32, 5799); pub const NELOG_NetlogonSpnMultipleSamAccountNames = @as(u32, 5800); pub const NELOG_NetlogonSpnCrackNamesFailure = @as(u32, 5801); pub const NELOG_NetlogonNoAddressToSiteMapping = @as(u32, 5802); pub const NELOG_NetlogonInvalidGenericParameterValue = @as(u32, 5803); pub const NELOG_NetlogonInvalidDwordParameterValue = @as(u32, 5804); pub const NELOG_NetlogonServerAuthFailedNoAccount = @as(u32, 5805); pub const NELOG_NetlogonNoDynamicDnsManual = @as(u32, 5806); pub const NELOG_NetlogonNoSiteForClients = @as(u32, 5807); pub const NELOG_NetlogonDnsDeregAborted = @as(u32, 5808); pub const NELOG_NetlogonRpcPortRequestFailure = @as(u32, 5809); pub const NELOG_NetlogonPartialSiteMappingForClients = @as(u32, 5810); pub const NELOG_NetlogonRemoteDynamicDnsRegisterFailure = @as(u32, 5811); pub const NELOG_NetlogonRemoteDynamicDnsDeregisterFailure = @as(u32, 5812); pub const NELOG_NetlogonRejectedRemoteDynamicDnsRegister = @as(u32, 5813); pub const NELOG_NetlogonRejectedRemoteDynamicDnsDeregister = @as(u32, 5814); pub const NELOG_NetlogonRemoteDynamicDnsUpdateRequestFailure = @as(u32, 5815); pub const NELOG_NetlogonUserValidationReqInitialTimeOut = @as(u32, 5816); pub const NELOG_NetlogonUserValidationReqRecurringTimeOut = @as(u32, 5817); pub const NELOG_NetlogonUserValidationReqWaitInitialWarning = @as(u32, 5818); pub const NELOG_NetlogonUserValidationReqWaitRecurringWarning = @as(u32, 5819); pub const NELOG_NetlogonFailedToAddAuthzRpcInterface = @as(u32, 5820); pub const NELOG_NetLogonFailedToInitializeAuthzRm = @as(u32, 5821); pub const NELOG_NetLogonFailedToInitializeRPCSD = @as(u32, 5822); pub const NELOG_NetlogonMachinePasswdSetSucceeded = @as(u32, 5823); pub const NELOG_NetlogonMsaPasswdSetSucceeded = @as(u32, 5824); pub const NETSETUP_ACCT_DELETE = @as(u32, 4); pub const NETSETUP_DNS_NAME_CHANGES_ONLY = @as(u32, 4096); pub const NETSETUP_INSTALL_INVOCATION = @as(u32, 262144); pub const NETSETUP_ALT_SAMACCOUNTNAME = @as(u32, 131072); pub const NET_IGNORE_UNSUPPORTED_FLAGS = @as(u32, 1); pub const NETSETUP_PROVISION_PERSISTENTSITE = @as(u32, 32); pub const NETSETUP_PROVISION_CHECK_PWD_ONLY = @as(u32, 2147483648); pub const NETSETUP_PROVISIONING_PARAMS_WIN8_VERSION = @as(u32, 1); pub const NETSETUP_PROVISIONING_PARAMS_CURRENT_VERSION = @as(u32, 2); pub const MSGNAME_NOT_FORWARDED = @as(u32, 0); pub const MSGNAME_FORWARDED_TO = @as(u32, 4); pub const MSGNAME_FORWARDED_FROM = @as(u32, 16); pub const SUPPORTS_ANY = @as(i32, -1); pub const NO_PERMISSION_REQUIRED = @as(u32, 1); pub const ALLOCATE_RESPONSE = @as(u32, 2); pub const USE_SPECIFIC_TRANSPORT = @as(u32, 2147483648); pub const SV_PLATFORM_ID_OS2 = @as(u32, 400); pub const SV_PLATFORM_ID_NT = @as(u32, 500); pub const MAJOR_VERSION_MASK = @as(u32, 15); pub const SV_NODISC = @as(i32, -1); pub const SV_PLATFORM_ID_PARMNUM = @as(u32, 101); pub const SV_NAME_PARMNUM = @as(u32, 102); pub const SV_VERSION_MAJOR_PARMNUM = @as(u32, 103); pub const SV_VERSION_MINOR_PARMNUM = @as(u32, 104); pub const SV_TYPE_PARMNUM = @as(u32, 105); pub const SV_COMMENT_PARMNUM = @as(u32, 5); pub const SV_USERS_PARMNUM = @as(u32, 107); pub const SV_DISC_PARMNUM = @as(u32, 10); pub const SV_HIDDEN_PARMNUM = @as(u32, 16); pub const SV_ANNOUNCE_PARMNUM = @as(u32, 17); pub const SV_ANNDELTA_PARMNUM = @as(u32, 18); pub const SV_USERPATH_PARMNUM = @as(u32, 112); pub const SV_ULIST_MTIME_PARMNUM = @as(u32, 401); pub const SV_GLIST_MTIME_PARMNUM = @as(u32, 402); pub const SV_ALIST_MTIME_PARMNUM = @as(u32, 403); pub const SV_ALERTS_PARMNUM = @as(u32, 11); pub const SV_SECURITY_PARMNUM = @as(u32, 405); pub const SV_NUMADMIN_PARMNUM = @as(u32, 406); pub const SV_LANMASK_PARMNUM = @as(u32, 407); pub const SV_GUESTACC_PARMNUM = @as(u32, 408); pub const SV_CHDEVQ_PARMNUM = @as(u32, 410); pub const SV_CHDEVJOBS_PARMNUM = @as(u32, 411); pub const SV_CONNECTIONS_PARMNUM = @as(u32, 412); pub const SV_SHARES_PARMNUM = @as(u32, 413); pub const SV_OPENFILES_PARMNUM = @as(u32, 414); pub const SV_SESSREQS_PARMNUM = @as(u32, 417); pub const SV_ACTIVELOCKS_PARMNUM = @as(u32, 419); pub const SV_NUMREQBUF_PARMNUM = @as(u32, 420); pub const SV_NUMBIGBUF_PARMNUM = @as(u32, 422); pub const SV_NUMFILETASKS_PARMNUM = @as(u32, 423); pub const SV_ALERTSCHED_PARMNUM = @as(u32, 37); pub const SV_ERRORALERT_PARMNUM = @as(u32, 38); pub const SV_LOGONALERT_PARMNUM = @as(u32, 39); pub const SV_ACCESSALERT_PARMNUM = @as(u32, 40); pub const SV_DISKALERT_PARMNUM = @as(u32, 41); pub const SV_NETIOALERT_PARMNUM = @as(u32, 42); pub const SV_MAXAUDITSZ_PARMNUM = @as(u32, 43); pub const SV_SRVHEURISTICS_PARMNUM = @as(u32, 431); pub const SV_SESSOPENS_PARMNUM = @as(u32, 501); pub const SV_SESSVCS_PARMNUM = @as(u32, 502); pub const SV_OPENSEARCH_PARMNUM = @as(u32, 503); pub const SV_SIZREQBUF_PARMNUM = @as(u32, 504); pub const SV_INITWORKITEMS_PARMNUM = @as(u32, 505); pub const SV_MAXWORKITEMS_PARMNUM = @as(u32, 506); pub const SV_RAWWORKITEMS_PARMNUM = @as(u32, 507); pub const SV_IRPSTACKSIZE_PARMNUM = @as(u32, 508); pub const SV_MAXRAWBUFLEN_PARMNUM = @as(u32, 509); pub const SV_SESSUSERS_PARMNUM = @as(u32, 510); pub const SV_SESSCONNS_PARMNUM = @as(u32, 511); pub const SV_MAXNONPAGEDMEMORYUSAGE_PARMNUM = @as(u32, 512); pub const SV_MAXPAGEDMEMORYUSAGE_PARMNUM = @as(u32, 513); pub const SV_ENABLESOFTCOMPAT_PARMNUM = @as(u32, 514); pub const SV_ENABLEFORCEDLOGOFF_PARMNUM = @as(u32, 515); pub const SV_TIMESOURCE_PARMNUM = @as(u32, 516); pub const SV_ACCEPTDOWNLEVELAPIS_PARMNUM = @as(u32, 517); pub const SV_LMANNOUNCE_PARMNUM = @as(u32, 518); pub const SV_DOMAIN_PARMNUM = @as(u32, 519); pub const SV_MAXCOPYREADLEN_PARMNUM = @as(u32, 520); pub const SV_MAXCOPYWRITELEN_PARMNUM = @as(u32, 521); pub const SV_MINKEEPSEARCH_PARMNUM = @as(u32, 522); pub const SV_MAXKEEPSEARCH_PARMNUM = @as(u32, 523); pub const SV_MINKEEPCOMPLSEARCH_PARMNUM = @as(u32, 524); pub const SV_MAXKEEPCOMPLSEARCH_PARMNUM = @as(u32, 525); pub const SV_THREADCOUNTADD_PARMNUM = @as(u32, 526); pub const SV_NUMBLOCKTHREADS_PARMNUM = @as(u32, 527); pub const SV_SCAVTIMEOUT_PARMNUM = @as(u32, 528); pub const SV_MINRCVQUEUE_PARMNUM = @as(u32, 529); pub const SV_MINFREEWORKITEMS_PARMNUM = @as(u32, 530); pub const SV_XACTMEMSIZE_PARMNUM = @as(u32, 531); pub const SV_THREADPRIORITY_PARMNUM = @as(u32, 532); pub const SV_MAXMPXCT_PARMNUM = @as(u32, 533); pub const SV_OPLOCKBREAKWAIT_PARMNUM = @as(u32, 534); pub const SV_OPLOCKBREAKRESPONSEWAIT_PARMNUM = @as(u32, 535); pub const SV_ENABLEOPLOCKS_PARMNUM = @as(u32, 536); pub const SV_ENABLEOPLOCKFORCECLOSE_PARMNUM = @as(u32, 537); pub const SV_ENABLEFCBOPENS_PARMNUM = @as(u32, 538); pub const SV_ENABLERAW_PARMNUM = @as(u32, 539); pub const SV_ENABLESHAREDNETDRIVES_PARMNUM = @as(u32, 540); pub const SV_MINFREECONNECTIONS_PARMNUM = @as(u32, 541); pub const SV_MAXFREECONNECTIONS_PARMNUM = @as(u32, 542); pub const SV_INITSESSTABLE_PARMNUM = @as(u32, 543); pub const SV_INITCONNTABLE_PARMNUM = @as(u32, 544); pub const SV_INITFILETABLE_PARMNUM = @as(u32, 545); pub const SV_INITSEARCHTABLE_PARMNUM = @as(u32, 546); pub const SV_ALERTSCHEDULE_PARMNUM = @as(u32, 547); pub const SV_ERRORTHRESHOLD_PARMNUM = @as(u32, 548); pub const SV_NETWORKERRORTHRESHOLD_PARMNUM = @as(u32, 549); pub const SV_DISKSPACETHRESHOLD_PARMNUM = @as(u32, 550); pub const SV_MAXLINKDELAY_PARMNUM = @as(u32, 552); pub const SV_MINLINKTHROUGHPUT_PARMNUM = @as(u32, 553); pub const SV_LINKINFOVALIDTIME_PARMNUM = @as(u32, 554); pub const SV_SCAVQOSINFOUPDATETIME_PARMNUM = @as(u32, 555); pub const SV_MAXWORKITEMIDLETIME_PARMNUM = @as(u32, 556); pub const SV_MAXRAWWORKITEMS_PARMNUM = @as(u32, 557); pub const SV_PRODUCTTYPE_PARMNUM = @as(u32, 560); pub const SV_SERVERSIZE_PARMNUM = @as(u32, 561); pub const SV_CONNECTIONLESSAUTODISC_PARMNUM = @as(u32, 562); pub const SV_SHARINGVIOLATIONRETRIES_PARMNUM = @as(u32, 563); pub const SV_SHARINGVIOLATIONDELAY_PARMNUM = @as(u32, 564); pub const SV_MAXGLOBALOPENSEARCH_PARMNUM = @as(u32, 565); pub const SV_REMOVEDUPLICATESEARCHES_PARMNUM = @as(u32, 566); pub const SV_LOCKVIOLATIONRETRIES_PARMNUM = @as(u32, 567); pub const SV_LOCKVIOLATIONOFFSET_PARMNUM = @as(u32, 568); pub const SV_LOCKVIOLATIONDELAY_PARMNUM = @as(u32, 569); pub const SV_MDLREADSWITCHOVER_PARMNUM = @as(u32, 570); pub const SV_CACHEDOPENLIMIT_PARMNUM = @as(u32, 571); pub const SV_CRITICALTHREADS_PARMNUM = @as(u32, 572); pub const SV_RESTRICTNULLSESSACCESS_PARMNUM = @as(u32, 573); pub const SV_ENABLEWFW311DIRECTIPX_PARMNUM = @as(u32, 574); pub const SV_OTHERQUEUEAFFINITY_PARMNUM = @as(u32, 575); pub const SV_QUEUESAMPLESECS_PARMNUM = @as(u32, 576); pub const SV_BALANCECOUNT_PARMNUM = @as(u32, 577); pub const SV_PREFERREDAFFINITY_PARMNUM = @as(u32, 578); pub const SV_MAXFREERFCBS_PARMNUM = @as(u32, 579); pub const SV_MAXFREEMFCBS_PARMNUM = @as(u32, 580); pub const SV_MAXFREELFCBS_PARMNUM = @as(u32, 581); pub const SV_MAXFREEPAGEDPOOLCHUNKS_PARMNUM = @as(u32, 582); pub const SV_MINPAGEDPOOLCHUNKSIZE_PARMNUM = @as(u32, 583); pub const SV_MAXPAGEDPOOLCHUNKSIZE_PARMNUM = @as(u32, 584); pub const SV_SENDSFROMPREFERREDPROCESSOR_PARMNUM = @as(u32, 585); pub const SV_MAXTHREADSPERQUEUE_PARMNUM = @as(u32, 586); pub const SV_CACHEDDIRECTORYLIMIT_PARMNUM = @as(u32, 587); pub const SV_MAXCOPYLENGTH_PARMNUM = @as(u32, 588); pub const SV_ENABLECOMPRESSION_PARMNUM = @as(u32, 590); pub const SV_AUTOSHAREWKS_PARMNUM = @as(u32, 591); pub const SV_AUTOSHARESERVER_PARMNUM = @as(u32, 592); pub const SV_ENABLESECURITYSIGNATURE_PARMNUM = @as(u32, 593); pub const SV_REQUIRESECURITYSIGNATURE_PARMNUM = @as(u32, 594); pub const SV_MINCLIENTBUFFERSIZE_PARMNUM = @as(u32, 595); pub const SV_CONNECTIONNOSESSIONSTIMEOUT_PARMNUM = @as(u32, 596); pub const SV_IDLETHREADTIMEOUT_PARMNUM = @as(u32, 597); pub const SV_ENABLEW9XSECURITYSIGNATURE_PARMNUM = @as(u32, 598); pub const SV_ENFORCEKERBEROSREAUTHENTICATION_PARMNUM = @as(u32, 599); pub const SV_DISABLEDOS_PARMNUM = @as(u32, 600); pub const SV_LOWDISKSPACEMINIMUM_PARMNUM = @as(u32, 601); pub const SV_DISABLESTRICTNAMECHECKING_PARMNUM = @as(u32, 602); pub const SV_ENABLEAUTHENTICATEUSERSHARING_PARMNUM = @as(u32, 603); pub const SVI1_NUM_ELEMENTS = @as(u32, 5); pub const SVI2_NUM_ELEMENTS = @as(u32, 40); pub const SVI3_NUM_ELEMENTS = @as(u32, 44); pub const SW_AUTOPROF_LOAD_MASK = @as(u32, 1); pub const SW_AUTOPROF_SAVE_MASK = @as(u32, 2); pub const SV_MAX_SRV_HEUR_LEN = @as(u32, 32); pub const SV_USERS_PER_LICENSE = @as(u32, 5); pub const SVTI2_REMAP_PIPE_NAMES = @as(u32, 2); pub const SVTI2_SCOPED_NAME = @as(u32, 4); pub const SVTI2_CLUSTER_NAME = @as(u32, 8); pub const SVTI2_CLUSTER_DNN_NAME = @as(u32, 16); pub const SVTI2_UNICODE_TRANSPORT_ADDRESS = @as(u32, 32); pub const SVTI2_RESERVED1 = @as(u32, 4096); pub const SVTI2_RESERVED2 = @as(u32, 8192); pub const SVTI2_RESERVED3 = @as(u32, 16384); pub const SRV_SUPPORT_HASH_GENERATION = @as(u32, 1); pub const SRV_HASH_GENERATION_ACTIVE = @as(u32, 2); pub const SERVICE_INSTALL_STATE = @as(u32, 3); pub const SERVICE_UNINSTALLED = @as(u32, 0); pub const SERVICE_INSTALL_PENDING = @as(u32, 1); pub const SERVICE_UNINSTALL_PENDING = @as(u32, 2); pub const SERVICE_INSTALLED = @as(u32, 3); pub const SERVICE_PAUSE_STATE = @as(u32, 12); pub const LM20_SERVICE_ACTIVE = @as(u32, 0); pub const LM20_SERVICE_CONTINUE_PENDING = @as(u32, 4); pub const LM20_SERVICE_PAUSE_PENDING = @as(u32, 8); pub const LM20_SERVICE_PAUSED = @as(u32, 12); pub const SERVICE_NOT_UNINSTALLABLE = @as(u32, 0); pub const SERVICE_UNINSTALLABLE = @as(u32, 16); pub const SERVICE_NOT_PAUSABLE = @as(u32, 0); pub const SERVICE_PAUSABLE = @as(u32, 32); pub const SERVICE_REDIR_PAUSED = @as(u32, 1792); pub const SERVICE_REDIR_DISK_PAUSED = @as(u32, 256); pub const SERVICE_REDIR_PRINT_PAUSED = @as(u32, 512); pub const SERVICE_REDIR_COMM_PAUSED = @as(u32, 1024); pub const SERVICE_CTRL_INTERROGATE = @as(u32, 0); pub const SERVICE_CTRL_PAUSE = @as(u32, 1); pub const SERVICE_CTRL_CONTINUE = @as(u32, 2); pub const SERVICE_CTRL_UNINSTALL = @as(u32, 3); pub const SERVICE_CTRL_REDIR_DISK = @as(u32, 1); pub const SERVICE_CTRL_REDIR_PRINT = @as(u32, 2); pub const SERVICE_CTRL_REDIR_COMM = @as(u32, 4); pub const SERVICE_IP_NO_HINT = @as(u32, 0); pub const SERVICE_CCP_NO_HINT = @as(u32, 0); pub const SERVICE_IP_QUERY_HINT = @as(u32, 65536); pub const SERVICE_CCP_QUERY_HINT = @as(u32, 65536); pub const SERVICE_IP_CHKPT_NUM = @as(u32, 255); pub const SERVICE_CCP_CHKPT_NUM = @as(u32, 255); pub const SERVICE_IP_WAIT_TIME = @as(u32, 65280); pub const SERVICE_CCP_WAIT_TIME = @as(u32, 65280); pub const SERVICE_IP_WAITTIME_SHIFT = @as(u32, 8); pub const SERVICE_NTIP_WAITTIME_SHIFT = @as(u32, 12); pub const UPPER_HINT_MASK = @as(u32, 65280); pub const LOWER_HINT_MASK = @as(u32, 255); pub const UPPER_GET_HINT_MASK = @as(u32, 267386880); pub const LOWER_GET_HINT_MASK = @as(u32, 65280); pub const SERVICE_NT_MAXTIME = @as(u32, 65535); pub const SERVICE_RESRV_MASK = @as(u32, 131071); pub const SERVICE_MAXTIME = @as(u32, 255); pub const SERVICE_BASE = @as(u32, 3050); pub const SERVICE_UIC_NORMAL = @as(u32, 0); pub const SERVICE_UIC_BADPARMVAL = @as(u32, 3051); pub const SERVICE_UIC_MISSPARM = @as(u32, 3052); pub const SERVICE_UIC_UNKPARM = @as(u32, 3053); pub const SERVICE_UIC_RESOURCE = @as(u32, 3054); pub const SERVICE_UIC_CONFIG = @as(u32, 3055); pub const SERVICE_UIC_SYSTEM = @as(u32, 3056); pub const SERVICE_UIC_INTERNAL = @as(u32, 3057); pub const SERVICE_UIC_AMBIGPARM = @as(u32, 3058); pub const SERVICE_UIC_DUPPARM = @as(u32, 3059); pub const SERVICE_UIC_KILL = @as(u32, 3060); pub const SERVICE_UIC_EXEC = @as(u32, 3061); pub const SERVICE_UIC_SUBSERV = @as(u32, 3062); pub const SERVICE_UIC_CONFLPARM = @as(u32, 3063); pub const SERVICE_UIC_FILE = @as(u32, 3064); pub const SERVICE_UIC_M_NULL = @as(u32, 0); pub const SERVICE_UIC_M_MEMORY = @as(u32, 3070); pub const SERVICE_UIC_M_DISK = @as(u32, 3071); pub const SERVICE_UIC_M_THREADS = @as(u32, 3072); pub const SERVICE_UIC_M_PROCESSES = @as(u32, 3073); pub const SERVICE_UIC_M_SECURITY = @as(u32, 3074); pub const SERVICE_UIC_M_LANROOT = @as(u32, 3075); pub const SERVICE_UIC_M_REDIR = @as(u32, 3076); pub const SERVICE_UIC_M_SERVER = @as(u32, 3077); pub const SERVICE_UIC_M_SEC_FILE_ERR = @as(u32, 3078); pub const SERVICE_UIC_M_FILES = @as(u32, 3079); pub const SERVICE_UIC_M_LOGS = @as(u32, 3080); pub const SERVICE_UIC_M_LANGROUP = @as(u32, 3081); pub const SERVICE_UIC_M_MSGNAME = @as(u32, 3082); pub const SERVICE_UIC_M_ANNOUNCE = @as(u32, 3083); pub const SERVICE_UIC_M_UAS = @as(u32, 3084); pub const SERVICE_UIC_M_SERVER_SEC_ERR = @as(u32, 3085); pub const SERVICE_UIC_M_WKSTA = @as(u32, 3087); pub const SERVICE_UIC_M_ERRLOG = @as(u32, 3088); pub const SERVICE_UIC_M_FILE_UW = @as(u32, 3089); pub const SERVICE_UIC_M_ADDPAK = @as(u32, 3090); pub const SERVICE_UIC_M_LAZY = @as(u32, 3091); pub const SERVICE_UIC_M_UAS_MACHINE_ACCT = @as(u32, 3092); pub const SERVICE_UIC_M_UAS_SERVERS_NMEMB = @as(u32, 3093); pub const SERVICE_UIC_M_UAS_SERVERS_NOGRP = @as(u32, 3094); pub const SERVICE_UIC_M_UAS_INVALID_ROLE = @as(u32, 3095); pub const SERVICE_UIC_M_NETLOGON_NO_DC = @as(u32, 3096); pub const SERVICE_UIC_M_NETLOGON_DC_CFLCT = @as(u32, 3097); pub const SERVICE_UIC_M_NETLOGON_AUTH = @as(u32, 3098); pub const SERVICE_UIC_M_UAS_PROLOG = @as(u32, 3099); pub const SERVICE2_BASE = @as(u32, 5600); pub const SERVICE_UIC_M_NETLOGON_MPATH = @as(u32, 5600); pub const SERVICE_UIC_M_LSA_MACHINE_ACCT = @as(u32, 5601); pub const SERVICE_UIC_M_DATABASE_ERROR = @as(u32, 5602); pub const USE_FLAG_GLOBAL_MAPPING = @as(u32, 65536); pub const USE_LOCAL_PARMNUM = @as(u32, 1); pub const USE_REMOTE_PARMNUM = @as(u32, 2); pub const USE_PASSWORD_PARMNUM = @as(u32, 3); pub const USE_ASGTYPE_PARMNUM = @as(u32, 4); pub const USE_USERNAME_PARMNUM = @as(u32, 5); pub const USE_DOMAINNAME_PARMNUM = @as(u32, 6); pub const USE_FLAGS_PARMNUM = @as(u32, 7); pub const USE_AUTHIDENTITY_PARMNUM = @as(u32, 8); pub const USE_SD_PARMNUM = @as(u32, 9); pub const USE_OPTIONS_PARMNUM = @as(u32, 10); pub const USE_OK = @as(u32, 0); pub const USE_PAUSED = @as(u32, 1); pub const USE_SESSLOST = @as(u32, 2); pub const USE_DISCONN = @as(u32, 2); pub const USE_NETERR = @as(u32, 3); pub const USE_CONN = @as(u32, 4); pub const USE_RECONN = @as(u32, 5); pub const USE_CHARDEV = @as(u32, 2); pub const CREATE_NO_CONNECT = @as(u32, 1); pub const CREATE_BYPASS_CSC = @as(u32, 2); pub const CREATE_CRED_RESET = @as(u32, 4); pub const USE_DEFAULT_CREDENTIALS = @as(u32, 4); pub const CREATE_REQUIRE_CONNECTION_INTEGRITY = @as(u32, 8); pub const CREATE_REQUIRE_CONNECTION_PRIVACY = @as(u32, 16); pub const CREATE_PERSIST_MAPPING = @as(u32, 32); pub const CREATE_WRITE_THROUGH_SEMANTICS = @as(u32, 64); pub const CREATE_COMPRESS_NETWORK_TRAFFIC = @as(u32, 128); pub const WKSTA_PLATFORM_ID_PARMNUM = @as(u32, 100); pub const WKSTA_COMPUTERNAME_PARMNUM = @as(u32, 1); pub const WKSTA_LANGROUP_PARMNUM = @as(u32, 2); pub const WKSTA_VER_MAJOR_PARMNUM = @as(u32, 4); pub const WKSTA_VER_MINOR_PARMNUM = @as(u32, 5); pub const WKSTA_LOGGED_ON_USERS_PARMNUM = @as(u32, 6); pub const WKSTA_LANROOT_PARMNUM = @as(u32, 7); pub const WKSTA_LOGON_DOMAIN_PARMNUM = @as(u32, 8); pub const WKSTA_LOGON_SERVER_PARMNUM = @as(u32, 9); pub const WKSTA_CHARWAIT_PARMNUM = @as(u32, 10); pub const WKSTA_CHARTIME_PARMNUM = @as(u32, 11); pub const WKSTA_CHARCOUNT_PARMNUM = @as(u32, 12); pub const WKSTA_KEEPCONN_PARMNUM = @as(u32, 13); pub const WKSTA_KEEPSEARCH_PARMNUM = @as(u32, 14); pub const WKSTA_MAXCMDS_PARMNUM = @as(u32, 15); pub const WKSTA_NUMWORKBUF_PARMNUM = @as(u32, 16); pub const WKSTA_MAXWRKCACHE_PARMNUM = @as(u32, 17); pub const WKSTA_SESSTIMEOUT_PARMNUM = @as(u32, 18); pub const WKSTA_SIZERROR_PARMNUM = @as(u32, 19); pub const WKSTA_NUMALERTS_PARMNUM = @as(u32, 20); pub const WKSTA_NUMSERVICES_PARMNUM = @as(u32, 21); pub const WKSTA_NUMCHARBUF_PARMNUM = @as(u32, 22); pub const WKSTA_SIZCHARBUF_PARMNUM = @as(u32, 23); pub const WKSTA_ERRLOGSZ_PARMNUM = @as(u32, 27); pub const WKSTA_PRINTBUFTIME_PARMNUM = @as(u32, 28); pub const WKSTA_SIZWORKBUF_PARMNUM = @as(u32, 29); pub const WKSTA_MAILSLOTS_PARMNUM = @as(u32, 30); pub const WKSTA_NUMDGRAMBUF_PARMNUM = @as(u32, 31); pub const WKSTA_WRKHEURISTICS_PARMNUM = @as(u32, 32); pub const WKSTA_MAXTHREADS_PARMNUM = @as(u32, 33); pub const WKSTA_LOCKQUOTA_PARMNUM = @as(u32, 41); pub const WKSTA_LOCKINCREMENT_PARMNUM = @as(u32, 42); pub const WKSTA_LOCKMAXIMUM_PARMNUM = @as(u32, 43); pub const WKSTA_PIPEINCREMENT_PARMNUM = @as(u32, 44); pub const WKSTA_PIPEMAXIMUM_PARMNUM = @as(u32, 45); pub const WKSTA_DORMANTFILELIMIT_PARMNUM = @as(u32, 46); pub const WKSTA_CACHEFILETIMEOUT_PARMNUM = @as(u32, 47); pub const WKSTA_USEOPPORTUNISTICLOCKING_PARMNUM = @as(u32, 48); pub const WKSTA_USEUNLOCKBEHIND_PARMNUM = @as(u32, 49); pub const WKSTA_USECLOSEBEHIND_PARMNUM = @as(u32, 50); pub const WKSTA_BUFFERNAMEDPIPES_PARMNUM = @as(u32, 51); pub const WKSTA_USELOCKANDREADANDUNLOCK_PARMNUM = @as(u32, 52); pub const WKSTA_UTILIZENTCACHING_PARMNUM = @as(u32, 53); pub const WKSTA_USERAWREAD_PARMNUM = @as(u32, 54); pub const WKSTA_USERAWWRITE_PARMNUM = @as(u32, 55); pub const WKSTA_USEWRITERAWWITHDATA_PARMNUM = @as(u32, 56); pub const WKSTA_USEENCRYPTION_PARMNUM = @as(u32, 57); pub const WKSTA_BUFFILESWITHDENYWRITE_PARMNUM = @as(u32, 58); pub const WKSTA_BUFFERREADONLYFILES_PARMNUM = @as(u32, 59); pub const WKSTA_FORCECORECREATEMODE_PARMNUM = @as(u32, 60); pub const WKSTA_USE512BYTESMAXTRANSFER_PARMNUM = @as(u32, 61); pub const WKSTA_READAHEADTHRUPUT_PARMNUM = @as(u32, 62); pub const WKSTA_OTH_DOMAINS_PARMNUM = @as(u32, 101); pub const TRANSPORT_QUALITYOFSERVICE_PARMNUM = @as(u32, 201); pub const TRANSPORT_NAME_PARMNUM = @as(u32, 202); //-------------------------------------------------------------------------------- // Section: Types (297) //-------------------------------------------------------------------------------- pub const NET_REQUEST_PROVISION_OPTIONS = enum(u32) { R = 1073741824, _, pub fn initFlags(o: struct { R: u1 = 0, }) NET_REQUEST_PROVISION_OPTIONS { return @intToEnum(NET_REQUEST_PROVISION_OPTIONS, (if (o.R == 1) @enumToInt(NET_REQUEST_PROVISION_OPTIONS.R) else 0) ); } }; pub const NETSETUP_PROVISION_ONLINE_CALLER = NET_REQUEST_PROVISION_OPTIONS.R; pub const NET_JOIN_DOMAIN_JOIN_OPTIONS = enum(u32) { JOIN_DOMAIN = 1, ACCT_CREATE = 2, WIN9X_UPGRADE = 16, DOMAIN_JOIN_IF_JOINED = 32, JOIN_UNSECURE = 64, MACHINE_PWD_PASSED = 128, DEFER_SPN_SET = 256, JOIN_DC_ACCOUNT = 512, JOIN_WITH_NEW_NAME = 1024, JOIN_READONLY = 2048, AMBIGUOUS_DC = 4096, NO_NETLOGON_CACHE = 8192, DONT_CONTROL_SERVICES = 16384, SET_MACHINE_NAME = 32768, FORCE_SPN_SET = 65536, NO_ACCT_REUSE = 131072, IGNORE_UNSUPPORTED_FLAGS = 268435456, _, pub fn initFlags(o: struct { JOIN_DOMAIN: u1 = 0, ACCT_CREATE: u1 = 0, WIN9X_UPGRADE: u1 = 0, DOMAIN_JOIN_IF_JOINED: u1 = 0, JOIN_UNSECURE: u1 = 0, MACHINE_PWD_PASSED: u1 = 0, DEFER_SPN_SET: u1 = 0, JOIN_DC_ACCOUNT: u1 = 0, JOIN_WITH_NEW_NAME: u1 = 0, JOIN_READONLY: u1 = 0, AMBIGUOUS_DC: u1 = 0, NO_NETLOGON_CACHE: u1 = 0, DONT_CONTROL_SERVICES: u1 = 0, SET_MACHINE_NAME: u1 = 0, FORCE_SPN_SET: u1 = 0, NO_ACCT_REUSE: u1 = 0, IGNORE_UNSUPPORTED_FLAGS: u1 = 0, }) NET_JOIN_DOMAIN_JOIN_OPTIONS { return @intToEnum(NET_JOIN_DOMAIN_JOIN_OPTIONS, (if (o.JOIN_DOMAIN == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_DOMAIN) else 0) | (if (o.ACCT_CREATE == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.ACCT_CREATE) else 0) | (if (o.WIN9X_UPGRADE == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.WIN9X_UPGRADE) else 0) | (if (o.DOMAIN_JOIN_IF_JOINED == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.DOMAIN_JOIN_IF_JOINED) else 0) | (if (o.JOIN_UNSECURE == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_UNSECURE) else 0) | (if (o.MACHINE_PWD_PASSED == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.MACHINE_PWD_PASSED) else 0) | (if (o.DEFER_SPN_SET == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.DEFER_SPN_SET) else 0) | (if (o.JOIN_DC_ACCOUNT == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_DC_ACCOUNT) else 0) | (if (o.JOIN_WITH_NEW_NAME == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_WITH_NEW_NAME) else 0) | (if (o.JOIN_READONLY == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_READONLY) else 0) | (if (o.AMBIGUOUS_DC == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.AMBIGUOUS_DC) else 0) | (if (o.NO_NETLOGON_CACHE == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.NO_NETLOGON_CACHE) else 0) | (if (o.DONT_CONTROL_SERVICES == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.DONT_CONTROL_SERVICES) else 0) | (if (o.SET_MACHINE_NAME == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.SET_MACHINE_NAME) else 0) | (if (o.FORCE_SPN_SET == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.FORCE_SPN_SET) else 0) | (if (o.NO_ACCT_REUSE == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.NO_ACCT_REUSE) else 0) | (if (o.IGNORE_UNSUPPORTED_FLAGS == 1) @enumToInt(NET_JOIN_DOMAIN_JOIN_OPTIONS.IGNORE_UNSUPPORTED_FLAGS) else 0) ); } }; pub const NETSETUP_JOIN_DOMAIN = NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_DOMAIN; pub const NETSETUP_ACCT_CREATE = NET_JOIN_DOMAIN_JOIN_OPTIONS.ACCT_CREATE; pub const NETSETUP_WIN9X_UPGRADE = NET_JOIN_DOMAIN_JOIN_OPTIONS.WIN9X_UPGRADE; pub const NETSETUP_DOMAIN_JOIN_IF_JOINED = NET_JOIN_DOMAIN_JOIN_OPTIONS.DOMAIN_JOIN_IF_JOINED; pub const NETSETUP_JOIN_UNSECURE = NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_UNSECURE; pub const NETSETUP_MACHINE_PWD_PASSED = NET_JOIN_DOMAIN_JOIN_OPTIONS.MACHINE_PWD_PASSED; pub const NETSETUP_DEFER_SPN_SET = NET_JOIN_DOMAIN_JOIN_OPTIONS.DEFER_SPN_SET; pub const NETSETUP_JOIN_DC_ACCOUNT = NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_DC_ACCOUNT; pub const NETSETUP_JOIN_WITH_NEW_NAME = NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_WITH_NEW_NAME; pub const NETSETUP_JOIN_READONLY = NET_JOIN_DOMAIN_JOIN_OPTIONS.JOIN_READONLY; pub const NETSETUP_AMBIGUOUS_DC = NET_JOIN_DOMAIN_JOIN_OPTIONS.AMBIGUOUS_DC; pub const NETSETUP_NO_NETLOGON_CACHE = NET_JOIN_DOMAIN_JOIN_OPTIONS.NO_NETLOGON_CACHE; pub const NETSETUP_DONT_CONTROL_SERVICES = NET_JOIN_DOMAIN_JOIN_OPTIONS.DONT_CONTROL_SERVICES; pub const NETSETUP_SET_MACHINE_NAME = NET_JOIN_DOMAIN_JOIN_OPTIONS.SET_MACHINE_NAME; pub const NETSETUP_FORCE_SPN_SET = NET_JOIN_DOMAIN_JOIN_OPTIONS.FORCE_SPN_SET; pub const NETSETUP_NO_ACCT_REUSE = NET_JOIN_DOMAIN_JOIN_OPTIONS.NO_ACCT_REUSE; pub const NETSETUP_IGNORE_UNSUPPORTED_FLAGS = NET_JOIN_DOMAIN_JOIN_OPTIONS.IGNORE_UNSUPPORTED_FLAGS; pub const NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS = enum(i32) { REMOTE_ADMIN_PROTOCOL = 2, RPC = 4, SAM_PROTOCOL = 8, UNICODE = 16, LOCAL = 32, }; pub const SUPPORTS_REMOTE_ADMIN_PROTOCOL = NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS.REMOTE_ADMIN_PROTOCOL; pub const SUPPORTS_RPC = NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS.RPC; pub const SUPPORTS_SAM_PROTOCOL = NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS.SAM_PROTOCOL; pub const SUPPORTS_UNICODE = NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS.UNICODE; pub const SUPPORTS_LOCAL = NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS.LOCAL; pub const FORCE_LEVEL_FLAGS = enum(u32) { NOFORCE = 0, FORCE = 1, LOTS_OF_FORCE = 2, }; pub const USE_NOFORCE = FORCE_LEVEL_FLAGS.NOFORCE; pub const USE_FORCE = FORCE_LEVEL_FLAGS.FORCE; pub const USE_LOTS_OF_FORCE = FORCE_LEVEL_FLAGS.LOTS_OF_FORCE; pub const NET_SERVER_TYPE = enum(u32) { WORKSTATION = 1, SERVER = 2, SQLSERVER = 4, DOMAIN_CTRL = 8, DOMAIN_BAKCTRL = 16, TIME_SOURCE = 32, AFP = 64, NOVELL = 128, DOMAIN_MEMBER = 256, PRINTQ_SERVER = 512, DIALIN_SERVER = 1024, XENIX_SERVER = 2048, // SERVER_UNIX = 2048, this enum value conflicts with XENIX_SERVER NT = 4096, WFW = 8192, SERVER_MFPN = 16384, SERVER_NT = 32768, POTENTIAL_BROWSER = 65536, BACKUP_BROWSER = 131072, MASTER_BROWSER = 262144, DOMAIN_MASTER = 524288, SERVER_OSF = 1048576, SERVER_VMS = 2097152, WINDOWS = 4194304, DFS = 8388608, CLUSTER_NT = 16777216, TERMINALSERVER = 33554432, CLUSTER_VS_NT = 67108864, DCE = 268435456, ALTERNATE_XPORT = 536870912, LOCAL_LIST_ONLY = 1073741824, DOMAIN_ENUM = 2147483648, ALL = 4294967295, _, pub fn initFlags(o: struct { WORKSTATION: u1 = 0, SERVER: u1 = 0, SQLSERVER: u1 = 0, DOMAIN_CTRL: u1 = 0, DOMAIN_BAKCTRL: u1 = 0, TIME_SOURCE: u1 = 0, AFP: u1 = 0, NOVELL: u1 = 0, DOMAIN_MEMBER: u1 = 0, PRINTQ_SERVER: u1 = 0, DIALIN_SERVER: u1 = 0, XENIX_SERVER: u1 = 0, NT: u1 = 0, WFW: u1 = 0, SERVER_MFPN: u1 = 0, SERVER_NT: u1 = 0, POTENTIAL_BROWSER: u1 = 0, BACKUP_BROWSER: u1 = 0, MASTER_BROWSER: u1 = 0, DOMAIN_MASTER: u1 = 0, SERVER_OSF: u1 = 0, SERVER_VMS: u1 = 0, WINDOWS: u1 = 0, DFS: u1 = 0, CLUSTER_NT: u1 = 0, TERMINALSERVER: u1 = 0, CLUSTER_VS_NT: u1 = 0, DCE: u1 = 0, ALTERNATE_XPORT: u1 = 0, LOCAL_LIST_ONLY: u1 = 0, DOMAIN_ENUM: u1 = 0, ALL: u1 = 0, }) NET_SERVER_TYPE { return @intToEnum(NET_SERVER_TYPE, (if (o.WORKSTATION == 1) @enumToInt(NET_SERVER_TYPE.WORKSTATION) else 0) | (if (o.SERVER == 1) @enumToInt(NET_SERVER_TYPE.SERVER) else 0) | (if (o.SQLSERVER == 1) @enumToInt(NET_SERVER_TYPE.SQLSERVER) else 0) | (if (o.DOMAIN_CTRL == 1) @enumToInt(NET_SERVER_TYPE.DOMAIN_CTRL) else 0) | (if (o.DOMAIN_BAKCTRL == 1) @enumToInt(NET_SERVER_TYPE.DOMAIN_BAKCTRL) else 0) | (if (o.TIME_SOURCE == 1) @enumToInt(NET_SERVER_TYPE.TIME_SOURCE) else 0) | (if (o.AFP == 1) @enumToInt(NET_SERVER_TYPE.AFP) else 0) | (if (o.NOVELL == 1) @enumToInt(NET_SERVER_TYPE.NOVELL) else 0) | (if (o.DOMAIN_MEMBER == 1) @enumToInt(NET_SERVER_TYPE.DOMAIN_MEMBER) else 0) | (if (o.PRINTQ_SERVER == 1) @enumToInt(NET_SERVER_TYPE.PRINTQ_SERVER) else 0) | (if (o.DIALIN_SERVER == 1) @enumToInt(NET_SERVER_TYPE.DIALIN_SERVER) else 0) | (if (o.XENIX_SERVER == 1) @enumToInt(NET_SERVER_TYPE.XENIX_SERVER) else 0) | (if (o.NT == 1) @enumToInt(NET_SERVER_TYPE.NT) else 0) | (if (o.WFW == 1) @enumToInt(NET_SERVER_TYPE.WFW) else 0) | (if (o.SERVER_MFPN == 1) @enumToInt(NET_SERVER_TYPE.SERVER_MFPN) else 0) | (if (o.SERVER_NT == 1) @enumToInt(NET_SERVER_TYPE.SERVER_NT) else 0) | (if (o.POTENTIAL_BROWSER == 1) @enumToInt(NET_SERVER_TYPE.POTENTIAL_BROWSER) else 0) | (if (o.BACKUP_BROWSER == 1) @enumToInt(NET_SERVER_TYPE.BACKUP_BROWSER) else 0) | (if (o.MASTER_BROWSER == 1) @enumToInt(NET_SERVER_TYPE.MASTER_BROWSER) else 0) | (if (o.DOMAIN_MASTER == 1) @enumToInt(NET_SERVER_TYPE.DOMAIN_MASTER) else 0) | (if (o.SERVER_OSF == 1) @enumToInt(NET_SERVER_TYPE.SERVER_OSF) else 0) | (if (o.SERVER_VMS == 1) @enumToInt(NET_SERVER_TYPE.SERVER_VMS) else 0) | (if (o.WINDOWS == 1) @enumToInt(NET_SERVER_TYPE.WINDOWS) else 0) | (if (o.DFS == 1) @enumToInt(NET_SERVER_TYPE.DFS) else 0) | (if (o.CLUSTER_NT == 1) @enumToInt(NET_SERVER_TYPE.CLUSTER_NT) else 0) | (if (o.TERMINALSERVER == 1) @enumToInt(NET_SERVER_TYPE.TERMINALSERVER) else 0) | (if (o.CLUSTER_VS_NT == 1) @enumToInt(NET_SERVER_TYPE.CLUSTER_VS_NT) else 0) | (if (o.DCE == 1) @enumToInt(NET_SERVER_TYPE.DCE) else 0) | (if (o.ALTERNATE_XPORT == 1) @enumToInt(NET_SERVER_TYPE.ALTERNATE_XPORT) else 0) | (if (o.LOCAL_LIST_ONLY == 1) @enumToInt(NET_SERVER_TYPE.LOCAL_LIST_ONLY) else 0) | (if (o.DOMAIN_ENUM == 1) @enumToInt(NET_SERVER_TYPE.DOMAIN_ENUM) else 0) | (if (o.ALL == 1) @enumToInt(NET_SERVER_TYPE.ALL) else 0) ); } }; pub const SV_TYPE_WORKSTATION = NET_SERVER_TYPE.WORKSTATION; pub const SV_TYPE_SERVER = NET_SERVER_TYPE.SERVER; pub const SV_TYPE_SQLSERVER = NET_SERVER_TYPE.SQLSERVER; pub const SV_TYPE_DOMAIN_CTRL = NET_SERVER_TYPE.DOMAIN_CTRL; pub const SV_TYPE_DOMAIN_BAKCTRL = NET_SERVER_TYPE.DOMAIN_BAKCTRL; pub const SV_TYPE_TIME_SOURCE = NET_SERVER_TYPE.TIME_SOURCE; pub const SV_TYPE_AFP = NET_SERVER_TYPE.AFP; pub const SV_TYPE_NOVELL = NET_SERVER_TYPE.NOVELL; pub const SV_TYPE_DOMAIN_MEMBER = NET_SERVER_TYPE.DOMAIN_MEMBER; pub const SV_TYPE_PRINTQ_SERVER = NET_SERVER_TYPE.PRINTQ_SERVER; pub const SV_TYPE_DIALIN_SERVER = NET_SERVER_TYPE.DIALIN_SERVER; pub const SV_TYPE_XENIX_SERVER = NET_SERVER_TYPE.XENIX_SERVER; pub const SV_TYPE_SERVER_UNIX = NET_SERVER_TYPE.XENIX_SERVER; pub const SV_TYPE_NT = NET_SERVER_TYPE.NT; pub const SV_TYPE_WFW = NET_SERVER_TYPE.WFW; pub const SV_TYPE_SERVER_MFPN = NET_SERVER_TYPE.SERVER_MFPN; pub const SV_TYPE_SERVER_NT = NET_SERVER_TYPE.SERVER_NT; pub const SV_TYPE_POTENTIAL_BROWSER = NET_SERVER_TYPE.POTENTIAL_BROWSER; pub const SV_TYPE_BACKUP_BROWSER = NET_SERVER_TYPE.BACKUP_BROWSER; pub const SV_TYPE_MASTER_BROWSER = NET_SERVER_TYPE.MASTER_BROWSER; pub const SV_TYPE_DOMAIN_MASTER = NET_SERVER_TYPE.DOMAIN_MASTER; pub const SV_TYPE_SERVER_OSF = NET_SERVER_TYPE.SERVER_OSF; pub const SV_TYPE_SERVER_VMS = NET_SERVER_TYPE.SERVER_VMS; pub const SV_TYPE_WINDOWS = NET_SERVER_TYPE.WINDOWS; pub const SV_TYPE_DFS = NET_SERVER_TYPE.DFS; pub const SV_TYPE_CLUSTER_NT = NET_SERVER_TYPE.CLUSTER_NT; pub const SV_TYPE_TERMINALSERVER = NET_SERVER_TYPE.TERMINALSERVER; pub const SV_TYPE_CLUSTER_VS_NT = NET_SERVER_TYPE.CLUSTER_VS_NT; pub const SV_TYPE_DCE = NET_SERVER_TYPE.DCE; pub const SV_TYPE_ALTERNATE_XPORT = NET_SERVER_TYPE.ALTERNATE_XPORT; pub const SV_TYPE_LOCAL_LIST_ONLY = NET_SERVER_TYPE.LOCAL_LIST_ONLY; pub const SV_TYPE_DOMAIN_ENUM = NET_SERVER_TYPE.DOMAIN_ENUM; pub const SV_TYPE_ALL = NET_SERVER_TYPE.ALL; pub const NET_USER_ENUM_FILTER_FLAGS = enum(u32) { TEMP_DUPLICATE_ACCOUNT = 1, NORMAL_ACCOUNT = 2, INTERDOMAIN_TRUST_ACCOUNT = 8, WORKSTATION_TRUST_ACCOUNT = 16, SERVER_TRUST_ACCOUNT = 32, _, pub fn initFlags(o: struct { TEMP_DUPLICATE_ACCOUNT: u1 = 0, NORMAL_ACCOUNT: u1 = 0, INTERDOMAIN_TRUST_ACCOUNT: u1 = 0, WORKSTATION_TRUST_ACCOUNT: u1 = 0, SERVER_TRUST_ACCOUNT: u1 = 0, }) NET_USER_ENUM_FILTER_FLAGS { return @intToEnum(NET_USER_ENUM_FILTER_FLAGS, (if (o.TEMP_DUPLICATE_ACCOUNT == 1) @enumToInt(NET_USER_ENUM_FILTER_FLAGS.TEMP_DUPLICATE_ACCOUNT) else 0) | (if (o.NORMAL_ACCOUNT == 1) @enumToInt(NET_USER_ENUM_FILTER_FLAGS.NORMAL_ACCOUNT) else 0) | (if (o.INTERDOMAIN_TRUST_ACCOUNT == 1) @enumToInt(NET_USER_ENUM_FILTER_FLAGS.INTERDOMAIN_TRUST_ACCOUNT) else 0) | (if (o.WORKSTATION_TRUST_ACCOUNT == 1) @enumToInt(NET_USER_ENUM_FILTER_FLAGS.WORKSTATION_TRUST_ACCOUNT) else 0) | (if (o.SERVER_TRUST_ACCOUNT == 1) @enumToInt(NET_USER_ENUM_FILTER_FLAGS.SERVER_TRUST_ACCOUNT) else 0) ); } }; pub const FILTER_TEMP_DUPLICATE_ACCOUNT = NET_USER_ENUM_FILTER_FLAGS.TEMP_DUPLICATE_ACCOUNT; pub const FILTER_NORMAL_ACCOUNT = NET_USER_ENUM_FILTER_FLAGS.NORMAL_ACCOUNT; pub const FILTER_INTERDOMAIN_TRUST_ACCOUNT = NET_USER_ENUM_FILTER_FLAGS.INTERDOMAIN_TRUST_ACCOUNT; pub const FILTER_WORKSTATION_TRUST_ACCOUNT = NET_USER_ENUM_FILTER_FLAGS.WORKSTATION_TRUST_ACCOUNT; pub const FILTER_SERVER_TRUST_ACCOUNT = NET_USER_ENUM_FILTER_FLAGS.SERVER_TRUST_ACCOUNT; pub const NETSETUP_PROVISION = enum(u32) { DOWNLEVEL_PRIV_SUPPORT = 1, REUSE_ACCOUNT = 2, USE_DEFAULT_PASSWORD = 4, SKIP_ACCOUNT_SEARCH = 8, ROOT_CA_CERTS = 16, _, pub fn initFlags(o: struct { DOWNLEVEL_PRIV_SUPPORT: u1 = 0, REUSE_ACCOUNT: u1 = 0, USE_DEFAULT_PASSWORD: u1 = 0, SKIP_ACCOUNT_SEARCH: u1 = 0, ROOT_CA_CERTS: u1 = 0, }) NETSETUP_PROVISION { return @intToEnum(NETSETUP_PROVISION, (if (o.DOWNLEVEL_PRIV_SUPPORT == 1) @enumToInt(NETSETUP_PROVISION.DOWNLEVEL_PRIV_SUPPORT) else 0) | (if (o.REUSE_ACCOUNT == 1) @enumToInt(NETSETUP_PROVISION.REUSE_ACCOUNT) else 0) | (if (o.USE_DEFAULT_PASSWORD == 1) @enumToInt(NETSETUP_PROVISION.USE_DEFAULT_PASSWORD) else 0) | (if (o.SKIP_ACCOUNT_SEARCH == 1) @enumToInt(NETSETUP_PROVISION.SKIP_ACCOUNT_SEARCH) else 0) | (if (o.ROOT_CA_CERTS == 1) @enumToInt(NETSETUP_PROVISION.ROOT_CA_CERTS) else 0) ); } }; pub const NETSETUP_PROVISION_DOWNLEVEL_PRIV_SUPPORT = NETSETUP_PROVISION.DOWNLEVEL_PRIV_SUPPORT; pub const NETSETUP_PROVISION_REUSE_ACCOUNT = NETSETUP_PROVISION.REUSE_ACCOUNT; pub const NETSETUP_PROVISION_USE_DEFAULT_PASSWORD = NETSETUP_PROVISION.USE_DEFAULT_PASSWORD; pub const NETSETUP_PROVISION_SKIP_ACCOUNT_SEARCH = NETSETUP_PROVISION.SKIP_ACCOUNT_SEARCH; pub const NETSETUP_PROVISION_ROOT_CA_CERTS = NETSETUP_PROVISION.ROOT_CA_CERTS; pub const USER_ACCOUNT_FLAGS = enum(u32) { SCRIPT = 1, ACCOUNTDISABLE = 2, HOMEDIR_REQUIRED = 8, PASSWD_NOTREQD = 32, PASSWD_CANT_CHANGE = 64, LOCKOUT = 16, DONT_EXPIRE_PASSWD = <PASSWORD>, ENCRYPTED_TEXT_PASSWORD_ALLOWED = 128, NOT_DELEGATED = 1048576, SMARTCARD_REQUIRED = 262144, USE_DES_KEY_ONLY = 2097152, DONT_REQUIRE_PREAUTH = 4194304, TRUSTED_FOR_DELEGATION = 524288, PASSWORD_EXPIRED = <PASSWORD>, TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION = 16777216, _, pub fn initFlags(o: struct { SCRIPT: u1 = 0, ACCOUNTDISABLE: u1 = 0, HOMEDIR_REQUIRED: u1 = 0, PASSWD_NOTREQD: u1 = 0, PASSWD_CANT_CHANGE: u1 = 0, LOCKOUT: u1 = 0, DONT_EXPIRE_PASSWD: u1 = 0, ENCRYPTED_TEXT_PASSWORD_ALLOWED: u1 = 0, NOT_DELEGATED: u1 = 0, SMARTCARD_REQUIRED: u1 = 0, USE_DES_KEY_ONLY: u1 = 0, DONT_REQUIRE_PREAUTH: u1 = 0, TRUSTED_FOR_DELEGATION: u1 = 0, PASSWORD_EXPIRED: u1 = 0, TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION: u1 = 0, }) USER_ACCOUNT_FLAGS { return @intToEnum(USER_ACCOUNT_FLAGS, (if (o.SCRIPT == 1) @enumToInt(USER_ACCOUNT_FLAGS.SCRIPT) else 0) | (if (o.ACCOUNTDISABLE == 1) @enumToInt(USER_ACCOUNT_FLAGS.ACCOUNTDISABLE) else 0) | (if (o.HOMEDIR_REQUIRED == 1) @enumToInt(USER_ACCOUNT_FLAGS.HOMEDIR_REQUIRED) else 0) | (if (o.PASSWD_NOTREQD == 1) @enumToInt(USER_ACCOUNT_FLAGS.PASSWD_NOTREQD) else 0) | (if (o.PASSWD_CANT_CHANGE == 1) @enumToInt(USER_ACCOUNT_FLAGS.PASSWD_CANT_CHANGE) else 0) | (if (o.LOCKOUT == 1) @enumToInt(USER_ACCOUNT_FLAGS.LOCKOUT) else 0) | (if (o.DONT_EXPIRE_PASSWD == 1) @enumToInt(USER_ACCOUNT_FLAGS.DONT_EXPIRE_PASSWD) else 0) | (if (o.ENCRYPTED_TEXT_PASSWORD_ALLOWED == 1) @enumToInt(USER_ACCOUNT_FLAGS.ENCRYPTED_TEXT_PASSWORD_ALLOWED) else 0) | (if (o.NOT_DELEGATED == 1) @enumToInt(USER_ACCOUNT_FLAGS.NOT_DELEGATED) else 0) | (if (o.SMARTCARD_REQUIRED == 1) @enumToInt(USER_ACCOUNT_FLAGS.SMARTCARD_REQUIRED) else 0) | (if (o.USE_DES_KEY_ONLY == 1) @enumToInt(USER_ACCOUNT_FLAGS.USE_DES_KEY_ONLY) else 0) | (if (o.DONT_REQUIRE_PREAUTH == 1) @enumToInt(USER_ACCOUNT_FLAGS.DONT_REQUIRE_PREAUTH) else 0) | (if (o.TRUSTED_FOR_DELEGATION == 1) @enumToInt(USER_ACCOUNT_FLAGS.TRUSTED_FOR_DELEGATION) else 0) | (if (o.PASSWORD_EXPIRED == 1) @enumToInt(USER_ACCOUNT_FLAGS.PASSWORD_EXPIRED) else 0) | (if (o.TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION == 1) @enumToInt(USER_ACCOUNT_FLAGS.TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION) else 0) ); } }; pub const UF_SCRIPT = USER_ACCOUNT_FLAGS.SCRIPT; pub const UF_ACCOUNTDISABLE = USER_ACCOUNT_FLAGS.ACCOUNTDISABLE; pub const UF_HOMEDIR_REQUIRED = USER_ACCOUNT_FLAGS.HOMEDIR_REQUIRED; pub const UF_PASSWD_NOTREQD = USER_ACCOUNT_FLAGS.PASSWD_NOTREQD; pub const UF_PASSWD_CANT_CHANGE = USER_ACCOUNT_FLAGS.PASSWD_CANT_CHANGE; pub const UF_LOCKOUT = USER_ACCOUNT_FLAGS.LOCKOUT; pub const UF_DONT_EXPIRE_PASSWD = USER_ACCOUNT_FLAGS.DONT_EXPIRE_PASSWD; pub const UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = USER_ACCOUNT_FLAGS.ENCRYPTED_TEXT_PASSWORD_ALLOWED; pub const UF_NOT_DELEGATED = USER_ACCOUNT_FLAGS.NOT_DELEGATED; pub const UF_SMARTCARD_REQUIRED = USER_ACCOUNT_FLAGS.SMARTCARD_REQUIRED; pub const UF_USE_DES_KEY_ONLY = USER_ACCOUNT_FLAGS.USE_DES_KEY_ONLY; pub const UF_DONT_REQUIRE_PREAUTH = USER_ACCOUNT_FLAGS.DONT_REQUIRE_PREAUTH; pub const UF_TRUSTED_FOR_DELEGATION = USER_ACCOUNT_FLAGS.TRUSTED_FOR_DELEGATION; pub const UF_PASSWORD_EXPIRED = USER_ACCOUNT_FLAGS.PASSWORD_EXPIRED; pub const UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION = USER_ACCOUNT_FLAGS.TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION; pub const AF_OP = enum(u32) { PRINT = 1, COMM = 2, SERVER = 4, ACCOUNTS = 8, _, pub fn initFlags(o: struct { PRINT: u1 = 0, COMM: u1 = 0, SERVER: u1 = 0, ACCOUNTS: u1 = 0, }) AF_OP { return @intToEnum(AF_OP, (if (o.PRINT == 1) @enumToInt(AF_OP.PRINT) else 0) | (if (o.COMM == 1) @enumToInt(AF_OP.COMM) else 0) | (if (o.SERVER == 1) @enumToInt(AF_OP.SERVER) else 0) | (if (o.ACCOUNTS == 1) @enumToInt(AF_OP.ACCOUNTS) else 0) ); } }; pub const AF_OP_PRINT = AF_OP.PRINT; pub const AF_OP_COMM = AF_OP.COMM; pub const AF_OP_SERVER = AF_OP.SERVER; pub const AF_OP_ACCOUNTS = AF_OP.ACCOUNTS; pub const SERVER_INFO_SECURITY = enum(u32) { SHARESECURITY = 0, USERSECURITY = 1, }; pub const SV_SHARESECURITY = SERVER_INFO_SECURITY.SHARESECURITY; pub const SV_USERSECURITY = SERVER_INFO_SECURITY.USERSECURITY; pub const USER_PRIV = enum(u32) { GUEST = 0, USER = 1, ADMIN = 2, }; pub const USER_PRIV_GUEST = USER_PRIV.GUEST; pub const USER_PRIV_USER = USER_PRIV.USER; pub const USER_PRIV_ADMIN = USER_PRIV.ADMIN; pub const USE_INFO_ASG_TYPE = enum(u32) { WILDCARD = 4294967295, DISKDEV = 0, SPOOLDEV = 1, IPC = 3, }; pub const USE_WILDCARD = USE_INFO_ASG_TYPE.WILDCARD; pub const USE_DISKDEV = USE_INFO_ASG_TYPE.DISKDEV; pub const USE_SPOOLDEV = USE_INFO_ASG_TYPE.SPOOLDEV; pub const USE_IPC = USE_INFO_ASG_TYPE.IPC; pub const SERVER_INFO_HIDDEN = enum(u32) { VISIBLE = 0, HIDDEN = 1, }; pub const SV_VISIBLE = SERVER_INFO_HIDDEN.VISIBLE; pub const SV_HIDDEN = SERVER_INFO_HIDDEN.HIDDEN; pub const USER_MODALS_ROLES = enum(u32) { STANDALONE = 0, MEMBER = 1, BACKUP = 2, PRIMARY = 3, }; pub const UAS_ROLE_STANDALONE = USER_MODALS_ROLES.STANDALONE; pub const UAS_ROLE_MEMBER = USER_MODALS_ROLES.MEMBER; pub const UAS_ROLE_BACKUP = USER_MODALS_ROLES.BACKUP; pub const UAS_ROLE_PRIMARY = USER_MODALS_ROLES.PRIMARY; pub const USER_INFO_0 = extern struct { usri0_name: ?PWSTR, }; pub const USER_INFO_1 = extern struct { usri1_name: ?PWSTR, usri1_password: ?<PASSWORD>, usri1_password_age: u32, usri1_priv: USER_PRIV, usri1_home_dir: ?PWSTR, usri1_comment: ?PWSTR, usri1_flags: USER_ACCOUNT_FLAGS, usri1_script_path: ?PWSTR, }; pub const USER_INFO_2 = extern struct { usri2_name: ?PWSTR, usri2_password: ?<PASSWORD>, usri2_password_age: u32, usri2_priv: USER_PRIV, usri2_home_dir: ?PWSTR, usri2_comment: ?PWSTR, usri2_flags: USER_ACCOUNT_FLAGS, usri2_script_path: ?PWSTR, usri2_auth_flags: AF_OP, usri2_full_name: ?PWSTR, usri2_usr_comment: ?PWSTR, usri2_parms: ?PWSTR, usri2_workstations: ?PWSTR, usri2_last_logon: u32, usri2_last_logoff: u32, usri2_acct_expires: u32, usri2_max_storage: u32, usri2_units_per_week: u32, usri2_logon_hours: ?*u8, usri2_bad_pw_count: u32, usri2_num_logons: u32, usri2_logon_server: ?PWSTR, usri2_country_code: u32, usri2_code_page: u32, }; pub const USER_INFO_3 = extern struct { usri3_name: ?PWSTR, usri3_password: <PASSWORD>, usri3_password_age: u32, usri3_priv: USER_PRIV, usri3_home_dir: ?PWSTR, usri3_comment: ?PWSTR, usri3_flags: USER_ACCOUNT_FLAGS, usri3_script_path: ?PWSTR, usri3_auth_flags: AF_OP, usri3_full_name: ?PWSTR, usri3_usr_comment: ?PWSTR, usri3_parms: ?PWSTR, usri3_workstations: ?PWSTR, usri3_last_logon: u32, usri3_last_logoff: u32, usri3_acct_expires: u32, usri3_max_storage: u32, usri3_units_per_week: u32, usri3_logon_hours: ?*u8, usri3_bad_pw_count: u32, usri3_num_logons: u32, usri3_logon_server: ?PWSTR, usri3_country_code: u32, usri3_code_page: u32, usri3_user_id: u32, usri3_primary_group_id: u32, usri3_profile: ?PWSTR, usri3_home_dir_drive: ?PWSTR, usri3_password_expired: u32, }; pub const USER_INFO_4 = extern struct { usri4_name: ?PWSTR, usri4_password: ?<PASSWORD>, usri4_password_age: u32, usri4_priv: USER_PRIV, usri4_home_dir: ?PWSTR, usri4_comment: ?PWSTR, usri4_flags: USER_ACCOUNT_FLAGS, usri4_script_path: ?PWSTR, usri4_auth_flags: AF_OP, usri4_full_name: ?PWSTR, usri4_usr_comment: ?PWSTR, usri4_parms: ?PWSTR, usri4_workstations: ?PWSTR, usri4_last_logon: u32, usri4_last_logoff: u32, usri4_acct_expires: u32, usri4_max_storage: u32, usri4_units_per_week: u32, usri4_logon_hours: ?*u8, usri4_bad_pw_count: u32, usri4_num_logons: u32, usri4_logon_server: ?PWSTR, usri4_country_code: u32, usri4_code_page: u32, usri4_user_sid: ?PSID, usri4_primary_group_id: u32, usri4_profile: ?PWSTR, usri4_home_dir_drive: ?PWSTR, usri4_password_expired: u32, }; pub const USER_INFO_10 = extern struct { usri10_name: ?PWSTR, usri10_comment: ?PWSTR, usri10_usr_comment: ?PWSTR, usri10_full_name: ?PWSTR, }; pub const USER_INFO_11 = extern struct { usri11_name: ?PWSTR, usri11_comment: ?PWSTR, usri11_usr_comment: ?PWSTR, usri11_full_name: ?PWSTR, usri11_priv: USER_PRIV, usri11_auth_flags: AF_OP, usri11_password_age: u32, usri11_home_dir: ?PWSTR, usri11_parms: ?PWSTR, usri11_last_logon: u32, usri11_last_logoff: u32, usri11_bad_pw_count: u32, usri11_num_logons: u32, usri11_logon_server: ?PWSTR, usri11_country_code: u32, usri11_workstations: ?PWSTR, usri11_max_storage: u32, usri11_units_per_week: u32, usri11_logon_hours: ?*u8, usri11_code_page: u32, }; pub const USER_INFO_20 = extern struct { usri20_name: ?PWSTR, usri20_full_name: ?PWSTR, usri20_comment: ?PWSTR, usri20_flags: USER_ACCOUNT_FLAGS, usri20_user_id: u32, }; pub const USER_INFO_21 = extern struct { usri21_password: [16]u8, }; pub const USER_INFO_22 = extern struct { usri22_name: ?PWSTR, usri22_password: [<PASSWORD>, usri22_password_age: u32, usri22_priv: USER_PRIV, usri22_home_dir: ?PWSTR, usri22_comment: ?PWSTR, usri22_flags: USER_ACCOUNT_FLAGS, usri22_script_path: ?PWSTR, usri22_auth_flags: AF_OP, usri22_full_name: ?PWSTR, usri22_usr_comment: ?PWSTR, usri22_parms: ?PWSTR, usri22_workstations: ?PWSTR, usri22_last_logon: u32, usri22_last_logoff: u32, usri22_acct_expires: u32, usri22_max_storage: u32, usri22_units_per_week: u32, usri22_logon_hours: ?*u8, usri22_bad_pw_count: u32, usri22_num_logons: u32, usri22_logon_server: ?PWSTR, usri22_country_code: u32, usri22_code_page: u32, }; pub const USER_INFO_23 = extern struct { usri23_name: ?PWSTR, usri23_full_name: ?PWSTR, usri23_comment: ?PWSTR, usri23_flags: USER_ACCOUNT_FLAGS, usri23_user_sid: ?PSID, }; pub const USER_INFO_24 = extern struct { usri24_internet_identity: BOOL, usri24_flags: u32, usri24_internet_provider_name: ?PWSTR, usri24_internet_principal_name: ?PWSTR, usri24_user_sid: ?PSID, }; pub const USER_INFO_1003 = extern struct { usri1003_password: ?PWSTR, }; pub const USER_INFO_1005 = extern struct { usri1005_priv: USER_PRIV, }; pub const USER_INFO_1006 = extern struct { usri1006_home_dir: ?PWSTR, }; pub const USER_INFO_1007 = extern struct { usri1007_comment: ?PWSTR, }; pub const USER_INFO_1008 = extern struct { usri1008_flags: USER_ACCOUNT_FLAGS, }; pub const USER_INFO_1009 = extern struct { usri1009_script_path: ?PWSTR, }; pub const USER_INFO_1010 = extern struct { usri1010_auth_flags: AF_OP, }; pub const USER_INFO_1011 = extern struct { usri1011_full_name: ?PWSTR, }; pub const USER_INFO_1012 = extern struct { usri1012_usr_comment: ?PWSTR, }; pub const USER_INFO_1013 = extern struct { usri1013_parms: ?PWSTR, }; pub const USER_INFO_1014 = extern struct { usri1014_workstations: ?PWSTR, }; pub const USER_INFO_1017 = extern struct { usri1017_acct_expires: u32, }; pub const USER_INFO_1018 = extern struct { usri1018_max_storage: u32, }; pub const USER_INFO_1020 = extern struct { usri1020_units_per_week: u32, usri1020_logon_hours: ?*u8, }; pub const USER_INFO_1023 = extern struct { usri1023_logon_server: ?PWSTR, }; pub const USER_INFO_1024 = extern struct { usri1024_country_code: u32, }; pub const USER_INFO_1025 = extern struct { usri1025_code_page: u32, }; pub const USER_INFO_1051 = extern struct { usri1051_primary_group_id: u32, }; pub const USER_INFO_1052 = extern struct { usri1052_profile: ?PWSTR, }; pub const USER_INFO_1053 = extern struct { usri1053_home_dir_drive: ?PWSTR, }; pub const USER_MODALS_INFO_0 = extern struct { usrmod0_min_passwd_len: u32, usrmod0_max_passwd_age: u32, usrmod0_min_passwd_age: u32, usrmod0_force_logoff: u32, usrmod0_password_hist_len: u32, }; pub const USER_MODALS_INFO_1 = extern struct { usrmod1_role: u32, usrmod1_primary: ?PWSTR, }; pub const USER_MODALS_INFO_2 = extern struct { usrmod2_domain_name: ?PWSTR, usrmod2_domain_id: ?PSID, }; pub const USER_MODALS_INFO_3 = extern struct { usrmod3_lockout_duration: u32, usrmod3_lockout_observation_window: u32, usrmod3_lockout_threshold: u32, }; pub const USER_MODALS_INFO_1001 = extern struct { usrmod1001_min_passwd_len: u32, }; pub const USER_MODALS_INFO_1002 = extern struct { usrmod1002_max_passwd_age: u32, }; pub const USER_MODALS_INFO_1003 = extern struct { usrmod1003_min_passwd_age: u32, }; pub const USER_MODALS_INFO_1004 = extern struct { usrmod1004_force_logoff: u32, }; pub const USER_MODALS_INFO_1005 = extern struct { usrmod1005_password_hist_len: u32, }; pub const USER_MODALS_INFO_1006 = extern struct { usrmod1006_role: USER_MODALS_ROLES, }; pub const USER_MODALS_INFO_1007 = extern struct { usrmod1007_primary: ?PWSTR, }; pub const GROUP_INFO_0 = extern struct { grpi0_name: ?PWSTR, }; pub const GROUP_INFO_1 = extern struct { grpi1_name: ?PWSTR, grpi1_comment: ?PWSTR, }; pub const GROUP_INFO_2 = extern struct { grpi2_name: ?PWSTR, grpi2_comment: ?PWSTR, grpi2_group_id: u32, grpi2_attributes: u32, }; pub const GROUP_INFO_3 = extern struct { grpi3_name: ?PWSTR, grpi3_comment: ?PWSTR, grpi3_group_sid: ?PSID, grpi3_attributes: u32, }; pub const GROUP_INFO_1002 = extern struct { grpi1002_comment: ?PWSTR, }; pub const GROUP_INFO_1005 = extern struct { grpi1005_attributes: u32, }; pub const GROUP_USERS_INFO_0 = extern struct { grui0_name: ?PWSTR, }; pub const GROUP_USERS_INFO_1 = extern struct { grui1_name: ?PWSTR, grui1_attributes: u32, }; pub const LOCALGROUP_INFO_0 = extern struct { lgrpi0_name: ?PWSTR, }; pub const LOCALGROUP_INFO_1 = extern struct { lgrpi1_name: ?PWSTR, lgrpi1_comment: ?PWSTR, }; pub const LOCALGROUP_INFO_1002 = extern struct { lgrpi1002_comment: ?PWSTR, }; pub const LOCALGROUP_MEMBERS_INFO_0 = extern struct { lgrmi0_sid: ?PSID, }; pub const LOCALGROUP_MEMBERS_INFO_1 = extern struct { lgrmi1_sid: ?PSID, lgrmi1_sidusage: SID_NAME_USE, lgrmi1_name: ?PWSTR, }; pub const LOCALGROUP_MEMBERS_INFO_2 = extern struct { lgrmi2_sid: ?PSID, lgrmi2_sidusage: SID_NAME_USE, lgrmi2_domainandname: ?PWSTR, }; pub const LOCALGROUP_MEMBERS_INFO_3 = extern struct { lgrmi3_domainandname: ?PWSTR, }; pub const LOCALGROUP_USERS_INFO_0 = extern struct { lgrui0_name: ?PWSTR, }; pub const NET_DISPLAY_USER = extern struct { usri1_name: ?PWSTR, usri1_comment: ?PWSTR, usri1_flags: USER_ACCOUNT_FLAGS, usri1_full_name: ?PWSTR, usri1_user_id: u32, usri1_next_index: u32, }; pub const NET_DISPLAY_MACHINE = extern struct { usri2_name: ?PWSTR, usri2_comment: ?PWSTR, usri2_flags: USER_ACCOUNT_FLAGS, usri2_user_id: u32, usri2_next_index: u32, }; pub const NET_DISPLAY_GROUP = extern struct { grpi3_name: ?PWSTR, grpi3_comment: ?PWSTR, grpi3_group_id: u32, grpi3_attributes: u32, grpi3_next_index: u32, }; pub const ACCESS_INFO_0 = extern struct { acc0_resource_name: ?PWSTR, }; pub const ACCESS_INFO_1 = extern struct { acc1_resource_name: ?PWSTR, acc1_attr: u32, acc1_count: u32, }; pub const ACCESS_INFO_1002 = extern struct { acc1002_attr: u32, }; pub const ACCESS_LIST = extern struct { acl_ugname: ?PWSTR, acl_access: u32, }; pub const NET_VALIDATE_PASSWORD_TYPE = enum(i32) { Authentication = 1, PasswordChange = 2, PasswordReset = 3, }; pub const NetValidateAuthentication = NET_VALIDATE_PASSWORD_TYPE.Authentication; pub const NetValidatePasswordChange = NET_VALIDATE_PASSWORD_TYPE.PasswordChange; pub const NetValidatePasswordReset = NET_VALIDATE_PASSWORD_TYPE.PasswordReset; pub const NET_VALIDATE_PASSWORD_HASH = extern struct { Length: u32, Hash: ?*u8, }; pub const NET_VALIDATE_PERSISTED_FIELDS = extern struct { PresentFields: u32, PasswordLastSet: FILETIME, BadPasswordTime: FILETIME, LockoutTime: FILETIME, BadPasswordCount: u32, PasswordHistoryLength: u32, PasswordHistory: ?*NET_VALIDATE_PASSWORD_HASH, }; pub const NET_VALIDATE_OUTPUT_ARG = extern struct { ChangedPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, ValidationStatus: u32, }; pub const NET_VALIDATE_AUTHENTICATION_INPUT_ARG = extern struct { InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, PasswordMatched: BOOLEAN, }; pub const NET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG = extern struct { InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, ClearPassword: ?PWSTR, UserAccountName: ?PWSTR, HashedPassword: NET_VALIDATE_PASSWORD_HASH, PasswordMatch: BOOLEAN, }; pub const NET_VALIDATE_PASSWORD_RESET_INPUT_ARG = extern struct { InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, ClearPassword: ?PWSTR, UserAccountName: ?PWSTR, HashedPassword: NET_VALIDATE_PASSWORD_HASH, PasswordMustChangeAtNextLogon: BOOLEAN, ClearLockout: BOOLEAN, }; pub const NETLOGON_INFO_1 = extern struct { netlog1_flags: u32, netlog1_pdc_connection_status: u32, }; pub const NETLOGON_INFO_2 = extern struct { netlog2_flags: u32, netlog2_pdc_connection_status: u32, netlog2_trusted_dc_name: ?PWSTR, netlog2_tc_connection_status: u32, }; pub const NETLOGON_INFO_3 = extern struct { netlog3_flags: u32, netlog3_logon_attempts: u32, netlog3_reserved1: u32, netlog3_reserved2: u32, netlog3_reserved3: u32, netlog3_reserved4: u32, netlog3_reserved5: u32, }; pub const NETLOGON_INFO_4 = extern struct { netlog4_trusted_dc_name: ?PWSTR, netlog4_trusted_domain_name: ?PWSTR, }; pub const MSA_INFO_LEVEL = enum(i32) { @"0" = 0, Max = 1, }; pub const MsaInfoLevel0 = MSA_INFO_LEVEL.@"0"; pub const MsaInfoLevelMax = MSA_INFO_LEVEL.Max; pub const MSA_INFO_STATE = enum(i32) { NotExist = 1, NotService = 2, CannotInstall = 3, CanInstall = 4, Installed = 5, }; pub const MsaInfoNotExist = MSA_INFO_STATE.NotExist; pub const MsaInfoNotService = MSA_INFO_STATE.NotService; pub const MsaInfoCannotInstall = MSA_INFO_STATE.CannotInstall; pub const MsaInfoCanInstall = MSA_INFO_STATE.CanInstall; pub const MsaInfoInstalled = MSA_INFO_STATE.Installed; pub const MSA_INFO_0 = extern struct { State: MSA_INFO_STATE, }; pub const NETSETUP_NAME_TYPE = enum(i32) { Unknown = 0, Machine = 1, Workgroup = 2, Domain = 3, NonExistentDomain = 4, DnsMachine = 5, }; pub const NetSetupUnknown = NETSETUP_NAME_TYPE.Unknown; pub const NetSetupMachine = NETSETUP_NAME_TYPE.Machine; pub const NetSetupWorkgroup = NETSETUP_NAME_TYPE.Workgroup; pub const NetSetupDomain = NETSETUP_NAME_TYPE.Domain; pub const NetSetupNonExistentDomain = NETSETUP_NAME_TYPE.NonExistentDomain; pub const NetSetupDnsMachine = NETSETUP_NAME_TYPE.DnsMachine; pub const DSREG_JOIN_TYPE = enum(i32) { UNKNOWN_JOIN = 0, DEVICE_JOIN = 1, WORKPLACE_JOIN = 2, }; pub const DSREG_UNKNOWN_JOIN = DSREG_JOIN_TYPE.UNKNOWN_JOIN; pub const DSREG_DEVICE_JOIN = DSREG_JOIN_TYPE.DEVICE_JOIN; pub const DSREG_WORKPLACE_JOIN = DSREG_JOIN_TYPE.WORKPLACE_JOIN; pub const DSREG_USER_INFO = extern struct { pszUserEmail: ?PWSTR, pszUserKeyId: ?PWSTR, pszUserKeyName: ?PWSTR, }; pub const DSREG_JOIN_INFO = extern struct { joinType: DSREG_JOIN_TYPE, pJoinCertificate: ?*const CERT_CONTEXT, pszDeviceId: ?PWSTR, pszIdpDomain: ?PWSTR, pszTenantId: ?PWSTR, pszJoinUserEmail: ?PWSTR, pszTenantDisplayName: ?PWSTR, pszMdmEnrollmentUrl: ?PWSTR, pszMdmTermsOfUseUrl: ?PWSTR, pszMdmComplianceUrl: ?PWSTR, pszUserSettingSyncUrl: ?PWSTR, pUserInfo: ?*DSREG_USER_INFO, }; pub const NET_COMPUTER_NAME_TYPE = enum(i32) { PrimaryComputerName = 0, AlternateComputerNames = 1, AllComputerNames = 2, ComputerNameTypeMax = 3, }; pub const NetPrimaryComputerName = NET_COMPUTER_NAME_TYPE.PrimaryComputerName; pub const NetAlternateComputerNames = NET_COMPUTER_NAME_TYPE.AlternateComputerNames; pub const NetAllComputerNames = NET_COMPUTER_NAME_TYPE.AllComputerNames; pub const NetComputerNameTypeMax = NET_COMPUTER_NAME_TYPE.ComputerNameTypeMax; pub const NETSETUP_PROVISIONING_PARAMS = extern struct { dwVersion: u32, lpDomain: ?[*:0]const u16, lpHostName: ?[*:0]const u16, lpMachineAccountOU: ?[*:0]const u16, lpDcName: ?[*:0]const u16, dwProvisionOptions: NETSETUP_PROVISION, aCertTemplateNames: ?*?PWSTR, cCertTemplateNames: u32, aMachinePolicyNames: ?*?PWSTR, cMachinePolicyNames: u32, aMachinePolicyPaths: ?*?PWSTR, cMachinePolicyPaths: u32, lpNetbiosName: ?PWSTR, lpSiteName: ?PWSTR, lpPrimaryDNSDomain: ?PWSTR, }; pub const NETSETUP_JOIN_STATUS = enum(i32) { UnknownStatus = 0, Unjoined = 1, WorkgroupName = 2, DomainName = 3, }; pub const NetSetupUnknownStatus = NETSETUP_JOIN_STATUS.UnknownStatus; pub const NetSetupUnjoined = NETSETUP_JOIN_STATUS.Unjoined; pub const NetSetupWorkgroupName = NETSETUP_JOIN_STATUS.WorkgroupName; pub const NetSetupDomainName = NETSETUP_JOIN_STATUS.DomainName; pub const STD_ALERT = extern struct { alrt_timestamp: u32, alrt_eventname: [17]u16, alrt_servicename: [81]u16, }; pub const ADMIN_OTHER_INFO = extern struct { alrtad_errcode: u32, alrtad_numstrings: u32, }; pub const ERRLOG_OTHER_INFO = extern struct { alrter_errcode: u32, alrter_offset: u32, }; pub const PRINT_OTHER_INFO = extern struct { alrtpr_jobid: u32, alrtpr_status: u32, alrtpr_submitted: u32, alrtpr_size: u32, }; pub const USER_OTHER_INFO = extern struct { alrtus_errcode: u32, alrtus_numstrings: u32, }; pub const HLOG = extern struct { time: u32, last_flags: u32, offset: u32, rec_offset: u32, }; pub const AUDIT_ENTRY = extern struct { ae_len: u32, ae_reserved: u32, ae_time: u32, ae_type: u32, ae_data_offset: u32, ae_data_size: u32, }; // WARNING: this type symbol conflicts with a const! pub const AE_SRVSTATUS_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_SESSLOGON_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_SESSLOGOFF_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_SESSPWERR_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_CONNSTART_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_CONNSTOP_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_CONNREJ_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_RESACCESS_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_RESACCESSREJ_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_CLOSEFILE_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_SERVICESTAT_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_ACLMOD_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_UASMOD_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_NETLOGON_CONFLICT_ = usize; // WARNING: this type symbol conflicts with a const! pub const AE_NETLOGOFF_CONFLICT_ = usize; pub const AE_ACCLIM = extern struct { ae_al_compname: u32, ae_al_username: u32, ae_al_resname: u32, ae_al_limit: u32, }; // WARNING: this type symbol conflicts with a const! pub const AE_LOCKOUT_CONFLICT_ = usize; pub const AE_GENERIC = extern struct { ae_ge_msgfile: u32, ae_ge_msgnum: u32, ae_ge_params: u32, ae_ge_param1: u32, ae_ge_param2: u32, ae_ge_param3: u32, ae_ge_param4: u32, ae_ge_param5: u32, ae_ge_param6: u32, ae_ge_param7: u32, ae_ge_param8: u32, ae_ge_param9: u32, }; pub const CONFIG_INFO_0 = extern struct { cfgi0_key: ?PWSTR, cfgi0_data: ?PWSTR, }; pub const ERROR_LOG = extern struct { el_len: u32, el_reserved: u32, el_time: u32, el_error: u32, el_name: ?PWSTR, el_text: ?PWSTR, el_data: ?*u8, el_data_size: u32, el_nstrings: u32, }; pub const MSG_INFO_0 = extern struct { msgi0_name: ?PWSTR, }; pub const MSG_INFO_1 = extern struct { msgi1_name: ?PWSTR, msgi1_forward_flag: u32, msgi1_forward: ?PWSTR, }; pub const TIME_OF_DAY_INFO = extern struct { tod_elapsedt: u32, tod_msecs: u32, tod_hours: u32, tod_mins: u32, tod_secs: u32, tod_hunds: u32, tod_timezone: i32, tod_tinterval: u32, tod_day: u32, tod_month: u32, tod_year: u32, tod_weekday: u32, }; pub const AT_INFO = extern struct { JobTime: usize, DaysOfMonth: u32, DaysOfWeek: u8, Flags: u8, Command: ?PWSTR, }; pub const AT_ENUM = extern struct { JobId: u32, JobTime: usize, DaysOfMonth: u32, DaysOfWeek: u8, Flags: u8, Command: ?PWSTR, }; pub const SERVER_INFO_100 = extern struct { sv100_platform_id: u32, sv100_name: ?PWSTR, }; pub const SERVER_INFO_101 = extern struct { sv101_platform_id: u32, sv101_name: ?PWSTR, sv101_version_major: u32, sv101_version_minor: u32, sv101_type: NET_SERVER_TYPE, sv101_comment: ?PWSTR, }; pub const SERVER_INFO_102 = extern struct { sv102_platform_id: u32, sv102_name: ?PWSTR, sv102_version_major: u32, sv102_version_minor: u32, sv102_type: NET_SERVER_TYPE, sv102_comment: ?PWSTR, sv102_users: u32, sv102_disc: i32, sv102_hidden: SERVER_INFO_HIDDEN, sv102_announce: u32, sv102_anndelta: u32, sv102_licenses: u32, sv102_userpath: ?PWSTR, }; pub const SERVER_INFO_103 = extern struct { sv103_platform_id: u32, sv103_name: ?PWSTR, sv103_version_major: u32, sv103_version_minor: u32, sv103_type: u32, sv103_comment: ?PWSTR, sv103_users: u32, sv103_disc: i32, sv103_hidden: BOOL, sv103_announce: u32, sv103_anndelta: u32, sv103_licenses: u32, sv103_userpath: ?PWSTR, sv103_capabilities: u32, }; pub const SERVER_INFO_402 = extern struct { sv402_ulist_mtime: u32, sv402_glist_mtime: u32, sv402_alist_mtime: u32, sv402_alerts: ?PWSTR, sv402_security: SERVER_INFO_SECURITY, sv402_numadmin: u32, sv402_lanmask: u32, sv402_guestacct: ?PWSTR, sv402_chdevs: u32, sv402_chdevq: u32, sv402_chdevjobs: u32, sv402_connections: u32, sv402_shares: u32, sv402_openfiles: u32, sv402_sessopens: u32, sv402_sessvcs: u32, sv402_sessreqs: u32, sv402_opensearch: u32, sv402_activelocks: u32, sv402_numreqbuf: u32, sv402_sizreqbuf: u32, sv402_numbigbuf: u32, sv402_numfiletasks: u32, sv402_alertsched: u32, sv402_erroralert: u32, sv402_logonalert: u32, sv402_accessalert: u32, sv402_diskalert: u32, sv402_netioalert: u32, sv402_maxauditsz: u32, sv402_srvheuristics: ?PWSTR, }; pub const SERVER_INFO_403 = extern struct { sv403_ulist_mtime: u32, sv403_glist_mtime: u32, sv403_alist_mtime: u32, sv403_alerts: ?PWSTR, sv403_security: SERVER_INFO_SECURITY, sv403_numadmin: u32, sv403_lanmask: u32, sv403_guestacct: ?PWSTR, sv403_chdevs: u32, sv403_chdevq: u32, sv403_chdevjobs: u32, sv403_connections: u32, sv403_shares: u32, sv403_openfiles: u32, sv403_sessopens: u32, sv403_sessvcs: u32, sv403_sessreqs: u32, sv403_opensearch: u32, sv403_activelocks: u32, sv403_numreqbuf: u32, sv403_sizreqbuf: u32, sv403_numbigbuf: u32, sv403_numfiletasks: u32, sv403_alertsched: u32, sv403_erroralert: u32, sv403_logonalert: u32, sv403_accessalert: u32, sv403_diskalert: u32, sv403_netioalert: u32, sv403_maxauditsz: u32, sv403_srvheuristics: ?PWSTR, sv403_auditedevents: u32, sv403_autoprofile: u32, sv403_autopath: ?PWSTR, }; pub const SERVER_INFO_502 = extern struct { sv502_sessopens: u32, sv502_sessvcs: u32, sv502_opensearch: u32, sv502_sizreqbuf: u32, sv502_initworkitems: u32, sv502_maxworkitems: u32, sv502_rawworkitems: u32, sv502_irpstacksize: u32, sv502_maxrawbuflen: u32, sv502_sessusers: u32, sv502_sessconns: u32, sv502_maxpagedmemoryusage: u32, sv502_maxnonpagedmemoryusage: u32, sv502_enablesoftcompat: BOOL, sv502_enableforcedlogoff: BOOL, sv502_timesource: BOOL, sv502_acceptdownlevelapis: BOOL, sv502_lmannounce: BOOL, }; pub const SERVER_INFO_503 = extern struct { sv503_sessopens: u32, sv503_sessvcs: u32, sv503_opensearch: u32, sv503_sizreqbuf: u32, sv503_initworkitems: u32, sv503_maxworkitems: u32, sv503_rawworkitems: u32, sv503_irpstacksize: u32, sv503_maxrawbuflen: u32, sv503_sessusers: u32, sv503_sessconns: u32, sv503_maxpagedmemoryusage: u32, sv503_maxnonpagedmemoryusage: u32, sv503_enablesoftcompat: BOOL, sv503_enableforcedlogoff: BOOL, sv503_timesource: BOOL, sv503_acceptdownlevelapis: BOOL, sv503_lmannounce: BOOL, sv503_domain: ?PWSTR, sv503_maxcopyreadlen: u32, sv503_maxcopywritelen: u32, sv503_minkeepsearch: u32, sv503_maxkeepsearch: u32, sv503_minkeepcomplsearch: u32, sv503_maxkeepcomplsearch: u32, sv503_threadcountadd: u32, sv503_numblockthreads: u32, sv503_scavtimeout: u32, sv503_minrcvqueue: u32, sv503_minfreeworkitems: u32, sv503_xactmemsize: u32, sv503_threadpriority: u32, sv503_maxmpxct: u32, sv503_oplockbreakwait: u32, sv503_oplockbreakresponsewait: u32, sv503_enableoplocks: BOOL, sv503_enableoplockforceclose: BOOL, sv503_enablefcbopens: BOOL, sv503_enableraw: BOOL, sv503_enablesharednetdrives: BOOL, sv503_minfreeconnections: u32, sv503_maxfreeconnections: u32, }; pub const SERVER_INFO_599 = extern struct { sv599_sessopens: u32, sv599_sessvcs: u32, sv599_opensearch: u32, sv599_sizreqbuf: u32, sv599_initworkitems: u32, sv599_maxworkitems: u32, sv599_rawworkitems: u32, sv599_irpstacksize: u32, sv599_maxrawbuflen: u32, sv599_sessusers: u32, sv599_sessconns: u32, sv599_maxpagedmemoryusage: u32, sv599_maxnonpagedmemoryusage: u32, sv599_enablesoftcompat: BOOL, sv599_enableforcedlogoff: BOOL, sv599_timesource: BOOL, sv599_acceptdownlevelapis: BOOL, sv599_lmannounce: BOOL, sv599_domain: ?PWSTR, sv599_maxcopyreadlen: u32, sv599_maxcopywritelen: u32, sv599_minkeepsearch: u32, sv599_maxkeepsearch: u32, sv599_minkeepcomplsearch: u32, sv599_maxkeepcomplsearch: u32, sv599_threadcountadd: u32, sv599_numblockthreads: u32, sv599_scavtimeout: u32, sv599_minrcvqueue: u32, sv599_minfreeworkitems: u32, sv599_xactmemsize: u32, sv599_threadpriority: u32, sv599_maxmpxct: u32, sv599_oplockbreakwait: u32, sv599_oplockbreakresponsewait: u32, sv599_enableoplocks: BOOL, sv599_enableoplockforceclose: BOOL, sv599_enablefcbopens: BOOL, sv599_enableraw: BOOL, sv599_enablesharednetdrives: BOOL, sv599_minfreeconnections: u32, sv599_maxfreeconnections: u32, sv599_initsesstable: u32, sv599_initconntable: u32, sv599_initfiletable: u32, sv599_initsearchtable: u32, sv599_alertschedule: u32, sv599_errorthreshold: u32, sv599_networkerrorthreshold: u32, sv599_diskspacethreshold: u32, sv599_reserved: u32, sv599_maxlinkdelay: u32, sv599_minlinkthroughput: u32, sv599_linkinfovalidtime: u32, sv599_scavqosinfoupdatetime: u32, sv599_maxworkitemidletime: u32, }; pub const SERVER_INFO_598 = extern struct { sv598_maxrawworkitems: u32, sv598_maxthreadsperqueue: u32, sv598_producttype: u32, sv598_serversize: u32, sv598_connectionlessautodisc: u32, sv598_sharingviolationretries: u32, sv598_sharingviolationdelay: u32, sv598_maxglobalopensearch: u32, sv598_removeduplicatesearches: u32, sv598_lockviolationoffset: u32, sv598_lockviolationdelay: u32, sv598_mdlreadswitchover: u32, sv598_cachedopenlimit: u32, sv598_otherqueueaffinity: u32, sv598_restrictnullsessaccess: BOOL, sv598_enablewfw311directipx: BOOL, sv598_queuesamplesecs: u32, sv598_balancecount: u32, sv598_preferredaffinity: u32, sv598_maxfreerfcbs: u32, sv598_maxfreemfcbs: u32, sv598_maxfreelfcbs: u32, sv598_maxfreepagedpoolchunks: u32, sv598_minpagedpoolchunksize: u32, sv598_maxpagedpoolchunksize: u32, sv598_sendsfrompreferredprocessor: BOOL, sv598_cacheddirectorylimit: u32, sv598_maxcopylength: u32, sv598_enablecompression: BOOL, sv598_autosharewks: BOOL, sv598_autoshareserver: BOOL, sv598_enablesecuritysignature: BOOL, sv598_requiresecuritysignature: BOOL, sv598_minclientbuffersize: u32, sv598_serverguid: Guid, sv598_ConnectionNoSessionsTimeout: u32, sv598_IdleThreadTimeOut: u32, sv598_enableW9xsecuritysignature: BOOL, sv598_enforcekerberosreauthentication: BOOL, sv598_disabledos: BOOL, sv598_lowdiskspaceminimum: u32, sv598_disablestrictnamechecking: BOOL, sv598_enableauthenticateusersharing: BOOL, }; pub const SERVER_INFO_1005 = extern struct { sv1005_comment: ?PWSTR, }; pub const SERVER_INFO_1107 = extern struct { sv1107_users: u32, }; pub const SERVER_INFO_1010 = extern struct { sv1010_disc: i32, }; pub const SERVER_INFO_1016 = extern struct { sv1016_hidden: SERVER_INFO_HIDDEN, }; pub const SERVER_INFO_1017 = extern struct { sv1017_announce: u32, }; pub const SERVER_INFO_1018 = extern struct { sv1018_anndelta: u32, }; pub const SERVER_INFO_1501 = extern struct { sv1501_sessopens: u32, }; pub const SERVER_INFO_1502 = extern struct { sv1502_sessvcs: u32, }; pub const SERVER_INFO_1503 = extern struct { sv1503_opensearch: u32, }; pub const SERVER_INFO_1506 = extern struct { sv1506_maxworkitems: u32, }; pub const SERVER_INFO_1509 = extern struct { sv1509_maxrawbuflen: u32, }; pub const SERVER_INFO_1510 = extern struct { sv1510_sessusers: u32, }; pub const SERVER_INFO_1511 = extern struct { sv1511_sessconns: u32, }; pub const SERVER_INFO_1512 = extern struct { sv1512_maxnonpagedmemoryusage: u32, }; pub const SERVER_INFO_1513 = extern struct { sv1513_maxpagedmemoryusage: u32, }; pub const SERVER_INFO_1514 = extern struct { sv1514_enablesoftcompat: BOOL, }; pub const SERVER_INFO_1515 = extern struct { sv1515_enableforcedlogoff: BOOL, }; pub const SERVER_INFO_1516 = extern struct { sv1516_timesource: BOOL, }; pub const SERVER_INFO_1518 = extern struct { sv1518_lmannounce: BOOL, }; pub const SERVER_INFO_1520 = extern struct { sv1520_maxcopyreadlen: u32, }; pub const SERVER_INFO_1521 = extern struct { sv1521_maxcopywritelen: u32, }; pub const SERVER_INFO_1522 = extern struct { sv1522_minkeepsearch: u32, }; pub const SERVER_INFO_1523 = extern struct { sv1523_maxkeepsearch: u32, }; pub const SERVER_INFO_1524 = extern struct { sv1524_minkeepcomplsearch: u32, }; pub const SERVER_INFO_1525 = extern struct { sv1525_maxkeepcomplsearch: u32, }; pub const SERVER_INFO_1528 = extern struct { sv1528_scavtimeout: u32, }; pub const SERVER_INFO_1529 = extern struct { sv1529_minrcvqueue: u32, }; pub const SERVER_INFO_1530 = extern struct { sv1530_minfreeworkitems: u32, }; pub const SERVER_INFO_1533 = extern struct { sv1533_maxmpxct: u32, }; pub const SERVER_INFO_1534 = extern struct { sv1534_oplockbreakwait: u32, }; pub const SERVER_INFO_1535 = extern struct { sv1535_oplockbreakresponsewait: u32, }; pub const SERVER_INFO_1536 = extern struct { sv1536_enableoplocks: BOOL, }; pub const SERVER_INFO_1537 = extern struct { sv1537_enableoplockforceclose: BOOL, }; pub const SERVER_INFO_1538 = extern struct { sv1538_enablefcbopens: BOOL, }; pub const SERVER_INFO_1539 = extern struct { sv1539_enableraw: BOOL, }; pub const SERVER_INFO_1540 = extern struct { sv1540_enablesharednetdrives: BOOL, }; pub const SERVER_INFO_1541 = extern struct { sv1541_minfreeconnections: BOOL, }; pub const SERVER_INFO_1542 = extern struct { sv1542_maxfreeconnections: BOOL, }; pub const SERVER_INFO_1543 = extern struct { sv1543_initsesstable: u32, }; pub const SERVER_INFO_1544 = extern struct { sv1544_initconntable: u32, }; pub const SERVER_INFO_1545 = extern struct { sv1545_initfiletable: u32, }; pub const SERVER_INFO_1546 = extern struct { sv1546_initsearchtable: u32, }; pub const SERVER_INFO_1547 = extern struct { sv1547_alertschedule: u32, }; pub const SERVER_INFO_1548 = extern struct { sv1548_errorthreshold: u32, }; pub const SERVER_INFO_1549 = extern struct { sv1549_networkerrorthreshold: u32, }; pub const SERVER_INFO_1550 = extern struct { sv1550_diskspacethreshold: u32, }; pub const SERVER_INFO_1552 = extern struct { sv1552_maxlinkdelay: u32, }; pub const SERVER_INFO_1553 = extern struct { sv1553_minlinkthroughput: u32, }; pub const SERVER_INFO_1554 = extern struct { sv1554_linkinfovalidtime: u32, }; pub const SERVER_INFO_1555 = extern struct { sv1555_scavqosinfoupdatetime: u32, }; pub const SERVER_INFO_1556 = extern struct { sv1556_maxworkitemidletime: u32, }; pub const SERVER_INFO_1557 = extern struct { sv1557_maxrawworkitems: u32, }; pub const SERVER_INFO_1560 = extern struct { sv1560_producttype: u32, }; pub const SERVER_INFO_1561 = extern struct { sv1561_serversize: u32, }; pub const SERVER_INFO_1562 = extern struct { sv1562_connectionlessautodisc: u32, }; pub const SERVER_INFO_1563 = extern struct { sv1563_sharingviolationretries: u32, }; pub const SERVER_INFO_1564 = extern struct { sv1564_sharingviolationdelay: u32, }; pub const SERVER_INFO_1565 = extern struct { sv1565_maxglobalopensearch: u32, }; pub const SERVER_INFO_1566 = extern struct { sv1566_removeduplicatesearches: BOOL, }; pub const SERVER_INFO_1567 = extern struct { sv1567_lockviolationretries: u32, }; pub const SERVER_INFO_1568 = extern struct { sv1568_lockviolationoffset: u32, }; pub const SERVER_INFO_1569 = extern struct { sv1569_lockviolationdelay: u32, }; pub const SERVER_INFO_1570 = extern struct { sv1570_mdlreadswitchover: u32, }; pub const SERVER_INFO_1571 = extern struct { sv1571_cachedopenlimit: u32, }; pub const SERVER_INFO_1572 = extern struct { sv1572_criticalthreads: u32, }; pub const SERVER_INFO_1573 = extern struct { sv1573_restrictnullsessaccess: u32, }; pub const SERVER_INFO_1574 = extern struct { sv1574_enablewfw311directipx: u32, }; pub const SERVER_INFO_1575 = extern struct { sv1575_otherqueueaffinity: u32, }; pub const SERVER_INFO_1576 = extern struct { sv1576_queuesamplesecs: u32, }; pub const SERVER_INFO_1577 = extern struct { sv1577_balancecount: u32, }; pub const SERVER_INFO_1578 = extern struct { sv1578_preferredaffinity: u32, }; pub const SERVER_INFO_1579 = extern struct { sv1579_maxfreerfcbs: u32, }; pub const SERVER_INFO_1580 = extern struct { sv1580_maxfreemfcbs: u32, }; pub const SERVER_INFO_1581 = extern struct { sv1581_maxfreemlcbs: u32, }; pub const SERVER_INFO_1582 = extern struct { sv1582_maxfreepagedpoolchunks: u32, }; pub const SERVER_INFO_1583 = extern struct { sv1583_minpagedpoolchunksize: u32, }; pub const SERVER_INFO_1584 = extern struct { sv1584_maxpagedpoolchunksize: u32, }; pub const SERVER_INFO_1585 = extern struct { sv1585_sendsfrompreferredprocessor: BOOL, }; pub const SERVER_INFO_1586 = extern struct { sv1586_maxthreadsperqueue: u32, }; pub const SERVER_INFO_1587 = extern struct { sv1587_cacheddirectorylimit: u32, }; pub const SERVER_INFO_1588 = extern struct { sv1588_maxcopylength: u32, }; pub const SERVER_INFO_1590 = extern struct { sv1590_enablecompression: u32, }; pub const SERVER_INFO_1591 = extern struct { sv1591_autosharewks: u32, }; pub const SERVER_INFO_1592 = extern struct { sv1592_autosharewks: u32, }; pub const SERVER_INFO_1593 = extern struct { sv1593_enablesecuritysignature: u32, }; pub const SERVER_INFO_1594 = extern struct { sv1594_requiresecuritysignature: u32, }; pub const SERVER_INFO_1595 = extern struct { sv1595_minclientbuffersize: u32, }; pub const SERVER_INFO_1596 = extern struct { sv1596_ConnectionNoSessionsTimeout: u32, }; pub const SERVER_INFO_1597 = extern struct { sv1597_IdleThreadTimeOut: u32, }; pub const SERVER_INFO_1598 = extern struct { sv1598_enableW9xsecuritysignature: u32, }; pub const SERVER_INFO_1599 = extern struct { sv1598_enforcekerberosreauthentication: BOOLEAN, }; pub const SERVER_INFO_1600 = extern struct { sv1598_disabledos: BOOLEAN, }; pub const SERVER_INFO_1601 = extern struct { sv1598_lowdiskspaceminimum: u32, }; pub const SERVER_INFO_1602 = extern struct { sv_1598_disablestrictnamechecking: BOOL, }; pub const SERVER_TRANSPORT_INFO_0 = extern struct { svti0_numberofvcs: u32, svti0_transportname: ?PWSTR, svti0_transportaddress: ?*u8, svti0_transportaddresslength: u32, svti0_networkaddress: ?PWSTR, }; pub const SERVER_TRANSPORT_INFO_1 = extern struct { svti1_numberofvcs: u32, svti1_transportname: ?PWSTR, svti1_transportaddress: ?*u8, svti1_transportaddresslength: u32, svti1_networkaddress: ?PWSTR, svti1_domain: ?PWSTR, }; pub const SERVER_TRANSPORT_INFO_2 = extern struct { svti2_numberofvcs: u32, svti2_transportname: ?PWSTR, svti2_transportaddress: ?*u8, svti2_transportaddresslength: u32, svti2_networkaddress: ?PWSTR, svti2_domain: ?PWSTR, svti2_flags: u32, }; pub const SERVER_TRANSPORT_INFO_3 = extern struct { svti3_numberofvcs: u32, svti3_transportname: ?PWSTR, svti3_transportaddress: ?*u8, svti3_transportaddresslength: u32, svti3_networkaddress: ?PWSTR, svti3_domain: ?PWSTR, svti3_flags: u32, svti3_passwordlength: u32, svti3_password: [<PASSWORD>, }; pub const SERVICE_INFO_0 = extern struct { svci0_name: ?PWSTR, }; pub const SERVICE_INFO_1 = extern struct { svci1_name: ?PWSTR, svci1_status: u32, svci1_code: u32, svci1_pid: u32, }; pub const SERVICE_INFO_2 = extern struct { svci2_name: ?PWSTR, svci2_status: u32, svci2_code: u32, svci2_pid: u32, svci2_text: ?PWSTR, svci2_specific_error: u32, svci2_display_name: ?PWSTR, }; pub const USE_INFO_0 = extern struct { ui0_local: ?PWSTR, ui0_remote: ?PWSTR, }; pub const USE_INFO_1 = extern struct { ui1_local: ?PWSTR, ui1_remote: ?PWSTR, ui1_password: ?<PASSWORD>, ui1_status: u32, ui1_asg_type: USE_INFO_ASG_TYPE, ui1_refcount: u32, ui1_usecount: u32, }; pub const USE_INFO_2 = extern struct { ui2_local: ?PWSTR, ui2_remote: ?PWSTR, ui2_password: ?<PASSWORD>, ui2_status: u32, ui2_asg_type: USE_INFO_ASG_TYPE, ui2_refcount: u32, ui2_usecount: u32, ui2_username: ?PWSTR, ui2_domainname: ?PWSTR, }; pub const USE_INFO_3 = extern struct { ui3_ui2: USE_INFO_2, ui3_flags: u32, }; pub const USE_INFO_4 = extern struct { ui4_ui3: USE_INFO_3, ui4_auth_identity_length: u32, ui4_auth_identity: ?*u8, }; pub const USE_INFO_5 = extern struct { ui4_ui3: USE_INFO_3, ui4_auth_identity_length: u32, ui4_auth_identity: ?*u8, ui5_security_descriptor_length: u32, ui5_security_descriptor: ?*u8, ui5_use_options_length: u32, ui5_use_options: ?*u8, }; pub const USE_OPTION_GENERIC = extern struct { Tag: u32, Length: u16, Reserved: u16, }; pub const USE_OPTION_DEFERRED_CONNECTION_PARAMETERS = extern struct { Tag: u32, Length: u16, Reserved: u16, }; pub const TRANSPORT_TYPE = enum(i32) { None = 0, Wsk = 1, Quic = 2, }; pub const UseTransportType_None = TRANSPORT_TYPE.None; pub const UseTransportType_Wsk = TRANSPORT_TYPE.Wsk; pub const UseTransportType_Quic = TRANSPORT_TYPE.Quic; pub const TRANSPORT_INFO = extern struct { Type: TRANSPORT_TYPE, }; pub const USE_OPTION_TRANSPORT_PARAMETERS = extern struct { Tag: u32, Length: u16, Reserved: u16, }; pub const WKSTA_INFO_100 = extern struct { wki100_platform_id: u32, wki100_computername: ?PWSTR, wki100_langroup: ?PWSTR, wki100_ver_major: u32, wki100_ver_minor: u32, }; pub const WKSTA_INFO_101 = extern struct { wki101_platform_id: u32, wki101_computername: ?PWSTR, wki101_langroup: ?PWSTR, wki101_ver_major: u32, wki101_ver_minor: u32, wki101_lanroot: ?PWSTR, }; pub const WKSTA_INFO_102 = extern struct { wki102_platform_id: u32, wki102_computername: ?PWSTR, wki102_langroup: ?PWSTR, wki102_ver_major: u32, wki102_ver_minor: u32, wki102_lanroot: ?PWSTR, wki102_logged_on_users: u32, }; pub const WKSTA_INFO_302 = extern struct { wki302_char_wait: u32, wki302_collection_time: u32, wki302_maximum_collection_count: u32, wki302_keep_conn: u32, wki302_keep_search: u32, wki302_max_cmds: u32, wki302_num_work_buf: u32, wki302_siz_work_buf: u32, wki302_max_wrk_cache: u32, wki302_sess_timeout: u32, wki302_siz_error: u32, wki302_num_alerts: u32, wki302_num_services: u32, wki302_errlog_sz: u32, wki302_print_buf_time: u32, wki302_num_char_buf: u32, wki302_siz_char_buf: u32, wki302_wrk_heuristics: ?PWSTR, wki302_mailslots: u32, wki302_num_dgram_buf: u32, }; pub const WKSTA_INFO_402 = extern struct { wki402_char_wait: u32, wki402_collection_time: u32, wki402_maximum_collection_count: u32, wki402_keep_conn: u32, wki402_keep_search: u32, wki402_max_cmds: u32, wki402_num_work_buf: u32, wki402_siz_work_buf: u32, wki402_max_wrk_cache: u32, wki402_sess_timeout: u32, wki402_siz_error: u32, wki402_num_alerts: u32, wki402_num_services: u32, wki402_errlog_sz: u32, wki402_print_buf_time: u32, wki402_num_char_buf: u32, wki402_siz_char_buf: u32, wki402_wrk_heuristics: ?PWSTR, wki402_mailslots: u32, wki402_num_dgram_buf: u32, wki402_max_threads: u32, }; pub const WKSTA_INFO_502 = extern struct { wki502_char_wait: u32, wki502_collection_time: u32, wki502_maximum_collection_count: u32, wki502_keep_conn: u32, wki502_max_cmds: u32, wki502_sess_timeout: u32, wki502_siz_char_buf: u32, wki502_max_threads: u32, wki502_lock_quota: u32, wki502_lock_increment: u32, wki502_lock_maximum: u32, wki502_pipe_increment: u32, wki502_pipe_maximum: u32, wki502_cache_file_timeout: u32, wki502_dormant_file_limit: u32, wki502_read_ahead_throughput: u32, wki502_num_mailslot_buffers: u32, wki502_num_srv_announce_buffers: u32, wki502_max_illegal_datagram_events: u32, wki502_illegal_datagram_event_reset_frequency: u32, wki502_log_election_packets: BOOL, wki502_use_opportunistic_locking: BOOL, wki502_use_unlock_behind: BOOL, wki502_use_close_behind: BOOL, wki502_buf_named_pipes: BOOL, wki502_use_lock_read_unlock: BOOL, wki502_utilize_nt_caching: BOOL, wki502_use_raw_read: BOOL, wki502_use_raw_write: BOOL, wki502_use_write_raw_data: BOOL, wki502_use_encryption: BOOL, wki502_buf_files_deny_write: BOOL, wki502_buf_read_only_files: BOOL, wki502_force_core_create_mode: BOOL, wki502_use_512_byte_max_transfer: BOOL, }; pub const WKSTA_INFO_1010 = extern struct { wki1010_char_wait: u32, }; pub const WKSTA_INFO_1011 = extern struct { wki1011_collection_time: u32, }; pub const WKSTA_INFO_1012 = extern struct { wki1012_maximum_collection_count: u32, }; pub const WKSTA_INFO_1027 = extern struct { wki1027_errlog_sz: u32, }; pub const WKSTA_INFO_1028 = extern struct { wki1028_print_buf_time: u32, }; pub const WKSTA_INFO_1032 = extern struct { wki1032_wrk_heuristics: u32, }; pub const WKSTA_INFO_1013 = extern struct { wki1013_keep_conn: u32, }; pub const WKSTA_INFO_1018 = extern struct { wki1018_sess_timeout: u32, }; pub const WKSTA_INFO_1023 = extern struct { wki1023_siz_char_buf: u32, }; pub const WKSTA_INFO_1033 = extern struct { wki1033_max_threads: u32, }; pub const WKSTA_INFO_1041 = extern struct { wki1041_lock_quota: u32, }; pub const WKSTA_INFO_1042 = extern struct { wki1042_lock_increment: u32, }; pub const WKSTA_INFO_1043 = extern struct { wki1043_lock_maximum: u32, }; pub const WKSTA_INFO_1044 = extern struct { wki1044_pipe_increment: u32, }; pub const WKSTA_INFO_1045 = extern struct { wki1045_pipe_maximum: u32, }; pub const WKSTA_INFO_1046 = extern struct { wki1046_dormant_file_limit: u32, }; pub const WKSTA_INFO_1047 = extern struct { wki1047_cache_file_timeout: u32, }; pub const WKSTA_INFO_1048 = extern struct { wki1048_use_opportunistic_locking: BOOL, }; pub const WKSTA_INFO_1049 = extern struct { wki1049_use_unlock_behind: BOOL, }; pub const WKSTA_INFO_1050 = extern struct { wki1050_use_close_behind: BOOL, }; pub const WKSTA_INFO_1051 = extern struct { wki1051_buf_named_pipes: BOOL, }; pub const WKSTA_INFO_1052 = extern struct { wki1052_use_lock_read_unlock: BOOL, }; pub const WKSTA_INFO_1053 = extern struct { wki1053_utilize_nt_caching: BOOL, }; pub const WKSTA_INFO_1054 = extern struct { wki1054_use_raw_read: BOOL, }; pub const WKSTA_INFO_1055 = extern struct { wki1055_use_raw_write: BOOL, }; pub const WKSTA_INFO_1056 = extern struct { wki1056_use_write_raw_data: BOOL, }; pub const WKSTA_INFO_1057 = extern struct { wki1057_use_encryption: BOOL, }; pub const WKSTA_INFO_1058 = extern struct { wki1058_buf_files_deny_write: BOOL, }; pub const WKSTA_INFO_1059 = extern struct { wki1059_buf_read_only_files: BOOL, }; pub const WKSTA_INFO_1060 = extern struct { wki1060_force_core_create_mode: BOOL, }; pub const WKSTA_INFO_1061 = extern struct { wki1061_use_512_byte_max_transfer: BOOL, }; pub const WKSTA_INFO_1062 = extern struct { wki1062_read_ahead_throughput: u32, }; pub const WKSTA_USER_INFO_0 = extern struct { wkui0_username: ?PWSTR, }; pub const WKSTA_USER_INFO_1 = extern struct { wkui1_username: ?PWSTR, wkui1_logon_domain: ?PWSTR, wkui1_oth_domains: ?PWSTR, wkui1_logon_server: ?PWSTR, }; pub const WKSTA_USER_INFO_1101 = extern struct { wkui1101_oth_domains: ?PWSTR, }; pub const WKSTA_TRANSPORT_INFO_0 = extern struct { wkti0_quality_of_service: u32, wkti0_number_of_vcs: u32, wkti0_transport_name: ?PWSTR, wkti0_transport_address: ?PWSTR, wkti0_wan_ish: BOOL, }; //-------------------------------------------------------------------------------- // Section: Functions (119) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserAdd( servername: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserEnum( servername: ?[*:0]const u16, level: u32, filter: NET_USER_ENUM_FILTER_FLAGS, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetUserGetInfo( servername: ?[*:0]const u16, username: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserSetInfo( servername: ?[*:0]const u16, username: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserDel( servername: ?[*:0]const u16, username: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserGetGroups( servername: ?[*:0]const u16, username: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserSetGroups( servername: ?[*:0]const u16, username: ?[*:0]const u16, level: u32, buf: ?*u8, num_entries: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserGetLocalGroups( servername: ?[*:0]const u16, username: ?[*:0]const u16, level: u32, flags: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserModalsGet( servername: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserModalsSet( servername: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUserChangePassword( domainname: ?[*:0]const u16, username: ?[*:0]const u16, oldpassword: ?[*:0]const u16, newpassword: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupAdd( servername: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupAddUser( servername: ?[*:0]const u16, GroupName: ?[*:0]const u16, username: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupEnum( servername: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*usize, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupGetInfo( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupSetInfo( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupDel( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupDelUser( servername: ?[*:0]const u16, GroupName: ?[*:0]const u16, Username: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupGetUsers( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, ResumeHandle: ?*usize, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGroupSetUsers( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, buf: ?*u8, totalentries: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupAdd( servername: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetLocalGroupAddMember( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, membersid: ?PSID, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupEnum( servername: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resumehandle: ?*usize, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupGetInfo( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupSetInfo( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupDel( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetLocalGroupDelMember( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, membersid: ?PSID, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupGetMembers( servername: ?[*:0]const u16, localgroupname: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resumehandle: ?*usize, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupSetMembers( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, buf: ?*u8, totalentries: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupAddMembers( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, buf: ?*u8, totalentries: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetLocalGroupDelMembers( servername: ?[*:0]const u16, groupname: ?[*:0]const u16, level: u32, buf: ?*u8, totalentries: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetQueryDisplayInformation( ServerName: ?[*:0]const u16, Level: u32, Index: u32, EntriesRequested: u32, PreferredMaximumLength: u32, ReturnedEntryCount: ?*u32, SortedBuffer: ?*?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGetDisplayInformationIndex( ServerName: ?[*:0]const u16, Level: u32, Prefix: ?[*:0]const u16, Index: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetAccessAdd( servername: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetAccessEnum( servername: ?[*:0]const u16, BasePath: ?[*:0]const u16, Recursive: u32, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetAccessGetInfo( servername: ?[*:0]const u16, resource: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetAccessSetInfo( servername: ?[*:0]const u16, resource: ?[*:0]const u16, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetAccessDel( servername: ?[*:0]const u16, resource: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetAccessGetUserPerms( servername: ?[*:0]const u16, UGname: ?[*:0]const u16, resource: ?[*:0]const u16, Perms: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windowsServer2003' pub extern "NETAPI32" fn NetValidatePasswordPolicy( ServerName: ?[*:0]const u16, Qualifier: ?*c_void, ValidationType: NET_VALIDATE_PASSWORD_TYPE, InputArg: ?*c_void, OutputArg: ?*?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windowsServer2003' pub extern "NETAPI32" fn NetValidatePasswordPolicyFree( OutputArg: ?*?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGetDCName( ServerName: ?[*:0]const u16, DomainName: ?[*:0]const u16, Buffer: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGetAnyDCName( ServerName: ?[*:0]const u16, DomainName: ?[*:0]const u16, Buffer: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn I_NetLogonControl2( ServerName: ?[*:0]const u16, FunctionCode: u32, QueryLevel: u32, Data: ?*u8, Buffer: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.1' pub extern "NETAPI32" fn NetAddServiceAccount( ServerName: ?PWSTR, AccountName: ?PWSTR, Password: ?PWSTR, Flags: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.1' pub extern "NETAPI32" fn NetRemoveServiceAccount( ServerName: ?PWSTR, AccountName: ?PWSTR, Flags: u32, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.1' pub extern "NETAPI32" fn NetEnumerateServiceAccounts( ServerName: ?PWSTR, Flags: u32, AccountsCount: ?*u32, Accounts: ?*?*?*u16, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.1' pub extern "NETAPI32" fn NetIsServiceAccount( ServerName: ?PWSTR, AccountName: ?PWSTR, IsService: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows6.1' pub extern "NETAPI32" fn NetQueryServiceAccount( ServerName: ?PWSTR, AccountName: ?PWSTR, InfoLevel: u32, Buffer: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) NTSTATUS; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetJoinDomain( lpServer: ?[*:0]const u16, lpDomain: ?[*:0]const u16, lpMachineAccountOU: ?[*:0]const u16, lpAccount: ?[*:0]const u16, lpPassword: ?[*:0]const u16, fJoinOptions: NET_JOIN_DOMAIN_JOIN_OPTIONS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUnjoinDomain( lpServer: ?[*:0]const u16, lpAccount: ?[*:0]const u16, lpPassword: ?[*:0]const u16, fUnjoinOptions: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetRenameMachineInDomain( lpServer: ?[*:0]const u16, lpNewMachineName: ?[*:0]const u16, lpAccount: ?[*:0]const u16, lpPassword: ?[*:0]const u16, fRenameOptions: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetValidateName( lpServer: ?[*:0]const u16, lpName: ?[*:0]const u16, lpAccount: ?[*:0]const u16, lpPassword: ?[*:0]const u16, NameType: NETSETUP_NAME_TYPE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGetJoinableOUs( lpServer: ?[*:0]const u16, lpDomain: ?[*:0]const u16, lpAccount: ?[*:0]const u16, lpPassword: ?[*:0]const u16, OUCount: ?*u32, OUs: ?*?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetAddAlternateComputerName( Server: ?[*:0]const u16, AlternateName: ?[*:0]const u16, DomainAccount: ?[*:0]const u16, DomainAccountPassword: ?[*:0]const u16, Reserved: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetRemoveAlternateComputerName( Server: ?[*:0]const u16, AlternateName: ?[*:0]const u16, DomainAccount: ?[*:0]const u16, DomainAccountPassword: ?[*:0]const u16, Reserved: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetSetPrimaryComputerName( Server: ?[*:0]const u16, PrimaryName: ?[*:0]const u16, DomainAccount: ?[*:0]const u16, DomainAccountPassword: ?[*:0]const u16, Reserved: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "NETAPI32" fn NetEnumerateComputerNames( Server: ?[*:0]const u16, NameType: NET_COMPUTER_NAME_TYPE, Reserved: u32, EntryCount: ?*u32, ComputerNames: ?*?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.1' pub extern "NETAPI32" fn NetProvisionComputerAccount( lpDomain: ?[*:0]const u16, lpMachineName: ?[*:0]const u16, lpMachineAccountOU: ?[*:0]const u16, lpDcName: ?[*:0]const u16, dwOptions: NETSETUP_PROVISION, pProvisionBinData: ?*?*u8, pdwProvisionBinDataSize: ?*u32, pProvisionTextData: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.1' pub extern "NETAPI32" fn NetRequestOfflineDomainJoin( // TODO: what to do with BytesParamIndex 1? pProvisionBinData: ?*u8, cbProvisionBinDataSize: u32, dwOptions: NET_REQUEST_PROVISION_OPTIONS, lpWindowsPath: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows8.0' pub extern "NETAPI32" fn NetCreateProvisioningPackage( pProvisioningParams: ?*NETSETUP_PROVISIONING_PARAMS, ppPackageBinData: ?*?*u8, pdwPackageBinDataSize: ?*u32, ppPackageTextData: ?*?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows8.0' pub extern "NETAPI32" fn NetRequestProvisioningPackageInstall( // TODO: what to do with BytesParamIndex 1? pPackageBinData: ?*u8, dwPackageBinDataSize: u32, dwProvisionOptions: NET_REQUEST_PROVISION_OPTIONS, lpWindowsPath: ?[*:0]const u16, pvReserved: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows10.0.10240' pub extern "NETAPI32" fn NetGetAadJoinInformation( pcszTenantId: ?[*:0]const u16, ppJoinInfo: ?*?*DSREG_JOIN_INFO, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows10.0.10240' pub extern "NETAPI32" fn NetFreeAadJoinInformation( pJoinInfo: ?*DSREG_JOIN_INFO, ) callconv(@import("std").os.windows.WINAPI) void; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetGetJoinInformation( lpServer: ?[*:0]const u16, lpNameBuffer: ?*?PWSTR, BufferType: ?*NETSETUP_JOIN_STATUS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "mstask" fn GetNetScheduleAccountInformation( pwszServerName: ?[*:0]const u16, ccAccount: u32, wszAccount: [*:0]u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows6.0.6000' pub extern "mstask" fn SetNetScheduleAccountInformation( pwszServerName: ?[*:0]const u16, pwszAccount: ?[*:0]const u16, pwszPassword: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetAlertRaise( AlertType: ?[*:0]const u16, Buffer: ?*c_void, BufferSize: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetAlertRaiseEx( AlertType: ?[*:0]const u16, VariableInfo: ?*c_void, VariableInfoSize: u32, ServiceName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetApiBufferAllocate( ByteCount: u32, Buffer: ?*?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetApiBufferFree( Buffer: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetApiBufferReallocate( OldBuffer: ?*c_void, NewByteCount: u32, NewBuffer: ?*?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetApiBufferSize( Buffer: ?*c_void, ByteCount: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetAuditClear( server: ?[*:0]const u16, backupfile: ?[*:0]const u16, service: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetAuditRead( server: ?[*:0]const u16, service: ?[*:0]const u16, auditloghandle: ?*HLOG, offset: u32, reserved1: ?*u32, reserved2: u32, offsetflag: u32, bufptr: ?*?*u8, prefmaxlen: u32, bytesread: ?*u32, totalavailable: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetAuditWrite( type: u32, buf: ?*u8, numbytes: u32, service: ?[*:0]const u16, reserved: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetConfigGet( server: ?[*:0]const u16, component: ?[*:0]const u16, parameter: ?[*:0]const u16, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetConfigGetAll( server: ?[*:0]const u16, component: ?[*:0]const u16, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetConfigSet( server: ?[*:0]const u16, reserved1: ?[*:0]const u16, component: ?[*:0]const u16, level: u32, reserved2: u32, buf: ?*u8, reserved3: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetErrorLogClear( UncServerName: ?[*:0]const u16, BackupFile: ?[*:0]const u16, Reserved: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetErrorLogRead( UncServerName: ?[*:0]const u16, Reserved1: ?PWSTR, ErrorLogHandle: ?*HLOG, Offset: u32, Reserved2: ?*u32, Reserved3: u32, OffsetFlag: u32, BufPtr: ?*?*u8, PrefMaxSize: u32, BytesRead: ?*u32, TotalAvailable: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetErrorLogWrite( Reserved1: ?*u8, Code: u32, Component: ?[*:0]const u16, Buffer: ?*u8, NumBytes: u32, MsgBuf: ?*u8, StrCount: u32, Reserved2: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetMessageNameAdd( servername: ?[*:0]const u16, msgname: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetMessageNameEnum( servername: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetMessageNameGetInfo( servername: ?[*:0]const u16, msgname: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetMessageNameDel( servername: ?[*:0]const u16, msgname: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetMessageBufferSend( servername: ?[*:0]const u16, msgname: ?[*:0]const u16, fromname: ?[*:0]const u16, buf: ?*u8, buflen: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetRemoteTOD( UncServerName: ?[*:0]const u16, BufferPtr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetRemoteComputerSupports( UncServerName: ?[*:0]const u16, OptionsWanted: NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS, OptionsSupported: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetScheduleJobAdd( Servername: ?[*:0]const u16, Buffer: ?*u8, JobId: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetScheduleJobDel( Servername: ?[*:0]const u16, MinJobId: u32, MaxJobId: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetScheduleJobEnum( Servername: ?[*:0]const u16, PointerToBuffer: ?*?*u8, PrefferedMaximumLength: u32, EntriesRead: ?*u32, TotalEntries: ?*u32, ResumeHandle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetScheduleJobGetInfo( Servername: ?[*:0]const u16, JobId: u32, PointerToBuffer: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerEnum( servername: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, servertype: NET_SERVER_TYPE, domain: ?[*:0]const u16, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerGetInfo( servername: ?PWSTR, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerSetInfo( servername: ?PWSTR, level: u32, buf: ?*u8, ParmError: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerDiskEnum( servername: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerComputerNameAdd( ServerName: ?PWSTR, EmulatedDomainName: ?PWSTR, EmulatedServerName: ?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerComputerNameDel( ServerName: ?PWSTR, EmulatedServerName: ?PWSTR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerTransportAdd( servername: ?PWSTR, level: u32, bufptr: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerTransportAddEx( servername: ?PWSTR, level: u32, bufptr: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerTransportDel( servername: ?PWSTR, level: u32, bufptr: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetServerTransportEnum( servername: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetServiceControl( servername: ?[*:0]const u16, service: ?[*:0]const u16, opcode: u32, arg: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetServiceEnum( servername: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetServiceGetInfo( servername: ?[*:0]const u16, service: ?[*:0]const u16, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetServiceInstall( servername: ?[*:0]const u16, service: ?[*:0]const u16, argc: u32, argv: [*]?PWSTR, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUseAdd( servername: ?*i8, LevelFlags: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUseDel( UncServerName: ?PWSTR, UseName: ?PWSTR, ForceLevelFlags: FORCE_LEVEL_FLAGS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUseEnum( UncServerName: ?PWSTR, LevelFlags: u32, BufPtr: ?*?*u8, PreferedMaximumSize: u32, EntriesRead: ?*u32, TotalEntries: ?*u32, ResumeHandle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetUseGetInfo( UncServerName: ?PWSTR, UseName: ?PWSTR, LevelFlags: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetWkstaGetInfo( servername: ?PWSTR, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetWkstaSetInfo( servername: ?PWSTR, level: u32, buffer: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetWkstaUserGetInfo( reserved: ?PWSTR, level: u32, bufptr: ?*?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetWkstaUserSetInfo( reserved: ?PWSTR, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetWkstaUserEnum( servername: ?PWSTR, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resumehandle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetWkstaTransportAdd( servername: ?*i8, level: u32, buf: ?*u8, parm_err: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "NETAPI32" fn NetWkstaTransportDel( servername: ?PWSTR, transportname: ?PWSTR, ucond: FORCE_LEVEL_FLAGS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "NETAPI32" fn NetWkstaTransportEnum( servername: ?*i8, level: u32, bufptr: ?*?*u8, prefmaxlen: u32, entriesread: ?*u32, totalentries: ?*u32, resume_handle: ?*u32, ) callconv(@import("std").os.windows.WINAPI) u32; //-------------------------------------------------------------------------------- // 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 (10) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const BOOL = @import("../foundation.zig").BOOL; const BOOLEAN = @import("../foundation.zig").BOOLEAN; const CERT_CONTEXT = @import("../security/cryptography/core.zig").CERT_CONTEXT; const FILETIME = @import("../foundation.zig").FILETIME; const HRESULT = @import("../foundation.zig").HRESULT; const NTSTATUS = @import("../foundation.zig").NTSTATUS; const PSID = @import("../foundation.zig").PSID; const PWSTR = @import("../foundation.zig").PWSTR; const SID_NAME_USE = @import("../security.zig").SID_NAME_USE; 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; } } }
deps/zigwin32/win32/network_management/net_management.zig
const std = @import("std"); const sign_extend26 = @import("cpu.zig").sign_extend26; const Allocator = std.mem.Allocator; const Cpu = @import("cpu.zig").Cpu; const Reg = @import("regs.zig").Reg; pub fn illegal(cpu: *Cpu, halfword: u16) void { std.debug.warn("Illegal opcode: 0x{x}\n", .{halfword}); } // move register pub fn mov(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); std.debug.warn("mov r{}, r{}\n", .{ r1, r2 }); } // add register pub fn add(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); std.debug.warn("add r{}, r{}\n", .{ r2, r1 }); } // subtract pub fn sub(cpu: *Cpu, halfword: u16) void { std.debug.warn("sub TODO\n", .{}); } pub fn cmp(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); std.debug.warn("cmp r{}, r{}\n", .{ r2, r1 }); } pub fn shl(cpu: *Cpu, halfword: u16) void { std.debug.warn("sl TODO\n", .{}); } pub fn shr(cpu: *Cpu, halfword: u16) void { std.debug.warn("shr TODO\n", .{}); } pub fn jmp(cpu: *Cpu, halfword: u16) void { const r1 = @intCast(usize, halfword & 0x001f); std.debug.warn("jmp [r{}]\n", .{r1}); } pub fn sar(cpu: *Cpu, halfword: u16) void { std.debug.warn("sar TODO\n", .{}); } pub fn mul(cpu: *Cpu, halfword: u16) void { std.debug.warn("mul TODO\n", .{}); } pub fn div(cpu: *Cpu, halfword: u16) void { std.debug.warn("div TODO\n", .{}); } pub fn mulu(cpu: *Cpu, halfword: u16) void { std.debug.warn("mulu TODO\n", .{}); } pub fn divu(cpu: *Cpu, halfword: u16) void { std.debug.warn("divu TODO\n", .{}); } pub fn orop(cpu: *Cpu, halfword: u16) void { std.debug.warn("or TODO\n", .{}); } pub fn andop(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); std.debug.warn("and r{}, r{}\n", .{ r1, r2 }); } pub fn xor(cpu: *Cpu, halfword: u16) void { std.debug.warn("xor TODO\n", .{}); } pub fn not(cpu: *Cpu, halfword: u16) void { std.debug.warn("not TODO\n", .{}); } pub fn mov2(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const imm = @bitCast(i5, @intCast(u5, halfword & 0x001f)); std.debug.warn("mov {}, r{}\n", .{ imm, r2 }); } pub fn add2(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const imm = @bitCast(i5, @intCast(u5, halfword & 0x001f)); std.debug.warn("add {}, r{}\n", .{ imm, r2 }); } pub fn cmp2(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const imm = @intCast(usize, halfword & 0x001f); std.debug.warn("cmp {}, r{}\n", .{ imm, r2 }); } pub fn shl2(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const imm = @intCast(u32, halfword & 0x001f); std.debug.warn("shl {}, r{}\n", .{ imm, r2 }); } pub fn shr2(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const imm = @intCast(u32, halfword & 0x001f); std.debug.warn("shr2 {}, r{}\n", .{ imm, r2 }); } // Nintendo-specific pub fn cli(cpu: *Cpu, halfword: u16) void { std.debug.warn("cli\n", .{}); } pub fn sar2(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const imm = @intCast(u32, halfword & 0x001f); std.debug.warn("sar {}, r{}\n", .{ imm, r2 }); } pub fn setf(cpu: *Cpu, halfword: u16) void { std.debug.warn("setf TODO\n", .{}); } pub fn trap(cpu: *Cpu, halfword: u16) void { std.debug.warn("trap TODO\n", .{}); } pub fn reti(cpu: *Cpu, halfword: u16) void { std.debug.warn("reti\n", .{}); } pub fn halt(cpu: *Cpu, halfword: u16) void { std.debug.warn("halt TODO\n", .{}); } pub fn ldsr(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const imm = @intCast(u5, halfword & 0x001f); std.debug.warn("ldsr r{}, {}\n", .{ r2, imm }); } pub fn stsr(cpu: *Cpu, halfword: u16) void { std.debug.warn("stsr TODO\n", .{}); } // Nintendo-specific pub fn sei(cpu: *Cpu, halfword: u16) void { std.debug.warn("sei\n", .{}); } pub fn bit_string(cpu: *Cpu, halfword: u16) void { std.debug.warn("bit_string TODO\n", .{}); } pub fn bcond(cpu: *Cpu, halfword: u16) void { const cond = @intCast(u4, (halfword & 0x1e00) >> 9); const disp = halfword & 0x01ff; switch (cond) { 0x0 => { std.debug.warn("bv 0x{x}\n", .{disp}); }, 0x1 => { std.debug.warn("bl 0x{x}\n", .{disp}); }, 0x2 => { std.debug.warn("bz 0x{x}\n", .{disp}); }, 0x3 => { std.debug.warn("bnh 0x{x}\n", .{disp}); }, 0x4 => { std.debug.warn("bn 0x{x}\n", .{disp}); }, 0x5 => { std.debug.warn("br 0x{x}\n", .{disp}); }, 0x6 => { std.debug.warn("blt 0x{x}\n", .{disp}); }, 0x7 => { std.debug.warn("ble 0x{x}\n", .{disp}); }, 0x8 => { std.debug.warn("bnv 0x{x}\n", .{disp}); }, 0x9 => { std.debug.warn("bnc 0x{x}\n", .{disp}); }, 0xa => { std.debug.warn("bnz 0x{x}\n", .{disp}); }, 0xb => { std.debug.warn("bh 0x{x}\n", .{disp}); }, 0xc => { std.debug.warn("bp 0x{x}\n", .{disp}); }, 0xd => { std.debug.warn("nop 0x{x}\n", .{disp}); }, 0xe => { std.debug.warn("bge 0x{x}\n", .{disp}); }, 0xf => { std.debug.warn("bgt 0x{x}\n", .{disp}); }, } } pub fn movea(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const imm = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("movea 0x{x}, r{}, r{}\n", .{ imm, r1, r2 }); } pub fn addi(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const imm = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("addi {}, r{}, r{}\n", .{ @bitCast(i16, imm), r1, r2 }); } pub fn jr(cpu: *Cpu, halfword: u16) void { const upper = @intCast(u32, halfword & 0x03ff) << 16; const lower = @intCast(u32, cpu.bus.read_halfword(cpu.pc + 2) catch unreachable); const disp = sign_extend26(@intCast(u26, (upper | lower))); std.debug.warn("jr {} (0x{x:08})\n", .{ @truncate(u26, disp), (cpu.pc +% disp & 0xfffffffe) }); } pub fn jal(cpu: *Cpu, halfword: u16) void { const upper = @intCast(u32, halfword & 0x03ff) << 16; const lower = @intCast(u32, cpu.bus.read_halfword(cpu.pc + 2) catch unreachable); const disp = sign_extend26(@intCast(u26, (upper | lower))); std.debug.warn("jal {} (0x{x:08})\n", .{ @truncate(u26, disp), (cpu.pc +% disp & 0xfffffffe) }); } pub fn ori(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const imm = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("ori 0x{x}, r{}, r{}\n", .{ imm, r1, r2 }); } pub fn andi(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const imm = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("andi 0x{x}, r{}, r{}\n", .{ imm, r1, r2 }); } pub fn xori(cpu: *Cpu, halfword: u16) void { std.debug.warn("xori TODO\n", .{}); } pub fn movhi(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const imm = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("movhi 0x{x}, r{}, r{}\n", .{ imm, r1, r2 }); } pub fn ldb(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("ld.b {}[r{}], r{}\n", .{ disp, r1, r2 }); } pub fn ldh(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("ld.h {}[r{}], r{}\n", .{ disp, r1, r2 }); } pub fn ldw(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("ld.w {}[r{}], r{}\n", .{ disp, r1, r2 }); } pub fn stb(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("st.b r{}, {}[r{}]\n", .{ r2, disp, r1 }); } pub fn sth(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("st.h r{}, {}[r{}]\n", .{ r2, disp, r1 }); } pub fn stw(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("st.w r{}, {}[r{}]\n", .{ r2, disp, r1 }); } pub fn inb(cpu: *Cpu, halfword: u16) void { std.debug.warn("inb TODO\n", .{}); } pub fn inh(cpu: *Cpu, halfword: u16) void { std.debug.warn("inh TODO\n", .{}); } pub fn caxi(cpu: *Cpu, halfword: u16) void { std.debug.warn("caxi TODO\n", .{}); } pub fn inw(cpu: *Cpu, halfword: u16) void { std.debug.warn("inw TODO\n", .{}); } pub fn outb(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("out.b r{}, {}[r{}]\n", .{ r2, disp, r1 }); } pub fn outh(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("out.h r{}, {}[r{}]\n", .{ r2, disp, r1 }); } pub fn float(cpu: *Cpu, halfword: u16) void { std.debug.warn("float TODO\n", .{}); } pub fn outw(cpu: *Cpu, halfword: u16) void { const r2 = @intCast(usize, (halfword & 0x03e0) >> 5); const r1 = @intCast(usize, halfword & 0x001f); const disp = cpu.bus.read_halfword(cpu.pc + 2) catch unreachable; std.debug.warn("out.w r{}, {}[r{}]\n", .{ r2, disp, r1 }); }
src/cpu/debug.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.warn(fmt, args); } const Computer = tools.IntCode_Computer; const Map = tools.Map(u8, 512, 512, true); const Vec2 = tools.Vec2; const State = struct { room_index: usize, door: u2, next_pos: Vec2, }; const Trace = struct { // cpu: Computer, // memory: [1000]Computer.Data, len: usize, commands: [4096]u8, }; const BFS = tools.BestFirstSearch(State, Trace); const Room = struct { name: []const u8, desc: []const u8, items: [][]const u8, doors: [4]bool, pos: Vec2, }; pub fn main() anyerror!void { const stdout = std.io.getStdOut().outStream(); const stdin = &std.io.getStdIn().inStream().stream; const allocator = &std.heap.ArenaAllocator.init(std.heap.page_allocator).allocator; const limit = 1 * 1024 * 1024 * 1024; const text = try std.fs.cwd().readFileAlloc(allocator, "day25.txt", limit); defer allocator.free(text); const int_count = blk: { var int_count: usize = 0; var it = std.mem.split(text, ","); 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(text, ","); 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); var cpu = Computer{ .name = "droid", .memory = try allocator.alloc(Computer.Data, 64000), }; defer allocator.free(cpu.memory); cpu.reboot(boot_image); trace("starting {s}\n", .{cpu.name}); _ = async cpu.run(); var map = Map{}; for (map.map) |*m| { m.* = '#'; } map.set(Vec2{ .x = 0, .y = 0 }, ' '); var bfs = BFS.init(allocator); defer bfs.deinit(); try bfs.insert(BFS.Node{ .cost = 0, .rating = 0, .state = State{ .room_index = 0, .next_pos = Vec2{ .x = 0, .y = 0 }, .door = 0, //.cpu = cpu, //.memory = try std.mem.dupe(u8, cpu.memory), }, .trace = Trace{ .len = 0, .commands = undefined }, }); var rooms = std.ArrayList(Room).init(allocator); defer rooms.deinit(); { const room0 = try rooms.addOne(); room0.name = "the void"; } const dirs = [_]Vec2{ .{ .x = 0, .y = -1 }, .{ .x = -1, .y = 0 }, .{ .x = 0, .y = 1 }, .{ .x = 1, .y = 0 } }; const cmds = [_][]const u8{ "north", "west", "south", "east" }; const interractive = false; if (interractive) { while (true) { assert(!cpu.is_halted()); if (cpu.io_mode == .input) { cpu.io_port = try stdin.readByte(); //try stdout.print("{c}", .{@intCast(u8, cpu.io_port)}); //trace("wrting input to {s} = {s}\n", .{ cpu.name, cpu.io_port }); } if (cpu.io_mode == .output) { //trace("{s} outputs {s}\n", .{ cpu.name, cpu.io_port }); try stdout.writeByte(@intCast(u8, cpu.io_port)); } //trace("resuming {s}\n", .{cpu.name}); resume cpu.io_runframe; } } else { while (bfs.pop()) |node| { cpu.reboot(boot_image); trace("starting {s}\n", .{cpu.name}); _ = async cpu.run(); // replay commands // trace("applying commands: {s}\n", .{node.trace.commands[0..node.trace.len]}); { const commands = node.trace.commands[0..node.trace.len]; for (commands) |input| { assert(!cpu.is_halted()); while (cpu.io_mode != .input) { // drop output resume cpu.io_runframe; } cpu.io_port = input; resume cpu.io_runframe; } } // parse desc var room_index: ?usize = blk: { var room: Room = undefined; var desc: [1000]u8 = undefined; var out: usize = 0; while (true) { assert(!cpu.is_halted()); if (cpu.io_mode == .input) { break; } if (cpu.io_mode == .output) { desc[out] = @intCast(u8, cpu.io_port); out += 1; } resume cpu.io_runframe; } // trace("parsing desc: {s}\n", .{desc[0..out]}); room.desc = ""; room.doors = [_]bool{ false, false, false, false }; room.items = &[0][]u8{s}; room.pos = node.state.next_pos; var sec: enum { title, desc, doors, items, done, } = .title; var it = std.mem.tokenize(desc[0..out], "\n"); while (it.next()) |line0| { const line = std.mem.trim(u8, line0, " \n\r\t"); if (line.len == 0) continue; switch (sec) { .title => { if (std.mem.eql(u8, line[0..3], "== ")) { room.name = line[3 .. line.len - 3]; //try std.mem.dupe(allocator, u8, line[3 .. line.len - 3]); sec = .desc; } else { trace("Skipping: {s}\n", .{line}); trace("after commands: {s}\n", .{node.trace.commands[0..node.trace.len]}); unreachable; } }, .desc => { if (std.mem.eql(u8, line, "Doors here lead:")) { sec = .doors; } else { assert(room.desc.len == 0); room.desc = line; //try std.mem.dupe(allocator, u8, line); } }, .doors => { if (std.mem.eql(u8, line, "A loud, robotic voice says \"Alert! Droids on this ship are heavier than the detected value!\" and you are ejected back to the checkpoint.")) { sec = .done; break :blk null; } else if (std.mem.eql(u8, line, "Items here:")) { sec = .items; } else if (std.mem.eql(u8, line, "Command?")) { sec = .done; } else if (std.mem.eql(u8, line, "- north")) { room.doors[0] = true; } else if (std.mem.eql(u8, line, "- west")) { room.doors[1] = true; } else if (std.mem.eql(u8, line, "- south")) { room.doors[2] = true; } else if (std.mem.eql(u8, line, "- east")) { room.doors[3] = true; } else { trace("Skipping: {s}\n", .{line}); trace("after commands: {s}\n", .{node.trace.commands[0..node.trace.len]}); unreachable; } }, .items => { if (std.mem.eql(u8, line[0..2], "- ")) { //room.name = std.mem.dupe(u8, line[3..line.len-3]); //sec = .desc; } else if (std.mem.eql(u8, line, "Command?")) { sec = .done; } else { trace("Skipping: {s}\n", .{line}); trace("after commands: {s}\n", .{node.trace.commands[0..node.trace.len]}); unreachable; } }, .done => { trace("Skipping: {s}\n", .{line}); trace("after commands: {s}\n", .{node.trace.commands[0..node.trace.len]}); unreachable; }, } } trace("room= {s}\n", .{room}); for (rooms.items) |r, i| { if (std.mem.eql(u8, room.name, r.name)) { assert(room.pos.x == r.pos.x and room.pos.y == r.pos.y); assert(std.mem.eql(bool, &room.doors, &r.doors)); assert(std.mem.eql(u8, room.desc, r.desc)); break :blk i; } } const newroom = try rooms.addOne(); newroom.* = room; newroom.name = try std.mem.dupe(allocator, u8, room.name); newroom.desc = try std.mem.dupe(allocator, u8, room.desc); break :blk rooms.len - 1; }; if (room_index == null) // action erronée continue; // update map { const room = rooms.at(room_index.?); const p = room.pos; map.set(p, ' '); for (room.doors) |open, d| { const np = Vec2{ .x = p.x + dirs[d].x, .y = p.y + dirs[d].y }; var prev_val = map.get(np) orelse '#'; const new_val: u8 = if (open) '.' else '#'; if (prev_val == '#' or prev_val == new_val) { map.set(np, new_val); } else { map.set(np, '+'); } } var buf: [1000]u8 = undefined; trace("map=\n{s}\n", .{map.print_to_buf(p, null, &buf)}); } // insert new nodes: { const room = rooms.at(room_index.?); const p = room.pos; for (room.doors) |open, d| { if (!open) continue; var new = BFS.Node{ .cost = node.cost + 1, .rating = node.rating + 1, .state = State{ .room_index = room_index.?, .door = @intCast(u2, d), .next_pos = Vec2{ .x = p.x + dirs[d].x * 2, .y = p.y + dirs[d].y * 2 }, }, .trace = node.trace, }; std.mem.copy(u8, new.trace.commands[new.trace.len .. new.trace.len + cmds[d].len], cmds[d]); new.trace.commands[new.trace.len + cmds[d].len] = '\n'; new.trace.len += cmds[d].len + 1; try bfs.insert(new); } } } } }
2019/day25a.zig
const std = @import("std"); const clap = @import("clap"); const zlib = @import("zlib"); const Allocator = std.mem.Allocator; // It would be preferable to use .evented here, but std does not support evented file handling yet pub const io_mode = .blocking; pub fn main() anyerror!void { const std_out = std.io.getStdOut().writer(); const std_err = std.io.getStdErr().writer(); // First we specify what parameters our program can take. // We can use `parseParam` to parse a string to a `Param(Help)` const params = comptime [_]clap.Param(clap.Help){ clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, clap.parseParam("-f, --file <STR>... Paths to a file that should be corrected ") catch unreachable, clap.parseParam("-d, --directory <STR>... Paths to a directory that should be corrected ") catch unreachable, clap.parseParam("-o, --output <STR> Folder where fixed files should be stored ") catch unreachable, }; // Initalize our diagnostics, which can be used for reporting useful errors. // This is optional. You can also pass `.{}` to `clap.parse` if you don't // care about the extra information `Diagnostics` provides. var diag = clap.Diagnostic{}; var args = clap.parse(clap.Help, &params, .{ .diagnostic = &diag }) catch |err| { // Report useful error and exit diag.report(std_err, err) catch {}; return; }; defer args.deinit(); // Print help message if user requested it if (args.flag("--help")) { try clap.help( std_out, params[0..], ); return; } // Parse path variables const file_paths = args.options("--file"); const directory_paths = args.options("--directory"); if (file_paths.len <= 0 and directory_paths.len <= 0) { diag.arg = "file or directory"; diag.report(std_err, error.MissingValue) catch {}; return; } const destination = args.option("--output") orelse { diag.arg = "output"; diag.report(std_err, error.MissingValue) catch {}; return; }; // Use allocator capable of detecting memory leaks in debug const is_debug = std.builtin.mode == .Debug; var alloc_api = if(is_debug) std.heap.GeneralPurposeAllocator(.{}){} else std.heap.c_allocator; defer { if(is_debug) { const leak = alloc_api.deinit(); if (leak) { std_err.print("leak detected in gpa!", .{}) catch unreachable; } } } var allocator = if(is_debug) &alloc_api.allocator else alloc_api; var source_files = std.ArrayList([]const u8).initCapacity(allocator, file_paths.len) catch |err| { std_err.print("failed to initialize source path list, err: {any}", .{err}) catch {}; return; }; defer source_files.deinit(); try source_files.insertSlice(0, file_paths); for (directory_paths) |directory_path| { var directory = blk: { if (std.fs.path.isAbsolute(directory_path)) { break :blk std.fs.openDirAbsolute(directory_path, .{ .iterate = true, }) catch |err| { std_err.print("failed to open directory at {s}, err: {any}", .{directory_path, err}) catch {}; return; }; } break :blk std.fs.cwd().openDir(directory_path, .{ .iterate = true, }) catch |err| { std_err.print("failed to open directory at {s}, err: {any}", .{directory_path, err}) catch {}; return; }; }; defer directory.close(); var iter = directory.iterate(); while ((try iter.next())) |some| { if (some.kind != std.fs.File.Kind.File) { continue; } // Append all compressed warc files if (std.mem.indexOf(u8, some.name, ".warc.gz")) |_| { // TODO: MEMORY LEAK: this leaks memory, but does not really matter since lifetime should be static anyways const file_path = try std.fs.path.join(allocator, &[_][]const u8{directory_path, some.name}); try source_files.append(file_path); } } } var destination_dir = blk: { if (std.fs.path.isAbsolute(destination)) { break :blk std.fs.openDirAbsolute(destination, .{}) catch |err| { std_err.print("failed to open directory at {s}, err: {any}", .{destination, err}) catch {}; return; }; } break :blk std.fs.cwd().openDir(destination, .{}) catch |err| { std_err.print("failed to open directory at {s}, err: {any}", .{destination, err}) catch {}; return; }; }; defer destination_dir.close(); var fix_frames = try std.ArrayList(@Frame(fixWarcIP)).initCapacity(allocator, source_files.items.len); defer fix_frames.deinit(); for (source_files.items) |path| { const ctx = AsyncContext{ .allocator = allocator, .std_out = std_out, .std_err = std_err, .path = path, .destination_dir = destination_dir, }; var frame = async fixWarcIP(ctx); fix_frames.appendAssumeCapacity(frame); } for(fix_frames.items) |*frame| { await frame; } } const AsyncContext = struct { allocator: *Allocator, std_out: std.fs.File.Writer, std_err: std.fs.File.Writer, path: []const u8, destination_dir: std.fs.Dir, }; /// Opens a warc.gz file and removes port number from any IP in the WARC-IP-Address header fn fixWarcIP(ctx: AsyncContext) void { const pre_alloc_size = 4096 * 2 * 2 * 2 * 2; var file_read_buffer = std.ArrayList(u8).initCapacity(ctx.allocator, pre_alloc_size) catch |err| { ctx.std_err.print("failed to allocate read buffer, err: {any}", .{err}) catch {}; return; }; defer file_read_buffer.deinit(); var file_write_buffer = std.ArrayList(u8).initCapacity(ctx.allocator, pre_alloc_size) catch |err| { ctx.std_err.print("failed to allocate write buffer, err: {any}", .{err}) catch {}; return; }; defer file_write_buffer.deinit(); var destination_file = blk: { const file_name = std.fs.path.basename(ctx.path); break :blk ctx.destination_dir.createFile(file_name, .{}) catch |err| { ctx.std_err.print("failed to create destination file, err: {any}", .{err}) catch {}; return; }; }; defer destination_file.close(); var desintation_file_pos: u64 = 0; const source_file: std.fs.File = blk: { if (std.fs.path.isAbsolute(ctx.path)) { break :blk std.fs.openFileAbsolute(ctx.path, .{}) catch |err| { ctx.std_err.print("failed to open file at {s}, err: {any}", .{ctx.path, err}) catch {}; return; }; } break :blk std.fs.cwd().openFile(ctx.path, .{}) catch |err| { ctx.std_err.print("failed to open file at {s}, err: {any}", .{ctx.path, err}) catch {}; return; }; }; defer source_file.close(); var file_end_pos = source_file.getEndPos() catch |err| { ctx.std_err.print("failed to get file end pos {s}, err: {any}", .{ctx.path, err}) catch {}; return; }; var file_pos = source_file.getPos() catch |err| { ctx.std_err.print("failed to get file pos {s}, err: {any}", .{ctx.path, err}) catch {}; return; }; while (file_pos < file_end_pos) { var gzip_stream = std.compress.gzip.gzipStream(ctx.allocator, source_file.reader()) catch |err| { ctx.std_err.print("failed to init gzip stream at {s}, err: {any}", .{ctx.path, err}) catch {}; return; }; defer gzip_stream.deinit(); // read gzip_stream and move data into an array list var bytes_read: usize = 0; read_gzip: while (true) { file_read_buffer.items.len = file_read_buffer.capacity; const new_bytes_read = gzip_stream.read(file_read_buffer.items[bytes_read..]) catch |err| { ctx.std_err.print("failed to read gzip stream from file {s} at {d}, err: {any}", .{ ctx.path, file_pos + gzip_stream.read_amt, err }) catch {}; return; }; bytes_read += new_bytes_read; file_read_buffer.items.len = bytes_read; if (new_bytes_read <= 0) { break :read_gzip; } if (bytes_read >= file_read_buffer.capacity) { // increase buffer size file_read_buffer.ensureTotalCapacity(file_read_buffer.capacity * 2) catch |err| { ctx.std_err.print("failed to increase read buffer size to {d}, err: {any}", .{file_read_buffer.capacity * 2, err}) catch {}; return; }; file_write_buffer.ensureTotalCapacity(file_write_buffer.capacity * 2) catch |err| { ctx.std_err.print("failed to increase write buffer size to {d}, err: {any}", .{file_write_buffer.capacity * 2, err}) catch {}; return; }; } } // Search record for WARC-IP-Address and replace port with whitespace if it exist const needle = "WARC-IP-Address: "; var bytes_in_use = bytes_read; var needle_search_start: usize = 0; header_search: while (std.mem.indexOf(u8, file_read_buffer.items[needle_search_start..bytes_in_use], needle)) |index| { if (index == 0) { break :header_search; } const SearchState = enum { IP, Port }; var state = SearchState.IP; // skip "WARC-IP-Address: " from port search const ip_start_index = index + needle.len; var i: usize = 0; port_search: while(file_read_buffer.items[ip_start_index+i] != '\n' and file_read_buffer.items[ip_start_index+i] != '\r') : (i += 1) { if (file_read_buffer.items[ip_start_index+i] == ':') { state = SearchState.Port; break :port_search; } } // replace port in buffer to whitespace if it exist if (state == SearchState.Port) { const port_start_index = ip_start_index + i; // find range between port begining and newline character const new_line_offset = std.mem.indexOf(u8, file_read_buffer.items[port_start_index..], "\n") orelse file_read_buffer.items.len; const carriage_return_offset = std.mem.indexOf(u8, file_read_buffer.items[port_start_index..], "\r") orelse file_read_buffer.items.len; const min_offset = std.math.min(new_line_offset, carriage_return_offset); // shift the whole buffer to replace port characters, a slow operation :( std.mem.copy(u8, file_read_buffer.items[port_start_index..], file_read_buffer.items[port_start_index+min_offset..]); // remove discared bytes from the program state file_read_buffer.items.len -= min_offset; bytes_in_use -= min_offset; } needle_search_start = ip_start_index + i + 1; } file_write_buffer.items.len = file_write_buffer.capacity; const bytes_compressed = zlib.compressGzip(file_read_buffer.items, file_write_buffer.items) catch |err| { ctx.std_err.print("failed to compress, err: {any}", .{err}) catch {}; return; }; file_write_buffer.items.len = bytes_compressed; // we allocate as much in the compressed buffer as uncompressed buffer, // if this assert fails it means that the compressed data is larger than the original data std.debug.assert(bytes_compressed < file_write_buffer.capacity); // Write to the new file with the corrected buffer const bytes_written = destination_file.pwrite(file_write_buffer.items, desintation_file_pos) catch |err| { ctx.std_err.print("failed to write to destination file at {d}, err: {any}", .{desintation_file_pos, err}) catch {}; return; }; desintation_file_pos += bytes_written; file_pos = source_file.getPos() catch |err| { ctx.std_err.print("failed to get file pos {s}, err: {any}", .{ctx.path, err}) catch {}; return; }; } }
src/main.zig
pub const PRLT = @as(u32, 0); pub const PRLE = @as(u32, 1); pub const PRGT = @as(u32, 2); pub const PRGE = @as(u32, 3); pub const PREQ = @as(u32, 4); pub const PRNE = @as(u32, 5); pub const QUERY_SORTASCEND = @as(u32, 0); pub const QUERY_SORTDESCEND = @as(u32, 1); pub const MQ_MOVE_ACCESS = @as(u32, 4); pub const MQ_ACTION_RECEIVE = @as(u32, 0); pub const MQ_ACTION_PEEK_CURRENT = @as(u32, 2147483648); pub const MQ_ACTION_PEEK_NEXT = @as(u32, 2147483649); pub const MQ_LOOKUP_PEEK_CURRENT = @as(u32, 1073741840); pub const MQ_LOOKUP_PEEK_NEXT = @as(u32, 1073741841); pub const MQ_LOOKUP_PEEK_PREV = @as(u32, 1073741842); pub const MQ_LOOKUP_PEEK_FIRST = @as(u32, 1073741844); pub const MQ_LOOKUP_PEEK_LAST = @as(u32, 1073741848); pub const MQ_LOOKUP_RECEIVE_CURRENT = @as(u32, 1073741856); pub const MQ_LOOKUP_RECEIVE_NEXT = @as(u32, 1073741857); pub const MQ_LOOKUP_RECEIVE_PREV = @as(u32, 1073741858); pub const MQ_LOOKUP_RECEIVE_FIRST = @as(u32, 1073741860); pub const MQ_LOOKUP_RECEIVE_LAST = @as(u32, 1073741864); pub const MQ_LOOKUP_RECEIVE_ALLOW_PEEK = @as(u32, 1073742112); pub const PROPID_M_BASE = @as(u32, 0); pub const PROPID_M_CLASS = @as(u32, 1); pub const PROPID_M_MSGID = @as(u32, 2); pub const PROPID_M_CORRELATIONID = @as(u32, 3); pub const PROPID_M_PRIORITY = @as(u32, 4); pub const PROPID_M_DELIVERY = @as(u32, 5); pub const PROPID_M_ACKNOWLEDGE = @as(u32, 6); pub const PROPID_M_JOURNAL = @as(u32, 7); pub const PROPID_M_APPSPECIFIC = @as(u32, 8); pub const PROPID_M_BODY = @as(u32, 9); pub const PROPID_M_BODY_SIZE = @as(u32, 10); pub const PROPID_M_LABEL = @as(u32, 11); pub const PROPID_M_LABEL_LEN = @as(u32, 12); pub const PROPID_M_TIME_TO_REACH_QUEUE = @as(u32, 13); pub const PROPID_M_TIME_TO_BE_RECEIVED = @as(u32, 14); pub const PROPID_M_RESP_QUEUE = @as(u32, 15); pub const PROPID_M_RESP_QUEUE_LEN = @as(u32, 16); pub const PROPID_M_ADMIN_QUEUE = @as(u32, 17); pub const PROPID_M_ADMIN_QUEUE_LEN = @as(u32, 18); pub const PROPID_M_VERSION = @as(u32, 19); pub const PROPID_M_SENDERID = @as(u32, 20); pub const PROPID_M_SENDERID_LEN = @as(u32, 21); pub const PROPID_M_SENDERID_TYPE = @as(u32, 22); pub const PROPID_M_PRIV_LEVEL = @as(u32, 23); pub const PROPID_M_AUTH_LEVEL = @as(u32, 24); pub const PROPID_M_AUTHENTICATED = @as(u32, 25); pub const PROPID_M_HASH_ALG = @as(u32, 26); pub const PROPID_M_ENCRYPTION_ALG = @as(u32, 27); pub const PROPID_M_SENDER_CERT = @as(u32, 28); pub const PROPID_M_SENDER_CERT_LEN = @as(u32, 29); pub const PROPID_M_SRC_MACHINE_ID = @as(u32, 30); pub const PROPID_M_SENTTIME = @as(u32, 31); pub const PROPID_M_ARRIVEDTIME = @as(u32, 32); pub const PROPID_M_DEST_QUEUE = @as(u32, 33); pub const PROPID_M_DEST_QUEUE_LEN = @as(u32, 34); pub const PROPID_M_EXTENSION = @as(u32, 35); pub const PROPID_M_EXTENSION_LEN = @as(u32, 36); pub const PROPID_M_SECURITY_CONTEXT = @as(u32, 37); pub const PROPID_M_CONNECTOR_TYPE = @as(u32, 38); pub const PROPID_M_XACT_STATUS_QUEUE = @as(u32, 39); pub const PROPID_M_XACT_STATUS_QUEUE_LEN = @as(u32, 40); pub const PROPID_M_TRACE = @as(u32, 41); pub const PROPID_M_BODY_TYPE = @as(u32, 42); pub const PROPID_M_DEST_SYMM_KEY = @as(u32, 43); pub const PROPID_M_DEST_SYMM_KEY_LEN = @as(u32, 44); pub const PROPID_M_SIGNATURE = @as(u32, 45); pub const PROPID_M_SIGNATURE_LEN = @as(u32, 46); pub const PROPID_M_PROV_TYPE = @as(u32, 47); pub const PROPID_M_PROV_NAME = @as(u32, 48); pub const PROPID_M_PROV_NAME_LEN = @as(u32, 49); pub const PROPID_M_FIRST_IN_XACT = @as(u32, 50); pub const PROPID_M_LAST_IN_XACT = @as(u32, 51); pub const PROPID_M_XACTID = @as(u32, 52); pub const PROPID_M_AUTHENTICATED_EX = @as(u32, 53); pub const PROPID_M_RESP_FORMAT_NAME = @as(u32, 54); pub const PROPID_M_RESP_FORMAT_NAME_LEN = @as(u32, 55); pub const PROPID_M_DEST_FORMAT_NAME = @as(u32, 58); pub const PROPID_M_DEST_FORMAT_NAME_LEN = @as(u32, 59); pub const PROPID_M_LOOKUPID = @as(u32, 60); pub const PROPID_M_SOAP_ENVELOPE = @as(u32, 61); pub const PROPID_M_SOAP_ENVELOPE_LEN = @as(u32, 62); pub const PROPID_M_COMPOUND_MESSAGE = @as(u32, 63); pub const PROPID_M_COMPOUND_MESSAGE_SIZE = @as(u32, 64); pub const PROPID_M_SOAP_HEADER = @as(u32, 65); pub const PROPID_M_SOAP_BODY = @as(u32, 66); pub const PROPID_M_DEADLETTER_QUEUE = @as(u32, 67); pub const PROPID_M_DEADLETTER_QUEUE_LEN = @as(u32, 68); pub const PROPID_M_ABORT_COUNT = @as(u32, 69); pub const PROPID_M_MOVE_COUNT = @as(u32, 70); pub const PROPID_M_LAST_MOVE_TIME = @as(u32, 75); pub const PROPID_M_MSGID_SIZE = @as(u32, 20); pub const PROPID_M_CORRELATIONID_SIZE = @as(u32, 20); pub const PROPID_M_XACTID_SIZE = @as(u32, 20); pub const MQMSG_PRIV_LEVEL_BODY_AES = @as(u32, 5); pub const MQMSG_AUTHENTICATED_QM_MESSAGE = @as(u32, 11); pub const MQMSG_NOT_FIRST_IN_XACT = @as(u32, 0); pub const MQMSG_FIRST_IN_XACT = @as(u32, 1); pub const MQMSG_NOT_LAST_IN_XACT = @as(u32, 0); pub const MQMSG_LAST_IN_XACT = @as(u32, 1); pub const PROPID_Q_BASE = @as(u32, 100); pub const PROPID_Q_INSTANCE = @as(u32, 101); pub const PROPID_Q_TYPE = @as(u32, 102); pub const PROPID_Q_PATHNAME = @as(u32, 103); pub const PROPID_Q_JOURNAL = @as(u32, 104); pub const PROPID_Q_QUOTA = @as(u32, 105); pub const PROPID_Q_BASEPRIORITY = @as(u32, 106); pub const PROPID_Q_JOURNAL_QUOTA = @as(u32, 107); pub const PROPID_Q_LABEL = @as(u32, 108); pub const PROPID_Q_CREATE_TIME = @as(u32, 109); pub const PROPID_Q_MODIFY_TIME = @as(u32, 110); pub const PROPID_Q_AUTHENTICATE = @as(u32, 111); pub const PROPID_Q_PRIV_LEVEL = @as(u32, 112); pub const PROPID_Q_TRANSACTION = @as(u32, 113); pub const PROPID_Q_PATHNAME_DNS = @as(u32, 124); pub const PROPID_Q_MULTICAST_ADDRESS = @as(u32, 125); pub const PROPID_Q_ADS_PATH = @as(u32, 126); pub const PROPID_QM_BASE = @as(u32, 200); pub const PROPID_QM_SITE_ID = @as(u32, 201); pub const PROPID_QM_MACHINE_ID = @as(u32, 202); pub const PROPID_QM_PATHNAME = @as(u32, 203); pub const PROPID_QM_CONNECTION = @as(u32, 204); pub const PROPID_QM_ENCRYPTION_PK = @as(u32, 205); pub const PROPID_QM_ENCRYPTION_PK_BASE = @as(u32, 231); pub const PROPID_QM_ENCRYPTION_PK_ENHANCED = @as(u32, 232); pub const PROPID_QM_PATHNAME_DNS = @as(u32, 233); pub const PROPID_QM_ENCRYPTION_PK_AES = @as(u32, 244); pub const PROPID_PC_BASE = @as(u32, 5800); pub const PROPID_PC_VERSION = @as(u32, 5801); pub const PROPID_PC_DS_ENABLED = @as(u32, 5802); pub const PROPID_MGMT_MSMQ_BASE = @as(u32, 0); pub const PROPID_MGMT_MSMQ_ACTIVEQUEUES = @as(u32, 1); pub const PROPID_MGMT_MSMQ_PRIVATEQ = @as(u32, 2); pub const PROPID_MGMT_MSMQ_DSSERVER = @as(u32, 3); pub const PROPID_MGMT_MSMQ_CONNECTED = @as(u32, 4); pub const PROPID_MGMT_MSMQ_TYPE = @as(u32, 5); pub const PROPID_MGMT_MSMQ_BYTES_IN_ALL_QUEUES = @as(u32, 6); pub const PROPID_MGMT_QUEUE_BASE = @as(u32, 0); pub const PROPID_MGMT_QUEUE_PATHNAME = @as(u32, 1); pub const PROPID_MGMT_QUEUE_FORMATNAME = @as(u32, 2); pub const PROPID_MGMT_QUEUE_TYPE = @as(u32, 3); pub const PROPID_MGMT_QUEUE_LOCATION = @as(u32, 4); pub const PROPID_MGMT_QUEUE_XACT = @as(u32, 5); pub const PROPID_MGMT_QUEUE_FOREIGN = @as(u32, 6); pub const PROPID_MGMT_QUEUE_MESSAGE_COUNT = @as(u32, 7); pub const PROPID_MGMT_QUEUE_BYTES_IN_QUEUE = @as(u32, 8); pub const PROPID_MGMT_QUEUE_JOURNAL_MESSAGE_COUNT = @as(u32, 9); pub const PROPID_MGMT_QUEUE_BYTES_IN_JOURNAL = @as(u32, 10); pub const PROPID_MGMT_QUEUE_STATE = @as(u32, 11); pub const PROPID_MGMT_QUEUE_NEXTHOPS = @as(u32, 12); pub const PROPID_MGMT_QUEUE_EOD_LAST_ACK = @as(u32, 13); pub const PROPID_MGMT_QUEUE_EOD_LAST_ACK_TIME = @as(u32, 14); pub const PROPID_MGMT_QUEUE_EOD_LAST_ACK_COUNT = @as(u32, 15); pub const PROPID_MGMT_QUEUE_EOD_FIRST_NON_ACK = @as(u32, 16); pub const PROPID_MGMT_QUEUE_EOD_LAST_NON_ACK = @as(u32, 17); pub const PROPID_MGMT_QUEUE_EOD_NEXT_SEQ = @as(u32, 18); pub const PROPID_MGMT_QUEUE_EOD_NO_READ_COUNT = @as(u32, 19); pub const PROPID_MGMT_QUEUE_EOD_NO_ACK_COUNT = @as(u32, 20); pub const PROPID_MGMT_QUEUE_EOD_RESEND_TIME = @as(u32, 21); pub const PROPID_MGMT_QUEUE_EOD_RESEND_INTERVAL = @as(u32, 22); pub const PROPID_MGMT_QUEUE_EOD_RESEND_COUNT = @as(u32, 23); pub const PROPID_MGMT_QUEUE_EOD_SOURCE_INFO = @as(u32, 24); pub const PROPID_MGMT_QUEUE_CONNECTION_HISTORY = @as(u32, 25); pub const PROPID_MGMT_QUEUE_SUBQUEUE_COUNT = @as(u32, 26); pub const PROPID_MGMT_QUEUE_SUBQUEUE_NAMES = @as(u32, 27); pub const PROPID_MGMT_QUEUE_USED_QUOTA = @as(u32, 8); pub const PROPID_MGMT_QUEUE_JOURNAL_USED_QUOTA = @as(u32, 10); pub const LONG_LIVED = @as(u32, 4294967294); pub const MQSEC_DELETE_MESSAGE = @as(u32, 1); pub const MQSEC_PEEK_MESSAGE = @as(u32, 2); pub const MQSEC_WRITE_MESSAGE = @as(u32, 4); pub const MQSEC_DELETE_JOURNAL_MESSAGE = @as(u32, 8); pub const MQSEC_SET_QUEUE_PROPERTIES = @as(u32, 16); pub const MQSEC_GET_QUEUE_PROPERTIES = @as(u32, 32); pub const MQSEC_DELETE_QUEUE = @as(u32, 65536); pub const MQSEC_CHANGE_QUEUE_PERMISSIONS = @as(u32, 262144); pub const MQSEC_TAKE_QUEUE_OWNERSHIP = @as(u32, 524288); pub const MQSEC_QUEUE_GENERIC_EXECUTE = @as(u32, 0); pub const MQ_OK = @import("../zig.zig").typedConst(HRESULT, @as(i32, 0)); pub const MQ_ERROR_RESOLVE_ADDRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -1072824167)); pub const MQ_ERROR_TOO_MANY_PROPERTIES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -1072824166)); pub const MQ_ERROR_MESSAGE_NOT_AUTHENTICATED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -1072824165)); pub const MQ_ERROR_MESSAGE_LOCKED_UNDER_TRANSACTION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -1072824164)); //-------------------------------------------------------------------------------- // Section: Types (89) //-------------------------------------------------------------------------------- const CLSID_MSMQQuery_Value = @import("../zig.zig").Guid.initString("d7d6e073-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQQuery = &CLSID_MSMQQuery_Value; const CLSID_MSMQMessage_Value = @import("../zig.zig").Guid.initString("d7d6e075-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQMessage = &CLSID_MSMQMessage_Value; const CLSID_MSMQQueue_Value = @import("../zig.zig").Guid.initString("d7d6e079-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQQueue = &CLSID_MSMQQueue_Value; const CLSID_MSMQEvent_Value = @import("../zig.zig").Guid.initString("d7d6e07a-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQEvent = &CLSID_MSMQEvent_Value; const CLSID_MSMQQueueInfo_Value = @import("../zig.zig").Guid.initString("d7d6e07c-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQQueueInfo = &CLSID_MSMQQueueInfo_Value; const CLSID_MSMQQueueInfos_Value = @import("../zig.zig").Guid.initString("d7d6e07e-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQQueueInfos = &CLSID_MSMQQueueInfos_Value; const CLSID_MSMQTransaction_Value = @import("../zig.zig").Guid.initString("d7d6e080-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQTransaction = &CLSID_MSMQTransaction_Value; const CLSID_MSMQCoordinatedTransactionDispenser_Value = @import("../zig.zig").Guid.initString("d7d6e082-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQCoordinatedTransactionDispenser = &CLSID_MSMQCoordinatedTransactionDispenser_Value; const CLSID_MSMQTransactionDispenser_Value = @import("../zig.zig").Guid.initString("d7d6e084-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQTransactionDispenser = &CLSID_MSMQTransactionDispenser_Value; const CLSID_MSMQApplication_Value = @import("../zig.zig").Guid.initString("d7d6e086-dccd-11d0-aa4b-0060970debae"); pub const CLSID_MSMQApplication = &CLSID_MSMQApplication_Value; const CLSID_MSMQDestination_Value = @import("../zig.zig").Guid.initString("eba96b18-2168-11d3-898c-00e02c074f6b"); pub const CLSID_MSMQDestination = &CLSID_MSMQDestination_Value; const CLSID_MSMQCollection_Value = @import("../zig.zig").Guid.initString("f72b9031-2f0c-43e8-924e-e6052cdc493f"); pub const CLSID_MSMQCollection = &CLSID_MSMQCollection_Value; const CLSID_MSMQManagement_Value = @import("../zig.zig").Guid.initString("39ce96fe-f4c5-4484-a143-4c2d5d324229"); pub const CLSID_MSMQManagement = &CLSID_MSMQManagement_Value; const CLSID_MSMQOutgoingQueueManagement_Value = @import("../zig.zig").Guid.initString("0188401c-247a-4fed-99c6-bf14119d7055"); pub const CLSID_MSMQOutgoingQueueManagement = &CLSID_MSMQOutgoingQueueManagement_Value; const CLSID_MSMQQueueManagement_Value = @import("../zig.zig").Guid.initString("33b6d07e-f27d-42fa-b2d7-bf82e11e9374"); pub const CLSID_MSMQQueueManagement = &CLSID_MSMQQueueManagement_Value; pub const MQCALG = enum(i32) { MD2 = 32769, MD4 = 32770, MD5 = 32771, SHA = 32772, // SHA1 = 32772, this enum value conflicts with SHA MAC = 32773, RSA_SIGN = 9216, DSS_SIGN = 8704, RSA_KEYX = 41984, DES = 26113, RC2 = 26114, RC4 = 26625, SEAL = 26626, }; pub const MQMSG_CALG_MD2 = MQCALG.MD2; pub const MQMSG_CALG_MD4 = MQCALG.MD4; pub const MQMSG_CALG_MD5 = MQCALG.MD5; pub const MQMSG_CALG_SHA = MQCALG.SHA; pub const MQMSG_CALG_SHA1 = MQCALG.SHA; pub const MQMSG_CALG_MAC = MQCALG.MAC; pub const MQMSG_CALG_RSA_SIGN = MQCALG.RSA_SIGN; pub const MQMSG_CALG_DSS_SIGN = MQCALG.DSS_SIGN; pub const MQMSG_CALG_RSA_KEYX = MQCALG.RSA_KEYX; pub const MQMSG_CALG_DES = MQCALG.DES; pub const MQMSG_CALG_RC2 = MQCALG.RC2; pub const MQMSG_CALG_RC4 = MQCALG.RC4; pub const MQMSG_CALG_SEAL = MQCALG.SEAL; pub const MQTRANSACTION = enum(i32) { NO_TRANSACTION = 0, MTS_TRANSACTION = 1, XA_TRANSACTION = 2, SINGLE_MESSAGE = 3, }; pub const MQ_NO_TRANSACTION = MQTRANSACTION.NO_TRANSACTION; pub const MQ_MTS_TRANSACTION = MQTRANSACTION.MTS_TRANSACTION; pub const MQ_XA_TRANSACTION = MQTRANSACTION.XA_TRANSACTION; pub const MQ_SINGLE_MESSAGE = MQTRANSACTION.SINGLE_MESSAGE; pub const RELOPS = enum(i32) { NOP = 0, EQ = 1, NEQ = 2, LT = 3, GT = 4, LE = 5, GE = 6, }; pub const REL_NOP = RELOPS.NOP; pub const REL_EQ = RELOPS.EQ; pub const REL_NEQ = RELOPS.NEQ; pub const REL_LT = RELOPS.LT; pub const REL_GT = RELOPS.GT; pub const REL_LE = RELOPS.LE; pub const REL_GE = RELOPS.GE; pub const MQCERT_REGISTER = enum(i32) { ALWAYS = 1, IF_NOT_EXIST = 2, }; pub const MQCERT_REGISTER_ALWAYS = MQCERT_REGISTER.ALWAYS; pub const MQCERT_REGISTER_IF_NOT_EXIST = MQCERT_REGISTER.IF_NOT_EXIST; pub const MQMSGCURSOR = enum(i32) { FIRST = 0, CURRENT = 1, NEXT = 2, }; pub const MQMSG_FIRST = MQMSGCURSOR.FIRST; pub const MQMSG_CURRENT = MQMSGCURSOR.CURRENT; pub const MQMSG_NEXT = MQMSGCURSOR.NEXT; pub const MQMSGCLASS = enum(i32) { NORMAL = 0, REPORT = 1, ACK_REACH_QUEUE = 2, ACK_RECEIVE = 16384, NACK_BAD_DST_Q = 32768, NACK_PURGED = 32769, NACK_REACH_QUEUE_TIMEOUT = 32770, NACK_Q_EXCEED_QUOTA = 32771, NACK_ACCESS_DENIED = 32772, NACK_HOP_COUNT_EXCEEDED = 32773, NACK_BAD_SIGNATURE = 32774, NACK_BAD_ENCRYPTION = 32775, NACK_COULD_NOT_ENCRYPT = 32776, NACK_NOT_TRANSACTIONAL_Q = 32777, NACK_NOT_TRANSACTIONAL_MSG = 32778, NACK_UNSUPPORTED_CRYPTO_PROVIDER = 32779, NACK_SOURCE_COMPUTER_GUID_CHANGED = 32780, NACK_Q_DELETED = 49152, NACK_Q_PURGED = 49153, NACK_RECEIVE_TIMEOUT = 49154, NACK_RECEIVE_TIMEOUT_AT_SENDER = 49155, }; pub const MQMSG_CLASS_NORMAL = MQMSGCLASS.NORMAL; pub const MQMSG_CLASS_REPORT = MQMSGCLASS.REPORT; pub const MQMSG_CLASS_ACK_REACH_QUEUE = MQMSGCLASS.ACK_REACH_QUEUE; pub const MQMSG_CLASS_ACK_RECEIVE = MQMSGCLASS.ACK_RECEIVE; pub const MQMSG_CLASS_NACK_BAD_DST_Q = MQMSGCLASS.NACK_BAD_DST_Q; pub const MQMSG_CLASS_NACK_PURGED = MQMSGCLASS.NACK_PURGED; pub const MQMSG_CLASS_NACK_REACH_QUEUE_TIMEOUT = MQMSGCLASS.NACK_REACH_QUEUE_TIMEOUT; pub const MQMSG_CLASS_NACK_Q_EXCEED_QUOTA = MQMSGCLASS.NACK_Q_EXCEED_QUOTA; pub const MQMSG_CLASS_NACK_ACCESS_DENIED = MQMSGCLASS.NACK_ACCESS_DENIED; pub const MQMSG_CLASS_NACK_HOP_COUNT_EXCEEDED = MQMSGCLASS.NACK_HOP_COUNT_EXCEEDED; pub const MQMSG_CLASS_NACK_BAD_SIGNATURE = MQMSGCLASS.NACK_BAD_SIGNATURE; pub const MQMSG_CLASS_NACK_BAD_ENCRYPTION = MQMSGCLASS.NACK_BAD_ENCRYPTION; pub const MQMSG_CLASS_NACK_COULD_NOT_ENCRYPT = MQMSGCLASS.NACK_COULD_NOT_ENCRYPT; pub const MQMSG_CLASS_NACK_NOT_TRANSACTIONAL_Q = MQMSGCLASS.NACK_NOT_TRANSACTIONAL_Q; pub const MQMSG_CLASS_NACK_NOT_TRANSACTIONAL_MSG = MQMSGCLASS.NACK_NOT_TRANSACTIONAL_MSG; pub const MQMSG_CLASS_NACK_UNSUPPORTED_CRYPTO_PROVIDER = MQMSGCLASS.NACK_UNSUPPORTED_CRYPTO_PROVIDER; pub const MQMSG_CLASS_NACK_SOURCE_COMPUTER_GUID_CHANGED = MQMSGCLASS.NACK_SOURCE_COMPUTER_GUID_CHANGED; pub const MQMSG_CLASS_NACK_Q_DELETED = MQMSGCLASS.NACK_Q_DELETED; pub const MQMSG_CLASS_NACK_Q_PURGED = MQMSGCLASS.NACK_Q_PURGED; pub const MQMSG_CLASS_NACK_RECEIVE_TIMEOUT = MQMSGCLASS.NACK_RECEIVE_TIMEOUT; pub const MQMSG_CLASS_NACK_RECEIVE_TIMEOUT_AT_SENDER = MQMSGCLASS.NACK_RECEIVE_TIMEOUT_AT_SENDER; pub const MQMSGDELIVERY = enum(i32) { EXPRESS = 0, RECOVERABLE = 1, }; pub const MQMSG_DELIVERY_EXPRESS = MQMSGDELIVERY.EXPRESS; pub const MQMSG_DELIVERY_RECOVERABLE = MQMSGDELIVERY.RECOVERABLE; pub const MQMSGACKNOWLEDGEMENT = enum(i32) { NONE = 0, POS_ARRIVAL = 1, POS_RECEIVE = 2, NEG_ARRIVAL = 4, NEG_RECEIVE = 8, // NACK_REACH_QUEUE = 4, this enum value conflicts with NEG_ARRIVAL FULL_REACH_QUEUE = 5, NACK_RECEIVE = 12, FULL_RECEIVE = 14, }; pub const MQMSG_ACKNOWLEDGMENT_NONE = MQMSGACKNOWLEDGEMENT.NONE; pub const MQMSG_ACKNOWLEDGMENT_POS_ARRIVAL = MQMSGACKNOWLEDGEMENT.POS_ARRIVAL; pub const MQMSG_ACKNOWLEDGMENT_POS_RECEIVE = MQMSGACKNOWLEDGEMENT.POS_RECEIVE; pub const MQMSG_ACKNOWLEDGMENT_NEG_ARRIVAL = MQMSGACKNOWLEDGEMENT.NEG_ARRIVAL; pub const MQMSG_ACKNOWLEDGMENT_NEG_RECEIVE = MQMSGACKNOWLEDGEMENT.NEG_RECEIVE; pub const MQMSG_ACKNOWLEDGMENT_NACK_REACH_QUEUE = MQMSGACKNOWLEDGEMENT.NEG_ARRIVAL; pub const MQMSG_ACKNOWLEDGMENT_FULL_REACH_QUEUE = MQMSGACKNOWLEDGEMENT.FULL_REACH_QUEUE; pub const MQMSG_ACKNOWLEDGMENT_NACK_RECEIVE = MQMSGACKNOWLEDGEMENT.NACK_RECEIVE; pub const MQMSG_ACKNOWLEDGMENT_FULL_RECEIVE = MQMSGACKNOWLEDGEMENT.FULL_RECEIVE; pub const MQMSGJOURNAL = enum(i32) { JOURNAL_NONE = 0, DEADLETTER = 1, JOURNAL = 2, }; pub const MQMSG_JOURNAL_NONE = MQMSGJOURNAL.JOURNAL_NONE; pub const MQMSG_DEADLETTER = MQMSGJOURNAL.DEADLETTER; pub const MQMSG_JOURNAL = MQMSGJOURNAL.JOURNAL; pub const MQMSGTRACE = enum(i32) { TRACE_NONE = 0, SEND_ROUTE_TO_REPORT_QUEUE = 1, }; pub const MQMSG_TRACE_NONE = MQMSGTRACE.TRACE_NONE; pub const MQMSG_SEND_ROUTE_TO_REPORT_QUEUE = MQMSGTRACE.SEND_ROUTE_TO_REPORT_QUEUE; pub const MQMSGSENDERIDTYPE = enum(i32) { NONE = 0, SID = 1, }; pub const MQMSG_SENDERID_TYPE_NONE = MQMSGSENDERIDTYPE.NONE; pub const MQMSG_SENDERID_TYPE_SID = MQMSGSENDERIDTYPE.SID; pub const MQMSGPRIVLEVEL = enum(i32) { NONE = 0, BODY_BASE = 1, BODY_ENHANCED = 3, }; pub const MQMSG_PRIV_LEVEL_NONE = MQMSGPRIVLEVEL.NONE; pub const MQMSG_PRIV_LEVEL_BODY_BASE = MQMSGPRIVLEVEL.BODY_BASE; pub const MQMSG_PRIV_LEVEL_BODY_ENHANCED = MQMSGPRIVLEVEL.BODY_ENHANCED; pub const MQMSGAUTHLEVEL = enum(i32) { NONE = 0, ALWAYS = 1, MSMQ10 = 2, // SIG10 = 2, this enum value conflicts with MSMQ10 MSMQ20 = 4, // SIG20 = 4, this enum value conflicts with MSMQ20 SIG30 = 8, }; pub const MQMSG_AUTH_LEVEL_NONE = MQMSGAUTHLEVEL.NONE; pub const MQMSG_AUTH_LEVEL_ALWAYS = MQMSGAUTHLEVEL.ALWAYS; pub const MQMSG_AUTH_LEVEL_MSMQ10 = MQMSGAUTHLEVEL.MSMQ10; pub const MQMSG_AUTH_LEVEL_SIG10 = MQMSGAUTHLEVEL.MSMQ10; pub const MQMSG_AUTH_LEVEL_MSMQ20 = MQMSGAUTHLEVEL.MSMQ20; pub const MQMSG_AUTH_LEVEL_SIG20 = MQMSGAUTHLEVEL.MSMQ20; pub const MQMSG_AUTH_LEVEL_SIG30 = MQMSGAUTHLEVEL.SIG30; pub const MQMSGIDSIZE = enum(i32) { MSGID_SIZE = 20, // CORRELATIONID_SIZE = 20, this enum value conflicts with MSGID_SIZE // XACTID_SIZE = 20, this enum value conflicts with MSGID_SIZE }; pub const MQMSG_MSGID_SIZE = MQMSGIDSIZE.MSGID_SIZE; pub const MQMSG_CORRELATIONID_SIZE = MQMSGIDSIZE.MSGID_SIZE; pub const MQMSG_XACTID_SIZE = MQMSGIDSIZE.MSGID_SIZE; pub const MQMSGMAX = enum(i32) { N = 249, }; pub const MQ_MAX_MSG_LABEL_LEN = MQMSGMAX.N; pub const MQMSGAUTHENTICATION = enum(i32) { ION_NOT_REQUESTED = 0, ION_REQUESTED = 1, // ED_SIG10 = 1, this enum value conflicts with ION_REQUESTED ION_REQUESTED_EX = 3, // ED_SIG20 = 3, this enum value conflicts with ION_REQUESTED_EX ED_SIG30 = 5, ED_SIGXML = 9, }; pub const MQMSG_AUTHENTICATION_NOT_REQUESTED = MQMSGAUTHENTICATION.ION_NOT_REQUESTED; pub const MQMSG_AUTHENTICATION_REQUESTED = MQMSGAUTHENTICATION.ION_REQUESTED; pub const MQMSG_AUTHENTICATED_SIG10 = MQMSGAUTHENTICATION.ION_REQUESTED; pub const MQMSG_AUTHENTICATION_REQUESTED_EX = MQMSGAUTHENTICATION.ION_REQUESTED_EX; pub const MQMSG_AUTHENTICATED_SIG20 = MQMSGAUTHENTICATION.ION_REQUESTED_EX; pub const MQMSG_AUTHENTICATED_SIG30 = MQMSGAUTHENTICATION.ED_SIG30; pub const MQMSG_AUTHENTICATED_SIGXML = MQMSGAUTHENTICATION.ED_SIGXML; pub const MQSHARE = enum(i32) { NONE = 0, RECEIVE_SHARE = 1, }; pub const MQ_DENY_NONE = MQSHARE.NONE; pub const MQ_DENY_RECEIVE_SHARE = MQSHARE.RECEIVE_SHARE; pub const MQACCESS = enum(i32) { RECEIVE_ACCESS = 1, SEND_ACCESS = 2, PEEK_ACCESS = 32, ADMIN_ACCESS = 128, }; pub const MQ_RECEIVE_ACCESS = MQACCESS.RECEIVE_ACCESS; pub const MQ_SEND_ACCESS = MQACCESS.SEND_ACCESS; pub const MQ_PEEK_ACCESS = MQACCESS.PEEK_ACCESS; pub const MQ_ADMIN_ACCESS = MQACCESS.ADMIN_ACCESS; pub const MQJOURNAL = enum(i32) { _NONE = 0, L = 1, }; pub const MQ_JOURNAL_NONE = MQJOURNAL._NONE; pub const MQ_JOURNAL = MQJOURNAL.L; pub const MQTRANSACTIONAL = enum(i32) { _NONE = 0, L = 1, }; pub const MQ_TRANSACTIONAL_NONE = MQTRANSACTIONAL._NONE; pub const MQ_TRANSACTIONAL = MQTRANSACTIONAL.L; pub const MQAUTHENTICATE = enum(i32) { _NONE = 0, E = 1, }; pub const MQ_AUTHENTICATE_NONE = MQAUTHENTICATE._NONE; pub const MQ_AUTHENTICATE = MQAUTHENTICATE.E; pub const MQPRIVLEVEL = enum(i32) { NONE = 0, OPTIONAL = 1, BODY = 2, }; pub const MQ_PRIV_LEVEL_NONE = MQPRIVLEVEL.NONE; pub const MQ_PRIV_LEVEL_OPTIONAL = MQPRIVLEVEL.OPTIONAL; pub const MQ_PRIV_LEVEL_BODY = MQPRIVLEVEL.BODY; pub const MQPRIORITY = enum(i32) { IN_PRIORITY = 0, AX_PRIORITY = 7, }; pub const MQ_MIN_PRIORITY = MQPRIORITY.IN_PRIORITY; pub const MQ_MAX_PRIORITY = MQPRIORITY.AX_PRIORITY; pub const MQMAX = enum(i32) { NAME_LEN = 124, // LABEL_LEN = 124, this enum value conflicts with NAME_LEN }; pub const MQ_MAX_Q_NAME_LEN = MQMAX.NAME_LEN; pub const MQ_MAX_Q_LABEL_LEN = MQMAX.NAME_LEN; pub const QUEUE_TYPE = enum(i32) { PUBLIC = 0, PRIVATE = 1, MACHINE = 2, CONNECTOR = 3, MULTICAST = 4, }; pub const MQ_TYPE_PUBLIC = QUEUE_TYPE.PUBLIC; pub const MQ_TYPE_PRIVATE = QUEUE_TYPE.PRIVATE; pub const MQ_TYPE_MACHINE = QUEUE_TYPE.MACHINE; pub const MQ_TYPE_CONNECTOR = QUEUE_TYPE.CONNECTOR; pub const MQ_TYPE_MULTICAST = QUEUE_TYPE.MULTICAST; pub const FOREIGN_STATUS = enum(i32) { FOREIGN = 0, NOT_FOREIGN = 1, UNKNOWN = 2, }; pub const MQ_STATUS_FOREIGN = FOREIGN_STATUS.FOREIGN; pub const MQ_STATUS_NOT_FOREIGN = FOREIGN_STATUS.NOT_FOREIGN; pub const MQ_STATUS_UNKNOWN = FOREIGN_STATUS.UNKNOWN; pub const XACT_STATUS = enum(i32) { XACT = 0, NOT_XACT = 1, UNKNOWN = 2, }; pub const MQ_XACT_STATUS_XACT = XACT_STATUS.XACT; pub const MQ_XACT_STATUS_NOT_XACT = XACT_STATUS.NOT_XACT; pub const MQ_XACT_STATUS_UNKNOWN = XACT_STATUS.UNKNOWN; pub const QUEUE_STATE = enum(i32) { LOCAL_CONNECTION = 0, DISCONNECTED = 1, WAITING = 2, NEEDVALIDATE = 3, ONHOLD = 4, NONACTIVE = 5, CONNECTED = 6, DISCONNECTING = 7, LOCKED = 8, }; pub const MQ_QUEUE_STATE_LOCAL_CONNECTION = QUEUE_STATE.LOCAL_CONNECTION; pub const MQ_QUEUE_STATE_DISCONNECTED = QUEUE_STATE.DISCONNECTED; pub const MQ_QUEUE_STATE_WAITING = QUEUE_STATE.WAITING; pub const MQ_QUEUE_STATE_NEEDVALIDATE = QUEUE_STATE.NEEDVALIDATE; pub const MQ_QUEUE_STATE_ONHOLD = QUEUE_STATE.ONHOLD; pub const MQ_QUEUE_STATE_NONACTIVE = QUEUE_STATE.NONACTIVE; pub const MQ_QUEUE_STATE_CONNECTED = QUEUE_STATE.CONNECTED; pub const MQ_QUEUE_STATE_DISCONNECTING = QUEUE_STATE.DISCONNECTING; pub const MQ_QUEUE_STATE_LOCKED = QUEUE_STATE.LOCKED; pub const MQDEFAULT = enum(i32) { M_PRIORITY = 3, M_DELIVERY = 0, // M_ACKNOWLEDGE = 0, this enum value conflicts with M_DELIVERY // M_JOURNAL = 0, this enum value conflicts with M_DELIVERY // M_APPSPECIFIC = 0, this enum value conflicts with M_DELIVERY // M_PRIV_LEVEL = 0, this enum value conflicts with M_DELIVERY // M_AUTH_LEVEL = 0, this enum value conflicts with M_DELIVERY M_SENDERID_TYPE = 1, // Q_JOURNAL = 0, this enum value conflicts with M_DELIVERY // Q_BASEPRIORITY = 0, this enum value conflicts with M_DELIVERY Q_QUOTA = -1, // Q_JOURNAL_QUOTA = -1, this enum value conflicts with Q_QUOTA // Q_TRANSACTION = 0, this enum value conflicts with M_DELIVERY // Q_AUTHENTICATE = 0, this enum value conflicts with M_DELIVERY // Q_PRIV_LEVEL = 1, this enum value conflicts with M_SENDERID_TYPE // M_LOOKUPID = 0, this enum value conflicts with M_DELIVERY }; pub const DEFAULT_M_PRIORITY = MQDEFAULT.M_PRIORITY; pub const DEFAULT_M_DELIVERY = MQDEFAULT.M_DELIVERY; pub const DEFAULT_M_ACKNOWLEDGE = MQDEFAULT.M_DELIVERY; pub const DEFAULT_M_JOURNAL = MQDEFAULT.M_DELIVERY; pub const DEFAULT_M_APPSPECIFIC = MQDEFAULT.M_DELIVERY; pub const DEFAULT_M_PRIV_LEVEL = MQDEFAULT.M_DELIVERY; pub const DEFAULT_M_AUTH_LEVEL = MQDEFAULT.M_DELIVERY; pub const DEFAULT_M_SENDERID_TYPE = MQDEFAULT.M_SENDERID_TYPE; pub const DEFAULT_Q_JOURNAL = MQDEFAULT.M_DELIVERY; pub const DEFAULT_Q_BASEPRIORITY = MQDEFAULT.M_DELIVERY; pub const DEFAULT_Q_QUOTA = MQDEFAULT.Q_QUOTA; pub const DEFAULT_Q_JOURNAL_QUOTA = MQDEFAULT.Q_QUOTA; pub const DEFAULT_Q_TRANSACTION = MQDEFAULT.M_DELIVERY; pub const DEFAULT_Q_AUTHENTICATE = MQDEFAULT.M_DELIVERY; pub const DEFAULT_Q_PRIV_LEVEL = MQDEFAULT.M_SENDERID_TYPE; pub const DEFAULT_M_LOOKUPID = MQDEFAULT.M_DELIVERY; pub const MQERROR = enum(i32) { ERROR = -1072824319, ERROR_PROPERTY = -1072824318, ERROR_QUEUE_NOT_FOUND = -1072824317, ERROR_QUEUE_NOT_ACTIVE = -1072824316, ERROR_QUEUE_EXISTS = -1072824315, ERROR_INVALID_PARAMETER = -1072824314, ERROR_INVALID_HANDLE = -1072824313, ERROR_OPERATION_CANCELLED = -1072824312, ERROR_SHARING_VIOLATION = -1072824311, ERROR_SERVICE_NOT_AVAILABLE = -1072824309, ERROR_MACHINE_NOT_FOUND = -1072824307, ERROR_ILLEGAL_SORT = -1072824304, ERROR_ILLEGAL_USER = -1072824303, ERROR_NO_DS = -1072824301, ERROR_ILLEGAL_QUEUE_PATHNAME = -1072824300, ERROR_ILLEGAL_PROPERTY_VALUE = -1072824296, ERROR_ILLEGAL_PROPERTY_VT = -1072824295, ERROR_BUFFER_OVERFLOW = -1072824294, ERROR_IO_TIMEOUT = -1072824293, ERROR_ILLEGAL_CURSOR_ACTION = -1072824292, ERROR_MESSAGE_ALREADY_RECEIVED = -1072824291, ERROR_ILLEGAL_FORMATNAME = -1072824290, ERROR_FORMATNAME_BUFFER_TOO_SMALL = -1072824289, ERROR_UNSUPPORTED_FORMATNAME_OPERATION = -1072824288, ERROR_ILLEGAL_SECURITY_DESCRIPTOR = -1072824287, ERROR_SENDERID_BUFFER_TOO_SMALL = -1072824286, ERROR_SECURITY_DESCRIPTOR_TOO_SMALL = -1072824285, ERROR_CANNOT_IMPERSONATE_CLIENT = -1072824284, ERROR_ACCESS_DENIED = -1072824283, ERROR_PRIVILEGE_NOT_HELD = -1072824282, ERROR_INSUFFICIENT_RESOURCES = -1072824281, ERROR_USER_BUFFER_TOO_SMALL = -1072824280, ERROR_MESSAGE_STORAGE_FAILED = -1072824278, ERROR_SENDER_CERT_BUFFER_TOO_SMALL = -1072824277, ERROR_INVALID_CERTIFICATE = -1072824276, ERROR_CORRUPTED_INTERNAL_CERTIFICATE = -1072824275, ERROR_INTERNAL_USER_CERT_EXIST = -1072824274, ERROR_NO_INTERNAL_USER_CERT = -1072824273, ERROR_CORRUPTED_SECURITY_DATA = -1072824272, ERROR_CORRUPTED_PERSONAL_CERT_STORE = -1072824271, ERROR_COMPUTER_DOES_NOT_SUPPORT_ENCRYPTION = -1072824269, ERROR_BAD_SECURITY_CONTEXT = -1072824267, ERROR_COULD_NOT_GET_USER_SID = -1072824266, ERROR_COULD_NOT_GET_ACCOUNT_INFO = -1072824265, ERROR_ILLEGAL_MQCOLUMNS = -1072824264, ERROR_ILLEGAL_PROPID = -1072824263, ERROR_ILLEGAL_RELATION = -1072824262, ERROR_ILLEGAL_PROPERTY_SIZE = -1072824261, ERROR_ILLEGAL_RESTRICTION_PROPID = -1072824260, ERROR_ILLEGAL_MQQUEUEPROPS = -1072824259, ERROR_PROPERTY_NOTALLOWED = -1072824258, ERROR_INSUFFICIENT_PROPERTIES = -1072824257, ERROR_MACHINE_EXISTS = -1072824256, ERROR_ILLEGAL_MQQMPROPS = -1072824255, ERROR_DS_IS_FULL = -1072824254, ERROR_DS_ERROR = -1072824253, ERROR_INVALID_OWNER = -1072824252, ERROR_UNSUPPORTED_ACCESS_MODE = -1072824251, ERROR_RESULT_BUFFER_TOO_SMALL = -1072824250, ERROR_DELETE_CN_IN_USE = -1072824248, ERROR_NO_RESPONSE_FROM_OBJECT_SERVER = -1072824247, ERROR_OBJECT_SERVER_NOT_AVAILABLE = -1072824246, ERROR_QUEUE_NOT_AVAILABLE = -1072824245, ERROR_DTC_CONNECT = -1072824244, ERROR_TRANSACTION_IMPORT = -1072824242, ERROR_TRANSACTION_USAGE = -1072824240, ERROR_TRANSACTION_SEQUENCE = -1072824239, ERROR_MISSING_CONNECTOR_TYPE = -1072824235, ERROR_STALE_HANDLE = -1072824234, ERROR_TRANSACTION_ENLIST = -1072824232, ERROR_QUEUE_DELETED = -1072824230, ERROR_ILLEGAL_CONTEXT = -1072824229, ERROR_ILLEGAL_SORT_PROPID = -1072824228, ERROR_LABEL_TOO_LONG = -1072824227, ERROR_LABEL_BUFFER_TOO_SMALL = -1072824226, ERROR_MQIS_SERVER_EMPTY = -1072824225, ERROR_MQIS_READONLY_MODE = -1072824224, ERROR_SYMM_KEY_BUFFER_TOO_SMALL = -1072824223, ERROR_SIGNATURE_BUFFER_TOO_SMALL = -1072824222, ERROR_PROV_NAME_BUFFER_TOO_SMALL = -1072824221, ERROR_ILLEGAL_OPERATION = -1072824220, ERROR_WRITE_NOT_ALLOWED = -1072824219, ERROR_WKS_CANT_SERVE_CLIENT = -1072824218, ERROR_DEPEND_WKS_LICENSE_OVERFLOW = -1072824217, CORRUPTED_QUEUE_WAS_DELETED = -1072824216, ERROR_REMOTE_MACHINE_NOT_AVAILABLE = -1072824215, ERROR_UNSUPPORTED_OPERATION = -1072824214, ERROR_ENCRYPTION_PROVIDER_NOT_SUPPORTED = -1072824213, ERROR_CANNOT_SET_CRYPTO_SEC_DESCR = -1072824212, ERROR_CERTIFICATE_NOT_PROVIDED = -1072824211, ERROR_Q_DNS_PROPERTY_NOT_SUPPORTED = -1072824210, ERROR_CANT_CREATE_CERT_STORE = -1072824209, // ERROR_CANNOT_CREATE_CERT_STORE = -1072824209, this enum value conflicts with ERROR_CANT_CREATE_CERT_STORE ERROR_CANT_OPEN_CERT_STORE = -1072824208, // ERROR_CANNOT_OPEN_CERT_STORE = -1072824208, this enum value conflicts with ERROR_CANT_OPEN_CERT_STORE ERROR_ILLEGAL_ENTERPRISE_OPERATION = -1072824207, ERROR_CANNOT_GRANT_ADD_GUID = -1072824206, ERROR_CANNOT_LOAD_MSMQOCM = -1072824205, ERROR_NO_ENTRY_POINT_MSMQOCM = -1072824204, ERROR_NO_MSMQ_SERVERS_ON_DC = -1072824203, ERROR_CANNOT_JOIN_DOMAIN = -1072824202, ERROR_CANNOT_CREATE_ON_GC = -1072824201, ERROR_GUID_NOT_MATCHING = -1072824200, ERROR_PUBLIC_KEY_NOT_FOUND = -1072824199, ERROR_PUBLIC_KEY_DOES_NOT_EXIST = -1072824198, ERROR_ILLEGAL_MQPRIVATEPROPS = -1072824197, ERROR_NO_GC_IN_DOMAIN = -1072824196, ERROR_NO_MSMQ_SERVERS_ON_GC = -1072824195, ERROR_CANNOT_GET_DN = -1072824194, ERROR_CANNOT_HASH_DATA_EX = -1072824193, ERROR_CANNOT_SIGN_DATA_EX = -1072824192, ERROR_CANNOT_CREATE_HASH_EX = -1072824191, ERROR_FAIL_VERIFY_SIGNATURE_EX = -1072824190, ERROR_CANNOT_DELETE_PSC_OBJECTS = -1072824189, ERROR_NO_MQUSER_OU = -1072824188, ERROR_CANNOT_LOAD_MQAD = -1072824187, ERROR_CANNOT_LOAD_MQDSSRV = -1072824186, ERROR_PROPERTIES_CONFLICT = -1072824185, ERROR_MESSAGE_NOT_FOUND = -1072824184, ERROR_CANT_RESOLVE_SITES = -1072824183, ERROR_NOT_SUPPORTED_BY_DEPENDENT_CLIENTS = -1072824182, ERROR_OPERATION_NOT_SUPPORTED_BY_REMOTE_COMPUTER = -1072824181, ERROR_NOT_A_CORRECT_OBJECT_CLASS = -1072824180, ERROR_MULTI_SORT_KEYS = -1072824179, ERROR_GC_NEEDED = -1072824178, ERROR_DS_BIND_ROOT_FOREST = -1072824177, ERROR_DS_LOCAL_USER = -1072824176, ERROR_Q_ADS_PROPERTY_NOT_SUPPORTED = -1072824175, ERROR_BAD_XML_FORMAT = -1072824174, ERROR_UNSUPPORTED_CLASS = -1072824173, ERROR_UNINITIALIZED_OBJECT = -1072824172, ERROR_CANNOT_CREATE_PSC_OBJECTS = -1072824171, ERROR_CANNOT_UPDATE_PSC_OBJECTS = -1072824170, }; pub const MQ_ERROR = MQERROR.ERROR; pub const MQ_ERROR_PROPERTY = MQERROR.ERROR_PROPERTY; pub const MQ_ERROR_QUEUE_NOT_FOUND = MQERROR.ERROR_QUEUE_NOT_FOUND; pub const MQ_ERROR_QUEUE_NOT_ACTIVE = MQERROR.ERROR_QUEUE_NOT_ACTIVE; pub const MQ_ERROR_QUEUE_EXISTS = MQERROR.ERROR_QUEUE_EXISTS; pub const MQ_ERROR_INVALID_PARAMETER = MQERROR.ERROR_INVALID_PARAMETER; pub const MQ_ERROR_INVALID_HANDLE = MQERROR.ERROR_INVALID_HANDLE; pub const MQ_ERROR_OPERATION_CANCELLED = MQERROR.ERROR_OPERATION_CANCELLED; pub const MQ_ERROR_SHARING_VIOLATION = MQERROR.ERROR_SHARING_VIOLATION; pub const MQ_ERROR_SERVICE_NOT_AVAILABLE = MQERROR.ERROR_SERVICE_NOT_AVAILABLE; pub const MQ_ERROR_MACHINE_NOT_FOUND = MQERROR.ERROR_MACHINE_NOT_FOUND; pub const MQ_ERROR_ILLEGAL_SORT = MQERROR.ERROR_ILLEGAL_SORT; pub const MQ_ERROR_ILLEGAL_USER = MQERROR.ERROR_ILLEGAL_USER; pub const MQ_ERROR_NO_DS = MQERROR.ERROR_NO_DS; pub const MQ_ERROR_ILLEGAL_QUEUE_PATHNAME = MQERROR.ERROR_ILLEGAL_QUEUE_PATHNAME; pub const MQ_ERROR_ILLEGAL_PROPERTY_VALUE = MQERROR.ERROR_ILLEGAL_PROPERTY_VALUE; pub const MQ_ERROR_ILLEGAL_PROPERTY_VT = MQERROR.ERROR_ILLEGAL_PROPERTY_VT; pub const MQ_ERROR_BUFFER_OVERFLOW = MQERROR.ERROR_BUFFER_OVERFLOW; pub const MQ_ERROR_IO_TIMEOUT = MQERROR.ERROR_IO_TIMEOUT; pub const MQ_ERROR_ILLEGAL_CURSOR_ACTION = MQERROR.ERROR_ILLEGAL_CURSOR_ACTION; pub const MQ_ERROR_MESSAGE_ALREADY_RECEIVED = MQERROR.ERROR_MESSAGE_ALREADY_RECEIVED; pub const MQ_ERROR_ILLEGAL_FORMATNAME = MQERROR.ERROR_ILLEGAL_FORMATNAME; pub const MQ_ERROR_FORMATNAME_BUFFER_TOO_SMALL = MQERROR.ERROR_FORMATNAME_BUFFER_TOO_SMALL; pub const MQ_ERROR_UNSUPPORTED_FORMATNAME_OPERATION = MQERROR.ERROR_UNSUPPORTED_FORMATNAME_OPERATION; pub const MQ_ERROR_ILLEGAL_SECURITY_DESCRIPTOR = MQERROR.ERROR_ILLEGAL_SECURITY_DESCRIPTOR; pub const MQ_ERROR_SENDERID_BUFFER_TOO_SMALL = MQERROR.ERROR_SENDERID_BUFFER_TOO_SMALL; pub const MQ_ERROR_SECURITY_DESCRIPTOR_TOO_SMALL = MQERROR.ERROR_SECURITY_DESCRIPTOR_TOO_SMALL; pub const MQ_ERROR_CANNOT_IMPERSONATE_CLIENT = MQERROR.ERROR_CANNOT_IMPERSONATE_CLIENT; pub const MQ_ERROR_ACCESS_DENIED = MQERROR.ERROR_ACCESS_DENIED; pub const MQ_ERROR_PRIVILEGE_NOT_HELD = MQERROR.ERROR_PRIVILEGE_NOT_HELD; pub const MQ_ERROR_INSUFFICIENT_RESOURCES = MQERROR.ERROR_INSUFFICIENT_RESOURCES; pub const MQ_ERROR_USER_BUFFER_TOO_SMALL = MQERROR.ERROR_USER_BUFFER_TOO_SMALL; pub const MQ_ERROR_MESSAGE_STORAGE_FAILED = MQERROR.ERROR_MESSAGE_STORAGE_FAILED; pub const MQ_ERROR_SENDER_CERT_BUFFER_TOO_SMALL = MQERROR.ERROR_SENDER_CERT_BUFFER_TOO_SMALL; pub const MQ_ERROR_INVALID_CERTIFICATE = MQERROR.ERROR_INVALID_CERTIFICATE; pub const MQ_ERROR_CORRUPTED_INTERNAL_CERTIFICATE = MQERROR.ERROR_CORRUPTED_INTERNAL_CERTIFICATE; pub const MQ_ERROR_INTERNAL_USER_CERT_EXIST = MQERROR.ERROR_INTERNAL_USER_CERT_EXIST; pub const MQ_ERROR_NO_INTERNAL_USER_CERT = MQERROR.ERROR_NO_INTERNAL_USER_CERT; pub const MQ_ERROR_CORRUPTED_SECURITY_DATA = MQERROR.ERROR_CORRUPTED_SECURITY_DATA; pub const MQ_ERROR_CORRUPTED_PERSONAL_CERT_STORE = MQERROR.ERROR_CORRUPTED_PERSONAL_CERT_STORE; pub const MQ_ERROR_COMPUTER_DOES_NOT_SUPPORT_ENCRYPTION = MQERROR.ERROR_COMPUTER_DOES_NOT_SUPPORT_ENCRYPTION; pub const MQ_ERROR_BAD_SECURITY_CONTEXT = MQERROR.ERROR_BAD_SECURITY_CONTEXT; pub const MQ_ERROR_COULD_NOT_GET_USER_SID = MQERROR.ERROR_COULD_NOT_GET_USER_SID; pub const MQ_ERROR_COULD_NOT_GET_ACCOUNT_INFO = MQERROR.ERROR_COULD_NOT_GET_ACCOUNT_INFO; pub const MQ_ERROR_ILLEGAL_MQCOLUMNS = MQERROR.ERROR_ILLEGAL_MQCOLUMNS; pub const MQ_ERROR_ILLEGAL_PROPID = MQERROR.ERROR_ILLEGAL_PROPID; pub const MQ_ERROR_ILLEGAL_RELATION = MQERROR.ERROR_ILLEGAL_RELATION; pub const MQ_ERROR_ILLEGAL_PROPERTY_SIZE = MQERROR.ERROR_ILLEGAL_PROPERTY_SIZE; pub const MQ_ERROR_ILLEGAL_RESTRICTION_PROPID = MQERROR.ERROR_ILLEGAL_RESTRICTION_PROPID; pub const MQ_ERROR_ILLEGAL_MQQUEUEPROPS = MQERROR.ERROR_ILLEGAL_MQQUEUEPROPS; pub const MQ_ERROR_PROPERTY_NOTALLOWED = MQERROR.ERROR_PROPERTY_NOTALLOWED; pub const MQ_ERROR_INSUFFICIENT_PROPERTIES = MQERROR.ERROR_INSUFFICIENT_PROPERTIES; pub const MQ_ERROR_MACHINE_EXISTS = MQERROR.ERROR_MACHINE_EXISTS; pub const MQ_ERROR_ILLEGAL_MQQMPROPS = MQERROR.ERROR_ILLEGAL_MQQMPROPS; pub const MQ_ERROR_DS_IS_FULL = MQERROR.ERROR_DS_IS_FULL; pub const MQ_ERROR_DS_ERROR = MQERROR.ERROR_DS_ERROR; pub const MQ_ERROR_INVALID_OWNER = MQERROR.ERROR_INVALID_OWNER; pub const MQ_ERROR_UNSUPPORTED_ACCESS_MODE = MQERROR.ERROR_UNSUPPORTED_ACCESS_MODE; pub const MQ_ERROR_RESULT_BUFFER_TOO_SMALL = MQERROR.ERROR_RESULT_BUFFER_TOO_SMALL; pub const MQ_ERROR_DELETE_CN_IN_USE = MQERROR.ERROR_DELETE_CN_IN_USE; pub const MQ_ERROR_NO_RESPONSE_FROM_OBJECT_SERVER = MQERROR.ERROR_NO_RESPONSE_FROM_OBJECT_SERVER; pub const MQ_ERROR_OBJECT_SERVER_NOT_AVAILABLE = MQERROR.ERROR_OBJECT_SERVER_NOT_AVAILABLE; pub const MQ_ERROR_QUEUE_NOT_AVAILABLE = MQERROR.ERROR_QUEUE_NOT_AVAILABLE; pub const MQ_ERROR_DTC_CONNECT = MQERROR.ERROR_DTC_CONNECT; pub const MQ_ERROR_TRANSACTION_IMPORT = MQERROR.ERROR_TRANSACTION_IMPORT; pub const MQ_ERROR_TRANSACTION_USAGE = MQERROR.ERROR_TRANSACTION_USAGE; pub const MQ_ERROR_TRANSACTION_SEQUENCE = MQERROR.ERROR_TRANSACTION_SEQUENCE; pub const MQ_ERROR_MISSING_CONNECTOR_TYPE = MQERROR.ERROR_MISSING_CONNECTOR_TYPE; pub const MQ_ERROR_STALE_HANDLE = MQERROR.ERROR_STALE_HANDLE; pub const MQ_ERROR_TRANSACTION_ENLIST = MQERROR.ERROR_TRANSACTION_ENLIST; pub const MQ_ERROR_QUEUE_DELETED = MQERROR.ERROR_QUEUE_DELETED; pub const MQ_ERROR_ILLEGAL_CONTEXT = MQERROR.ERROR_ILLEGAL_CONTEXT; pub const MQ_ERROR_ILLEGAL_SORT_PROPID = MQERROR.ERROR_ILLEGAL_SORT_PROPID; pub const MQ_ERROR_LABEL_TOO_LONG = MQERROR.ERROR_LABEL_TOO_LONG; pub const MQ_ERROR_LABEL_BUFFER_TOO_SMALL = MQERROR.ERROR_LABEL_BUFFER_TOO_SMALL; pub const MQ_ERROR_MQIS_SERVER_EMPTY = MQERROR.ERROR_MQIS_SERVER_EMPTY; pub const MQ_ERROR_MQIS_READONLY_MODE = MQERROR.ERROR_MQIS_READONLY_MODE; pub const MQ_ERROR_SYMM_KEY_BUFFER_TOO_SMALL = MQERROR.ERROR_SYMM_KEY_BUFFER_TOO_SMALL; pub const MQ_ERROR_SIGNATURE_BUFFER_TOO_SMALL = MQERROR.ERROR_SIGNATURE_BUFFER_TOO_SMALL; pub const MQ_ERROR_PROV_NAME_BUFFER_TOO_SMALL = MQERROR.ERROR_PROV_NAME_BUFFER_TOO_SMALL; pub const MQ_ERROR_ILLEGAL_OPERATION = MQERROR.ERROR_ILLEGAL_OPERATION; pub const MQ_ERROR_WRITE_NOT_ALLOWED = MQERROR.ERROR_WRITE_NOT_ALLOWED; pub const MQ_ERROR_WKS_CANT_SERVE_CLIENT = MQERROR.ERROR_WKS_CANT_SERVE_CLIENT; pub const MQ_ERROR_DEPEND_WKS_LICENSE_OVERFLOW = MQERROR.ERROR_DEPEND_WKS_LICENSE_OVERFLOW; pub const MQ_CORRUPTED_QUEUE_WAS_DELETED = MQERROR.CORRUPTED_QUEUE_WAS_DELETED; pub const MQ_ERROR_REMOTE_MACHINE_NOT_AVAILABLE = MQERROR.ERROR_REMOTE_MACHINE_NOT_AVAILABLE; pub const MQ_ERROR_UNSUPPORTED_OPERATION = MQERROR.ERROR_UNSUPPORTED_OPERATION; pub const MQ_ERROR_ENCRYPTION_PROVIDER_NOT_SUPPORTED = MQERROR.ERROR_ENCRYPTION_PROVIDER_NOT_SUPPORTED; pub const MQ_ERROR_CANNOT_SET_CRYPTO_SEC_DESCR = MQERROR.ERROR_CANNOT_SET_CRYPTO_SEC_DESCR; pub const MQ_ERROR_CERTIFICATE_NOT_PROVIDED = MQERROR.ERROR_CERTIFICATE_NOT_PROVIDED; pub const MQ_ERROR_Q_DNS_PROPERTY_NOT_SUPPORTED = MQERROR.ERROR_Q_DNS_PROPERTY_NOT_SUPPORTED; pub const MQ_ERROR_CANT_CREATE_CERT_STORE = MQERROR.ERROR_CANT_CREATE_CERT_STORE; pub const MQ_ERROR_CANNOT_CREATE_CERT_STORE = MQERROR.ERROR_CANT_CREATE_CERT_STORE; pub const MQ_ERROR_CANT_OPEN_CERT_STORE = MQERROR.ERROR_CANT_OPEN_CERT_STORE; pub const MQ_ERROR_CANNOT_OPEN_CERT_STORE = MQERROR.ERROR_CANT_OPEN_CERT_STORE; pub const MQ_ERROR_ILLEGAL_ENTERPRISE_OPERATION = MQERROR.ERROR_ILLEGAL_ENTERPRISE_OPERATION; pub const MQ_ERROR_CANNOT_GRANT_ADD_GUID = MQERROR.ERROR_CANNOT_GRANT_ADD_GUID; pub const MQ_ERROR_CANNOT_LOAD_MSMQOCM = MQERROR.ERROR_CANNOT_LOAD_MSMQOCM; pub const MQ_ERROR_NO_ENTRY_POINT_MSMQOCM = MQERROR.ERROR_NO_ENTRY_POINT_MSMQOCM; pub const MQ_ERROR_NO_MSMQ_SERVERS_ON_DC = MQERROR.ERROR_NO_MSMQ_SERVERS_ON_DC; pub const MQ_ERROR_CANNOT_JOIN_DOMAIN = MQERROR.ERROR_CANNOT_JOIN_DOMAIN; pub const MQ_ERROR_CANNOT_CREATE_ON_GC = MQERROR.ERROR_CANNOT_CREATE_ON_GC; pub const MQ_ERROR_GUID_NOT_MATCHING = MQERROR.ERROR_GUID_NOT_MATCHING; pub const MQ_ERROR_PUBLIC_KEY_NOT_FOUND = MQERROR.ERROR_PUBLIC_KEY_NOT_FOUND; pub const MQ_ERROR_PUBLIC_KEY_DOES_NOT_EXIST = MQERROR.ERROR_PUBLIC_KEY_DOES_NOT_EXIST; pub const MQ_ERROR_ILLEGAL_MQPRIVATEPROPS = MQERROR.ERROR_ILLEGAL_MQPRIVATEPROPS; pub const MQ_ERROR_NO_GC_IN_DOMAIN = MQERROR.ERROR_NO_GC_IN_DOMAIN; pub const MQ_ERROR_NO_MSMQ_SERVERS_ON_GC = MQERROR.ERROR_NO_MSMQ_SERVERS_ON_GC; pub const MQ_ERROR_CANNOT_GET_DN = MQERROR.ERROR_CANNOT_GET_DN; pub const MQ_ERROR_CANNOT_HASH_DATA_EX = MQERROR.ERROR_CANNOT_HASH_DATA_EX; pub const MQ_ERROR_CANNOT_SIGN_DATA_EX = MQERROR.ERROR_CANNOT_SIGN_DATA_EX; pub const MQ_ERROR_CANNOT_CREATE_HASH_EX = MQERROR.ERROR_CANNOT_CREATE_HASH_EX; pub const MQ_ERROR_FAIL_VERIFY_SIGNATURE_EX = MQERROR.ERROR_FAIL_VERIFY_SIGNATURE_EX; pub const MQ_ERROR_CANNOT_DELETE_PSC_OBJECTS = MQERROR.ERROR_CANNOT_DELETE_PSC_OBJECTS; pub const MQ_ERROR_NO_MQUSER_OU = MQERROR.ERROR_NO_MQUSER_OU; pub const MQ_ERROR_CANNOT_LOAD_MQAD = MQERROR.ERROR_CANNOT_LOAD_MQAD; pub const MQ_ERROR_CANNOT_LOAD_MQDSSRV = MQERROR.ERROR_CANNOT_LOAD_MQDSSRV; pub const MQ_ERROR_PROPERTIES_CONFLICT = MQERROR.ERROR_PROPERTIES_CONFLICT; pub const MQ_ERROR_MESSAGE_NOT_FOUND = MQERROR.ERROR_MESSAGE_NOT_FOUND; pub const MQ_ERROR_CANT_RESOLVE_SITES = MQERROR.ERROR_CANT_RESOLVE_SITES; pub const MQ_ERROR_NOT_SUPPORTED_BY_DEPENDENT_CLIENTS = MQERROR.ERROR_NOT_SUPPORTED_BY_DEPENDENT_CLIENTS; pub const MQ_ERROR_OPERATION_NOT_SUPPORTED_BY_REMOTE_COMPUTER = MQERROR.ERROR_OPERATION_NOT_SUPPORTED_BY_REMOTE_COMPUTER; pub const MQ_ERROR_NOT_A_CORRECT_OBJECT_CLASS = MQERROR.ERROR_NOT_A_CORRECT_OBJECT_CLASS; pub const MQ_ERROR_MULTI_SORT_KEYS = MQERROR.ERROR_MULTI_SORT_KEYS; pub const MQ_ERROR_GC_NEEDED = MQERROR.ERROR_GC_NEEDED; pub const MQ_ERROR_DS_BIND_ROOT_FOREST = MQERROR.ERROR_DS_BIND_ROOT_FOREST; pub const MQ_ERROR_DS_LOCAL_USER = MQERROR.ERROR_DS_LOCAL_USER; pub const MQ_ERROR_Q_ADS_PROPERTY_NOT_SUPPORTED = MQERROR.ERROR_Q_ADS_PROPERTY_NOT_SUPPORTED; pub const MQ_ERROR_BAD_XML_FORMAT = MQERROR.ERROR_BAD_XML_FORMAT; pub const MQ_ERROR_UNSUPPORTED_CLASS = MQERROR.ERROR_UNSUPPORTED_CLASS; pub const MQ_ERROR_UNINITIALIZED_OBJECT = MQERROR.ERROR_UNINITIALIZED_OBJECT; pub const MQ_ERROR_CANNOT_CREATE_PSC_OBJECTS = MQERROR.ERROR_CANNOT_CREATE_PSC_OBJECTS; pub const MQ_ERROR_CANNOT_UPDATE_PSC_OBJECTS = MQERROR.ERROR_CANNOT_UPDATE_PSC_OBJECTS; pub const MQWARNING = enum(i32) { PROPERTY = 1074659329, ILLEGAL_PROPERTY = 1074659330, PROPERTY_IGNORED = 1074659331, UNSUPPORTED_PROPERTY = 1074659332, DUPLICATE_PROPERTY = 1074659333, OPERATION_PENDING = 1074659334, FORMATNAME_BUFFER_TOO_SMALL = 1074659337, INTERNAL_USER_CERT_EXIST = 1074659338, OWNER_IGNORED = 1074659339, }; pub const MQ_INFORMATION_PROPERTY = MQWARNING.PROPERTY; pub const MQ_INFORMATION_ILLEGAL_PROPERTY = MQWARNING.ILLEGAL_PROPERTY; pub const MQ_INFORMATION_PROPERTY_IGNORED = MQWARNING.PROPERTY_IGNORED; pub const MQ_INFORMATION_UNSUPPORTED_PROPERTY = MQWARNING.UNSUPPORTED_PROPERTY; pub const MQ_INFORMATION_DUPLICATE_PROPERTY = MQWARNING.DUPLICATE_PROPERTY; pub const MQ_INFORMATION_OPERATION_PENDING = MQWARNING.OPERATION_PENDING; pub const MQ_INFORMATION_FORMATNAME_BUFFER_TOO_SMALL = MQWARNING.FORMATNAME_BUFFER_TOO_SMALL; pub const MQ_INFORMATION_INTERNAL_USER_CERT_EXIST = MQWARNING.INTERNAL_USER_CERT_EXIST; pub const MQ_INFORMATION_OWNER_IGNORED = MQWARNING.OWNER_IGNORED; const IID_IMSMQQuery_Value = @import("../zig.zig").Guid.initString("d7d6e072-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQQuery = &IID_IMSMQQuery_Value; pub const IMSMQQuery = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, LookupQueue: fn( self: *const IMSMQQuery, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos, ) 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 IMSMQQuery_LookupQueue(self: *const T, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery.VTable, self.vtable).LookupQueue(@ptrCast(*const IMSMQQuery, self), QueueGuid, ServiceTypeGuid, Label, CreateTime, ModifyTime, RelServiceType, RelLabel, RelCreateTime, RelModifyTime, ppqinfos); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueInfo_Value = @import("../zig.zig").Guid.initString("d7d6e07b-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQQueueInfo = &IID_IMSMQQueueInfo_Value; pub const IMSMQQueueInfo = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueGuid: fn( self: *const IMSMQQueueInfo, pbstrGuidQueue: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceTypeGuid: fn( self: *const IMSMQQueueInfo, pbstrGuidServiceType: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ServiceTypeGuid: fn( self: *const IMSMQQueueInfo, bstrGuidServiceType: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Label: fn( self: *const IMSMQQueueInfo, pbstrLabel: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Label: fn( self: *const IMSMQQueueInfo, bstrLabel: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PathName: fn( self: *const IMSMQQueueInfo, pbstrPathName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PathName: fn( self: *const IMSMQQueueInfo, bstrPathName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FormatName: fn( self: *const IMSMQQueueInfo, pbstrFormatName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FormatName: fn( self: *const IMSMQQueueInfo, bstrFormatName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsTransactional: fn( self: *const IMSMQQueueInfo, pisTransactional: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivLevel: fn( self: *const IMSMQQueueInfo, plPrivLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PrivLevel: fn( self: *const IMSMQQueueInfo, lPrivLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Journal: fn( self: *const IMSMQQueueInfo, plJournal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Journal: fn( self: *const IMSMQQueueInfo, lJournal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Quota: fn( self: *const IMSMQQueueInfo, plQuota: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Quota: fn( self: *const IMSMQQueueInfo, lQuota: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BasePriority: fn( self: *const IMSMQQueueInfo, plBasePriority: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BasePriority: fn( self: *const IMSMQQueueInfo, lBasePriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CreateTime: fn( self: *const IMSMQQueueInfo, pvarCreateTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModifyTime: fn( self: *const IMSMQQueueInfo, pvarModifyTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Authenticate: fn( self: *const IMSMQQueueInfo, plAuthenticate: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Authenticate: fn( self: *const IMSMQQueueInfo, lAuthenticate: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_JournalQuota: fn( self: *const IMSMQQueueInfo, plJournalQuota: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_JournalQuota: fn( self: *const IMSMQQueueInfo, lJournalQuota: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsWorldReadable: fn( self: *const IMSMQQueueInfo, pisWorldReadable: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Create: fn( self: *const IMSMQQueueInfo, IsTransactional: ?*VARIANT, IsWorldReadable: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Open: fn( self: *const IMSMQQueueInfo, Access: i32, ShareMode: i32, ppq: ?*?*IMSMQQueue, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Refresh: fn( self: *const IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Update: fn( self: *const IMSMQQueueInfo, ) 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 IMSMQQueueInfo_get_QueueGuid(self: *const T, pbstrGuidQueue: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_QueueGuid(@ptrCast(*const IMSMQQueueInfo, self), pbstrGuidQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_ServiceTypeGuid(self: *const T, pbstrGuidServiceType: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_ServiceTypeGuid(@ptrCast(*const IMSMQQueueInfo, self), pbstrGuidServiceType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_ServiceTypeGuid(self: *const T, bstrGuidServiceType: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_ServiceTypeGuid(@ptrCast(*const IMSMQQueueInfo, self), bstrGuidServiceType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_Label(self: *const T, pbstrLabel: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_Label(@ptrCast(*const IMSMQQueueInfo, self), pbstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_Label(self: *const T, bstrLabel: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_Label(@ptrCast(*const IMSMQQueueInfo, self), bstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_PathName(self: *const T, pbstrPathName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_PathName(@ptrCast(*const IMSMQQueueInfo, self), pbstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_PathName(self: *const T, bstrPathName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_PathName(@ptrCast(*const IMSMQQueueInfo, self), bstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_FormatName(self: *const T, pbstrFormatName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_FormatName(@ptrCast(*const IMSMQQueueInfo, self), pbstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_FormatName(self: *const T, bstrFormatName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_FormatName(@ptrCast(*const IMSMQQueueInfo, self), bstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_IsTransactional(self: *const T, pisTransactional: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_IsTransactional(@ptrCast(*const IMSMQQueueInfo, self), pisTransactional); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_PrivLevel(self: *const T, plPrivLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_PrivLevel(@ptrCast(*const IMSMQQueueInfo, self), plPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_PrivLevel(self: *const T, lPrivLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_PrivLevel(@ptrCast(*const IMSMQQueueInfo, self), lPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_Journal(self: *const T, plJournal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_Journal(@ptrCast(*const IMSMQQueueInfo, self), plJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_Journal(self: *const T, lJournal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_Journal(@ptrCast(*const IMSMQQueueInfo, self), lJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_Quota(self: *const T, plQuota: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_Quota(@ptrCast(*const IMSMQQueueInfo, self), plQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_Quota(self: *const T, lQuota: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_Quota(@ptrCast(*const IMSMQQueueInfo, self), lQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_BasePriority(self: *const T, plBasePriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_BasePriority(@ptrCast(*const IMSMQQueueInfo, self), plBasePriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_BasePriority(self: *const T, lBasePriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_BasePriority(@ptrCast(*const IMSMQQueueInfo, self), lBasePriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_CreateTime(self: *const T, pvarCreateTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_CreateTime(@ptrCast(*const IMSMQQueueInfo, self), pvarCreateTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_ModifyTime(self: *const T, pvarModifyTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_ModifyTime(@ptrCast(*const IMSMQQueueInfo, self), pvarModifyTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_Authenticate(self: *const T, plAuthenticate: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_Authenticate(@ptrCast(*const IMSMQQueueInfo, self), plAuthenticate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_Authenticate(self: *const T, lAuthenticate: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_Authenticate(@ptrCast(*const IMSMQQueueInfo, self), lAuthenticate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_JournalQuota(self: *const T, plJournalQuota: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_JournalQuota(@ptrCast(*const IMSMQQueueInfo, self), plJournalQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_put_JournalQuota(self: *const T, lJournalQuota: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).put_JournalQuota(@ptrCast(*const IMSMQQueueInfo, self), lJournalQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_get_IsWorldReadable(self: *const T, pisWorldReadable: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).get_IsWorldReadable(@ptrCast(*const IMSMQQueueInfo, self), pisWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_Create(self: *const T, IsTransactional: ?*VARIANT, IsWorldReadable: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).Create(@ptrCast(*const IMSMQQueueInfo, self), IsTransactional, IsWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).Delete(@ptrCast(*const IMSMQQueueInfo, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_Open(self: *const T, Access: i32, ShareMode: i32, ppq: ?*?*IMSMQQueue) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).Open(@ptrCast(*const IMSMQQueueInfo, self), Access, ShareMode, ppq); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_Refresh(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).Refresh(@ptrCast(*const IMSMQQueueInfo, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo_Update(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo.VTable, self.vtable).Update(@ptrCast(*const IMSMQQueueInfo, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueInfo2_Value = @import("../zig.zig").Guid.initString("fd174a80-89cf-11d2-b0f2-00e02c074f6b"); pub const IID_IMSMQQueueInfo2 = &IID_IMSMQQueueInfo2_Value; pub const IMSMQQueueInfo2 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueGuid: fn( self: *const IMSMQQueueInfo2, pbstrGuidQueue: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceTypeGuid: fn( self: *const IMSMQQueueInfo2, pbstrGuidServiceType: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ServiceTypeGuid: fn( self: *const IMSMQQueueInfo2, bstrGuidServiceType: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Label: fn( self: *const IMSMQQueueInfo2, pbstrLabel: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Label: fn( self: *const IMSMQQueueInfo2, bstrLabel: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PathName: fn( self: *const IMSMQQueueInfo2, pbstrPathName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PathName: fn( self: *const IMSMQQueueInfo2, bstrPathName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FormatName: fn( self: *const IMSMQQueueInfo2, pbstrFormatName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FormatName: fn( self: *const IMSMQQueueInfo2, bstrFormatName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsTransactional: fn( self: *const IMSMQQueueInfo2, pisTransactional: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivLevel: fn( self: *const IMSMQQueueInfo2, plPrivLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PrivLevel: fn( self: *const IMSMQQueueInfo2, lPrivLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Journal: fn( self: *const IMSMQQueueInfo2, plJournal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Journal: fn( self: *const IMSMQQueueInfo2, lJournal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Quota: fn( self: *const IMSMQQueueInfo2, plQuota: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Quota: fn( self: *const IMSMQQueueInfo2, lQuota: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BasePriority: fn( self: *const IMSMQQueueInfo2, plBasePriority: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BasePriority: fn( self: *const IMSMQQueueInfo2, lBasePriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CreateTime: fn( self: *const IMSMQQueueInfo2, pvarCreateTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModifyTime: fn( self: *const IMSMQQueueInfo2, pvarModifyTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Authenticate: fn( self: *const IMSMQQueueInfo2, plAuthenticate: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Authenticate: fn( self: *const IMSMQQueueInfo2, lAuthenticate: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_JournalQuota: fn( self: *const IMSMQQueueInfo2, plJournalQuota: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_JournalQuota: fn( self: *const IMSMQQueueInfo2, lJournalQuota: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsWorldReadable: fn( self: *const IMSMQQueueInfo2, pisWorldReadable: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Create: fn( self: *const IMSMQQueueInfo2, IsTransactional: ?*VARIANT, IsWorldReadable: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Open: fn( self: *const IMSMQQueueInfo2, Access: i32, ShareMode: i32, ppq: ?*?*IMSMQQueue2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Refresh: fn( self: *const IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Update: fn( self: *const IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PathNameDNS: fn( self: *const IMSMQQueueInfo2, pbstrPathNameDNS: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueueInfo2, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Security: fn( self: *const IMSMQQueueInfo2, pvarSecurity: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Security: fn( self: *const IMSMQQueueInfo2, varSecurity: 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 IMSMQQueueInfo2_get_QueueGuid(self: *const T, pbstrGuidQueue: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_QueueGuid(@ptrCast(*const IMSMQQueueInfo2, self), pbstrGuidQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_ServiceTypeGuid(self: *const T, pbstrGuidServiceType: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_ServiceTypeGuid(@ptrCast(*const IMSMQQueueInfo2, self), pbstrGuidServiceType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_ServiceTypeGuid(self: *const T, bstrGuidServiceType: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_ServiceTypeGuid(@ptrCast(*const IMSMQQueueInfo2, self), bstrGuidServiceType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_Label(self: *const T, pbstrLabel: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_Label(@ptrCast(*const IMSMQQueueInfo2, self), pbstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_Label(self: *const T, bstrLabel: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_Label(@ptrCast(*const IMSMQQueueInfo2, self), bstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_PathName(self: *const T, pbstrPathName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_PathName(@ptrCast(*const IMSMQQueueInfo2, self), pbstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_PathName(self: *const T, bstrPathName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_PathName(@ptrCast(*const IMSMQQueueInfo2, self), bstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_FormatName(self: *const T, pbstrFormatName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_FormatName(@ptrCast(*const IMSMQQueueInfo2, self), pbstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_FormatName(self: *const T, bstrFormatName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_FormatName(@ptrCast(*const IMSMQQueueInfo2, self), bstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_IsTransactional(self: *const T, pisTransactional: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_IsTransactional(@ptrCast(*const IMSMQQueueInfo2, self), pisTransactional); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_PrivLevel(self: *const T, plPrivLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_PrivLevel(@ptrCast(*const IMSMQQueueInfo2, self), plPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_PrivLevel(self: *const T, lPrivLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_PrivLevel(@ptrCast(*const IMSMQQueueInfo2, self), lPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_Journal(self: *const T, plJournal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_Journal(@ptrCast(*const IMSMQQueueInfo2, self), plJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_Journal(self: *const T, lJournal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_Journal(@ptrCast(*const IMSMQQueueInfo2, self), lJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_Quota(self: *const T, plQuota: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_Quota(@ptrCast(*const IMSMQQueueInfo2, self), plQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_Quota(self: *const T, lQuota: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_Quota(@ptrCast(*const IMSMQQueueInfo2, self), lQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_BasePriority(self: *const T, plBasePriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_BasePriority(@ptrCast(*const IMSMQQueueInfo2, self), plBasePriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_BasePriority(self: *const T, lBasePriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_BasePriority(@ptrCast(*const IMSMQQueueInfo2, self), lBasePriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_CreateTime(self: *const T, pvarCreateTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_CreateTime(@ptrCast(*const IMSMQQueueInfo2, self), pvarCreateTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_ModifyTime(self: *const T, pvarModifyTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_ModifyTime(@ptrCast(*const IMSMQQueueInfo2, self), pvarModifyTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_Authenticate(self: *const T, plAuthenticate: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_Authenticate(@ptrCast(*const IMSMQQueueInfo2, self), plAuthenticate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_Authenticate(self: *const T, lAuthenticate: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_Authenticate(@ptrCast(*const IMSMQQueueInfo2, self), lAuthenticate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_JournalQuota(self: *const T, plJournalQuota: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_JournalQuota(@ptrCast(*const IMSMQQueueInfo2, self), plJournalQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_JournalQuota(self: *const T, lJournalQuota: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_JournalQuota(@ptrCast(*const IMSMQQueueInfo2, self), lJournalQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_IsWorldReadable(self: *const T, pisWorldReadable: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_IsWorldReadable(@ptrCast(*const IMSMQQueueInfo2, self), pisWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_Create(self: *const T, IsTransactional: ?*VARIANT, IsWorldReadable: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).Create(@ptrCast(*const IMSMQQueueInfo2, self), IsTransactional, IsWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).Delete(@ptrCast(*const IMSMQQueueInfo2, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_Open(self: *const T, Access: i32, ShareMode: i32, ppq: ?*?*IMSMQQueue2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).Open(@ptrCast(*const IMSMQQueueInfo2, self), Access, ShareMode, ppq); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_Refresh(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).Refresh(@ptrCast(*const IMSMQQueueInfo2, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_Update(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).Update(@ptrCast(*const IMSMQQueueInfo2, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_PathNameDNS(self: *const T, pbstrPathNameDNS: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_PathNameDNS(@ptrCast(*const IMSMQQueueInfo2, self), pbstrPathNameDNS); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueueInfo2, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_get_Security(self: *const T, pvarSecurity: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).get_Security(@ptrCast(*const IMSMQQueueInfo2, self), pvarSecurity); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo2_put_Security(self: *const T, varSecurity: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo2.VTable, self.vtable).put_Security(@ptrCast(*const IMSMQQueueInfo2, self), varSecurity); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueInfo3_Value = @import("../zig.zig").Guid.initString("eba96b1d-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQueueInfo3 = &IID_IMSMQQueueInfo3_Value; pub const IMSMQQueueInfo3 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueGuid: fn( self: *const IMSMQQueueInfo3, pbstrGuidQueue: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceTypeGuid: fn( self: *const IMSMQQueueInfo3, pbstrGuidServiceType: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ServiceTypeGuid: fn( self: *const IMSMQQueueInfo3, bstrGuidServiceType: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Label: fn( self: *const IMSMQQueueInfo3, pbstrLabel: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Label: fn( self: *const IMSMQQueueInfo3, bstrLabel: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PathName: fn( self: *const IMSMQQueueInfo3, pbstrPathName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PathName: fn( self: *const IMSMQQueueInfo3, bstrPathName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FormatName: fn( self: *const IMSMQQueueInfo3, pbstrFormatName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FormatName: fn( self: *const IMSMQQueueInfo3, bstrFormatName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsTransactional: fn( self: *const IMSMQQueueInfo3, pisTransactional: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivLevel: fn( self: *const IMSMQQueueInfo3, plPrivLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PrivLevel: fn( self: *const IMSMQQueueInfo3, lPrivLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Journal: fn( self: *const IMSMQQueueInfo3, plJournal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Journal: fn( self: *const IMSMQQueueInfo3, lJournal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Quota: fn( self: *const IMSMQQueueInfo3, plQuota: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Quota: fn( self: *const IMSMQQueueInfo3, lQuota: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BasePriority: fn( self: *const IMSMQQueueInfo3, plBasePriority: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BasePriority: fn( self: *const IMSMQQueueInfo3, lBasePriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CreateTime: fn( self: *const IMSMQQueueInfo3, pvarCreateTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModifyTime: fn( self: *const IMSMQQueueInfo3, pvarModifyTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Authenticate: fn( self: *const IMSMQQueueInfo3, plAuthenticate: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Authenticate: fn( self: *const IMSMQQueueInfo3, lAuthenticate: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_JournalQuota: fn( self: *const IMSMQQueueInfo3, plJournalQuota: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_JournalQuota: fn( self: *const IMSMQQueueInfo3, lJournalQuota: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsWorldReadable: fn( self: *const IMSMQQueueInfo3, pisWorldReadable: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Create: fn( self: *const IMSMQQueueInfo3, IsTransactional: ?*VARIANT, IsWorldReadable: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Open: fn( self: *const IMSMQQueueInfo3, Access: i32, ShareMode: i32, ppq: ?*?*IMSMQQueue3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Refresh: fn( self: *const IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Update: fn( self: *const IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PathNameDNS: fn( self: *const IMSMQQueueInfo3, pbstrPathNameDNS: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueueInfo3, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Security: fn( self: *const IMSMQQueueInfo3, pvarSecurity: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Security: fn( self: *const IMSMQQueueInfo3, varSecurity: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsTransactional2: fn( self: *const IMSMQQueueInfo3, pisTransactional: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsWorldReadable2: fn( self: *const IMSMQQueueInfo3, pisWorldReadable: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MulticastAddress: fn( self: *const IMSMQQueueInfo3, pbstrMulticastAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MulticastAddress: fn( self: *const IMSMQQueueInfo3, bstrMulticastAddress: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ADsPath: fn( self: *const IMSMQQueueInfo3, pbstrADsPath: ?*?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 IMSMQQueueInfo3_get_QueueGuid(self: *const T, pbstrGuidQueue: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_QueueGuid(@ptrCast(*const IMSMQQueueInfo3, self), pbstrGuidQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_ServiceTypeGuid(self: *const T, pbstrGuidServiceType: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_ServiceTypeGuid(@ptrCast(*const IMSMQQueueInfo3, self), pbstrGuidServiceType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_ServiceTypeGuid(self: *const T, bstrGuidServiceType: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_ServiceTypeGuid(@ptrCast(*const IMSMQQueueInfo3, self), bstrGuidServiceType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_Label(self: *const T, pbstrLabel: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_Label(@ptrCast(*const IMSMQQueueInfo3, self), pbstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_Label(self: *const T, bstrLabel: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_Label(@ptrCast(*const IMSMQQueueInfo3, self), bstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_PathName(self: *const T, pbstrPathName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_PathName(@ptrCast(*const IMSMQQueueInfo3, self), pbstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_PathName(self: *const T, bstrPathName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_PathName(@ptrCast(*const IMSMQQueueInfo3, self), bstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_FormatName(self: *const T, pbstrFormatName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_FormatName(@ptrCast(*const IMSMQQueueInfo3, self), pbstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_FormatName(self: *const T, bstrFormatName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_FormatName(@ptrCast(*const IMSMQQueueInfo3, self), bstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_IsTransactional(self: *const T, pisTransactional: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_IsTransactional(@ptrCast(*const IMSMQQueueInfo3, self), pisTransactional); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_PrivLevel(self: *const T, plPrivLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_PrivLevel(@ptrCast(*const IMSMQQueueInfo3, self), plPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_PrivLevel(self: *const T, lPrivLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_PrivLevel(@ptrCast(*const IMSMQQueueInfo3, self), lPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_Journal(self: *const T, plJournal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_Journal(@ptrCast(*const IMSMQQueueInfo3, self), plJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_Journal(self: *const T, lJournal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_Journal(@ptrCast(*const IMSMQQueueInfo3, self), lJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_Quota(self: *const T, plQuota: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_Quota(@ptrCast(*const IMSMQQueueInfo3, self), plQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_Quota(self: *const T, lQuota: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_Quota(@ptrCast(*const IMSMQQueueInfo3, self), lQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_BasePriority(self: *const T, plBasePriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_BasePriority(@ptrCast(*const IMSMQQueueInfo3, self), plBasePriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_BasePriority(self: *const T, lBasePriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_BasePriority(@ptrCast(*const IMSMQQueueInfo3, self), lBasePriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_CreateTime(self: *const T, pvarCreateTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_CreateTime(@ptrCast(*const IMSMQQueueInfo3, self), pvarCreateTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_ModifyTime(self: *const T, pvarModifyTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_ModifyTime(@ptrCast(*const IMSMQQueueInfo3, self), pvarModifyTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_Authenticate(self: *const T, plAuthenticate: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_Authenticate(@ptrCast(*const IMSMQQueueInfo3, self), plAuthenticate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_Authenticate(self: *const T, lAuthenticate: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_Authenticate(@ptrCast(*const IMSMQQueueInfo3, self), lAuthenticate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_JournalQuota(self: *const T, plJournalQuota: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_JournalQuota(@ptrCast(*const IMSMQQueueInfo3, self), plJournalQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_JournalQuota(self: *const T, lJournalQuota: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_JournalQuota(@ptrCast(*const IMSMQQueueInfo3, self), lJournalQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_IsWorldReadable(self: *const T, pisWorldReadable: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_IsWorldReadable(@ptrCast(*const IMSMQQueueInfo3, self), pisWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_Create(self: *const T, IsTransactional: ?*VARIANT, IsWorldReadable: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).Create(@ptrCast(*const IMSMQQueueInfo3, self), IsTransactional, IsWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).Delete(@ptrCast(*const IMSMQQueueInfo3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_Open(self: *const T, Access: i32, ShareMode: i32, ppq: ?*?*IMSMQQueue3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).Open(@ptrCast(*const IMSMQQueueInfo3, self), Access, ShareMode, ppq); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_Refresh(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).Refresh(@ptrCast(*const IMSMQQueueInfo3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_Update(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).Update(@ptrCast(*const IMSMQQueueInfo3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_PathNameDNS(self: *const T, pbstrPathNameDNS: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_PathNameDNS(@ptrCast(*const IMSMQQueueInfo3, self), pbstrPathNameDNS); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueueInfo3, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_Security(self: *const T, pvarSecurity: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_Security(@ptrCast(*const IMSMQQueueInfo3, self), pvarSecurity); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_Security(self: *const T, varSecurity: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_Security(@ptrCast(*const IMSMQQueueInfo3, self), varSecurity); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_IsTransactional2(self: *const T, pisTransactional: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_IsTransactional2(@ptrCast(*const IMSMQQueueInfo3, self), pisTransactional); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_IsWorldReadable2(self: *const T, pisWorldReadable: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_IsWorldReadable2(@ptrCast(*const IMSMQQueueInfo3, self), pisWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_MulticastAddress(self: *const T, pbstrMulticastAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_MulticastAddress(@ptrCast(*const IMSMQQueueInfo3, self), pbstrMulticastAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_put_MulticastAddress(self: *const T, bstrMulticastAddress: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).put_MulticastAddress(@ptrCast(*const IMSMQQueueInfo3, self), bstrMulticastAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo3_get_ADsPath(self: *const T, pbstrADsPath: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo3.VTable, self.vtable).get_ADsPath(@ptrCast(*const IMSMQQueueInfo3, self), pbstrADsPath); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueInfo4_Value = @import("../zig.zig").Guid.initString("eba96b21-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQueueInfo4 = &IID_IMSMQQueueInfo4_Value; pub const IMSMQQueueInfo4 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueGuid: fn( self: *const IMSMQQueueInfo4, pbstrGuidQueue: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ServiceTypeGuid: fn( self: *const IMSMQQueueInfo4, pbstrGuidServiceType: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ServiceTypeGuid: fn( self: *const IMSMQQueueInfo4, bstrGuidServiceType: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Label: fn( self: *const IMSMQQueueInfo4, pbstrLabel: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Label: fn( self: *const IMSMQQueueInfo4, bstrLabel: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PathName: fn( self: *const IMSMQQueueInfo4, pbstrPathName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PathName: fn( self: *const IMSMQQueueInfo4, bstrPathName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FormatName: fn( self: *const IMSMQQueueInfo4, pbstrFormatName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FormatName: fn( self: *const IMSMQQueueInfo4, bstrFormatName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsTransactional: fn( self: *const IMSMQQueueInfo4, pisTransactional: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivLevel: fn( self: *const IMSMQQueueInfo4, plPrivLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PrivLevel: fn( self: *const IMSMQQueueInfo4, lPrivLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Journal: fn( self: *const IMSMQQueueInfo4, plJournal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Journal: fn( self: *const IMSMQQueueInfo4, lJournal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Quota: fn( self: *const IMSMQQueueInfo4, plQuota: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Quota: fn( self: *const IMSMQQueueInfo4, lQuota: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BasePriority: fn( self: *const IMSMQQueueInfo4, plBasePriority: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BasePriority: fn( self: *const IMSMQQueueInfo4, lBasePriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CreateTime: fn( self: *const IMSMQQueueInfo4, pvarCreateTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModifyTime: fn( self: *const IMSMQQueueInfo4, pvarModifyTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Authenticate: fn( self: *const IMSMQQueueInfo4, plAuthenticate: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Authenticate: fn( self: *const IMSMQQueueInfo4, lAuthenticate: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_JournalQuota: fn( self: *const IMSMQQueueInfo4, plJournalQuota: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_JournalQuota: fn( self: *const IMSMQQueueInfo4, lJournalQuota: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsWorldReadable: fn( self: *const IMSMQQueueInfo4, pisWorldReadable: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Create: fn( self: *const IMSMQQueueInfo4, IsTransactional: ?*VARIANT, IsWorldReadable: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Open: fn( self: *const IMSMQQueueInfo4, Access: i32, ShareMode: i32, ppq: ?*?*IMSMQQueue4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Refresh: fn( self: *const IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Update: fn( self: *const IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PathNameDNS: fn( self: *const IMSMQQueueInfo4, pbstrPathNameDNS: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueueInfo4, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Security: fn( self: *const IMSMQQueueInfo4, pvarSecurity: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Security: fn( self: *const IMSMQQueueInfo4, varSecurity: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsTransactional2: fn( self: *const IMSMQQueueInfo4, pisTransactional: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsWorldReadable2: fn( self: *const IMSMQQueueInfo4, pisWorldReadable: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MulticastAddress: fn( self: *const IMSMQQueueInfo4, pbstrMulticastAddress: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MulticastAddress: fn( self: *const IMSMQQueueInfo4, bstrMulticastAddress: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ADsPath: fn( self: *const IMSMQQueueInfo4, pbstrADsPath: ?*?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 IMSMQQueueInfo4_get_QueueGuid(self: *const T, pbstrGuidQueue: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_QueueGuid(@ptrCast(*const IMSMQQueueInfo4, self), pbstrGuidQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_ServiceTypeGuid(self: *const T, pbstrGuidServiceType: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_ServiceTypeGuid(@ptrCast(*const IMSMQQueueInfo4, self), pbstrGuidServiceType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_ServiceTypeGuid(self: *const T, bstrGuidServiceType: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_ServiceTypeGuid(@ptrCast(*const IMSMQQueueInfo4, self), bstrGuidServiceType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_Label(self: *const T, pbstrLabel: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_Label(@ptrCast(*const IMSMQQueueInfo4, self), pbstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_Label(self: *const T, bstrLabel: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_Label(@ptrCast(*const IMSMQQueueInfo4, self), bstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_PathName(self: *const T, pbstrPathName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_PathName(@ptrCast(*const IMSMQQueueInfo4, self), pbstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_PathName(self: *const T, bstrPathName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_PathName(@ptrCast(*const IMSMQQueueInfo4, self), bstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_FormatName(self: *const T, pbstrFormatName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_FormatName(@ptrCast(*const IMSMQQueueInfo4, self), pbstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_FormatName(self: *const T, bstrFormatName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_FormatName(@ptrCast(*const IMSMQQueueInfo4, self), bstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_IsTransactional(self: *const T, pisTransactional: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_IsTransactional(@ptrCast(*const IMSMQQueueInfo4, self), pisTransactional); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_PrivLevel(self: *const T, plPrivLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_PrivLevel(@ptrCast(*const IMSMQQueueInfo4, self), plPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_PrivLevel(self: *const T, lPrivLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_PrivLevel(@ptrCast(*const IMSMQQueueInfo4, self), lPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_Journal(self: *const T, plJournal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_Journal(@ptrCast(*const IMSMQQueueInfo4, self), plJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_Journal(self: *const T, lJournal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_Journal(@ptrCast(*const IMSMQQueueInfo4, self), lJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_Quota(self: *const T, plQuota: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_Quota(@ptrCast(*const IMSMQQueueInfo4, self), plQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_Quota(self: *const T, lQuota: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_Quota(@ptrCast(*const IMSMQQueueInfo4, self), lQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_BasePriority(self: *const T, plBasePriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_BasePriority(@ptrCast(*const IMSMQQueueInfo4, self), plBasePriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_BasePriority(self: *const T, lBasePriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_BasePriority(@ptrCast(*const IMSMQQueueInfo4, self), lBasePriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_CreateTime(self: *const T, pvarCreateTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_CreateTime(@ptrCast(*const IMSMQQueueInfo4, self), pvarCreateTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_ModifyTime(self: *const T, pvarModifyTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_ModifyTime(@ptrCast(*const IMSMQQueueInfo4, self), pvarModifyTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_Authenticate(self: *const T, plAuthenticate: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_Authenticate(@ptrCast(*const IMSMQQueueInfo4, self), plAuthenticate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_Authenticate(self: *const T, lAuthenticate: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_Authenticate(@ptrCast(*const IMSMQQueueInfo4, self), lAuthenticate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_JournalQuota(self: *const T, plJournalQuota: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_JournalQuota(@ptrCast(*const IMSMQQueueInfo4, self), plJournalQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_JournalQuota(self: *const T, lJournalQuota: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_JournalQuota(@ptrCast(*const IMSMQQueueInfo4, self), lJournalQuota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_IsWorldReadable(self: *const T, pisWorldReadable: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_IsWorldReadable(@ptrCast(*const IMSMQQueueInfo4, self), pisWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_Create(self: *const T, IsTransactional: ?*VARIANT, IsWorldReadable: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).Create(@ptrCast(*const IMSMQQueueInfo4, self), IsTransactional, IsWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).Delete(@ptrCast(*const IMSMQQueueInfo4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_Open(self: *const T, Access: i32, ShareMode: i32, ppq: ?*?*IMSMQQueue4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).Open(@ptrCast(*const IMSMQQueueInfo4, self), Access, ShareMode, ppq); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_Refresh(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).Refresh(@ptrCast(*const IMSMQQueueInfo4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_Update(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).Update(@ptrCast(*const IMSMQQueueInfo4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_PathNameDNS(self: *const T, pbstrPathNameDNS: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_PathNameDNS(@ptrCast(*const IMSMQQueueInfo4, self), pbstrPathNameDNS); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueueInfo4, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_Security(self: *const T, pvarSecurity: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_Security(@ptrCast(*const IMSMQQueueInfo4, self), pvarSecurity); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_Security(self: *const T, varSecurity: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_Security(@ptrCast(*const IMSMQQueueInfo4, self), varSecurity); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_IsTransactional2(self: *const T, pisTransactional: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_IsTransactional2(@ptrCast(*const IMSMQQueueInfo4, self), pisTransactional); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_IsWorldReadable2(self: *const T, pisWorldReadable: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_IsWorldReadable2(@ptrCast(*const IMSMQQueueInfo4, self), pisWorldReadable); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_MulticastAddress(self: *const T, pbstrMulticastAddress: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_MulticastAddress(@ptrCast(*const IMSMQQueueInfo4, self), pbstrMulticastAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_put_MulticastAddress(self: *const T, bstrMulticastAddress: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).put_MulticastAddress(@ptrCast(*const IMSMQQueueInfo4, self), bstrMulticastAddress); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfo4_get_ADsPath(self: *const T, pbstrADsPath: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfo4.VTable, self.vtable).get_ADsPath(@ptrCast(*const IMSMQQueueInfo4, self), pbstrADsPath); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueue_Value = @import("../zig.zig").Guid.initString("d7d6e076-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQQueue = &IID_IMSMQQueue_Value; pub const IMSMQQueue = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Access: fn( self: *const IMSMQQueue, plAccess: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ShareMode: fn( self: *const IMSMQQueue, plShareMode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueInfo: fn( self: *const IMSMQQueue, ppqinfo: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Handle: fn( self: *const IMSMQQueue, plHandle: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsOpen: fn( self: *const IMSMQQueue, pisOpen: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Close: fn( self: *const IMSMQQueue, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Receive: fn( self: *const IMSMQQueue, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Peek: fn( self: *const IMSMQQueue, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnableNotification: fn( self: *const IMSMQQueue, Event: ?*IMSMQEvent, Cursor: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IMSMQQueue, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveCurrent: fn( self: *const IMSMQQueue, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNext: fn( self: *const IMSMQQueue, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekCurrent: fn( self: *const IMSMQQueue, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) 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 IMSMQQueue_get_Access(self: *const T, plAccess: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).get_Access(@ptrCast(*const IMSMQQueue, self), plAccess); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_get_ShareMode(self: *const T, plShareMode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).get_ShareMode(@ptrCast(*const IMSMQQueue, self), plShareMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_get_QueueInfo(self: *const T, ppqinfo: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).get_QueueInfo(@ptrCast(*const IMSMQQueue, self), ppqinfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_get_Handle(self: *const T, plHandle: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).get_Handle(@ptrCast(*const IMSMQQueue, self), plHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_get_IsOpen(self: *const T, pisOpen: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).get_IsOpen(@ptrCast(*const IMSMQQueue, self), pisOpen); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_Close(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).Close(@ptrCast(*const IMSMQQueue, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_Receive(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).Receive(@ptrCast(*const IMSMQQueue, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_Peek(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).Peek(@ptrCast(*const IMSMQQueue, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_EnableNotification(self: *const T, Event: ?*IMSMQEvent, Cursor: ?*VARIANT, ReceiveTimeout: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).EnableNotification(@ptrCast(*const IMSMQQueue, self), Event, Cursor, ReceiveTimeout); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).Reset(@ptrCast(*const IMSMQQueue, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_ReceiveCurrent(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).ReceiveCurrent(@ptrCast(*const IMSMQQueue, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_PeekNext(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).PeekNext(@ptrCast(*const IMSMQQueue, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue_PeekCurrent(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue.VTable, self.vtable).PeekCurrent(@ptrCast(*const IMSMQQueue, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueue2_Value = @import("../zig.zig").Guid.initString("ef0574e0-06d8-11d3-b100-00e02c074f6b"); pub const IID_IMSMQQueue2 = &IID_IMSMQQueue2_Value; pub const IMSMQQueue2 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Access: fn( self: *const IMSMQQueue2, plAccess: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ShareMode: fn( self: *const IMSMQQueue2, plShareMode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueInfo: fn( self: *const IMSMQQueue2, ppqinfo: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Handle: fn( self: *const IMSMQQueue2, plHandle: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsOpen: fn( self: *const IMSMQQueue2, pisOpen: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Close: fn( self: *const IMSMQQueue2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Receive_v1: fn( self: *const IMSMQQueue2, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Peek_v1: fn( self: *const IMSMQQueue2, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnableNotification: fn( self: *const IMSMQQueue2, Event: ?*IMSMQEvent2, Cursor: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IMSMQQueue2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveCurrent_v1: fn( self: *const IMSMQQueue2, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNext_v1: fn( self: *const IMSMQQueue2, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekCurrent_v1: fn( self: *const IMSMQQueue2, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Receive: fn( self: *const IMSMQQueue2, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Peek: fn( self: *const IMSMQQueue2, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveCurrent: fn( self: *const IMSMQQueue2, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNext: fn( self: *const IMSMQQueue2, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekCurrent: fn( self: *const IMSMQQueue2, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueue2, ppcolProperties: ?*?*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 IMSMQQueue2_get_Access(self: *const T, plAccess: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).get_Access(@ptrCast(*const IMSMQQueue2, self), plAccess); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_get_ShareMode(self: *const T, plShareMode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).get_ShareMode(@ptrCast(*const IMSMQQueue2, self), plShareMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_get_QueueInfo(self: *const T, ppqinfo: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).get_QueueInfo(@ptrCast(*const IMSMQQueue2, self), ppqinfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_get_Handle(self: *const T, plHandle: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).get_Handle(@ptrCast(*const IMSMQQueue2, self), plHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_get_IsOpen(self: *const T, pisOpen: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).get_IsOpen(@ptrCast(*const IMSMQQueue2, self), pisOpen); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_Close(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).Close(@ptrCast(*const IMSMQQueue2, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_Receive_v1(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).Receive_v1(@ptrCast(*const IMSMQQueue2, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_Peek_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).Peek_v1(@ptrCast(*const IMSMQQueue2, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_EnableNotification(self: *const T, Event: ?*IMSMQEvent2, Cursor: ?*VARIANT, ReceiveTimeout: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).EnableNotification(@ptrCast(*const IMSMQQueue2, self), Event, Cursor, ReceiveTimeout); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).Reset(@ptrCast(*const IMSMQQueue2, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_ReceiveCurrent_v1(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).ReceiveCurrent_v1(@ptrCast(*const IMSMQQueue2, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_PeekNext_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).PeekNext_v1(@ptrCast(*const IMSMQQueue2, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_PeekCurrent_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).PeekCurrent_v1(@ptrCast(*const IMSMQQueue2, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_Receive(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).Receive(@ptrCast(*const IMSMQQueue2, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_Peek(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).Peek(@ptrCast(*const IMSMQQueue2, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_ReceiveCurrent(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).ReceiveCurrent(@ptrCast(*const IMSMQQueue2, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_PeekNext(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).PeekNext(@ptrCast(*const IMSMQQueue2, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_PeekCurrent(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).PeekCurrent(@ptrCast(*const IMSMQQueue2, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueue2, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueue3_Value = @import("../zig.zig").Guid.initString("eba96b1b-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQueue3 = &IID_IMSMQQueue3_Value; pub const IMSMQQueue3 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Access: fn( self: *const IMSMQQueue3, plAccess: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ShareMode: fn( self: *const IMSMQQueue3, plShareMode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueInfo: fn( self: *const IMSMQQueue3, ppqinfo: ?*?*IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Handle: fn( self: *const IMSMQQueue3, plHandle: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsOpen: fn( self: *const IMSMQQueue3, pisOpen: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Close: fn( self: *const IMSMQQueue3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Receive_v1: fn( self: *const IMSMQQueue3, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Peek_v1: fn( self: *const IMSMQQueue3, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnableNotification: fn( self: *const IMSMQQueue3, Event: ?*IMSMQEvent3, Cursor: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IMSMQQueue3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveCurrent_v1: fn( self: *const IMSMQQueue3, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNext_v1: fn( self: *const IMSMQQueue3, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekCurrent_v1: fn( self: *const IMSMQQueue3, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Receive: fn( self: *const IMSMQQueue3, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Peek: fn( self: *const IMSMQQueue3, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveCurrent: fn( self: *const IMSMQQueue3, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNext: fn( self: *const IMSMQQueue3, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekCurrent: fn( self: *const IMSMQQueue3, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueue3, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Handle2: fn( self: *const IMSMQQueue3, pvarHandle: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveByLookupId: fn( self: *const IMSMQQueue3, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveNextByLookupId: fn( self: *const IMSMQQueue3, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceivePreviousByLookupId: fn( self: *const IMSMQQueue3, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveFirstByLookupId: fn( self: *const IMSMQQueue3, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveLastByLookupId: fn( self: *const IMSMQQueue3, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekByLookupId: fn( self: *const IMSMQQueue3, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNextByLookupId: fn( self: *const IMSMQQueue3, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekPreviousByLookupId: fn( self: *const IMSMQQueue3, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekFirstByLookupId: fn( self: *const IMSMQQueue3, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekLastByLookupId: fn( self: *const IMSMQQueue3, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Purge: fn( self: *const IMSMQQueue3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsOpen2: fn( self: *const IMSMQQueue3, pisOpen: ?*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 IMSMQQueue3_get_Access(self: *const T, plAccess: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).get_Access(@ptrCast(*const IMSMQQueue3, self), plAccess); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_get_ShareMode(self: *const T, plShareMode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).get_ShareMode(@ptrCast(*const IMSMQQueue3, self), plShareMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_get_QueueInfo(self: *const T, ppqinfo: ?*?*IMSMQQueueInfo3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).get_QueueInfo(@ptrCast(*const IMSMQQueue3, self), ppqinfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_get_Handle(self: *const T, plHandle: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).get_Handle(@ptrCast(*const IMSMQQueue3, self), plHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_get_IsOpen(self: *const T, pisOpen: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).get_IsOpen(@ptrCast(*const IMSMQQueue3, self), pisOpen); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_Close(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).Close(@ptrCast(*const IMSMQQueue3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_Receive_v1(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).Receive_v1(@ptrCast(*const IMSMQQueue3, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_Peek_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).Peek_v1(@ptrCast(*const IMSMQQueue3, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_EnableNotification(self: *const T, Event: ?*IMSMQEvent3, Cursor: ?*VARIANT, ReceiveTimeout: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).EnableNotification(@ptrCast(*const IMSMQQueue3, self), Event, Cursor, ReceiveTimeout); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).Reset(@ptrCast(*const IMSMQQueue3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_ReceiveCurrent_v1(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).ReceiveCurrent_v1(@ptrCast(*const IMSMQQueue3, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekNext_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekNext_v1(@ptrCast(*const IMSMQQueue3, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekCurrent_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekCurrent_v1(@ptrCast(*const IMSMQQueue3, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_Receive(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).Receive(@ptrCast(*const IMSMQQueue3, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_Peek(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).Peek(@ptrCast(*const IMSMQQueue3, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_ReceiveCurrent(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).ReceiveCurrent(@ptrCast(*const IMSMQQueue3, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekNext(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekNext(@ptrCast(*const IMSMQQueue3, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekCurrent(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekCurrent(@ptrCast(*const IMSMQQueue3, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueue3, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_get_Handle2(self: *const T, pvarHandle: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).get_Handle2(@ptrCast(*const IMSMQQueue3, self), pvarHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_ReceiveByLookupId(self: *const T, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).ReceiveByLookupId(@ptrCast(*const IMSMQQueue3, self), LookupId, Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_ReceiveNextByLookupId(self: *const T, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).ReceiveNextByLookupId(@ptrCast(*const IMSMQQueue3, self), LookupId, Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_ReceivePreviousByLookupId(self: *const T, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).ReceivePreviousByLookupId(@ptrCast(*const IMSMQQueue3, self), LookupId, Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_ReceiveFirstByLookupId(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).ReceiveFirstByLookupId(@ptrCast(*const IMSMQQueue3, self), Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_ReceiveLastByLookupId(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).ReceiveLastByLookupId(@ptrCast(*const IMSMQQueue3, self), Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekByLookupId(self: *const T, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekByLookupId(@ptrCast(*const IMSMQQueue3, self), LookupId, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekNextByLookupId(self: *const T, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekNextByLookupId(@ptrCast(*const IMSMQQueue3, self), LookupId, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekPreviousByLookupId(self: *const T, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekPreviousByLookupId(@ptrCast(*const IMSMQQueue3, self), LookupId, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekFirstByLookupId(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekFirstByLookupId(@ptrCast(*const IMSMQQueue3, self), WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_PeekLastByLookupId(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).PeekLastByLookupId(@ptrCast(*const IMSMQQueue3, self), WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_Purge(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).Purge(@ptrCast(*const IMSMQQueue3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue3_get_IsOpen2(self: *const T, pisOpen: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue3.VTable, self.vtable).get_IsOpen2(@ptrCast(*const IMSMQQueue3, self), pisOpen); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueue4_Value = @import("../zig.zig").Guid.initString("eba96b20-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQueue4 = &IID_IMSMQQueue4_Value; pub const IMSMQQueue4 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Access: fn( self: *const IMSMQQueue4, plAccess: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ShareMode: fn( self: *const IMSMQQueue4, plShareMode: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueInfo: fn( self: *const IMSMQQueue4, ppqinfo: ?*?*IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Handle: fn( self: *const IMSMQQueue4, plHandle: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsOpen: fn( self: *const IMSMQQueue4, pisOpen: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Close: fn( self: *const IMSMQQueue4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Receive_v1: fn( self: *const IMSMQQueue4, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Peek_v1: fn( self: *const IMSMQQueue4, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnableNotification: fn( self: *const IMSMQQueue4, Event: ?*IMSMQEvent3, Cursor: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Reset: fn( self: *const IMSMQQueue4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveCurrent_v1: fn( self: *const IMSMQQueue4, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNext_v1: fn( self: *const IMSMQQueue4, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekCurrent_v1: fn( self: *const IMSMQQueue4, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Receive: fn( self: *const IMSMQQueue4, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Peek: fn( self: *const IMSMQQueue4, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveCurrent: fn( self: *const IMSMQQueue4, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNext: fn( self: *const IMSMQQueue4, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekCurrent: fn( self: *const IMSMQQueue4, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueue4, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Handle2: fn( self: *const IMSMQQueue4, pvarHandle: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveByLookupId: fn( self: *const IMSMQQueue4, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveNextByLookupId: fn( self: *const IMSMQQueue4, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceivePreviousByLookupId: fn( self: *const IMSMQQueue4, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveFirstByLookupId: fn( self: *const IMSMQQueue4, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveLastByLookupId: fn( self: *const IMSMQQueue4, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekByLookupId: fn( self: *const IMSMQQueue4, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekNextByLookupId: fn( self: *const IMSMQQueue4, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekPreviousByLookupId: fn( self: *const IMSMQQueue4, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekFirstByLookupId: fn( self: *const IMSMQQueue4, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, PeekLastByLookupId: fn( self: *const IMSMQQueue4, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Purge: fn( self: *const IMSMQQueue4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsOpen2: fn( self: *const IMSMQQueue4, pisOpen: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ReceiveByLookupIdAllowPeek: fn( self: *const IMSMQQueue4, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4, ) 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 IMSMQQueue4_get_Access(self: *const T, plAccess: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).get_Access(@ptrCast(*const IMSMQQueue4, self), plAccess); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_get_ShareMode(self: *const T, plShareMode: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).get_ShareMode(@ptrCast(*const IMSMQQueue4, self), plShareMode); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_get_QueueInfo(self: *const T, ppqinfo: ?*?*IMSMQQueueInfo4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).get_QueueInfo(@ptrCast(*const IMSMQQueue4, self), ppqinfo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_get_Handle(self: *const T, plHandle: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).get_Handle(@ptrCast(*const IMSMQQueue4, self), plHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_get_IsOpen(self: *const T, pisOpen: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).get_IsOpen(@ptrCast(*const IMSMQQueue4, self), pisOpen); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_Close(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).Close(@ptrCast(*const IMSMQQueue4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_Receive_v1(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).Receive_v1(@ptrCast(*const IMSMQQueue4, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_Peek_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).Peek_v1(@ptrCast(*const IMSMQQueue4, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_EnableNotification(self: *const T, Event: ?*IMSMQEvent3, Cursor: ?*VARIANT, ReceiveTimeout: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).EnableNotification(@ptrCast(*const IMSMQQueue4, self), Event, Cursor, ReceiveTimeout); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).Reset(@ptrCast(*const IMSMQQueue4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_ReceiveCurrent_v1(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).ReceiveCurrent_v1(@ptrCast(*const IMSMQQueue4, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekNext_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekNext_v1(@ptrCast(*const IMSMQQueue4, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekCurrent_v1(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, ppmsg: ?*?*IMSMQMessage) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekCurrent_v1(@ptrCast(*const IMSMQQueue4, self), WantDestinationQueue, WantBody, ReceiveTimeout, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_Receive(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).Receive(@ptrCast(*const IMSMQQueue4, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_Peek(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).Peek(@ptrCast(*const IMSMQQueue4, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_ReceiveCurrent(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).ReceiveCurrent(@ptrCast(*const IMSMQQueue4, self), Transaction, WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekNext(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekNext(@ptrCast(*const IMSMQQueue4, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekCurrent(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, ReceiveTimeout: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekCurrent(@ptrCast(*const IMSMQQueue4, self), WantDestinationQueue, WantBody, ReceiveTimeout, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueue4, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_get_Handle2(self: *const T, pvarHandle: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).get_Handle2(@ptrCast(*const IMSMQQueue4, self), pvarHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_ReceiveByLookupId(self: *const T, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).ReceiveByLookupId(@ptrCast(*const IMSMQQueue4, self), LookupId, Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_ReceiveNextByLookupId(self: *const T, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).ReceiveNextByLookupId(@ptrCast(*const IMSMQQueue4, self), LookupId, Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_ReceivePreviousByLookupId(self: *const T, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).ReceivePreviousByLookupId(@ptrCast(*const IMSMQQueue4, self), LookupId, Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_ReceiveFirstByLookupId(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).ReceiveFirstByLookupId(@ptrCast(*const IMSMQQueue4, self), Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_ReceiveLastByLookupId(self: *const T, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).ReceiveLastByLookupId(@ptrCast(*const IMSMQQueue4, self), Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekByLookupId(self: *const T, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekByLookupId(@ptrCast(*const IMSMQQueue4, self), LookupId, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekNextByLookupId(self: *const T, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekNextByLookupId(@ptrCast(*const IMSMQQueue4, self), LookupId, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekPreviousByLookupId(self: *const T, LookupId: VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekPreviousByLookupId(@ptrCast(*const IMSMQQueue4, self), LookupId, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekFirstByLookupId(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekFirstByLookupId(@ptrCast(*const IMSMQQueue4, self), WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_PeekLastByLookupId(self: *const T, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).PeekLastByLookupId(@ptrCast(*const IMSMQQueue4, self), WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_Purge(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).Purge(@ptrCast(*const IMSMQQueue4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_get_IsOpen2(self: *const T, pisOpen: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).get_IsOpen2(@ptrCast(*const IMSMQQueue4, self), pisOpen); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueue4_ReceiveByLookupIdAllowPeek(self: *const T, LookupId: VARIANT, Transaction: ?*VARIANT, WantDestinationQueue: ?*VARIANT, WantBody: ?*VARIANT, WantConnectorType: ?*VARIANT, ppmsg: ?*?*IMSMQMessage4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueue4.VTable, self.vtable).ReceiveByLookupIdAllowPeek(@ptrCast(*const IMSMQQueue4, self), LookupId, Transaction, WantDestinationQueue, WantBody, WantConnectorType, ppmsg); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQMessage_Value = @import("../zig.zig").Guid.initString("d7d6e074-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQMessage = &IID_IMSMQMessage_Value; pub const IMSMQMessage = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Class: fn( self: *const IMSMQMessage, plClass: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivLevel: fn( self: *const IMSMQMessage, plPrivLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PrivLevel: fn( self: *const IMSMQMessage, lPrivLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthLevel: fn( self: *const IMSMQMessage, plAuthLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthLevel: fn( self: *const IMSMQMessage, lAuthLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsAuthenticated: fn( self: *const IMSMQMessage, pisAuthenticated: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Delivery: fn( self: *const IMSMQMessage, plDelivery: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Delivery: fn( self: *const IMSMQMessage, lDelivery: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Trace: fn( self: *const IMSMQMessage, plTrace: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Trace: fn( self: *const IMSMQMessage, lTrace: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Priority: fn( self: *const IMSMQMessage, plPriority: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Priority: fn( self: *const IMSMQMessage, lPriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Journal: fn( self: *const IMSMQMessage, plJournal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Journal: fn( self: *const IMSMQMessage, lJournal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo: fn( self: *const IMSMQMessage, ppqinfoResponse: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo: fn( self: *const IMSMQMessage, pqinfoResponse: ?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AppSpecific: fn( self: *const IMSMQMessage, 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 IMSMQMessage, lAppSpecific: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SourceMachineGuid: fn( self: *const IMSMQMessage, pbstrGuidSrcMachine: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BodyLength: fn( self: *const IMSMQMessage, pcbBody: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Body: fn( self: *const IMSMQMessage, pvarBody: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Body: fn( self: *const IMSMQMessage, varBody: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo: fn( self: *const IMSMQMessage, ppqinfoAdmin: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo: fn( self: *const IMSMQMessage, pqinfoAdmin: ?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Id: fn( self: *const IMSMQMessage, pvarMsgId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CorrelationId: fn( self: *const IMSMQMessage, pvarMsgId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CorrelationId: fn( self: *const IMSMQMessage, varMsgId: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Ack: fn( self: *const IMSMQMessage, plAck: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Ack: fn( self: *const IMSMQMessage, lAck: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Label: fn( self: *const IMSMQMessage, pbstrLabel: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Label: fn( self: *const IMSMQMessage, bstrLabel: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxTimeToReachQueue: fn( self: *const IMSMQMessage, plMaxTimeToReachQueue: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MaxTimeToReachQueue: fn( self: *const IMSMQMessage, lMaxTimeToReachQueue: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxTimeToReceive: fn( self: *const IMSMQMessage, plMaxTimeToReceive: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MaxTimeToReceive: fn( self: *const IMSMQMessage, lMaxTimeToReceive: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HashAlgorithm: fn( self: *const IMSMQMessage, plHashAlg: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_HashAlgorithm: fn( self: *const IMSMQMessage, lHashAlg: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EncryptAlgorithm: fn( self: *const IMSMQMessage, plEncryptAlg: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EncryptAlgorithm: fn( self: *const IMSMQMessage, lEncryptAlg: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SentTime: fn( self: *const IMSMQMessage, pvarSentTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ArrivedTime: fn( self: *const IMSMQMessage, plArrivedTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestinationQueueInfo: fn( self: *const IMSMQMessage, ppqinfoDest: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderCertificate: fn( self: *const IMSMQMessage, pvarSenderCert: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderCertificate: fn( self: *const IMSMQMessage, varSenderCert: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderId: fn( self: *const IMSMQMessage, pvarSenderId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderIdType: fn( self: *const IMSMQMessage, plSenderIdType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderIdType: fn( self: *const IMSMQMessage, lSenderIdType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Send: fn( self: *const IMSMQMessage, DestinationQueue: ?*IMSMQQueue, Transaction: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AttachCurrentSecurityContext: fn( self: *const IMSMQMessage, ) 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 IMSMQMessage_get_Class(self: *const T, plClass: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Class(@ptrCast(*const IMSMQMessage, self), plClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_PrivLevel(self: *const T, plPrivLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_PrivLevel(@ptrCast(*const IMSMQMessage, self), plPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_PrivLevel(self: *const T, lPrivLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_PrivLevel(@ptrCast(*const IMSMQMessage, self), lPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_AuthLevel(self: *const T, plAuthLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_AuthLevel(@ptrCast(*const IMSMQMessage, self), plAuthLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_AuthLevel(self: *const T, lAuthLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_AuthLevel(@ptrCast(*const IMSMQMessage, self), lAuthLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_IsAuthenticated(self: *const T, pisAuthenticated: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_IsAuthenticated(@ptrCast(*const IMSMQMessage, self), pisAuthenticated); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_Delivery(self: *const T, plDelivery: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Delivery(@ptrCast(*const IMSMQMessage, self), plDelivery); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_Delivery(self: *const T, lDelivery: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_Delivery(@ptrCast(*const IMSMQMessage, self), lDelivery); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_Trace(self: *const T, plTrace: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Trace(@ptrCast(*const IMSMQMessage, self), plTrace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_Trace(self: *const T, lTrace: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_Trace(@ptrCast(*const IMSMQMessage, self), lTrace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_Priority(self: *const T, plPriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Priority(@ptrCast(*const IMSMQMessage, self), plPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_Priority(self: *const T, lPriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_Priority(@ptrCast(*const IMSMQMessage, self), lPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_Journal(self: *const T, plJournal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Journal(@ptrCast(*const IMSMQMessage, self), plJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_Journal(self: *const T, lJournal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_Journal(@ptrCast(*const IMSMQMessage, self), lJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_ResponseQueueInfo(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_ResponseQueueInfo(@ptrCast(*const IMSMQMessage, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_putref_ResponseQueueInfo(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).putref_ResponseQueueInfo(@ptrCast(*const IMSMQMessage, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_AppSpecific(self: *const T, plAppSpecific: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_AppSpecific(@ptrCast(*const IMSMQMessage, self), plAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_AppSpecific(self: *const T, lAppSpecific: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_AppSpecific(@ptrCast(*const IMSMQMessage, self), lAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_SourceMachineGuid(self: *const T, pbstrGuidSrcMachine: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_SourceMachineGuid(@ptrCast(*const IMSMQMessage, self), pbstrGuidSrcMachine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_BodyLength(self: *const T, pcbBody: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_BodyLength(@ptrCast(*const IMSMQMessage, self), pcbBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_Body(self: *const T, pvarBody: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Body(@ptrCast(*const IMSMQMessage, self), pvarBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_Body(self: *const T, varBody: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_Body(@ptrCast(*const IMSMQMessage, self), varBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_AdminQueueInfo(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_AdminQueueInfo(@ptrCast(*const IMSMQMessage, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_putref_AdminQueueInfo(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).putref_AdminQueueInfo(@ptrCast(*const IMSMQMessage, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_Id(self: *const T, pvarMsgId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Id(@ptrCast(*const IMSMQMessage, self), pvarMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_CorrelationId(self: *const T, pvarMsgId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_CorrelationId(@ptrCast(*const IMSMQMessage, self), pvarMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_CorrelationId(self: *const T, varMsgId: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_CorrelationId(@ptrCast(*const IMSMQMessage, self), varMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_Ack(self: *const T, plAck: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Ack(@ptrCast(*const IMSMQMessage, self), plAck); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_Ack(self: *const T, lAck: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_Ack(@ptrCast(*const IMSMQMessage, self), lAck); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_Label(self: *const T, pbstrLabel: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_Label(@ptrCast(*const IMSMQMessage, self), pbstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_Label(self: *const T, bstrLabel: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_Label(@ptrCast(*const IMSMQMessage, self), bstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_MaxTimeToReachQueue(self: *const T, plMaxTimeToReachQueue: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_MaxTimeToReachQueue(@ptrCast(*const IMSMQMessage, self), plMaxTimeToReachQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_MaxTimeToReachQueue(self: *const T, lMaxTimeToReachQueue: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_MaxTimeToReachQueue(@ptrCast(*const IMSMQMessage, self), lMaxTimeToReachQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_MaxTimeToReceive(self: *const T, plMaxTimeToReceive: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_MaxTimeToReceive(@ptrCast(*const IMSMQMessage, self), plMaxTimeToReceive); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_MaxTimeToReceive(self: *const T, lMaxTimeToReceive: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_MaxTimeToReceive(@ptrCast(*const IMSMQMessage, self), lMaxTimeToReceive); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_HashAlgorithm(self: *const T, plHashAlg: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const IMSMQMessage, self), plHashAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_HashAlgorithm(self: *const T, lHashAlg: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const IMSMQMessage, self), lHashAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_EncryptAlgorithm(self: *const T, plEncryptAlg: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_EncryptAlgorithm(@ptrCast(*const IMSMQMessage, self), plEncryptAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_EncryptAlgorithm(self: *const T, lEncryptAlg: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_EncryptAlgorithm(@ptrCast(*const IMSMQMessage, self), lEncryptAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_SentTime(self: *const T, pvarSentTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_SentTime(@ptrCast(*const IMSMQMessage, self), pvarSentTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_ArrivedTime(self: *const T, plArrivedTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_ArrivedTime(@ptrCast(*const IMSMQMessage, self), plArrivedTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_DestinationQueueInfo(self: *const T, ppqinfoDest: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_DestinationQueueInfo(@ptrCast(*const IMSMQMessage, self), ppqinfoDest); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_SenderCertificate(self: *const T, pvarSenderCert: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_SenderCertificate(@ptrCast(*const IMSMQMessage, self), pvarSenderCert); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_SenderCertificate(self: *const T, varSenderCert: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_SenderCertificate(@ptrCast(*const IMSMQMessage, self), varSenderCert); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_SenderId(self: *const T, pvarSenderId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_SenderId(@ptrCast(*const IMSMQMessage, self), pvarSenderId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_get_SenderIdType(self: *const T, plSenderIdType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).get_SenderIdType(@ptrCast(*const IMSMQMessage, self), plSenderIdType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_put_SenderIdType(self: *const T, lSenderIdType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).put_SenderIdType(@ptrCast(*const IMSMQMessage, self), lSenderIdType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_Send(self: *const T, DestinationQueue: ?*IMSMQQueue, Transaction: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).Send(@ptrCast(*const IMSMQMessage, self), DestinationQueue, Transaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage_AttachCurrentSecurityContext(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage.VTable, self.vtable).AttachCurrentSecurityContext(@ptrCast(*const IMSMQMessage, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueInfos_Value = @import("../zig.zig").Guid.initString("d7d6e07d-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQQueueInfos = &IID_IMSMQQueueInfos_Value; pub const IMSMQQueueInfos = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Reset: fn( self: *const IMSMQQueueInfos, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Next: fn( self: *const IMSMQQueueInfos, ppqinfoNext: ?*?*IMSMQQueueInfo, ) 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 IMSMQQueueInfos_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos.VTable, self.vtable).Reset(@ptrCast(*const IMSMQQueueInfos, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfos_Next(self: *const T, ppqinfoNext: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos.VTable, self.vtable).Next(@ptrCast(*const IMSMQQueueInfos, self), ppqinfoNext); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueInfos2_Value = @import("../zig.zig").Guid.initString("eba96b0f-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQueueInfos2 = &IID_IMSMQQueueInfos2_Value; pub const IMSMQQueueInfos2 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Reset: fn( self: *const IMSMQQueueInfos2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Next: fn( self: *const IMSMQQueueInfos2, ppqinfoNext: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueueInfos2, ppcolProperties: ?*?*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 IMSMQQueueInfos2_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos2.VTable, self.vtable).Reset(@ptrCast(*const IMSMQQueueInfos2, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfos2_Next(self: *const T, ppqinfoNext: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos2.VTable, self.vtable).Next(@ptrCast(*const IMSMQQueueInfos2, self), ppqinfoNext); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfos2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueueInfos2, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueInfos3_Value = @import("../zig.zig").Guid.initString("eba96b1e-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQueueInfos3 = &IID_IMSMQQueueInfos3_Value; pub const IMSMQQueueInfos3 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Reset: fn( self: *const IMSMQQueueInfos3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Next: fn( self: *const IMSMQQueueInfos3, ppqinfoNext: ?*?*IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueueInfos3, ppcolProperties: ?*?*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 IMSMQQueueInfos3_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos3.VTable, self.vtable).Reset(@ptrCast(*const IMSMQQueueInfos3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfos3_Next(self: *const T, ppqinfoNext: ?*?*IMSMQQueueInfo3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos3.VTable, self.vtable).Next(@ptrCast(*const IMSMQQueueInfos3, self), ppqinfoNext); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfos3_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos3.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueueInfos3, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueInfos4_Value = @import("../zig.zig").Guid.initString("eba96b22-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQueueInfos4 = &IID_IMSMQQueueInfos4_Value; pub const IMSMQQueueInfos4 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Reset: fn( self: *const IMSMQQueueInfos4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Next: fn( self: *const IMSMQQueueInfos4, ppqinfoNext: ?*?*IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQueueInfos4, ppcolProperties: ?*?*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 IMSMQQueueInfos4_Reset(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos4.VTable, self.vtable).Reset(@ptrCast(*const IMSMQQueueInfos4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfos4_Next(self: *const T, ppqinfoNext: ?*?*IMSMQQueueInfo4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos4.VTable, self.vtable).Next(@ptrCast(*const IMSMQQueueInfos4, self), ppqinfoNext); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueInfos4_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueInfos4.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQueueInfos4, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQEvent_Value = @import("../zig.zig").Guid.initString("d7d6e077-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQEvent = &IID_IMSMQEvent_Value; pub const IMSMQEvent = 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 IID_IMSMQEvent2_Value = @import("../zig.zig").Guid.initString("eba96b12-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQEvent2 = &IID_IMSMQEvent2_Value; pub const IMSMQEvent2 = extern struct { pub const VTable = extern struct { base: IMSMQEvent.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQEvent2, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IMSMQEvent.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQEvent2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQEvent2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQEvent2, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQEvent3_Value = @import("../zig.zig").Guid.initString("eba96b1c-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQEvent3 = &IID_IMSMQEvent3_Value; pub const IMSMQEvent3 = extern struct { pub const VTable = extern struct { base: IMSMQEvent2.VTable, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IMSMQEvent2.MethodMixin(T); };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQTransaction_Value = @import("../zig.zig").Guid.initString("d7d6e07f-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQTransaction = &IID_IMSMQTransaction_Value; pub const IMSMQTransaction = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Transaction: fn( self: *const IMSMQTransaction, plTransaction: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Commit: fn( self: *const IMSMQTransaction, fRetaining: ?*VARIANT, grfTC: ?*VARIANT, grfRM: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Abort: fn( self: *const IMSMQTransaction, fRetaining: ?*VARIANT, fAsync: ?*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 IMSMQTransaction_get_Transaction(self: *const T, plTransaction: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransaction.VTable, self.vtable).get_Transaction(@ptrCast(*const IMSMQTransaction, self), plTransaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQTransaction_Commit(self: *const T, fRetaining: ?*VARIANT, grfTC: ?*VARIANT, grfRM: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransaction.VTable, self.vtable).Commit(@ptrCast(*const IMSMQTransaction, self), fRetaining, grfTC, grfRM); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQTransaction_Abort(self: *const T, fRetaining: ?*VARIANT, fAsync: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransaction.VTable, self.vtable).Abort(@ptrCast(*const IMSMQTransaction, self), fRetaining, fAsync); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQCoordinatedTransactionDispenser_Value = @import("../zig.zig").Guid.initString("d7d6e081-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQCoordinatedTransactionDispenser = &IID_IMSMQCoordinatedTransactionDispenser_Value; pub const IMSMQCoordinatedTransactionDispenser = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, BeginTransaction: fn( self: *const IMSMQCoordinatedTransactionDispenser, ptransaction: ?*?*IMSMQTransaction, ) 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 IMSMQCoordinatedTransactionDispenser_BeginTransaction(self: *const T, ptransaction: ?*?*IMSMQTransaction) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQCoordinatedTransactionDispenser.VTable, self.vtable).BeginTransaction(@ptrCast(*const IMSMQCoordinatedTransactionDispenser, self), ptransaction); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQTransactionDispenser_Value = @import("../zig.zig").Guid.initString("d7d6e083-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQTransactionDispenser = &IID_IMSMQTransactionDispenser_Value; pub const IMSMQTransactionDispenser = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, BeginTransaction: fn( self: *const IMSMQTransactionDispenser, ptransaction: ?*?*IMSMQTransaction, ) 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 IMSMQTransactionDispenser_BeginTransaction(self: *const T, ptransaction: ?*?*IMSMQTransaction) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransactionDispenser.VTable, self.vtable).BeginTransaction(@ptrCast(*const IMSMQTransactionDispenser, self), ptransaction); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQuery2_Value = @import("../zig.zig").Guid.initString("eba96b0e-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQuery2 = &IID_IMSMQQuery2_Value; pub const IMSMQQuery2 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, LookupQueue: fn( self: *const IMSMQQuery2, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQuery2, ppcolProperties: ?*?*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 IMSMQQuery2_LookupQueue(self: *const T, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery2.VTable, self.vtable).LookupQueue(@ptrCast(*const IMSMQQuery2, self), QueueGuid, ServiceTypeGuid, Label, CreateTime, ModifyTime, RelServiceType, RelLabel, RelCreateTime, RelModifyTime, ppqinfos); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQuery2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQuery2, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQuery3_Value = @import("../zig.zig").Guid.initString("eba96b19-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQuery3 = &IID_IMSMQQuery3_Value; pub const IMSMQQuery3 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, LookupQueue_v2: fn( self: *const IMSMQQuery3, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQuery3, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, LookupQueue: fn( self: *const IMSMQQuery3, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, MulticastAddress: ?*VARIANT, RelMulticastAddress: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos3, ) 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 IMSMQQuery3_LookupQueue_v2(self: *const T, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery3.VTable, self.vtable).LookupQueue_v2(@ptrCast(*const IMSMQQuery3, self), QueueGuid, ServiceTypeGuid, Label, CreateTime, ModifyTime, RelServiceType, RelLabel, RelCreateTime, RelModifyTime, ppqinfos); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQuery3_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery3.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQuery3, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQuery3_LookupQueue(self: *const T, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, MulticastAddress: ?*VARIANT, RelMulticastAddress: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery3.VTable, self.vtable).LookupQueue(@ptrCast(*const IMSMQQuery3, self), QueueGuid, ServiceTypeGuid, Label, CreateTime, ModifyTime, RelServiceType, RelLabel, RelCreateTime, RelModifyTime, MulticastAddress, RelMulticastAddress, ppqinfos); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQuery4_Value = @import("../zig.zig").Guid.initString("eba96b24-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQQuery4 = &IID_IMSMQQuery4_Value; pub const IMSMQQuery4 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, LookupQueue_v2: fn( self: *const IMSMQQuery4, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQQuery4, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, LookupQueue: fn( self: *const IMSMQQuery4, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, MulticastAddress: ?*VARIANT, RelMulticastAddress: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos4, ) 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 IMSMQQuery4_LookupQueue_v2(self: *const T, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery4.VTable, self.vtable).LookupQueue_v2(@ptrCast(*const IMSMQQuery4, self), QueueGuid, ServiceTypeGuid, Label, CreateTime, ModifyTime, RelServiceType, RelLabel, RelCreateTime, RelModifyTime, ppqinfos); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQuery4_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery4.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQQuery4, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQuery4_LookupQueue(self: *const T, QueueGuid: ?*VARIANT, ServiceTypeGuid: ?*VARIANT, Label: ?*VARIANT, CreateTime: ?*VARIANT, ModifyTime: ?*VARIANT, RelServiceType: ?*VARIANT, RelLabel: ?*VARIANT, RelCreateTime: ?*VARIANT, RelModifyTime: ?*VARIANT, MulticastAddress: ?*VARIANT, RelMulticastAddress: ?*VARIANT, ppqinfos: ?*?*IMSMQQueueInfos4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQuery4.VTable, self.vtable).LookupQueue(@ptrCast(*const IMSMQQuery4, self), QueueGuid, ServiceTypeGuid, Label, CreateTime, ModifyTime, RelServiceType, RelLabel, RelCreateTime, RelModifyTime, MulticastAddress, RelMulticastAddress, ppqinfos); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQMessage2_Value = @import("../zig.zig").Guid.initString("d9933be0-a567-11d2-b0f3-00e02c074f6b"); pub const IID_IMSMQMessage2 = &IID_IMSMQMessage2_Value; pub const IMSMQMessage2 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Class: fn( self: *const IMSMQMessage2, plClass: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivLevel: fn( self: *const IMSMQMessage2, plPrivLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PrivLevel: fn( self: *const IMSMQMessage2, lPrivLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthLevel: fn( self: *const IMSMQMessage2, plAuthLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthLevel: fn( self: *const IMSMQMessage2, lAuthLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsAuthenticated: fn( self: *const IMSMQMessage2, pisAuthenticated: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Delivery: fn( self: *const IMSMQMessage2, plDelivery: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Delivery: fn( self: *const IMSMQMessage2, lDelivery: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Trace: fn( self: *const IMSMQMessage2, plTrace: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Trace: fn( self: *const IMSMQMessage2, lTrace: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Priority: fn( self: *const IMSMQMessage2, plPriority: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Priority: fn( self: *const IMSMQMessage2, lPriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Journal: fn( self: *const IMSMQMessage2, plJournal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Journal: fn( self: *const IMSMQMessage2, lJournal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo_v1: fn( self: *const IMSMQMessage2, ppqinfoResponse: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo_v1: fn( self: *const IMSMQMessage2, pqinfoResponse: ?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AppSpecific: fn( self: *const IMSMQMessage2, 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 IMSMQMessage2, lAppSpecific: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SourceMachineGuid: fn( self: *const IMSMQMessage2, pbstrGuidSrcMachine: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BodyLength: fn( self: *const IMSMQMessage2, pcbBody: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Body: fn( self: *const IMSMQMessage2, pvarBody: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Body: fn( self: *const IMSMQMessage2, varBody: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo_v1: fn( self: *const IMSMQMessage2, ppqinfoAdmin: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo_v1: fn( self: *const IMSMQMessage2, pqinfoAdmin: ?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Id: fn( self: *const IMSMQMessage2, pvarMsgId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CorrelationId: fn( self: *const IMSMQMessage2, pvarMsgId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CorrelationId: fn( self: *const IMSMQMessage2, varMsgId: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Ack: fn( self: *const IMSMQMessage2, plAck: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Ack: fn( self: *const IMSMQMessage2, lAck: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Label: fn( self: *const IMSMQMessage2, pbstrLabel: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Label: fn( self: *const IMSMQMessage2, bstrLabel: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxTimeToReachQueue: fn( self: *const IMSMQMessage2, plMaxTimeToReachQueue: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MaxTimeToReachQueue: fn( self: *const IMSMQMessage2, lMaxTimeToReachQueue: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxTimeToReceive: fn( self: *const IMSMQMessage2, plMaxTimeToReceive: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MaxTimeToReceive: fn( self: *const IMSMQMessage2, lMaxTimeToReceive: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HashAlgorithm: fn( self: *const IMSMQMessage2, plHashAlg: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_HashAlgorithm: fn( self: *const IMSMQMessage2, lHashAlg: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EncryptAlgorithm: fn( self: *const IMSMQMessage2, plEncryptAlg: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EncryptAlgorithm: fn( self: *const IMSMQMessage2, lEncryptAlg: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SentTime: fn( self: *const IMSMQMessage2, pvarSentTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ArrivedTime: fn( self: *const IMSMQMessage2, plArrivedTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestinationQueueInfo: fn( self: *const IMSMQMessage2, ppqinfoDest: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderCertificate: fn( self: *const IMSMQMessage2, pvarSenderCert: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderCertificate: fn( self: *const IMSMQMessage2, varSenderCert: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderId: fn( self: *const IMSMQMessage2, pvarSenderId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderIdType: fn( self: *const IMSMQMessage2, plSenderIdType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderIdType: fn( self: *const IMSMQMessage2, lSenderIdType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Send: fn( self: *const IMSMQMessage2, DestinationQueue: ?*IMSMQQueue2, Transaction: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AttachCurrentSecurityContext: fn( self: *const IMSMQMessage2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderVersion: fn( self: *const IMSMQMessage2, plSenderVersion: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Extension: fn( self: *const IMSMQMessage2, pvarExtension: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Extension: fn( self: *const IMSMQMessage2, varExtension: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ConnectorTypeGuid: fn( self: *const IMSMQMessage2, pbstrGuidConnectorType: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ConnectorTypeGuid: fn( self: *const IMSMQMessage2, bstrGuidConnectorType: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TransactionStatusQueueInfo: fn( self: *const IMSMQMessage2, ppqinfoXactStatus: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestinationSymmetricKey: fn( self: *const IMSMQMessage2, pvarDestSymmKey: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DestinationSymmetricKey: fn( self: *const IMSMQMessage2, varDestSymmKey: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Signature: fn( self: *const IMSMQMessage2, pvarSignature: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Signature: fn( self: *const IMSMQMessage2, varSignature: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthenticationProviderType: fn( self: *const IMSMQMessage2, plAuthProvType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthenticationProviderType: fn( self: *const IMSMQMessage2, lAuthProvType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthenticationProviderName: fn( self: *const IMSMQMessage2, pbstrAuthProvName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthenticationProviderName: fn( self: *const IMSMQMessage2, bstrAuthProvName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderId: fn( self: *const IMSMQMessage2, varSenderId: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MsgClass: fn( self: *const IMSMQMessage2, plMsgClass: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MsgClass: fn( self: *const IMSMQMessage2, lMsgClass: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQMessage2, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TransactionId: fn( self: *const IMSMQMessage2, pvarXactId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsFirstInTransaction: fn( self: *const IMSMQMessage2, pisFirstInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsLastInTransaction: fn( self: *const IMSMQMessage2, pisLastInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo: fn( self: *const IMSMQMessage2, ppqinfoResponse: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo: fn( self: *const IMSMQMessage2, pqinfoResponse: ?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo: fn( self: *const IMSMQMessage2, ppqinfoAdmin: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo: fn( self: *const IMSMQMessage2, pqinfoAdmin: ?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReceivedAuthenticationLevel: fn( self: *const IMSMQMessage2, psReceivedAuthenticationLevel: ?*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 IMSMQMessage2_get_Class(self: *const T, plClass: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Class(@ptrCast(*const IMSMQMessage2, self), plClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_PrivLevel(self: *const T, plPrivLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_PrivLevel(@ptrCast(*const IMSMQMessage2, self), plPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_PrivLevel(self: *const T, lPrivLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_PrivLevel(@ptrCast(*const IMSMQMessage2, self), lPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_AuthLevel(self: *const T, plAuthLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_AuthLevel(@ptrCast(*const IMSMQMessage2, self), plAuthLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_AuthLevel(self: *const T, lAuthLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_AuthLevel(@ptrCast(*const IMSMQMessage2, self), lAuthLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_IsAuthenticated(self: *const T, pisAuthenticated: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_IsAuthenticated(@ptrCast(*const IMSMQMessage2, self), pisAuthenticated); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Delivery(self: *const T, plDelivery: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Delivery(@ptrCast(*const IMSMQMessage2, self), plDelivery); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Delivery(self: *const T, lDelivery: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Delivery(@ptrCast(*const IMSMQMessage2, self), lDelivery); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Trace(self: *const T, plTrace: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Trace(@ptrCast(*const IMSMQMessage2, self), plTrace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Trace(self: *const T, lTrace: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Trace(@ptrCast(*const IMSMQMessage2, self), lTrace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Priority(self: *const T, plPriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Priority(@ptrCast(*const IMSMQMessage2, self), plPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Priority(self: *const T, lPriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Priority(@ptrCast(*const IMSMQMessage2, self), lPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Journal(self: *const T, plJournal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Journal(@ptrCast(*const IMSMQMessage2, self), plJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Journal(self: *const T, lJournal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Journal(@ptrCast(*const IMSMQMessage2, self), lJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_ResponseQueueInfo_v1(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_ResponseQueueInfo_v1(@ptrCast(*const IMSMQMessage2, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_putref_ResponseQueueInfo_v1(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).putref_ResponseQueueInfo_v1(@ptrCast(*const IMSMQMessage2, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_AppSpecific(self: *const T, plAppSpecific: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_AppSpecific(@ptrCast(*const IMSMQMessage2, self), plAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_AppSpecific(self: *const T, lAppSpecific: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_AppSpecific(@ptrCast(*const IMSMQMessage2, self), lAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_SourceMachineGuid(self: *const T, pbstrGuidSrcMachine: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_SourceMachineGuid(@ptrCast(*const IMSMQMessage2, self), pbstrGuidSrcMachine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_BodyLength(self: *const T, pcbBody: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_BodyLength(@ptrCast(*const IMSMQMessage2, self), pcbBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Body(self: *const T, pvarBody: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Body(@ptrCast(*const IMSMQMessage2, self), pvarBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Body(self: *const T, varBody: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Body(@ptrCast(*const IMSMQMessage2, self), varBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_AdminQueueInfo_v1(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_AdminQueueInfo_v1(@ptrCast(*const IMSMQMessage2, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_putref_AdminQueueInfo_v1(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).putref_AdminQueueInfo_v1(@ptrCast(*const IMSMQMessage2, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Id(self: *const T, pvarMsgId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Id(@ptrCast(*const IMSMQMessage2, self), pvarMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_CorrelationId(self: *const T, pvarMsgId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_CorrelationId(@ptrCast(*const IMSMQMessage2, self), pvarMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_CorrelationId(self: *const T, varMsgId: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_CorrelationId(@ptrCast(*const IMSMQMessage2, self), varMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Ack(self: *const T, plAck: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Ack(@ptrCast(*const IMSMQMessage2, self), plAck); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Ack(self: *const T, lAck: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Ack(@ptrCast(*const IMSMQMessage2, self), lAck); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Label(self: *const T, pbstrLabel: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Label(@ptrCast(*const IMSMQMessage2, self), pbstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Label(self: *const T, bstrLabel: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Label(@ptrCast(*const IMSMQMessage2, self), bstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_MaxTimeToReachQueue(self: *const T, plMaxTimeToReachQueue: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_MaxTimeToReachQueue(@ptrCast(*const IMSMQMessage2, self), plMaxTimeToReachQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_MaxTimeToReachQueue(self: *const T, lMaxTimeToReachQueue: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_MaxTimeToReachQueue(@ptrCast(*const IMSMQMessage2, self), lMaxTimeToReachQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_MaxTimeToReceive(self: *const T, plMaxTimeToReceive: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_MaxTimeToReceive(@ptrCast(*const IMSMQMessage2, self), plMaxTimeToReceive); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_MaxTimeToReceive(self: *const T, lMaxTimeToReceive: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_MaxTimeToReceive(@ptrCast(*const IMSMQMessage2, self), lMaxTimeToReceive); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_HashAlgorithm(self: *const T, plHashAlg: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const IMSMQMessage2, self), plHashAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_HashAlgorithm(self: *const T, lHashAlg: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const IMSMQMessage2, self), lHashAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_EncryptAlgorithm(self: *const T, plEncryptAlg: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_EncryptAlgorithm(@ptrCast(*const IMSMQMessage2, self), plEncryptAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_EncryptAlgorithm(self: *const T, lEncryptAlg: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_EncryptAlgorithm(@ptrCast(*const IMSMQMessage2, self), lEncryptAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_SentTime(self: *const T, pvarSentTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_SentTime(@ptrCast(*const IMSMQMessage2, self), pvarSentTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_ArrivedTime(self: *const T, plArrivedTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_ArrivedTime(@ptrCast(*const IMSMQMessage2, self), plArrivedTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_DestinationQueueInfo(self: *const T, ppqinfoDest: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_DestinationQueueInfo(@ptrCast(*const IMSMQMessage2, self), ppqinfoDest); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_SenderCertificate(self: *const T, pvarSenderCert: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_SenderCertificate(@ptrCast(*const IMSMQMessage2, self), pvarSenderCert); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_SenderCertificate(self: *const T, varSenderCert: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_SenderCertificate(@ptrCast(*const IMSMQMessage2, self), varSenderCert); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_SenderId(self: *const T, pvarSenderId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_SenderId(@ptrCast(*const IMSMQMessage2, self), pvarSenderId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_SenderIdType(self: *const T, plSenderIdType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_SenderIdType(@ptrCast(*const IMSMQMessage2, self), plSenderIdType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_SenderIdType(self: *const T, lSenderIdType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_SenderIdType(@ptrCast(*const IMSMQMessage2, self), lSenderIdType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_Send(self: *const T, DestinationQueue: ?*IMSMQQueue2, Transaction: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).Send(@ptrCast(*const IMSMQMessage2, self), DestinationQueue, Transaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_AttachCurrentSecurityContext(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).AttachCurrentSecurityContext(@ptrCast(*const IMSMQMessage2, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_SenderVersion(self: *const T, plSenderVersion: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_SenderVersion(@ptrCast(*const IMSMQMessage2, self), plSenderVersion); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Extension(self: *const T, pvarExtension: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Extension(@ptrCast(*const IMSMQMessage2, self), pvarExtension); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Extension(self: *const T, varExtension: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Extension(@ptrCast(*const IMSMQMessage2, self), varExtension); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_ConnectorTypeGuid(self: *const T, pbstrGuidConnectorType: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_ConnectorTypeGuid(@ptrCast(*const IMSMQMessage2, self), pbstrGuidConnectorType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_ConnectorTypeGuid(self: *const T, bstrGuidConnectorType: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_ConnectorTypeGuid(@ptrCast(*const IMSMQMessage2, self), bstrGuidConnectorType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_TransactionStatusQueueInfo(self: *const T, ppqinfoXactStatus: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_TransactionStatusQueueInfo(@ptrCast(*const IMSMQMessage2, self), ppqinfoXactStatus); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_DestinationSymmetricKey(self: *const T, pvarDestSymmKey: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_DestinationSymmetricKey(@ptrCast(*const IMSMQMessage2, self), pvarDestSymmKey); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_DestinationSymmetricKey(self: *const T, varDestSymmKey: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_DestinationSymmetricKey(@ptrCast(*const IMSMQMessage2, self), varDestSymmKey); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Signature(self: *const T, pvarSignature: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Signature(@ptrCast(*const IMSMQMessage2, self), pvarSignature); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_Signature(self: *const T, varSignature: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_Signature(@ptrCast(*const IMSMQMessage2, self), varSignature); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_AuthenticationProviderType(self: *const T, plAuthProvType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_AuthenticationProviderType(@ptrCast(*const IMSMQMessage2, self), plAuthProvType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_AuthenticationProviderType(self: *const T, lAuthProvType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_AuthenticationProviderType(@ptrCast(*const IMSMQMessage2, self), lAuthProvType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_AuthenticationProviderName(self: *const T, pbstrAuthProvName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_AuthenticationProviderName(@ptrCast(*const IMSMQMessage2, self), pbstrAuthProvName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_AuthenticationProviderName(self: *const T, bstrAuthProvName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_AuthenticationProviderName(@ptrCast(*const IMSMQMessage2, self), bstrAuthProvName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_SenderId(self: *const T, varSenderId: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_SenderId(@ptrCast(*const IMSMQMessage2, self), varSenderId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_MsgClass(self: *const T, plMsgClass: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_MsgClass(@ptrCast(*const IMSMQMessage2, self), plMsgClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_put_MsgClass(self: *const T, lMsgClass: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).put_MsgClass(@ptrCast(*const IMSMQMessage2, self), lMsgClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQMessage2, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_TransactionId(self: *const T, pvarXactId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_TransactionId(@ptrCast(*const IMSMQMessage2, self), pvarXactId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_IsFirstInTransaction(self: *const T, pisFirstInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_IsFirstInTransaction(@ptrCast(*const IMSMQMessage2, self), pisFirstInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_IsLastInTransaction(self: *const T, pisLastInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_IsLastInTransaction(@ptrCast(*const IMSMQMessage2, self), pisLastInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_ResponseQueueInfo(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_ResponseQueueInfo(@ptrCast(*const IMSMQMessage2, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_putref_ResponseQueueInfo(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).putref_ResponseQueueInfo(@ptrCast(*const IMSMQMessage2, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_AdminQueueInfo(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_AdminQueueInfo(@ptrCast(*const IMSMQMessage2, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_putref_AdminQueueInfo(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).putref_AdminQueueInfo(@ptrCast(*const IMSMQMessage2, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage2_get_ReceivedAuthenticationLevel(self: *const T, psReceivedAuthenticationLevel: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage2.VTable, self.vtable).get_ReceivedAuthenticationLevel(@ptrCast(*const IMSMQMessage2, self), psReceivedAuthenticationLevel); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQMessage3_Value = @import("../zig.zig").Guid.initString("eba96b1a-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQMessage3 = &IID_IMSMQMessage3_Value; pub const IMSMQMessage3 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Class: fn( self: *const IMSMQMessage3, plClass: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivLevel: fn( self: *const IMSMQMessage3, plPrivLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PrivLevel: fn( self: *const IMSMQMessage3, lPrivLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthLevel: fn( self: *const IMSMQMessage3, plAuthLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthLevel: fn( self: *const IMSMQMessage3, lAuthLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsAuthenticated: fn( self: *const IMSMQMessage3, pisAuthenticated: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Delivery: fn( self: *const IMSMQMessage3, plDelivery: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Delivery: fn( self: *const IMSMQMessage3, lDelivery: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Trace: fn( self: *const IMSMQMessage3, plTrace: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Trace: fn( self: *const IMSMQMessage3, lTrace: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Priority: fn( self: *const IMSMQMessage3, plPriority: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Priority: fn( self: *const IMSMQMessage3, lPriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Journal: fn( self: *const IMSMQMessage3, plJournal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Journal: fn( self: *const IMSMQMessage3, lJournal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo_v1: fn( self: *const IMSMQMessage3, ppqinfoResponse: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo_v1: fn( self: *const IMSMQMessage3, pqinfoResponse: ?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AppSpecific: fn( self: *const IMSMQMessage3, 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 IMSMQMessage3, lAppSpecific: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SourceMachineGuid: fn( self: *const IMSMQMessage3, pbstrGuidSrcMachine: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BodyLength: fn( self: *const IMSMQMessage3, pcbBody: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Body: fn( self: *const IMSMQMessage3, pvarBody: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Body: fn( self: *const IMSMQMessage3, varBody: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo_v1: fn( self: *const IMSMQMessage3, ppqinfoAdmin: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo_v1: fn( self: *const IMSMQMessage3, pqinfoAdmin: ?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Id: fn( self: *const IMSMQMessage3, pvarMsgId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CorrelationId: fn( self: *const IMSMQMessage3, pvarMsgId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CorrelationId: fn( self: *const IMSMQMessage3, varMsgId: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Ack: fn( self: *const IMSMQMessage3, plAck: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Ack: fn( self: *const IMSMQMessage3, lAck: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Label: fn( self: *const IMSMQMessage3, pbstrLabel: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Label: fn( self: *const IMSMQMessage3, bstrLabel: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxTimeToReachQueue: fn( self: *const IMSMQMessage3, plMaxTimeToReachQueue: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MaxTimeToReachQueue: fn( self: *const IMSMQMessage3, lMaxTimeToReachQueue: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxTimeToReceive: fn( self: *const IMSMQMessage3, plMaxTimeToReceive: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MaxTimeToReceive: fn( self: *const IMSMQMessage3, lMaxTimeToReceive: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HashAlgorithm: fn( self: *const IMSMQMessage3, plHashAlg: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_HashAlgorithm: fn( self: *const IMSMQMessage3, lHashAlg: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EncryptAlgorithm: fn( self: *const IMSMQMessage3, plEncryptAlg: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EncryptAlgorithm: fn( self: *const IMSMQMessage3, lEncryptAlg: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SentTime: fn( self: *const IMSMQMessage3, pvarSentTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ArrivedTime: fn( self: *const IMSMQMessage3, plArrivedTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestinationQueueInfo: fn( self: *const IMSMQMessage3, ppqinfoDest: ?*?*IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderCertificate: fn( self: *const IMSMQMessage3, pvarSenderCert: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderCertificate: fn( self: *const IMSMQMessage3, varSenderCert: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderId: fn( self: *const IMSMQMessage3, pvarSenderId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderIdType: fn( self: *const IMSMQMessage3, plSenderIdType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderIdType: fn( self: *const IMSMQMessage3, lSenderIdType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Send: fn( self: *const IMSMQMessage3, DestinationQueue: ?*IDispatch, Transaction: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AttachCurrentSecurityContext: fn( self: *const IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderVersion: fn( self: *const IMSMQMessage3, plSenderVersion: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Extension: fn( self: *const IMSMQMessage3, pvarExtension: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Extension: fn( self: *const IMSMQMessage3, varExtension: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ConnectorTypeGuid: fn( self: *const IMSMQMessage3, pbstrGuidConnectorType: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ConnectorTypeGuid: fn( self: *const IMSMQMessage3, bstrGuidConnectorType: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TransactionStatusQueueInfo: fn( self: *const IMSMQMessage3, ppqinfoXactStatus: ?*?*IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestinationSymmetricKey: fn( self: *const IMSMQMessage3, pvarDestSymmKey: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DestinationSymmetricKey: fn( self: *const IMSMQMessage3, varDestSymmKey: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Signature: fn( self: *const IMSMQMessage3, pvarSignature: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Signature: fn( self: *const IMSMQMessage3, varSignature: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthenticationProviderType: fn( self: *const IMSMQMessage3, plAuthProvType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthenticationProviderType: fn( self: *const IMSMQMessage3, lAuthProvType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthenticationProviderName: fn( self: *const IMSMQMessage3, pbstrAuthProvName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthenticationProviderName: fn( self: *const IMSMQMessage3, bstrAuthProvName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderId: fn( self: *const IMSMQMessage3, varSenderId: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MsgClass: fn( self: *const IMSMQMessage3, plMsgClass: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MsgClass: fn( self: *const IMSMQMessage3, lMsgClass: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQMessage3, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TransactionId: fn( self: *const IMSMQMessage3, pvarXactId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsFirstInTransaction: fn( self: *const IMSMQMessage3, pisFirstInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsLastInTransaction: fn( self: *const IMSMQMessage3, pisLastInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo_v2: fn( self: *const IMSMQMessage3, ppqinfoResponse: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo_v2: fn( self: *const IMSMQMessage3, pqinfoResponse: ?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo_v2: fn( self: *const IMSMQMessage3, ppqinfoAdmin: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo_v2: fn( self: *const IMSMQMessage3, pqinfoAdmin: ?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReceivedAuthenticationLevel: fn( self: *const IMSMQMessage3, psReceivedAuthenticationLevel: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo: fn( self: *const IMSMQMessage3, ppqinfoResponse: ?*?*IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo: fn( self: *const IMSMQMessage3, pqinfoResponse: ?*IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo: fn( self: *const IMSMQMessage3, ppqinfoAdmin: ?*?*IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo: fn( self: *const IMSMQMessage3, pqinfoAdmin: ?*IMSMQQueueInfo3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseDestination: fn( self: *const IMSMQMessage3, ppdestResponse: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseDestination: fn( self: *const IMSMQMessage3, pdestResponse: ?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Destination: fn( self: *const IMSMQMessage3, ppdestDestination: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LookupId: fn( self: *const IMSMQMessage3, pvarLookupId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsAuthenticated2: fn( self: *const IMSMQMessage3, pisAuthenticated: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsFirstInTransaction2: fn( self: *const IMSMQMessage3, pisFirstInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsLastInTransaction2: fn( self: *const IMSMQMessage3, pisLastInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AttachCurrentSecurityContext2: fn( self: *const IMSMQMessage3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SoapEnvelope: fn( self: *const IMSMQMessage3, pbstrSoapEnvelope: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CompoundMessage: fn( self: *const IMSMQMessage3, pvarCompoundMessage: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SoapHeader: fn( self: *const IMSMQMessage3, bstrSoapHeader: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SoapBody: fn( self: *const IMSMQMessage3, bstrSoapBody: ?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 IMSMQMessage3_get_Class(self: *const T, plClass: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Class(@ptrCast(*const IMSMQMessage3, self), plClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_PrivLevel(self: *const T, plPrivLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_PrivLevel(@ptrCast(*const IMSMQMessage3, self), plPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_PrivLevel(self: *const T, lPrivLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_PrivLevel(@ptrCast(*const IMSMQMessage3, self), lPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_AuthLevel(self: *const T, plAuthLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_AuthLevel(@ptrCast(*const IMSMQMessage3, self), plAuthLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_AuthLevel(self: *const T, lAuthLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_AuthLevel(@ptrCast(*const IMSMQMessage3, self), lAuthLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_IsAuthenticated(self: *const T, pisAuthenticated: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_IsAuthenticated(@ptrCast(*const IMSMQMessage3, self), pisAuthenticated); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Delivery(self: *const T, plDelivery: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Delivery(@ptrCast(*const IMSMQMessage3, self), plDelivery); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Delivery(self: *const T, lDelivery: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Delivery(@ptrCast(*const IMSMQMessage3, self), lDelivery); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Trace(self: *const T, plTrace: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Trace(@ptrCast(*const IMSMQMessage3, self), plTrace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Trace(self: *const T, lTrace: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Trace(@ptrCast(*const IMSMQMessage3, self), lTrace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Priority(self: *const T, plPriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Priority(@ptrCast(*const IMSMQMessage3, self), plPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Priority(self: *const T, lPriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Priority(@ptrCast(*const IMSMQMessage3, self), lPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Journal(self: *const T, plJournal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Journal(@ptrCast(*const IMSMQMessage3, self), plJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Journal(self: *const T, lJournal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Journal(@ptrCast(*const IMSMQMessage3, self), lJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_ResponseQueueInfo_v1(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_ResponseQueueInfo_v1(@ptrCast(*const IMSMQMessage3, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_putref_ResponseQueueInfo_v1(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).putref_ResponseQueueInfo_v1(@ptrCast(*const IMSMQMessage3, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_AppSpecific(self: *const T, plAppSpecific: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_AppSpecific(@ptrCast(*const IMSMQMessage3, self), plAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_AppSpecific(self: *const T, lAppSpecific: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_AppSpecific(@ptrCast(*const IMSMQMessage3, self), lAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_SourceMachineGuid(self: *const T, pbstrGuidSrcMachine: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_SourceMachineGuid(@ptrCast(*const IMSMQMessage3, self), pbstrGuidSrcMachine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_BodyLength(self: *const T, pcbBody: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_BodyLength(@ptrCast(*const IMSMQMessage3, self), pcbBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Body(self: *const T, pvarBody: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Body(@ptrCast(*const IMSMQMessage3, self), pvarBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Body(self: *const T, varBody: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Body(@ptrCast(*const IMSMQMessage3, self), varBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_AdminQueueInfo_v1(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_AdminQueueInfo_v1(@ptrCast(*const IMSMQMessage3, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_putref_AdminQueueInfo_v1(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).putref_AdminQueueInfo_v1(@ptrCast(*const IMSMQMessage3, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Id(self: *const T, pvarMsgId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Id(@ptrCast(*const IMSMQMessage3, self), pvarMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_CorrelationId(self: *const T, pvarMsgId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_CorrelationId(@ptrCast(*const IMSMQMessage3, self), pvarMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_CorrelationId(self: *const T, varMsgId: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_CorrelationId(@ptrCast(*const IMSMQMessage3, self), varMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Ack(self: *const T, plAck: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Ack(@ptrCast(*const IMSMQMessage3, self), plAck); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Ack(self: *const T, lAck: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Ack(@ptrCast(*const IMSMQMessage3, self), lAck); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Label(self: *const T, pbstrLabel: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Label(@ptrCast(*const IMSMQMessage3, self), pbstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Label(self: *const T, bstrLabel: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Label(@ptrCast(*const IMSMQMessage3, self), bstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_MaxTimeToReachQueue(self: *const T, plMaxTimeToReachQueue: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_MaxTimeToReachQueue(@ptrCast(*const IMSMQMessage3, self), plMaxTimeToReachQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_MaxTimeToReachQueue(self: *const T, lMaxTimeToReachQueue: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_MaxTimeToReachQueue(@ptrCast(*const IMSMQMessage3, self), lMaxTimeToReachQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_MaxTimeToReceive(self: *const T, plMaxTimeToReceive: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_MaxTimeToReceive(@ptrCast(*const IMSMQMessage3, self), plMaxTimeToReceive); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_MaxTimeToReceive(self: *const T, lMaxTimeToReceive: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_MaxTimeToReceive(@ptrCast(*const IMSMQMessage3, self), lMaxTimeToReceive); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_HashAlgorithm(self: *const T, plHashAlg: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const IMSMQMessage3, self), plHashAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_HashAlgorithm(self: *const T, lHashAlg: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const IMSMQMessage3, self), lHashAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_EncryptAlgorithm(self: *const T, plEncryptAlg: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_EncryptAlgorithm(@ptrCast(*const IMSMQMessage3, self), plEncryptAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_EncryptAlgorithm(self: *const T, lEncryptAlg: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_EncryptAlgorithm(@ptrCast(*const IMSMQMessage3, self), lEncryptAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_SentTime(self: *const T, pvarSentTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_SentTime(@ptrCast(*const IMSMQMessage3, self), pvarSentTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_ArrivedTime(self: *const T, plArrivedTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_ArrivedTime(@ptrCast(*const IMSMQMessage3, self), plArrivedTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_DestinationQueueInfo(self: *const T, ppqinfoDest: ?*?*IMSMQQueueInfo3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_DestinationQueueInfo(@ptrCast(*const IMSMQMessage3, self), ppqinfoDest); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_SenderCertificate(self: *const T, pvarSenderCert: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_SenderCertificate(@ptrCast(*const IMSMQMessage3, self), pvarSenderCert); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_SenderCertificate(self: *const T, varSenderCert: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_SenderCertificate(@ptrCast(*const IMSMQMessage3, self), varSenderCert); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_SenderId(self: *const T, pvarSenderId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_SenderId(@ptrCast(*const IMSMQMessage3, self), pvarSenderId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_SenderIdType(self: *const T, plSenderIdType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_SenderIdType(@ptrCast(*const IMSMQMessage3, self), plSenderIdType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_SenderIdType(self: *const T, lSenderIdType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_SenderIdType(@ptrCast(*const IMSMQMessage3, self), lSenderIdType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_Send(self: *const T, DestinationQueue: ?*IDispatch, Transaction: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).Send(@ptrCast(*const IMSMQMessage3, self), DestinationQueue, Transaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_AttachCurrentSecurityContext(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).AttachCurrentSecurityContext(@ptrCast(*const IMSMQMessage3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_SenderVersion(self: *const T, plSenderVersion: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_SenderVersion(@ptrCast(*const IMSMQMessage3, self), plSenderVersion); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Extension(self: *const T, pvarExtension: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Extension(@ptrCast(*const IMSMQMessage3, self), pvarExtension); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Extension(self: *const T, varExtension: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Extension(@ptrCast(*const IMSMQMessage3, self), varExtension); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_ConnectorTypeGuid(self: *const T, pbstrGuidConnectorType: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_ConnectorTypeGuid(@ptrCast(*const IMSMQMessage3, self), pbstrGuidConnectorType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_ConnectorTypeGuid(self: *const T, bstrGuidConnectorType: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_ConnectorTypeGuid(@ptrCast(*const IMSMQMessage3, self), bstrGuidConnectorType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_TransactionStatusQueueInfo(self: *const T, ppqinfoXactStatus: ?*?*IMSMQQueueInfo3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_TransactionStatusQueueInfo(@ptrCast(*const IMSMQMessage3, self), ppqinfoXactStatus); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_DestinationSymmetricKey(self: *const T, pvarDestSymmKey: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_DestinationSymmetricKey(@ptrCast(*const IMSMQMessage3, self), pvarDestSymmKey); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_DestinationSymmetricKey(self: *const T, varDestSymmKey: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_DestinationSymmetricKey(@ptrCast(*const IMSMQMessage3, self), varDestSymmKey); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Signature(self: *const T, pvarSignature: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Signature(@ptrCast(*const IMSMQMessage3, self), pvarSignature); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_Signature(self: *const T, varSignature: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_Signature(@ptrCast(*const IMSMQMessage3, self), varSignature); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_AuthenticationProviderType(self: *const T, plAuthProvType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_AuthenticationProviderType(@ptrCast(*const IMSMQMessage3, self), plAuthProvType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_AuthenticationProviderType(self: *const T, lAuthProvType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_AuthenticationProviderType(@ptrCast(*const IMSMQMessage3, self), lAuthProvType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_AuthenticationProviderName(self: *const T, pbstrAuthProvName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_AuthenticationProviderName(@ptrCast(*const IMSMQMessage3, self), pbstrAuthProvName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_AuthenticationProviderName(self: *const T, bstrAuthProvName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_AuthenticationProviderName(@ptrCast(*const IMSMQMessage3, self), bstrAuthProvName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_SenderId(self: *const T, varSenderId: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_SenderId(@ptrCast(*const IMSMQMessage3, self), varSenderId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_MsgClass(self: *const T, plMsgClass: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_MsgClass(@ptrCast(*const IMSMQMessage3, self), plMsgClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_MsgClass(self: *const T, lMsgClass: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_MsgClass(@ptrCast(*const IMSMQMessage3, self), lMsgClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQMessage3, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_TransactionId(self: *const T, pvarXactId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_TransactionId(@ptrCast(*const IMSMQMessage3, self), pvarXactId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_IsFirstInTransaction(self: *const T, pisFirstInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_IsFirstInTransaction(@ptrCast(*const IMSMQMessage3, self), pisFirstInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_IsLastInTransaction(self: *const T, pisLastInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_IsLastInTransaction(@ptrCast(*const IMSMQMessage3, self), pisLastInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_ResponseQueueInfo_v2(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_ResponseQueueInfo_v2(@ptrCast(*const IMSMQMessage3, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_putref_ResponseQueueInfo_v2(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).putref_ResponseQueueInfo_v2(@ptrCast(*const IMSMQMessage3, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_AdminQueueInfo_v2(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_AdminQueueInfo_v2(@ptrCast(*const IMSMQMessage3, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_putref_AdminQueueInfo_v2(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).putref_AdminQueueInfo_v2(@ptrCast(*const IMSMQMessage3, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_ReceivedAuthenticationLevel(self: *const T, psReceivedAuthenticationLevel: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_ReceivedAuthenticationLevel(@ptrCast(*const IMSMQMessage3, self), psReceivedAuthenticationLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_ResponseQueueInfo(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_ResponseQueueInfo(@ptrCast(*const IMSMQMessage3, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_putref_ResponseQueueInfo(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).putref_ResponseQueueInfo(@ptrCast(*const IMSMQMessage3, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_AdminQueueInfo(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_AdminQueueInfo(@ptrCast(*const IMSMQMessage3, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_putref_AdminQueueInfo(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).putref_AdminQueueInfo(@ptrCast(*const IMSMQMessage3, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_ResponseDestination(self: *const T, ppdestResponse: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_ResponseDestination(@ptrCast(*const IMSMQMessage3, self), ppdestResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_putref_ResponseDestination(self: *const T, pdestResponse: ?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).putref_ResponseDestination(@ptrCast(*const IMSMQMessage3, self), pdestResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_Destination(self: *const T, ppdestDestination: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_Destination(@ptrCast(*const IMSMQMessage3, self), ppdestDestination); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_LookupId(self: *const T, pvarLookupId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_LookupId(@ptrCast(*const IMSMQMessage3, self), pvarLookupId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_IsAuthenticated2(self: *const T, pisAuthenticated: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_IsAuthenticated2(@ptrCast(*const IMSMQMessage3, self), pisAuthenticated); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_IsFirstInTransaction2(self: *const T, pisFirstInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_IsFirstInTransaction2(@ptrCast(*const IMSMQMessage3, self), pisFirstInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_IsLastInTransaction2(self: *const T, pisLastInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_IsLastInTransaction2(@ptrCast(*const IMSMQMessage3, self), pisLastInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_AttachCurrentSecurityContext2(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).AttachCurrentSecurityContext2(@ptrCast(*const IMSMQMessage3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_SoapEnvelope(self: *const T, pbstrSoapEnvelope: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_SoapEnvelope(@ptrCast(*const IMSMQMessage3, self), pbstrSoapEnvelope); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_get_CompoundMessage(self: *const T, pvarCompoundMessage: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).get_CompoundMessage(@ptrCast(*const IMSMQMessage3, self), pvarCompoundMessage); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_SoapHeader(self: *const T, bstrSoapHeader: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_SoapHeader(@ptrCast(*const IMSMQMessage3, self), bstrSoapHeader); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage3_put_SoapBody(self: *const T, bstrSoapBody: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage3.VTable, self.vtable).put_SoapBody(@ptrCast(*const IMSMQMessage3, self), bstrSoapBody); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQMessage4_Value = @import("../zig.zig").Guid.initString("eba96b23-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQMessage4 = &IID_IMSMQMessage4_Value; pub const IMSMQMessage4 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Class: fn( self: *const IMSMQMessage4, plClass: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivLevel: fn( self: *const IMSMQMessage4, plPrivLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PrivLevel: fn( self: *const IMSMQMessage4, lPrivLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthLevel: fn( self: *const IMSMQMessage4, plAuthLevel: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthLevel: fn( self: *const IMSMQMessage4, lAuthLevel: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsAuthenticated: fn( self: *const IMSMQMessage4, pisAuthenticated: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Delivery: fn( self: *const IMSMQMessage4, plDelivery: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Delivery: fn( self: *const IMSMQMessage4, lDelivery: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Trace: fn( self: *const IMSMQMessage4, plTrace: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Trace: fn( self: *const IMSMQMessage4, lTrace: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Priority: fn( self: *const IMSMQMessage4, plPriority: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Priority: fn( self: *const IMSMQMessage4, lPriority: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Journal: fn( self: *const IMSMQMessage4, plJournal: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Journal: fn( self: *const IMSMQMessage4, lJournal: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo_v1: fn( self: *const IMSMQMessage4, ppqinfoResponse: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo_v1: fn( self: *const IMSMQMessage4, pqinfoResponse: ?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AppSpecific: fn( self: *const IMSMQMessage4, 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 IMSMQMessage4, lAppSpecific: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SourceMachineGuid: fn( self: *const IMSMQMessage4, pbstrGuidSrcMachine: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BodyLength: fn( self: *const IMSMQMessage4, pcbBody: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Body: fn( self: *const IMSMQMessage4, pvarBody: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Body: fn( self: *const IMSMQMessage4, varBody: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo_v1: fn( self: *const IMSMQMessage4, ppqinfoAdmin: ?*?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo_v1: fn( self: *const IMSMQMessage4, pqinfoAdmin: ?*IMSMQQueueInfo, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Id: fn( self: *const IMSMQMessage4, pvarMsgId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CorrelationId: fn( self: *const IMSMQMessage4, pvarMsgId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_CorrelationId: fn( self: *const IMSMQMessage4, varMsgId: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Ack: fn( self: *const IMSMQMessage4, plAck: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Ack: fn( self: *const IMSMQMessage4, lAck: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Label: fn( self: *const IMSMQMessage4, pbstrLabel: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Label: fn( self: *const IMSMQMessage4, bstrLabel: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxTimeToReachQueue: fn( self: *const IMSMQMessage4, plMaxTimeToReachQueue: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MaxTimeToReachQueue: fn( self: *const IMSMQMessage4, lMaxTimeToReachQueue: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MaxTimeToReceive: fn( self: *const IMSMQMessage4, plMaxTimeToReceive: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MaxTimeToReceive: fn( self: *const IMSMQMessage4, lMaxTimeToReceive: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HashAlgorithm: fn( self: *const IMSMQMessage4, plHashAlg: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_HashAlgorithm: fn( self: *const IMSMQMessage4, lHashAlg: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EncryptAlgorithm: fn( self: *const IMSMQMessage4, plEncryptAlg: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EncryptAlgorithm: fn( self: *const IMSMQMessage4, lEncryptAlg: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SentTime: fn( self: *const IMSMQMessage4, pvarSentTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ArrivedTime: fn( self: *const IMSMQMessage4, plArrivedTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestinationQueueInfo: fn( self: *const IMSMQMessage4, ppqinfoDest: ?*?*IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderCertificate: fn( self: *const IMSMQMessage4, pvarSenderCert: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderCertificate: fn( self: *const IMSMQMessage4, varSenderCert: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderId: fn( self: *const IMSMQMessage4, pvarSenderId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderIdType: fn( self: *const IMSMQMessage4, plSenderIdType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderIdType: fn( self: *const IMSMQMessage4, lSenderIdType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Send: fn( self: *const IMSMQMessage4, DestinationQueue: ?*IDispatch, Transaction: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AttachCurrentSecurityContext: fn( self: *const IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SenderVersion: fn( self: *const IMSMQMessage4, plSenderVersion: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Extension: fn( self: *const IMSMQMessage4, pvarExtension: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Extension: fn( self: *const IMSMQMessage4, varExtension: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ConnectorTypeGuid: fn( self: *const IMSMQMessage4, pbstrGuidConnectorType: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ConnectorTypeGuid: fn( self: *const IMSMQMessage4, bstrGuidConnectorType: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TransactionStatusQueueInfo: fn( self: *const IMSMQMessage4, ppqinfoXactStatus: ?*?*IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DestinationSymmetricKey: fn( self: *const IMSMQMessage4, pvarDestSymmKey: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DestinationSymmetricKey: fn( self: *const IMSMQMessage4, varDestSymmKey: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Signature: fn( self: *const IMSMQMessage4, pvarSignature: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Signature: fn( self: *const IMSMQMessage4, varSignature: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthenticationProviderType: fn( self: *const IMSMQMessage4, plAuthProvType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthenticationProviderType: fn( self: *const IMSMQMessage4, lAuthProvType: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AuthenticationProviderName: fn( self: *const IMSMQMessage4, pbstrAuthProvName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AuthenticationProviderName: fn( self: *const IMSMQMessage4, bstrAuthProvName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SenderId: fn( self: *const IMSMQMessage4, varSenderId: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MsgClass: fn( self: *const IMSMQMessage4, plMsgClass: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MsgClass: fn( self: *const IMSMQMessage4, lMsgClass: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQMessage4, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TransactionId: fn( self: *const IMSMQMessage4, pvarXactId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsFirstInTransaction: fn( self: *const IMSMQMessage4, pisFirstInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsLastInTransaction: fn( self: *const IMSMQMessage4, pisLastInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo_v2: fn( self: *const IMSMQMessage4, ppqinfoResponse: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo_v2: fn( self: *const IMSMQMessage4, pqinfoResponse: ?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo_v2: fn( self: *const IMSMQMessage4, ppqinfoAdmin: ?*?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo_v2: fn( self: *const IMSMQMessage4, pqinfoAdmin: ?*IMSMQQueueInfo2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReceivedAuthenticationLevel: fn( self: *const IMSMQMessage4, psReceivedAuthenticationLevel: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseQueueInfo: fn( self: *const IMSMQMessage4, ppqinfoResponse: ?*?*IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseQueueInfo: fn( self: *const IMSMQMessage4, pqinfoResponse: ?*IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminQueueInfo: fn( self: *const IMSMQMessage4, ppqinfoAdmin: ?*?*IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_AdminQueueInfo: fn( self: *const IMSMQMessage4, pqinfoAdmin: ?*IMSMQQueueInfo4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ResponseDestination: fn( self: *const IMSMQMessage4, ppdestResponse: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_ResponseDestination: fn( self: *const IMSMQMessage4, pdestResponse: ?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Destination: fn( self: *const IMSMQMessage4, ppdestDestination: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LookupId: fn( self: *const IMSMQMessage4, pvarLookupId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsAuthenticated2: fn( self: *const IMSMQMessage4, pisAuthenticated: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsFirstInTransaction2: fn( self: *const IMSMQMessage4, pisFirstInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsLastInTransaction2: fn( self: *const IMSMQMessage4, pisLastInXact: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AttachCurrentSecurityContext2: fn( self: *const IMSMQMessage4, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SoapEnvelope: fn( self: *const IMSMQMessage4, pbstrSoapEnvelope: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CompoundMessage: fn( self: *const IMSMQMessage4, pvarCompoundMessage: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SoapHeader: fn( self: *const IMSMQMessage4, bstrSoapHeader: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SoapBody: fn( self: *const IMSMQMessage4, bstrSoapBody: ?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 IMSMQMessage4_get_Class(self: *const T, plClass: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Class(@ptrCast(*const IMSMQMessage4, self), plClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_PrivLevel(self: *const T, plPrivLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_PrivLevel(@ptrCast(*const IMSMQMessage4, self), plPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_PrivLevel(self: *const T, lPrivLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_PrivLevel(@ptrCast(*const IMSMQMessage4, self), lPrivLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_AuthLevel(self: *const T, plAuthLevel: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_AuthLevel(@ptrCast(*const IMSMQMessage4, self), plAuthLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_AuthLevel(self: *const T, lAuthLevel: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_AuthLevel(@ptrCast(*const IMSMQMessage4, self), lAuthLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_IsAuthenticated(self: *const T, pisAuthenticated: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_IsAuthenticated(@ptrCast(*const IMSMQMessage4, self), pisAuthenticated); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Delivery(self: *const T, plDelivery: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Delivery(@ptrCast(*const IMSMQMessage4, self), plDelivery); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Delivery(self: *const T, lDelivery: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Delivery(@ptrCast(*const IMSMQMessage4, self), lDelivery); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Trace(self: *const T, plTrace: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Trace(@ptrCast(*const IMSMQMessage4, self), plTrace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Trace(self: *const T, lTrace: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Trace(@ptrCast(*const IMSMQMessage4, self), lTrace); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Priority(self: *const T, plPriority: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Priority(@ptrCast(*const IMSMQMessage4, self), plPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Priority(self: *const T, lPriority: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Priority(@ptrCast(*const IMSMQMessage4, self), lPriority); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Journal(self: *const T, plJournal: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Journal(@ptrCast(*const IMSMQMessage4, self), plJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Journal(self: *const T, lJournal: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Journal(@ptrCast(*const IMSMQMessage4, self), lJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_ResponseQueueInfo_v1(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_ResponseQueueInfo_v1(@ptrCast(*const IMSMQMessage4, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_putref_ResponseQueueInfo_v1(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).putref_ResponseQueueInfo_v1(@ptrCast(*const IMSMQMessage4, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_AppSpecific(self: *const T, plAppSpecific: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_AppSpecific(@ptrCast(*const IMSMQMessage4, self), plAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_AppSpecific(self: *const T, lAppSpecific: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_AppSpecific(@ptrCast(*const IMSMQMessage4, self), lAppSpecific); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_SourceMachineGuid(self: *const T, pbstrGuidSrcMachine: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_SourceMachineGuid(@ptrCast(*const IMSMQMessage4, self), pbstrGuidSrcMachine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_BodyLength(self: *const T, pcbBody: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_BodyLength(@ptrCast(*const IMSMQMessage4, self), pcbBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Body(self: *const T, pvarBody: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Body(@ptrCast(*const IMSMQMessage4, self), pvarBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Body(self: *const T, varBody: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Body(@ptrCast(*const IMSMQMessage4, self), varBody); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_AdminQueueInfo_v1(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_AdminQueueInfo_v1(@ptrCast(*const IMSMQMessage4, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_putref_AdminQueueInfo_v1(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).putref_AdminQueueInfo_v1(@ptrCast(*const IMSMQMessage4, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Id(self: *const T, pvarMsgId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Id(@ptrCast(*const IMSMQMessage4, self), pvarMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_CorrelationId(self: *const T, pvarMsgId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_CorrelationId(@ptrCast(*const IMSMQMessage4, self), pvarMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_CorrelationId(self: *const T, varMsgId: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_CorrelationId(@ptrCast(*const IMSMQMessage4, self), varMsgId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Ack(self: *const T, plAck: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Ack(@ptrCast(*const IMSMQMessage4, self), plAck); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Ack(self: *const T, lAck: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Ack(@ptrCast(*const IMSMQMessage4, self), lAck); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Label(self: *const T, pbstrLabel: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Label(@ptrCast(*const IMSMQMessage4, self), pbstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Label(self: *const T, bstrLabel: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Label(@ptrCast(*const IMSMQMessage4, self), bstrLabel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_MaxTimeToReachQueue(self: *const T, plMaxTimeToReachQueue: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_MaxTimeToReachQueue(@ptrCast(*const IMSMQMessage4, self), plMaxTimeToReachQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_MaxTimeToReachQueue(self: *const T, lMaxTimeToReachQueue: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_MaxTimeToReachQueue(@ptrCast(*const IMSMQMessage4, self), lMaxTimeToReachQueue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_MaxTimeToReceive(self: *const T, plMaxTimeToReceive: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_MaxTimeToReceive(@ptrCast(*const IMSMQMessage4, self), plMaxTimeToReceive); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_MaxTimeToReceive(self: *const T, lMaxTimeToReceive: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_MaxTimeToReceive(@ptrCast(*const IMSMQMessage4, self), lMaxTimeToReceive); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_HashAlgorithm(self: *const T, plHashAlg: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_HashAlgorithm(@ptrCast(*const IMSMQMessage4, self), plHashAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_HashAlgorithm(self: *const T, lHashAlg: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_HashAlgorithm(@ptrCast(*const IMSMQMessage4, self), lHashAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_EncryptAlgorithm(self: *const T, plEncryptAlg: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_EncryptAlgorithm(@ptrCast(*const IMSMQMessage4, self), plEncryptAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_EncryptAlgorithm(self: *const T, lEncryptAlg: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_EncryptAlgorithm(@ptrCast(*const IMSMQMessage4, self), lEncryptAlg); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_SentTime(self: *const T, pvarSentTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_SentTime(@ptrCast(*const IMSMQMessage4, self), pvarSentTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_ArrivedTime(self: *const T, plArrivedTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_ArrivedTime(@ptrCast(*const IMSMQMessage4, self), plArrivedTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_DestinationQueueInfo(self: *const T, ppqinfoDest: ?*?*IMSMQQueueInfo4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_DestinationQueueInfo(@ptrCast(*const IMSMQMessage4, self), ppqinfoDest); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_SenderCertificate(self: *const T, pvarSenderCert: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_SenderCertificate(@ptrCast(*const IMSMQMessage4, self), pvarSenderCert); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_SenderCertificate(self: *const T, varSenderCert: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_SenderCertificate(@ptrCast(*const IMSMQMessage4, self), varSenderCert); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_SenderId(self: *const T, pvarSenderId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_SenderId(@ptrCast(*const IMSMQMessage4, self), pvarSenderId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_SenderIdType(self: *const T, plSenderIdType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_SenderIdType(@ptrCast(*const IMSMQMessage4, self), plSenderIdType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_SenderIdType(self: *const T, lSenderIdType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_SenderIdType(@ptrCast(*const IMSMQMessage4, self), lSenderIdType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_Send(self: *const T, DestinationQueue: ?*IDispatch, Transaction: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).Send(@ptrCast(*const IMSMQMessage4, self), DestinationQueue, Transaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_AttachCurrentSecurityContext(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).AttachCurrentSecurityContext(@ptrCast(*const IMSMQMessage4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_SenderVersion(self: *const T, plSenderVersion: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_SenderVersion(@ptrCast(*const IMSMQMessage4, self), plSenderVersion); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Extension(self: *const T, pvarExtension: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Extension(@ptrCast(*const IMSMQMessage4, self), pvarExtension); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Extension(self: *const T, varExtension: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Extension(@ptrCast(*const IMSMQMessage4, self), varExtension); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_ConnectorTypeGuid(self: *const T, pbstrGuidConnectorType: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_ConnectorTypeGuid(@ptrCast(*const IMSMQMessage4, self), pbstrGuidConnectorType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_ConnectorTypeGuid(self: *const T, bstrGuidConnectorType: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_ConnectorTypeGuid(@ptrCast(*const IMSMQMessage4, self), bstrGuidConnectorType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_TransactionStatusQueueInfo(self: *const T, ppqinfoXactStatus: ?*?*IMSMQQueueInfo4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_TransactionStatusQueueInfo(@ptrCast(*const IMSMQMessage4, self), ppqinfoXactStatus); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_DestinationSymmetricKey(self: *const T, pvarDestSymmKey: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_DestinationSymmetricKey(@ptrCast(*const IMSMQMessage4, self), pvarDestSymmKey); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_DestinationSymmetricKey(self: *const T, varDestSymmKey: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_DestinationSymmetricKey(@ptrCast(*const IMSMQMessage4, self), varDestSymmKey); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Signature(self: *const T, pvarSignature: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Signature(@ptrCast(*const IMSMQMessage4, self), pvarSignature); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_Signature(self: *const T, varSignature: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_Signature(@ptrCast(*const IMSMQMessage4, self), varSignature); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_AuthenticationProviderType(self: *const T, plAuthProvType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_AuthenticationProviderType(@ptrCast(*const IMSMQMessage4, self), plAuthProvType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_AuthenticationProviderType(self: *const T, lAuthProvType: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_AuthenticationProviderType(@ptrCast(*const IMSMQMessage4, self), lAuthProvType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_AuthenticationProviderName(self: *const T, pbstrAuthProvName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_AuthenticationProviderName(@ptrCast(*const IMSMQMessage4, self), pbstrAuthProvName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_AuthenticationProviderName(self: *const T, bstrAuthProvName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_AuthenticationProviderName(@ptrCast(*const IMSMQMessage4, self), bstrAuthProvName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_SenderId(self: *const T, varSenderId: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_SenderId(@ptrCast(*const IMSMQMessage4, self), varSenderId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_MsgClass(self: *const T, plMsgClass: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_MsgClass(@ptrCast(*const IMSMQMessage4, self), plMsgClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_MsgClass(self: *const T, lMsgClass: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_MsgClass(@ptrCast(*const IMSMQMessage4, self), lMsgClass); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQMessage4, self), ppcolProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_TransactionId(self: *const T, pvarXactId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_TransactionId(@ptrCast(*const IMSMQMessage4, self), pvarXactId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_IsFirstInTransaction(self: *const T, pisFirstInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_IsFirstInTransaction(@ptrCast(*const IMSMQMessage4, self), pisFirstInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_IsLastInTransaction(self: *const T, pisLastInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_IsLastInTransaction(@ptrCast(*const IMSMQMessage4, self), pisLastInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_ResponseQueueInfo_v2(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_ResponseQueueInfo_v2(@ptrCast(*const IMSMQMessage4, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_putref_ResponseQueueInfo_v2(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).putref_ResponseQueueInfo_v2(@ptrCast(*const IMSMQMessage4, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_AdminQueueInfo_v2(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_AdminQueueInfo_v2(@ptrCast(*const IMSMQMessage4, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_putref_AdminQueueInfo_v2(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).putref_AdminQueueInfo_v2(@ptrCast(*const IMSMQMessage4, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_ReceivedAuthenticationLevel(self: *const T, psReceivedAuthenticationLevel: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_ReceivedAuthenticationLevel(@ptrCast(*const IMSMQMessage4, self), psReceivedAuthenticationLevel); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_ResponseQueueInfo(self: *const T, ppqinfoResponse: ?*?*IMSMQQueueInfo4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_ResponseQueueInfo(@ptrCast(*const IMSMQMessage4, self), ppqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_putref_ResponseQueueInfo(self: *const T, pqinfoResponse: ?*IMSMQQueueInfo4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).putref_ResponseQueueInfo(@ptrCast(*const IMSMQMessage4, self), pqinfoResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_AdminQueueInfo(self: *const T, ppqinfoAdmin: ?*?*IMSMQQueueInfo4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_AdminQueueInfo(@ptrCast(*const IMSMQMessage4, self), ppqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_putref_AdminQueueInfo(self: *const T, pqinfoAdmin: ?*IMSMQQueueInfo4) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).putref_AdminQueueInfo(@ptrCast(*const IMSMQMessage4, self), pqinfoAdmin); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_ResponseDestination(self: *const T, ppdestResponse: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_ResponseDestination(@ptrCast(*const IMSMQMessage4, self), ppdestResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_putref_ResponseDestination(self: *const T, pdestResponse: ?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).putref_ResponseDestination(@ptrCast(*const IMSMQMessage4, self), pdestResponse); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_Destination(self: *const T, ppdestDestination: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_Destination(@ptrCast(*const IMSMQMessage4, self), ppdestDestination); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_LookupId(self: *const T, pvarLookupId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_LookupId(@ptrCast(*const IMSMQMessage4, self), pvarLookupId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_IsAuthenticated2(self: *const T, pisAuthenticated: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_IsAuthenticated2(@ptrCast(*const IMSMQMessage4, self), pisAuthenticated); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_IsFirstInTransaction2(self: *const T, pisFirstInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_IsFirstInTransaction2(@ptrCast(*const IMSMQMessage4, self), pisFirstInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_IsLastInTransaction2(self: *const T, pisLastInXact: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_IsLastInTransaction2(@ptrCast(*const IMSMQMessage4, self), pisLastInXact); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_AttachCurrentSecurityContext2(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).AttachCurrentSecurityContext2(@ptrCast(*const IMSMQMessage4, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_SoapEnvelope(self: *const T, pbstrSoapEnvelope: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_SoapEnvelope(@ptrCast(*const IMSMQMessage4, self), pbstrSoapEnvelope); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_get_CompoundMessage(self: *const T, pvarCompoundMessage: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).get_CompoundMessage(@ptrCast(*const IMSMQMessage4, self), pvarCompoundMessage); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_SoapHeader(self: *const T, bstrSoapHeader: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_SoapHeader(@ptrCast(*const IMSMQMessage4, self), bstrSoapHeader); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQMessage4_put_SoapBody(self: *const T, bstrSoapBody: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQMessage4.VTable, self.vtable).put_SoapBody(@ptrCast(*const IMSMQMessage4, self), bstrSoapBody); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQPrivateEvent_Value = @import("../zig.zig").Guid.initString("d7ab3341-c9d3-11d1-bb47-0080c7c5a2c0"); pub const IID_IMSMQPrivateEvent = &IID_IMSMQPrivateEvent_Value; pub const IMSMQPrivateEvent = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Hwnd: fn( self: *const IMSMQPrivateEvent, phwnd: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FireArrivedEvent: fn( self: *const IMSMQPrivateEvent, pq: ?*IMSMQQueue, msgcursor: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, FireArrivedErrorEvent: fn( self: *const IMSMQPrivateEvent, pq: ?*IMSMQQueue, hrStatus: HRESULT, msgcursor: 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 IMSMQPrivateEvent_get_Hwnd(self: *const T, phwnd: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQPrivateEvent.VTable, self.vtable).get_Hwnd(@ptrCast(*const IMSMQPrivateEvent, self), phwnd); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQPrivateEvent_FireArrivedEvent(self: *const T, pq: ?*IMSMQQueue, msgcursor: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQPrivateEvent.VTable, self.vtable).FireArrivedEvent(@ptrCast(*const IMSMQPrivateEvent, self), pq, msgcursor); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQPrivateEvent_FireArrivedErrorEvent(self: *const T, pq: ?*IMSMQQueue, hrStatus: HRESULT, msgcursor: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQPrivateEvent.VTable, self.vtable).FireArrivedErrorEvent(@ptrCast(*const IMSMQPrivateEvent, self), pq, hrStatus, msgcursor); } };} pub usingnamespace MethodMixin(@This()); }; const IID__DMSMQEventEvents_Value = @import("../zig.zig").Guid.initString("d7d6e078-dccd-11d0-aa4b-0060970debae"); pub const IID__DMSMQEventEvents = &IID__DMSMQEventEvents_Value; pub const _DMSMQEventEvents = 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 IID_IMSMQTransaction2_Value = @import("../zig.zig").Guid.initString("2ce0c5b0-6e67-11d2-b0e6-00e02c074f6b"); pub const IID_IMSMQTransaction2 = &IID_IMSMQTransaction2_Value; pub const IMSMQTransaction2 = extern struct { pub const VTable = extern struct { base: IMSMQTransaction.VTable, InitNew: fn( self: *const IMSMQTransaction2, varTransaction: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQTransaction2, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IMSMQTransaction.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQTransaction2_InitNew(self: *const T, varTransaction: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransaction2.VTable, self.vtable).InitNew(@ptrCast(*const IMSMQTransaction2, self), varTransaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQTransaction2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransaction2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQTransaction2, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQTransaction3_Value = @import("../zig.zig").Guid.initString("eba96b13-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQTransaction3 = &IID_IMSMQTransaction3_Value; pub const IMSMQTransaction3 = extern struct { pub const VTable = extern struct { base: IMSMQTransaction2.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ITransaction: fn( self: *const IMSMQTransaction3, pvarITransaction: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IMSMQTransaction2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQTransaction3_get_ITransaction(self: *const T, pvarITransaction: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransaction3.VTable, self.vtable).get_ITransaction(@ptrCast(*const IMSMQTransaction3, self), pvarITransaction); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQCoordinatedTransactionDispenser2_Value = @import("../zig.zig").Guid.initString("eba96b10-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQCoordinatedTransactionDispenser2 = &IID_IMSMQCoordinatedTransactionDispenser2_Value; pub const IMSMQCoordinatedTransactionDispenser2 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, BeginTransaction: fn( self: *const IMSMQCoordinatedTransactionDispenser2, ptransaction: ?*?*IMSMQTransaction2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQCoordinatedTransactionDispenser2, ppcolProperties: ?*?*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 IMSMQCoordinatedTransactionDispenser2_BeginTransaction(self: *const T, ptransaction: ?*?*IMSMQTransaction2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQCoordinatedTransactionDispenser2.VTable, self.vtable).BeginTransaction(@ptrCast(*const IMSMQCoordinatedTransactionDispenser2, self), ptransaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQCoordinatedTransactionDispenser2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQCoordinatedTransactionDispenser2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQCoordinatedTransactionDispenser2, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQCoordinatedTransactionDispenser3_Value = @import("../zig.zig").Guid.initString("eba96b14-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQCoordinatedTransactionDispenser3 = &IID_IMSMQCoordinatedTransactionDispenser3_Value; pub const IMSMQCoordinatedTransactionDispenser3 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, BeginTransaction: fn( self: *const IMSMQCoordinatedTransactionDispenser3, ptransaction: ?*?*IMSMQTransaction3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQCoordinatedTransactionDispenser3, ppcolProperties: ?*?*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 IMSMQCoordinatedTransactionDispenser3_BeginTransaction(self: *const T, ptransaction: ?*?*IMSMQTransaction3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQCoordinatedTransactionDispenser3.VTable, self.vtable).BeginTransaction(@ptrCast(*const IMSMQCoordinatedTransactionDispenser3, self), ptransaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQCoordinatedTransactionDispenser3_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQCoordinatedTransactionDispenser3.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQCoordinatedTransactionDispenser3, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQTransactionDispenser2_Value = @import("../zig.zig").Guid.initString("eba96b11-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQTransactionDispenser2 = &IID_IMSMQTransactionDispenser2_Value; pub const IMSMQTransactionDispenser2 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, BeginTransaction: fn( self: *const IMSMQTransactionDispenser2, ptransaction: ?*?*IMSMQTransaction2, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQTransactionDispenser2, ppcolProperties: ?*?*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 IMSMQTransactionDispenser2_BeginTransaction(self: *const T, ptransaction: ?*?*IMSMQTransaction2) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransactionDispenser2.VTable, self.vtable).BeginTransaction(@ptrCast(*const IMSMQTransactionDispenser2, self), ptransaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQTransactionDispenser2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransactionDispenser2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQTransactionDispenser2, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQTransactionDispenser3_Value = @import("../zig.zig").Guid.initString("eba96b15-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQTransactionDispenser3 = &IID_IMSMQTransactionDispenser3_Value; pub const IMSMQTransactionDispenser3 = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, BeginTransaction: fn( self: *const IMSMQTransactionDispenser3, ptransaction: ?*?*IMSMQTransaction3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQTransactionDispenser3, ppcolProperties: ?*?*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 IMSMQTransactionDispenser3_BeginTransaction(self: *const T, ptransaction: ?*?*IMSMQTransaction3) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransactionDispenser3.VTable, self.vtable).BeginTransaction(@ptrCast(*const IMSMQTransactionDispenser3, self), ptransaction); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQTransactionDispenser3_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQTransactionDispenser3.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQTransactionDispenser3, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQApplication_Value = @import("../zig.zig").Guid.initString("d7d6e085-dccd-11d0-aa4b-0060970debae"); pub const IID_IMSMQApplication = &IID_IMSMQApplication_Value; pub const IMSMQApplication = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, MachineIdOfMachineName: fn( self: *const IMSMQApplication, MachineName: ?BSTR, pbstrGuid: ?*?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 IMSMQApplication_MachineIdOfMachineName(self: *const T, MachineName: ?BSTR, pbstrGuid: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication.VTable, self.vtable).MachineIdOfMachineName(@ptrCast(*const IMSMQApplication, self), MachineName, pbstrGuid); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQApplication2_Value = @import("../zig.zig").Guid.initString("12a30900-7300-11d2-b0e6-00e02c074f6b"); pub const IID_IMSMQApplication2 = &IID_IMSMQApplication2_Value; pub const IMSMQApplication2 = extern struct { pub const VTable = extern struct { base: IMSMQApplication.VTable, RegisterCertificate: fn( self: *const IMSMQApplication2, Flags: ?*VARIANT, ExternalCertificate: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, MachineNameOfMachineId: fn( self: *const IMSMQApplication2, bstrGuid: ?BSTR, pbstrMachineName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MSMQVersionMajor: fn( self: *const IMSMQApplication2, psMSMQVersionMajor: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MSMQVersionMinor: fn( self: *const IMSMQApplication2, psMSMQVersionMinor: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MSMQVersionBuild: fn( self: *const IMSMQApplication2, psMSMQVersionBuild: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsDsEnabled: fn( self: *const IMSMQApplication2, pfIsDsEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQApplication2, ppcolProperties: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IMSMQApplication.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication2_RegisterCertificate(self: *const T, Flags: ?*VARIANT, ExternalCertificate: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication2.VTable, self.vtable).RegisterCertificate(@ptrCast(*const IMSMQApplication2, self), Flags, ExternalCertificate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication2_MachineNameOfMachineId(self: *const T, bstrGuid: ?BSTR, pbstrMachineName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication2.VTable, self.vtable).MachineNameOfMachineId(@ptrCast(*const IMSMQApplication2, self), bstrGuid, pbstrMachineName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication2_get_MSMQVersionMajor(self: *const T, psMSMQVersionMajor: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication2.VTable, self.vtable).get_MSMQVersionMajor(@ptrCast(*const IMSMQApplication2, self), psMSMQVersionMajor); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication2_get_MSMQVersionMinor(self: *const T, psMSMQVersionMinor: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication2.VTable, self.vtable).get_MSMQVersionMinor(@ptrCast(*const IMSMQApplication2, self), psMSMQVersionMinor); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication2_get_MSMQVersionBuild(self: *const T, psMSMQVersionBuild: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication2.VTable, self.vtable).get_MSMQVersionBuild(@ptrCast(*const IMSMQApplication2, self), psMSMQVersionBuild); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication2_get_IsDsEnabled(self: *const T, pfIsDsEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication2.VTable, self.vtable).get_IsDsEnabled(@ptrCast(*const IMSMQApplication2, self), pfIsDsEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication2_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication2.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQApplication2, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQApplication3_Value = @import("../zig.zig").Guid.initString("eba96b1f-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQApplication3 = &IID_IMSMQApplication3_Value; pub const IMSMQApplication3 = extern struct { pub const VTable = extern struct { base: IMSMQApplication2.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ActiveQueues: fn( self: *const IMSMQApplication3, pvActiveQueues: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PrivateQueues: fn( self: *const IMSMQApplication3, pvPrivateQueues: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DirectoryServiceServer: fn( self: *const IMSMQApplication3, pbstrDirectoryServiceServer: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsConnected: fn( self: *const IMSMQApplication3, pfIsConnected: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BytesInAllQueues: fn( self: *const IMSMQApplication3, pvBytesInAllQueues: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Machine: fn( self: *const IMSMQApplication3, bstrMachine: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Machine: fn( self: *const IMSMQApplication3, pbstrMachine: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Connect: fn( self: *const IMSMQApplication3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Disconnect: fn( self: *const IMSMQApplication3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Tidy: fn( self: *const IMSMQApplication3, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IMSMQApplication2.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_get_ActiveQueues(self: *const T, pvActiveQueues: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).get_ActiveQueues(@ptrCast(*const IMSMQApplication3, self), pvActiveQueues); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_get_PrivateQueues(self: *const T, pvPrivateQueues: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).get_PrivateQueues(@ptrCast(*const IMSMQApplication3, self), pvPrivateQueues); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_get_DirectoryServiceServer(self: *const T, pbstrDirectoryServiceServer: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).get_DirectoryServiceServer(@ptrCast(*const IMSMQApplication3, self), pbstrDirectoryServiceServer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_get_IsConnected(self: *const T, pfIsConnected: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).get_IsConnected(@ptrCast(*const IMSMQApplication3, self), pfIsConnected); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_get_BytesInAllQueues(self: *const T, pvBytesInAllQueues: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).get_BytesInAllQueues(@ptrCast(*const IMSMQApplication3, self), pvBytesInAllQueues); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_put_Machine(self: *const T, bstrMachine: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).put_Machine(@ptrCast(*const IMSMQApplication3, self), bstrMachine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_get_Machine(self: *const T, pbstrMachine: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).get_Machine(@ptrCast(*const IMSMQApplication3, self), pbstrMachine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_Connect(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).Connect(@ptrCast(*const IMSMQApplication3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_Disconnect(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).Disconnect(@ptrCast(*const IMSMQApplication3, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQApplication3_Tidy(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQApplication3.VTable, self.vtable).Tidy(@ptrCast(*const IMSMQApplication3, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQDestination_Value = @import("../zig.zig").Guid.initString("eba96b16-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQDestination = &IID_IMSMQDestination_Value; pub const IMSMQDestination = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Open: fn( self: *const IMSMQDestination, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Close: fn( self: *const IMSMQDestination, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsOpen: fn( self: *const IMSMQDestination, pfIsOpen: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IADs: fn( self: *const IMSMQDestination, ppIADs: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_IADs: fn( self: *const IMSMQDestination, pIADs: ?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ADsPath: fn( self: *const IMSMQDestination, pbstrADsPath: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ADsPath: fn( self: *const IMSMQDestination, bstrADsPath: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PathName: fn( self: *const IMSMQDestination, pbstrPathName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PathName: fn( self: *const IMSMQDestination, bstrPathName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FormatName: fn( self: *const IMSMQDestination, pbstrFormatName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FormatName: fn( self: *const IMSMQDestination, bstrFormatName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Destinations: fn( self: *const IMSMQDestination, ppDestinations: ?*?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, putref_Destinations: fn( self: *const IMSMQDestination, pDestinations: ?*IDispatch, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Properties: fn( self: *const IMSMQDestination, ppcolProperties: ?*?*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 IMSMQDestination_Open(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).Open(@ptrCast(*const IMSMQDestination, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_Close(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).Close(@ptrCast(*const IMSMQDestination, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_get_IsOpen(self: *const T, pfIsOpen: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).get_IsOpen(@ptrCast(*const IMSMQDestination, self), pfIsOpen); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_get_IADs(self: *const T, ppIADs: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).get_IADs(@ptrCast(*const IMSMQDestination, self), ppIADs); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_putref_IADs(self: *const T, pIADs: ?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).putref_IADs(@ptrCast(*const IMSMQDestination, self), pIADs); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_get_ADsPath(self: *const T, pbstrADsPath: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).get_ADsPath(@ptrCast(*const IMSMQDestination, self), pbstrADsPath); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_put_ADsPath(self: *const T, bstrADsPath: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).put_ADsPath(@ptrCast(*const IMSMQDestination, self), bstrADsPath); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_get_PathName(self: *const T, pbstrPathName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).get_PathName(@ptrCast(*const IMSMQDestination, self), pbstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_put_PathName(self: *const T, bstrPathName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).put_PathName(@ptrCast(*const IMSMQDestination, self), bstrPathName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_get_FormatName(self: *const T, pbstrFormatName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).get_FormatName(@ptrCast(*const IMSMQDestination, self), pbstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_put_FormatName(self: *const T, bstrFormatName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).put_FormatName(@ptrCast(*const IMSMQDestination, self), bstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_get_Destinations(self: *const T, ppDestinations: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).get_Destinations(@ptrCast(*const IMSMQDestination, self), ppDestinations); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_putref_Destinations(self: *const T, pDestinations: ?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).putref_Destinations(@ptrCast(*const IMSMQDestination, self), pDestinations); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQDestination_get_Properties(self: *const T, ppcolProperties: ?*?*IDispatch) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQDestination.VTable, self.vtable).get_Properties(@ptrCast(*const IMSMQDestination, self), ppcolProperties); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQPrivateDestination_Value = @import("../zig.zig").Guid.initString("eba96b17-2168-11d3-898c-00e02c074f6b"); pub const IID_IMSMQPrivateDestination = &IID_IMSMQPrivateDestination_Value; pub const IMSMQPrivateDestination = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Handle: fn( self: *const IMSMQPrivateDestination, pvarHandle: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Handle: fn( self: *const IMSMQPrivateDestination, varHandle: 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 IMSMQPrivateDestination_get_Handle(self: *const T, pvarHandle: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQPrivateDestination.VTable, self.vtable).get_Handle(@ptrCast(*const IMSMQPrivateDestination, self), pvarHandle); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQPrivateDestination_put_Handle(self: *const T, varHandle: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQPrivateDestination.VTable, self.vtable).put_Handle(@ptrCast(*const IMSMQPrivateDestination, self), varHandle); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQCollection_Value = @import("../zig.zig").Guid.initString("0188ac2f-ecb3-4173-9779-635ca2039c72"); pub const IID_IMSMQCollection = &IID_IMSMQCollection_Value; pub const IMSMQCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Item: fn( self: *const IMSMQCollection, Index: ?*VARIANT, pvarRet: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IMSMQCollection, pCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, _NewEnum: fn( self: *const IMSMQCollection, ppunk: ?*?*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 IMSMQCollection_Item(self: *const T, Index: ?*VARIANT, pvarRet: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQCollection.VTable, self.vtable).Item(@ptrCast(*const IMSMQCollection, self), Index, pvarRet); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQCollection_get_Count(self: *const T, pCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQCollection.VTable, self.vtable).get_Count(@ptrCast(*const IMSMQCollection, self), pCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQCollection__NewEnum(self: *const T, ppunk: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQCollection.VTable, self.vtable)._NewEnum(@ptrCast(*const IMSMQCollection, self), ppunk); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQManagement_Value = @import("../zig.zig").Guid.initString("be5f0241-e489-4957-8cc4-a452fcf3e23e"); pub const IID_IMSMQManagement = &IID_IMSMQManagement_Value; pub const IMSMQManagement = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Init: fn( self: *const IMSMQManagement, Machine: ?*VARIANT, Pathname: ?*VARIANT, FormatName: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FormatName: fn( self: *const IMSMQManagement, pbstrFormatName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Machine: fn( self: *const IMSMQManagement, pbstrMachine: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MessageCount: fn( self: *const IMSMQManagement, plMessageCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ForeignStatus: fn( self: *const IMSMQManagement, plForeignStatus: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QueueType: fn( self: *const IMSMQManagement, plQueueType: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_IsLocal: fn( self: *const IMSMQManagement, pfIsLocal: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_TransactionalStatus: fn( self: *const IMSMQManagement, plTransactionalStatus: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BytesInQueue: fn( self: *const IMSMQManagement, pvBytesInQueue: ?*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 IMSMQManagement_Init(self: *const T, Machine: ?*VARIANT, Pathname: ?*VARIANT, FormatName: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).Init(@ptrCast(*const IMSMQManagement, self), Machine, Pathname, FormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQManagement_get_FormatName(self: *const T, pbstrFormatName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).get_FormatName(@ptrCast(*const IMSMQManagement, self), pbstrFormatName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQManagement_get_Machine(self: *const T, pbstrMachine: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).get_Machine(@ptrCast(*const IMSMQManagement, self), pbstrMachine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQManagement_get_MessageCount(self: *const T, plMessageCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).get_MessageCount(@ptrCast(*const IMSMQManagement, self), plMessageCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQManagement_get_ForeignStatus(self: *const T, plForeignStatus: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).get_ForeignStatus(@ptrCast(*const IMSMQManagement, self), plForeignStatus); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQManagement_get_QueueType(self: *const T, plQueueType: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).get_QueueType(@ptrCast(*const IMSMQManagement, self), plQueueType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQManagement_get_IsLocal(self: *const T, pfIsLocal: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).get_IsLocal(@ptrCast(*const IMSMQManagement, self), pfIsLocal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQManagement_get_TransactionalStatus(self: *const T, plTransactionalStatus: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).get_TransactionalStatus(@ptrCast(*const IMSMQManagement, self), plTransactionalStatus); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQManagement_get_BytesInQueue(self: *const T, pvBytesInQueue: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQManagement.VTable, self.vtable).get_BytesInQueue(@ptrCast(*const IMSMQManagement, self), pvBytesInQueue); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQOutgoingQueueManagement_Value = @import("../zig.zig").Guid.initString("64c478fb-f9b0-4695-8a7f-439ac94326d3"); pub const IID_IMSMQOutgoingQueueManagement = &IID_IMSMQOutgoingQueueManagement_Value; pub const IMSMQOutgoingQueueManagement = extern struct { pub const VTable = extern struct { base: IMSMQManagement.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const IMSMQOutgoingQueueManagement, plState: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NextHops: fn( self: *const IMSMQOutgoingQueueManagement, pvNextHops: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EodGetSendInfo: fn( self: *const IMSMQOutgoingQueueManagement, ppCollection: ?*?*IMSMQCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Resume: fn( self: *const IMSMQOutgoingQueueManagement, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Pause: fn( self: *const IMSMQOutgoingQueueManagement, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EodResend: fn( self: *const IMSMQOutgoingQueueManagement, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IMSMQManagement.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQOutgoingQueueManagement_get_State(self: *const T, plState: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQOutgoingQueueManagement.VTable, self.vtable).get_State(@ptrCast(*const IMSMQOutgoingQueueManagement, self), plState); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQOutgoingQueueManagement_get_NextHops(self: *const T, pvNextHops: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQOutgoingQueueManagement.VTable, self.vtable).get_NextHops(@ptrCast(*const IMSMQOutgoingQueueManagement, self), pvNextHops); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQOutgoingQueueManagement_EodGetSendInfo(self: *const T, ppCollection: ?*?*IMSMQCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQOutgoingQueueManagement.VTable, self.vtable).EodGetSendInfo(@ptrCast(*const IMSMQOutgoingQueueManagement, self), ppCollection); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQOutgoingQueueManagement_Resume(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQOutgoingQueueManagement.VTable, self.vtable).Resume(@ptrCast(*const IMSMQOutgoingQueueManagement, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQOutgoingQueueManagement_Pause(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQOutgoingQueueManagement.VTable, self.vtable).Pause(@ptrCast(*const IMSMQOutgoingQueueManagement, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQOutgoingQueueManagement_EodResend(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQOutgoingQueueManagement.VTable, self.vtable).EodResend(@ptrCast(*const IMSMQOutgoingQueueManagement, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IMSMQQueueManagement_Value = @import("../zig.zig").Guid.initString("7fbe7759-5760-444d-b8a5-5e7ab9a84cce"); pub const IID_IMSMQQueueManagement = &IID_IMSMQQueueManagement_Value; pub const IMSMQQueueManagement = extern struct { pub const VTable = extern struct { base: IMSMQManagement.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_JournalMessageCount: fn( self: *const IMSMQQueueManagement, plJournalMessageCount: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BytesInJournal: fn( self: *const IMSMQQueueManagement, pvBytesInJournal: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EodGetReceiveInfo: fn( self: *const IMSMQQueueManagement, pvCollection: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IMSMQManagement.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueManagement_get_JournalMessageCount(self: *const T, plJournalMessageCount: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueManagement.VTable, self.vtable).get_JournalMessageCount(@ptrCast(*const IMSMQQueueManagement, self), plJournalMessageCount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueManagement_get_BytesInJournal(self: *const T, pvBytesInJournal: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueManagement.VTable, self.vtable).get_BytesInJournal(@ptrCast(*const IMSMQQueueManagement, self), pvBytesInJournal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IMSMQQueueManagement_EodGetReceiveInfo(self: *const T, pvCollection: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IMSMQQueueManagement.VTable, self.vtable).EodGetReceiveInfo(@ptrCast(*const IMSMQQueueManagement, self), pvCollection); } };} pub usingnamespace MethodMixin(@This()); }; //-------------------------------------------------------------------------------- // Section: Functions (0) //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // Section: Unicode Aliases (0) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { }, .wide => struct { }, .unspecified => if (@import("builtin").is_test) struct { } else struct { }, }; //-------------------------------------------------------------------------------- // Section: Imports (5) //-------------------------------------------------------------------------------- const BSTR = @import("../foundation.zig").BSTR; const HRESULT = @import("../foundation.zig").HRESULT; const IDispatch = @import("../system/com.zig").IDispatch; const IUnknown = @import("../system/com.zig").IUnknown; const VARIANT = @import("../system/com.zig").VARIANT; test { @setEvalBranchQuota( @import("std").meta.declarations(@This()).len * 3 ); // reference all the pub declarations if (!@import("builtin").is_test) return; inline for (@import("std").meta.declarations(@This())) |decl| { if (decl.is_pub) { _ = decl; } } }
win32/system/message_queuing.zig
const std = @import("std"); const strs = [_][]const u8{ "f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", "db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", "<KEY>", "536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", "<KEY>", "d88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", "87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", "26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", "<KEY>", "ffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", "<KEY>", "b7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", "<KEY>", "b58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", "<KEY>", "8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", "8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", "95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", "f893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", "cddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", "8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", "<KEY>", "e71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", "31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", "21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", "619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", "7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", "<KEY>", "<KEY>", "<KEY>", "985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7", "<KEY>", "1c9a7e5ff1cf48b4ad1582d3f4e4a1004f3b20d8c5a2b71387a4254ad933ebc5", "<KEY>", "<KEY>", "<KEY>", "55d8fb3687ba3ba49f342c77f5a1f89bec83d811446e1a467139213d640b6a74", "<KEY>", "ad21b516cbc645ffe34ab5de1c8aef8cd4e7f8d2b51e8e1456adc7563cda206f", "<KEY>", "a7f23ce9181740dc220c814782654fee6aceb9f1ec9222c4e2467d0ab1680837", "<KEY>", "9a42bcad82f6a9e41284d808ead319f29f3b08209d680f0e2ce71510d071e205", "d1a66d354a67b9cf179571d8e5f97792716e8dd4ec44196839a3f7c6b74f8bac", "<KEY>", "<KEY>", "<KEY>", "7ba3ae4a417fe8545b142bc89f4adcd7ae13941cbab7750b83e9f0a66d16be64", "788fafcc4aa520399adbaed195f8b12c4eb31ec10168e50aabc659a6aea516dc", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "a0a08dfc9b42d96c2de19b6d127b8ae136ddcf3e5ad0dce422c45a56f61f6a74", "<KEY>", "3ab134751d191269026c86994eaa8b43a83b4ad1f6d0e77381c4e2974afbc8f6", "9a7452611db2d23eae26f9bdbb88958ef44c64d0fe987be9f726adf938f50f6c", "725c7f816037bfe452cd1e7ba35ac47edcb49a9a2b27aeca70dce483cb7ded1f", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "2fd4c32b0a65616d4bceb9e2f2bd4dcf7535546f433a3e1d45ce54abc059c867", "2f8d300488ab4f7464d9ee9e59d80aaa8a2039af5513f320e5a3083c63ea68ef", "48562f2ab1873a6120f575267a37db470d4a6bc83ed1ad903e64f7b3755766ad", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "e726e40dbd2f9841293b5b3c15e918a872aed2ba491f4e111ea0913a04ffe165", "<KEY>", "<KEY>", "<KEY>", "dc243614ffda79e3d7556ef3fdea0b44df1757badae017b05f5133fd15c27aea", "<KEY>", "<KEY>", "5e5c577e401fb0ed3c051979201cfc5ec100dae9942278e99e3434cfe560c276", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "5ef1e53a05f43d01472447d914409459ce5f2b0d24566187efdbefc25864da2b", "<KEY>", "180fedca06656cb910077013ad2679695090269fad1589e290162fe90e97d4aa", "<KEY>", "<KEY>", "2e98ae4b6e69b95b71048ec119719851c050529a20c67a2c401723b34de9748a", "3b5c39d7274c2a74d4ed2d9e8410ead2f351dfd6158148f1b10d97d60d739207", "423f672311c1a44ce5a44765f6217eabf759de2bd882b6bf0f7b09694e4b8043", "<KEY>", "d3d47dffaa99a033c8c3bb62dc0a438b71f91b18a38c87a49fa88474dde87924", "4189d201eed3f4ebcb3fd5a4c73f282923f010e753c3c5e7e3d0199037a3b087", "142a03b09d66cbe5b45fea8fa25d6a297084aed9e03bee72862f9d6b3dbabba0", "4cd8ea52aca52408fb87b0e697cd24632d94a6df757fa3f29cc0a5d5494edcc5", "afa2c75dc2c5a8462c17092ee1efe21de9b10f0dc0dea0794f304513e1aa33d2", "3d39740655edfc46fb8afd539e23070dfb35e0d6d1cf67eed7a1c25442e01696", "7d609e3eee6fa33910f427d52e88efcca673e453b4acde37a8a8687f3d3af57a", "<KEY>", "571c032857aadbec07310299b0041c26924a619669e161559a5b1f49aff9cc09", "0a6b5e75c36a716b43d41d262adb047d165da4c39a512f145f5fc90f86923ea3", "547374ec1a58c7a4d14d51afb52ed4e404a9eb22f008b3387d326edbd3066c77", "f9e4305daad80dfb3776230d54edddf5050cefe0846999414c706ea60aa3fe11", "<KEY>", "<KEY>", "ef97d5ba70031de19734533a11bc7a52ca5b05c3b1d2c61d53010a57878dae8d", "854accef35670517593e126a933f9a77ffb7b6ced2735f5518f5dc16b16ec0cd", "<KEY>", "313a6522e9eaae01ff1e4bb545c042d2ce3a7271f668ecaa303b54eb70ebf294", "<KEY>", "38e5e5559730caf93710ca7937ceb17511e70d5356979a700223828f5b58e9e9", "c39ed9a49132e90199629a542f75e932dfc2a808684e19719af55eaa5b7da7fc", "<KEY>", "<KEY>", "77a3fe503f5c11aaf32d40ac768143769cd0f21ff89214ffda1bdbc69a5d4ace", "<KEY>", "27803233e079f2509c07cbb25962a808c7a6c65f8a99bd99fe54da707b9a45a4", "765ff12c95a406baf48020d6ae348e2021a94ce6b40c1426ea4c44a74cab228c", "d0522d45ad5883d1dfe4c36925a94fcbc30e828083a87c53ccaa12cd679fed56", "<KEY>", "<KEY>", "<KEY>", "ad484a007384e0b23f629cd335620edbae313dc07a31ca58fe1d97fac2ca0b55", "<KEY>", "b4c9dacf8e194e353dce7638d76f282fe40399f7b0ad74a2229a6d4f5be774de", "6fb8963ceb8052837b3fab4f986921791b82afe3dffe09a5e0fe54f86281a2b4", "7a209efa3abf7e0e278d4f3eb9a7af187beefa55d5657b7d44cfaf5c02739464", "<KEY>", "<KEY>", "38334b001abba65528ab2a81bdd124a4ebb3aa9245d8665eed4747fe9887e6d2", "<KEY>", "<KEY>", "9c9c16d380ee2ea38bf56c28847c1a88e3dce7eee91f326693936b4549bc58ec", "a4eaba691de0db77612509511112db76db988de972717075365a35718d990421", "bca1e063a76c7d73265032929b4eadab4be617ed5433c0571649c63bd2734558", "<KEY>", "1ed5177e70183ce8333cf11ad039ba6c5e3e520ff7fa89a91c90dbf2b3db7331", "b72e64036cfff91f2ac171401ca8003e2f94b55d4184fe737303ab51590af450", "d08206d65b51d895e2a6ea9bad707e72a9f87461dd46837ee4f930d7c4df0c61", "829d361560d54e2dd41b1f719895b9e8e98f34137a8cfeb162430fe2c666c891", "bf273a4700e01b28e69407ef41048098f29a6d98cb8e243a106e3c82d41982a2", "<KEY>", "951373e6f752e59746f00193340574df6d3529b07665f6da156552d5182e5489", "191adb5f532266e046db16b27f63caf7e438d3fee916b742ce1d4dc0b64a1dd8", "de189968460a1e88cad6fcadc03af1a821b9e8c938062b49bb8d2b5f751dd5c6", "<KEY>", "dda4dbed53bff8d2d814694ea8e4ce88fa6629e1e450d923ce4f1fa7d0491b5e", "989923a8f20c4fa00dd52678f2b96d620f28ec8867307320d9b9eeaffef29d06", "<KEY>", "7a4234694dab0d28edc60c9312c0ed418c240358e271bd24236335694e3c10b1", "fad91317824119818d4bea60cdd1553368cad703193510f6ea049ffd121b36a8", "<KEY>", "0bd8c308e2b0e69e8c45a0d857642a490f365bdb1d444c5439ea91bd68543a9a", "250198a7ea057d3617a61d8392ce8ecfd3913a3dda3c9de66292a19729af1f34", "9e8efb2de6594b4e0c9ef31cbe56a2828d616e7bbaadc9f8b66822f19c60d9e9", "d337256346a5878d3a13cd8810196dc529187031514adaf021f202d4de68fc40", "0071bb79d0a2e58b2d539f99f49b08af1ad9c85e735227f04875a356c6b18edb", "<KEY>", "e4e1e8eef0d58e9955e345919a9d8eb44ee5f2b3986f6de4c661896b8e128836", "<KEY>", "7f71344c776124c9f687317237a8c015a274adbc9805d3c03942e8f9052021a4", "<KEY>", "<KEY>", "00e406a0bfe6d6f430081dadde423977bac40ae1c68ebb3f4f2fbe9c8698f49d", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "9b3079358080d1de88b5bad267018b5ead9a2f388798aa719cb303bde156af74", "d16373e1873dfc8486796bb101253677a58a22a8ea55744c4c1424d716beba92", "<KEY>", "<KEY>", "6c6ad986cebf730ec593477de186609e9aa68ab84e15c15df3ca88669f7c9ec6", "6bd2bf838ef7e14d552727a397e138d801daabac2e8b434788826ea8c201cafc", "<KEY>", "6b224e497203715208f44b280f4f0839ab4155ffbba59c6762adf7eb34a961d3", "ded73980da15312194a6da966a17babdfd33a9c5fe7583aea91152c604e2652b", "5ba6d07cc9e01caa61389c0529d9fc6a21ea6caf66b8701f739faac2535d922a", "6d63be408e4f8b96b65eb47ccd73983a01fbb163fec1e56b9745a5dc0ca67ad7", "7b8228a258542d1a63c29a2f85111d35ef30d46704882b2fd63558f3ba380987", "2b0a46ee56f357e4f68dd7633d768b0beb9483b3eabb934abb085b84331dfbd7", "<KEY>", "<KEY>", "038531c316198eb2463137682985ccb4093defc7af935d9778ee93cc77232e20", "d1d0ffe2757e92387ff26802c2567d3b517edd8ab0ed735f1bda40e19189e4a8", "<KEY>", "f5ff0267d136ad5fb7803f9a52124305336f884578b8313d52aab6e68cc6ed71", "<KEY>", "<KEY>", "<KEY>", "9a54efdd129fd4693c820f2716821442b1eca853e7c93741ef9f0161ea06d4b8", "<KEY>", "<KEY>", "faaa988db02ead8936809594f187d4900e83c1e8b227b768091f040369ceb22c", "c7efe477b58a476456ce268710468c190ce895c72990d8c5f3d70f48bd9777af", "9db840f7f4435a6e2601def426a1cafab40c383934d46efa8f637606ef17a167", "7071b73f59d8ee9e262774d07ffe8e9bd13b4bb03812a868bbe8020dc6af9b4e", "<KEY>", "55be44002962674316f8eadd80c25d9bb88129002bcdeecf8879f32c9a7222ec", "<KEY>", "01f2c4d66c4c10b75d2955794db414ac9ac47a3da4ce8d73df6e709a57a9da8d", "<KEY>", "77b82bed4f49392ca8ed1f9e89e2224804ab1876d5ae3a0a38476fdc88a1e1bf", "18b110e4533cd8e24dceeb0d6f25c6fe6f21861ad6738cbd07ea21b3fe6d299f", "c1acc7d94d6c77a97ec33829ab04aad2cfe2a66f87e515c39c86281e1958bae0", "<KEY>", "c1a6c34f8efa4117812b95df5e852c17d953f41897e6fc56b7930b3270a02d0d", "<KEY>", "<KEY>", "369e9df2ac6ca05847434d3d7b75ea754aa406d96b534a2b3ddf99ee314bd756", "f02ea520110c2ecf0b9d24e1a932df150c7ae6d0406c9702437331df11537d83", "7adf30a5042aa23d0f2b86b943ffdf8e1a387f9db78354a99ccc70c759c3b3ef", "422233b3d3990f51861cb4a0be62fc1158f7d66d1af1e6be190538da1a47675e", "2865fdece0d6736d4cc927baf48bbcb71a3cedbcca33c907c95dedbe084e65f2", "a219a6d9e8400cb724968b120cd6b0137147270219984475823e8931c315adc6", "<KEY>", "<KEY>", "b455965645953a7cc469c9ef671c407b4692cee7974de006ef8376b781ef4c1a", "<KEY>", "<KEY>", "<KEY>", "d48e5a4623aeef5c5a5a0b9c546167c264430f1f37412657b49e56f7810524e5", "34cdc61dc537af35237b6cdb423ed5b9ded8be86e786241945f02d11e3e95574", "<KEY>", "<KEY>", "7e8b64ff11d81d9e0d4fd388e5498d7cd7a2a84a967ce2b50c22b1671a15ce91", "<KEY>", "<KEY>", "20991a32e12d4c2fa136135cf47f2e2f58d1d7dd67946a5d4692eb69a4063d11", "<KEY>", "2363288c85ce865622d14bc1d7b29bf5c51222ece0aca35d086747178af7ed04", "<KEY>", "4af5de7f837dc337115b548461c18bb8ecf37a512f0e01d93065d951acc2129e", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "247ea2dba8b59353286e8d5c0d0af41ad5299ec8423430892894783b0b21934c", "820aa3db6e2cd5c94b3ee6927472a2b4e2dea2485d497d2166b8899658900812", "2c7ee7353ee7663a908a6cc9542e260ef192b524f9a981d838c32aa521757289", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "dfc37b264ff3ee0baddef4fed331ff3dd3b071b9ab1bb3953de983eceafafd77", "811a2613205b53fa3f998b1d9cd39e6212b6094a7b5a0fa38682b0a20387097d", "b2d6e7c753480a05a88fef18731354e934a75785009b07b268e844382a9b9cb2", "5331bbc48eeaf872baea693d187c43dc5a267881b90d2f2659c9af724c3c48c5", "e579b9be0b8f58daacc4f66c959ed3ec903884d1914e11e7e0c3bbf2a5627b43", "b9d06312bf5aee1fa7c879fc61c62edf16e9b523a9f89e04c02000223fbd0de9", }; pub const hashes_of_zero: [256][32]u8 = calc: { @setEvalBranchQuota(100000); var ret: [256][32]u8 = undefined; comptime var i = 1; while (i < 256) : (i += 1) { _ = std.fmt.hexToBytes(ret[i][0..], strs[i - 1]) catch @panic("could not convert hash of zero"); } break :calc ret; };
src/zeros.zig
const std = @import("std"); usingnamespace @import("common.zig"); usingnamespace @import("location.zig"); pub const TokenKind = enum { Unknown, Newline, Colon, Comma, Period, Range, RangeInclusive, Spread, Bar, Ampersand, Bang, Plus, Minus, Asterisk, Slash, Percent, PlusEqual, MinusEqual, AsteriskEqual, SlashEqual, PercentEqual, BraceLeft, BraceRight, ParenLeft, ParenRight, BracketLeft, BracketRight, GreaterEqual, Greater, LessEqual, Less, EqualEqual, Equal, NotEqual, Arrow, Underscore, KwLoop, KwFor, KwMatch, KwThen, KwElse, KwBreak, KwContinue, KwStruct, KwEnum, KwFn, Identifier, Char, String, Int, Float, DocComment, }; pub const TokenData = union { none: void, char: u21, text: String, int: u128, float: f128, }; pub const Token = struct { location: Location, kind: TokenKind, data: TokenData, const Self = @This(); }; pub const Lexer = struct { input: String, peeked: ?Token, location: Location, const Self = @This(); pub fn init(filename: String, input: String) !Lexer { if (!std.unicode.utf8ValidateSlice(input)) { return error.InvalidUtf8; } return Lexer{ .input = input, .peeked = null, .location = .{ .file = filename, .index = 0, .line = 1, .column = 1 }, }; } fn peekChar(self: *Self, offset: usize) ?u8 { const i = self.location.index + offset; if (i >= self.input.len) { return null; } else { return self.input[i]; } } fn readChar(self: *Self) ?u8 { if (self.location.index >= self.input.len) { return null; } else { defer self.nextChar(); return self.input[self.location.index]; } } pub fn peek(self: *Self) ?Token { if (self.peeked == null) { self.peeked = self.parseNextToken(); } return self.peeked; } pub fn read(self: *Self) ?Token { if (self.peeked) |token| { self.peeked = null; return token; } return self.parseNextToken(); } fn nextChar(self: *Self) void { if (self.location.index < self.input.len and self.input[self.location.index] == '\n') { self.location.line += 1; self.location.column = 0; } self.location.index += 1; self.location.column += 1; } fn parseNextToken(self: *Self) ?Token { // skip whitespace and comments var newlineLocation: ?Location = null; while (self.location.index < self.input.len) { switch (self.input[self.location.index]) { ' ' => self.nextChar(), '\t' => self.nextChar(), '\r' => self.nextChar(), '\n' => { newlineLocation = newlineLocation orelse self.location; self.nextChar(); }, '#' => { while (self.location.index < self.input.len) { self.nextChar(); if (self.input[self.location.index - 1] == '\n') { newlineLocation = newlineLocation orelse self.location; break; } } }, else => break, } } if (newlineLocation) |loc| { return Token{ .location = loc, .kind = .Newline, .data = TokenData{ .none = {} }, }; } if (self.location.index >= self.input.len) { return null; } var token = Token{ .location = self.location, .kind = .Unknown, .data = TokenData{ .none = {} }, }; switch (self.readChar().?) { ':' => token.kind = .Colon, ',' => token.kind = .Comma, '.' => if (self.peekChar(0)) |c1| { if (c1 == '.') { if (self.peekChar(1)) |c2| { switch (c2) { '.' => { self.nextChar(); self.nextChar(); token.kind = .Spread; }, '=' => { self.nextChar(); self.nextChar(); token.kind = .RangeInclusive; }, else => { self.nextChar(); token.kind = .Range; }, } } else { self.nextChar(); token.kind = .Range; } } else { token.kind = .Period; } } else { token.kind = .Period; }, '|' => token.kind = .Bar, '&' => token.kind = .Ampersand, '+' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .PlusEqual; } else { token.kind = .Plus; } } else { token.kind = .Plus; }, '-' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .MinusEqual; } else if (c1 == '>') { self.nextChar(); token.kind = .Arrow; } else { token.kind = .Minus; } } else { token.kind = .Minus; }, '*' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .AsteriskEqual; } else { token.kind = .Asterisk; } } else { token.kind = .Asterisk; }, '/' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .SlashEqual; } else { token.kind = .Slash; } } else { token.kind = .Slash; }, '%' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .PercentEqual; } else { token.kind = .Percent; } } else { token.kind = .Percent; }, '{' => token.kind = .BraceLeft, '}' => token.kind = .BraceRight, '(' => token.kind = .ParenLeft, ')' => token.kind = .ParenRight, '[' => token.kind = .BracketLeft, ']' => token.kind = .BracketRight, '>' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .GreaterEqual; } else { token.kind = .Greater; } } else { token.kind = .Greater; }, '<' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .LessEqual; } else { token.kind = .Less; } } else { token.kind = .Less; }, '=' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .EqualEqual; } else { token.kind = .Equal; } } else { token.kind = .Equal; }, '!' => if (self.peekChar(0)) |c1| { if (c1 == '=') { self.nextChar(); token.kind = .NotEqual; } else { token.kind = .Bang; } } else { token.kind = .Bang; }, '"' => if (self.parseString('"')) |text| { token.kind = .String; token.data = TokenData{ .text = text }; } else { token.kind = .Unknown; }, '\'' => if (self.parseString('\'')) |text| { var utf8View = std.unicode.Utf8View.initUnchecked(text).iterator(); if (utf8View.nextCodepoint()) |c| { if (utf8View.nextCodepoint()) |_| { // text longer than one char } else { token.kind = .Char; token.data = TokenData{ .char = c }; } } else { // empty char literal token.kind = .Unknown; } } else { token.kind = .Unknown; }, //' ' => token.kind = .DocComment: []const u8, //' ' => token.kind = .Int: u128, //' ' => token.kind = .Float: f128, else => |c| { token.kind = .Unknown; if (isValidFirstIdentifierChar(c)) { const start = self.location.index - 1; // index pointing to second char while (self.location.index < self.input.len and isValidIdentifierChar(self.input[self.location.index])) { self.nextChar(); } token.kind = .Identifier; token.data = TokenData{ .text = self.input[start..self.location.index] }; } else if (c >= '0' and c <= '9') { self.location.index -= 1; self.parseNumber(&token); } }, } return token; } fn parseNumber(self: *Self, token: *Token) void { var radix: u8 = 10; const startRaw = self.location.index; if (self.location.index + 1 < self.input.len and self.input[self.location.index] == '0') { switch (self.input[self.location.index + 1]) { 'x' => { radix = 16; self.nextChar(); self.nextChar(); }, 'b' => { radix = 2; self.nextChar(); self.nextChar(); }, else => {}, } } const start = self.location.index; while (self.location.index < self.input.len and isDigit(self.input[self.location.index], radix)) { self.nextChar(); } const end = self.location.index; // check if empty if (start == end) { std.log.err("Failed to parse int literal: '{s}'", .{self.input[startRaw..end]}); return; } const number = std.fmt.parseInt(u128, self.input[start..end], radix) catch { std.log.err("Failed to parse int literal: '{s}'", .{self.input[startRaw..end]}); return; }; token.kind = .Int; token.data = TokenData{ .int = number }; } fn parseString(self: *Self, end: u8) ?[]const u8 { // self.location.index already points to first byte of content const start = self.location.index; while (self.location.index < self.input.len) : (self.nextChar()) { if (self.input[self.location.index] == end) { self.nextChar(); return self.input[start..(self.location.index - 1)]; } } return null; } }; fn isValidFirstIdentifierChar(c: u8) bool { return c == '$' or c == '@' or c == '_' or (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z'); } fn isValidIdentifierChar(c: u8) bool { return c == '_' or (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or (c >= '0' and c <= '9'); } fn isDigit(c: u8, radix: u8) bool { if (radix <= 10) { return c >= '0' and c < ('0' + radix); } else { return (c >= '0' and c <= '9') or (c >= 'a' and c < ('a' + radix - 10)) or (c >= 'A' and c < ('A' + radix - 10)); } }
src/lexer.zig
usingnamespace @import("root").preamble; const PixelFormat = lib.graphics.pixel_format.PixelFormat; const Color = lib.graphics.color.Color; pub const InvalidateRectFunc = fn (r: *ImageRegion, x: usize, y: usize, width: usize, height: usize) void; pub const ImageRegion = struct { width: usize, height: usize, pixel_format: PixelFormat, bytes: []u8, pitch: usize, /// Function to call when a subregion of the image has been modified invalidateRectFunc: ?InvalidateRectFunc, // The following variables are managed by this struct and shouldn't be changed /// If the image is a less wide subregion() of any other ImageRegion /// means that the bytes between bpp*width and pitch can't be overwritten full_width: bool = true, // Offsets are needed for the invalidation callbacks for subregions x_offset: usize = 0, y_offset: usize = 0, pub fn subregion( self: *const @This(), x: usize, y: usize, width: usize, height: usize, ) @This() { if (x + width > self.width) unreachable; if (y + height > self.height) unreachable; return .{ .width = width, .height = height, .pixel_format = self.pixel_format, .bytes = self.startingAt(x, y), .pitch = self.pitch, .invalidateRectFunc = self.invalidateRectFunc, .full_width = self.full_width and width == self.width, .x_offset = self.x_offset + x, .y_offset = self.y_offset + y, }; } pub fn invalidateRect( self: *const @This(), x: usize, y: usize, width: usize, height: usize, ) void { if (x + width > self.width) unreachable; if (y + height > self.height) unreachable; if (self.invalidateRectFunc) |func| func(@intToPtr(*@This(), @ptrToInt(self)), x + self.x_offset, y + self.y_offset, width, height); } /// Draw a pixel to the region pub fn drawPixel( self: *const @This(), c: Color, x: usize, y: usize, comptime invalidate: bool, ) void { switch (self.pixel_format) { .rgb => self.drawPixelWithFormat(.rgb, c, x, y, invalidate), .rgba => self.drawPixelWithFormat(.rgba, c, x, y, invalidate), .rgbx => self.drawPixelWithFormat(.rgbx, c, x, y, invalidate), } } /// Draw a pixel, assuming the target format pub fn drawPixelWithFormat( self: *const @This(), comptime fmt: PixelFormat, c: Color, x: usize, y: usize, comptime invalidate: bool, ) void { if (x > self.width) unreachable; if (y > self.height) unreachable; if (fmt != self.pixel_format) unreachable; c.writeAsFmt(fmt, self.startingAt(x, y)); if (comptime invalidate) self.invalidateRect(x, y, 1, 1); } pub fn getPixel( self: *const @This(), x: usize, y: usize, ) Color { return switch (self.pixel_format) { .rgb => self.getPixelWithFormat(.rgb, x, y), .rgba => self.getPixelWithFormat(.rgba, x, y), .rgbx => self.getPixelWithFormat(.rgbx, x, y), }; } pub fn getPixelWithFormat(self: *const @This(), comptime fmt: PixelFormat, x: usize, y: usize) Color { if (x > self.width) unreachable; if (y > self.height) unreachable; if (fmt != self.pixel_format) unreachable; return readAsFmt(fmt, startingAt(x, y)); } pub fn fill( self: *const @This(), c: Color, x: usize, y: usize, width: usize, height: usize, comptime invalidate: bool, ) void { switch (self.pixel_format) { .rgb => self.fillWithFormat(.rgb, c, x, y, width, height, invalidate), .rgba => self.fillWithFormat(.rgba, c, x, y, width, height, invalidate), .rgbx => self.fillWithFormat(.rgbx, c, x, y, width, height, invalidate), } } pub fn fillWithFormat( target: *const @This(), comptime fmt: PixelFormat, c: Color, x: usize, y: usize, width: usize, height: usize, comptime invalidate: bool, ) void { if (!target.pixel_format.canWrite(fmt)) unreachable; if (width + x > target.width) unreachable; if (height + y > target.height) unreachable; // Can we memset (all bytes equal) when filing? if (c.memsetAsFmt(fmt)) |byte_value| { if (x == 0 and width == target.width and target.full_width) { lib.util.libalign.alignedFill(u32, target.startingAt(0, y)[0 .. height * target.pitch], byte_value); } else { var curr_y: usize = 0; var target_lines = target.startingAt(x, y); while (true) { const line = target_lines[0 .. width * comptime fmt.bytesPerPixel()]; lib.util.libalign.alignedFill(u32, line, byte_value); curr_y += 1; if (curr_y == height) break; target_lines = target_lines[target.pitch..]; } } } else { var pixel_bytes: [fmt.meaningfulBytesPerPixel()]u8 = undefined; c.writeAsFmt(fmt, &pixel_bytes); var curr_y: usize = 0; var target_lines = target.startingAt(x, y); while (true) { var curr_x: usize = 0; var target_pixels = target_lines; while (true) { lib.util.libalign.alignedCopy(u8, target_pixels, pixel_bytes[0..]); curr_x += 1; if (curr_x == width) break; target_pixels = target_pixels[comptime fmt.bytesPerPixel()..]; } curr_y += 1; if (curr_y == height) break; target_lines = target_lines[target.pitch..]; } } if (comptime invalidate) target.invalidateRect(x, y, width, height); } /// Assume both source and target formats pub fn drawImageWithFmt( target: *const @This(), comptime source_fmt: PixelFormat, comptime target_fmt: PixelFormat, source: ImageRegion, x: usize, y: usize, comptime invalidate: bool, ) void { // Check if the formats we're using are valid if (!source.pixel_format.canReadManyAs(source_fmt)) unreachable; if (!target.pixel_format.canWriteMany(target_fmt)) unreachable; // Bounds checks if (source.width + x > target.width) unreachable; if (source.height + y > target.height) unreachable; // Check if the input and output formats are bit-compatible if (comptime target_fmt.canWriteMany(source_fmt)) { // Can we copy the entire thing in one memcpy? if (source.pitch == target.pitch and source.full_width and target.full_width) { const num_bytes = source.pitch * source.height; lib.util.libalign.alignedCopy(u32, target.startingAt(x, y), source.bytes); } else { const num_bytes = source.width * comptime source_fmt.bytesPerPixel(); var source_bytes = source.bytes; var target_bytes = target.startingAt(x, y); var source_y: usize = 0; while (true) { lib.util.libalign.alignedCopy(u32, target_bytes, source_bytes[0..num_bytes]); source_y += 1; if (source_y == source.height) break; target_bytes = target_bytes[target.pitch..]; source_bytes = source_bytes[source.pitch..]; } } } // Fine, do one pixel at a time else { var source_lines = source.bytes; var target_lines = target.startingAt(x, y); var source_y: usize = 0; while (true) { var source_x: usize = 0; var source_pixels = source_lines; var target_pixels = target_lines; while (true) { if (comptime target_fmt.canWrite(source_fmt)) { const source_bytes = source_fmt.meaningfulBytesPerPixel(); const target_bytes = target_fmt.meaningfulBytesPerPixel(); const bytes_to_copy = std.math.min(source_bytes, target_bytes); lib.util.libalign.alignedCopy(u32, target_pixels, source_pixels[0..comptime bytes_to_copy]); } else { lib.graphics.color.Color.readAsFmt( source_fmt, source_pixels, ).writeAsFmt( target_fmt, target_pixels, ); } source_x += 1; if (source_x == source.width) break; source_pixels = source_pixels[comptime source_fmt.bytesPerPixel()..]; target_pixels = target_pixels[comptime target_fmt.bytesPerPixel()..]; } source_y += 1; if (source_y == source.height) break; source_lines = source_lines[source.pitch..]; target_lines = target_lines[target.pitch..]; } } if (comptime invalidate) target.invalidateRect(x, y, source.width, source.height); } // I wish I could use https://github.com/ziglang/zig/issues/7224 right now... /// Assume the sourcce format pub fn drawImageWithSourceFmt( self: *const @This(), comptime source_fmt: PixelFormat, source: ImageRegion, x: usize, y: usize, comptime invalidate: bool, ) void { switch (self.pixel_format) { .rgb => self.drawImageWithFmt(source_fmt, .rgb, source, x, y, invalidate), .rgba => self.drawImageWithFmt(source_fmt, .rgba, source, x, y, invalidate), .rgbx => self.drawImageWithFmt(source_fmt, .rgbx, source, x, y, invalidate), } } /// Assume the target format pub fn drawImageWithTargetFmt( self: *const @This(), comptime target_fmt: PixelFormat, source: ImageRegion, x: usize, y: usize, comptime invalidate: bool, ) void { switch (source.pixel_format) { .rgb => self.drawImageWithFmt(.rgb, target_fmt, source, x, y, invalidate), .rgba => self.drawImageWithFmt(.rgba, target_fmt, source, x, y, invalidate), .rgbx => self.drawImageWithFmt(.rgbx, target_fmt, source, x, y, invalidate), } } /// Assume the source and target pixel formats are equal pub fn drawImageSameFmt( self: *const @This(), source: ImageRegion, x: usize, y: usize, comptime invalidate: bool, ) void { switch (self.pixel_format) { .rgb => self.drawImageWithFmt(.rgb, .rgb, source, x, y, invalidate), .rgba => self.drawImageWithFmt(.rgba, .rgba, source, x, y, invalidate), .rgbx => self.drawImageWithFmt(.rgbx, .rgbx, source, x, y, invalidate), } } /// Draw the source image region to the target one pub fn drawImage( self: *const @This(), source: ImageRegion, x: usize, y: usize, comptime invalidate: bool, ) void { switch (self.pixel_format) { .rgb => self.drawImageWithTargetFmt(.rgb, source, x, y, invalidate), .rgba => self.drawImageWithTargetFmt(.rgba, source, x, y, invalidate), .rgbx => self.drawImageWithTargetFmt(.rgbx, source, x, y, invalidate), } } fn startingAt(self: *const @This(), x: usize, y: usize) []u8 { if (x > self.width) unreachable; if (y > self.height) unreachable; const offset = self.pixel_format.bytesPerPixel() * x + self.pitch * y; return self.bytes[offset..]; } };
lib/graphics/image_region.zig
const std = @import("std"); const fun = @import("fun"); const testing = std.testing; const heap = std.heap; const io = std.io; const math = std.math; const mem = std.mem; const os = std.os; const scan = fun.scan.scan; pub fn main() !void { const stdin = &(try io.getStdIn()).inStream().stream; const stdout = &(try io.getStdOut()).outStream().stream; var ps = io.PeekStream(1, os.File.InStream.Error).init(stdin); const input = try scan(&ps, "{}", struct { serial_number: usize, }); const grid = makeGrid(input.serial_number); const p = findSquareWithLargestSum(grid, 3, 3).?; try stdout.print("{},{}\n", p.x, p.y); var max = findSquareWithLargestSum(grid, 1, 1).?; var size: usize = 1; var i: usize = 2; while (i <= grid.len) : (i += 1) { const sq = findSquareWithLargestSum(grid, i, i).?; if (max.sum < sq.sum) { size = i; max = sq; } } try stdout.print("{},{},{}\n", max.x, max.y, size); } fn findSquareWithLargestSum(grid: var, size_x: usize, size_y: usize) ?Point { var largest: ?Point = null; if (size_x == 0) return null; if (size_y == 0) return null; if (grid.len < size_y) return null; if (grid[0].len < size_x) return null; for (grid[0 .. grid.len - size_y]) |*_, y| { for (grid[0 .. grid.len - size_y]) |_, x| { var sum: isize = 0; for (grid[y .. size_y + y]) |*col| { for (col[x .. size_x + x]) |p| { sum += p; } } if (largest) |*l| { if (l.sum < sum) { l.* = Point{ .x = x, .y = y, .sum = sum }; } } else { largest = Point{ .x = x, .y = y, .sum = sum }; } } } return largest; } const Point = struct { x: usize, y: usize, sum: isize, }; fn makeGrid(serial_number: usize) [300][300]isize { var res = [][300]isize{[]isize{0} ** 300} ** 300; for (res) |*row, y| { for (row) |*p, x| p.* = calcPower(x, y, serial_number); } return res; } fn calcPower(x: usize, y: usize, serial_number: usize) isize { const rack_id = x + 10; const power = rack_id * y + serial_number; const power2 = power * rack_id; const digit = (power2 / 100) % 10; return @intCast(isize, digit) - 5; } test "calcPower" { testing.expectEqual(isize(4), calcPower(3, 5, 8)); testing.expectEqual(isize(-5), calcPower(122, 79, 57)); testing.expectEqual(isize(0), calcPower(217, 196, 39)); testing.expectEqual(isize(4), calcPower(101, 153, 71)); }
src/day11.zig